Skip to content

Commit

Permalink
feat/all: Add everything
Browse files Browse the repository at this point in the history
  • Loading branch information
madadam committed Dec 6, 2017
1 parent 185d27c commit ead7f9b
Show file tree
Hide file tree
Showing 9 changed files with 1,466 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

# IDEs/Editors
*.sublime-*
14 changes: 14 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "ifaddrs"
version = "0.1.0"

[dependencies]
libc = "~0.2.28"
c_linked_list = "~1.1.0"

[target.'cfg(target_os = "android")'.dependencies.ifaddrs-sys]
version = "0.1.0"
path = "ifaddrs-sys"

[dev-dependencies]
unwrap = "~1.1.0"
15 changes: 15 additions & 0 deletions ifaddrs-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "ifaddrs-sys"
version = "0.1.0"
links = "ifaddrs"
build = "build.rs"

[lib]
name = "ifaddrs_sys"
path = "lib.rs"

[dependencies]
libc = "~0.2.28"

[build-dependencies]
gcc = "0.3"
12 changes: 12 additions & 0 deletions ifaddrs-sys/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
extern crate gcc;

use std::env;

fn main() {
let mut cfg = gcc::Build::new();
if env::var("TARGET").unwrap().contains("android") {
cfg.include("native").file("native/ifaddrs.c").compile(
"libifaddrs.a",
);
}
}
19 changes: 19 additions & 0 deletions ifaddrs-sys/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#![cfg(target_os = "android")]
extern crate libc;
use libc::*;
#[repr(C)]
#[derive(Debug)]
pub struct ifaddrs {
pub ifa_next: *mut ifaddrs,
pub ifa_name: *mut c_char,
pub ifa_flags: ::c_uint,
pub ifa_addr: *mut ::sockaddr,
pub ifa_netmask: *mut ::sockaddr,
pub ifa_ifu: *mut ::sockaddr,
pub ifa_data: *mut ::c_void,
}

extern "C" {
pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int;
pub fn freeifaddrs(ifa: *mut ::ifaddrs);
}
Loading

0 comments on commit ead7f9b

Please sign in to comment.