diff options
author | Fredrick Brennan <copypaste@kittens.ph> | 2018-03-03 11:13:02 +0000 |
---|---|---|
committer | Fredrick Brennan <copypaste@kittens.ph> | 2018-03-03 11:13:02 +0000 |
commit | 5f9538d1e2af29901c5e498b6ef408163b5816e8 (patch) | |
tree | 0428f2fff7891971bd32a1d621129bb589c2a226 /src | |
parent | 2bfacc8633b440958c75d88752709152eaaec9f6 (diff) | |
download | rust-libc-5f9538d1e2af29901c5e498b6ef408163b5816e8.tar.gz |
Add passwd/group APIs needed for nix-rust/nix#864
Diffstat (limited to 'src')
-rw-r--r-- | src/unix/bsd/mod.rs | 23 | ||||
-rw-r--r-- | src/unix/notbsd/linux/mod.rs | 24 |
2 files changed, 47 insertions, 0 deletions
diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index bacfb41189..592e0643a9 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -50,6 +50,13 @@ s! { pub pw_fields: ::c_int, } + pub struct group { + pub gr_name: *mut ::c_char, + pub gr_passwd: *mut ::c_char, + pub gr_gid: ::gid_t, + pub gr_mem: *mut *mut ::c_char + } + pub struct ifaddrs { pub ifa_next: *mut ifaddrs, pub ifa_name: *mut ::c_char, @@ -388,6 +395,10 @@ extern { pub fn getpwent() -> *mut passwd; pub fn setpwent(); pub fn endpwent(); + pub fn setgrent(); + pub fn endgrent(); + pub fn getgrent() -> *mut group; + pub fn getprogname() -> *const ::c_char; pub fn setprogname(name: *const ::c_char); pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int; @@ -513,6 +524,18 @@ extern { buf: *mut ::c_char, buflen: ::size_t, result: *mut *mut passwd) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__getpwent_r50")] + #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwent_r")] + pub fn getpwent_r(pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__getgrent_r50")] + #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrent_r")] + pub fn getgrent_r(grp: *mut group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut group) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch ="x86"), link_name = "sigwait$UNIX2003")] #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")] diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 33c397626b..729eb312b4 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -160,6 +160,13 @@ s! { pub pw_shell: *mut ::c_char, } + pub struct group { + pub gr_name: *mut ::c_char, + pub gr_passwd: *mut ::c_char, + pub gr_gid: ::gid_t, + pub gr_mem: *mut *mut ::c_char + } + pub struct spwd { pub sp_namp: *mut ::c_char, pub sp_pwdp: *mut ::c_char, @@ -1468,9 +1475,14 @@ extern { pub fn setpwent(); pub fn endpwent(); pub fn getpwent() -> *mut passwd; + pub fn setgrent(); + pub fn endgrent(); + pub fn getgrent() -> *mut group; pub fn setspent(); pub fn endspent(); pub fn getspent() -> *mut spwd; + + pub fn getspnam(__name: *const ::c_char) -> *mut spwd; pub fn shm_open(name: *const c_char, oflag: ::c_int, @@ -1826,6 +1838,18 @@ extern { buf: *mut ::c_char, buflen: ::size_t, result: *mut *mut passwd) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__getpwent_r50")] + #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwent_r")] + pub fn getpwent_r(pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd) -> ::c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__getgrent_r50")] + #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrent_r")] + pub fn getgrent_r(grp: *mut group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut group) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch ="x86"), link_name = "sigwait$UNIX2003")] #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")] |