Skip to content

Commit baf71f8

Browse files
authored
Merge pull request rust-lang#317 from cjschneider2/master
Add `if_nameindex()` and `if_freenameindex()` from POSIX-2001
2 parents b0d6253 + 332bd86 commit baf71f8

File tree

3 files changed

+37
-15
lines changed

3 files changed

+37
-15
lines changed

src/unix/bsd/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ s! {
120120
pub struct fsid_t {
121121
__fsid_val: [::int32_t; 2],
122122
}
123+
124+
pub struct if_nameindex {
125+
pub if_index: ::c_uint,
126+
pub if_name: *mut ::c_char,
127+
}
123128
}
124129

125130
pub const LC_ALL: ::c_int = 0;
@@ -358,6 +363,8 @@ extern {
358363
pub fn getprogname() -> *const ::c_char;
359364
pub fn setprogname(name: *const ::c_char);
360365
pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int;
366+
pub fn if_nameindex() -> *mut if_nameindex;
367+
pub fn if_freenameindex(ptr: *mut if_nameindex);
361368
}
362369

363370
cfg_if! {

src/unix/notbsd/linux/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ s! {
181181
#[cfg(target_pointer_width = "64")]
182182
bits: [u64; 16],
183183
}
184+
185+
pub struct if_nameindex {
186+
pub if_index: ::c_uint,
187+
pub if_name: *mut ::c_char,
188+
}
189+
184190
}
185191

186192
pub const ABDAY_1: ::nl_item = 0x20000;
@@ -637,6 +643,8 @@ extern {
637643
// Not available now on Android
638644
pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char,
639645
mode: ::mode_t) -> ::c_int;
646+
pub fn if_nameindex() -> *mut if_nameindex;
647+
pub fn if_freenameindex(ptr: *mut if_nameindex);
640648
}
641649

642650
cfg_if! {

src/unix/solaris/mod.rs

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,11 @@ s! {
318318
pub l_pid: ::pid_t,
319319
pub l_pad: [::c_long; 4]
320320
}
321+
322+
pub struct if_nameindex {
323+
pub if_index: ::c_uint,
324+
pub if_name: *mut ::c_char,
325+
}
321326
}
322327

323328
pub const LC_CTYPE: ::c_int = 0;
@@ -990,21 +995,23 @@ extern {
990995
pub fn linkat(olddirfd: ::c_int, oldpath: *const ::c_char,
991996
newdirfd: ::c_int, newpath: *const ::c_char,
992997
flags: ::c_int) -> ::c_int;
993-
pub fn mkdirat(dirfd: ::c_int, pathname: *const ::c_char,
994-
mode: ::mode_t) -> ::c_int;
995-
pub fn mknodat(dirfd: ::c_int, pathname: *const ::c_char,
996-
mode: ::mode_t, dev: dev_t) -> ::c_int;
997-
pub fn readlinkat(dirfd: ::c_int, pathname: *const ::c_char,
998-
buf: *mut ::c_char, bufsiz: ::size_t) -> ::ssize_t;
999-
pub fn renameat(olddirfd: ::c_int, oldpath: *const ::c_char,
1000-
newdirfd: ::c_int, newpath: *const ::c_char)
1001-
-> ::c_int;
1002-
pub fn symlinkat(target: *const ::c_char, newdirfd: ::c_int,
1003-
linkpath: *const ::c_char) -> ::c_int;
1004-
pub fn unlinkat(dirfd: ::c_int, pathname: *const ::c_char,
1005-
flags: ::c_int) -> ::c_int;
1006-
pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char,
998+
pub fn mkdirat(dirfd: ::c_int, pathname: *const ::c_char,
1007999
mode: ::mode_t) -> ::c_int;
1008-
pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int;
1000+
pub fn mknodat(dirfd: ::c_int, pathname: *const ::c_char,
1001+
mode: ::mode_t, dev: dev_t) -> ::c_int;
1002+
pub fn readlinkat(dirfd: ::c_int, pathname: *const ::c_char,
1003+
buf: *mut ::c_char, bufsiz: ::size_t) -> ::ssize_t;
1004+
pub fn renameat(olddirfd: ::c_int, oldpath: *const ::c_char,
1005+
newdirfd: ::c_int, newpath: *const ::c_char)
1006+
-> ::c_int;
1007+
pub fn symlinkat(target: *const ::c_char, newdirfd: ::c_int,
1008+
linkpath: *const ::c_char) -> ::c_int;
1009+
pub fn unlinkat(dirfd: ::c_int, pathname: *const ::c_char,
1010+
flags: ::c_int) -> ::c_int;
1011+
pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char,
1012+
mode: ::mode_t) -> ::c_int;
1013+
pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int;
1014+
pub fn if_nameindex() -> *mut if_nameindex;
1015+
pub fn if_freenameindex(ptr: *mut if_nameindex);
10091016
}
10101017

0 commit comments

Comments
 (0)