Merge pull request #342 from knight42/getpw

Add functions to get password/group file entry
This commit is contained in:
Alex Crichton 2016-07-31 15:11:53 -07:00 committed by GitHub
commit 932f22be4e
5 changed files with 39 additions and 1 deletions

View File

@ -354,12 +354,21 @@ extern {
pub fn kqueue() -> ::c_int;
pub fn unmount(target: *const ::c_char, arg: ::c_int) -> ::c_int;
pub fn syscall(num: ::c_int, ...) -> ::c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")]
pub fn getpwnam_r(name: *const ::c_char,
pwd: *mut passwd,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut passwd) -> ::c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")]
pub fn getpwuid_r(uid: ::uid_t,
pwd: *mut passwd,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut passwd) -> ::c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__getpwent50")]
pub fn getpwent() -> *mut passwd;
pub fn setpwent();
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;

View File

@ -17,6 +17,13 @@ pub enum DIR {}
pub enum locale_t {}
s! {
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 utimbuf {
pub actime: time_t,
pub modtime: time_t,
@ -226,6 +233,15 @@ cfg_if! {
}
extern {
pub fn getgrnam(name: *const ::c_char) -> *mut group;
pub fn getgrgid(gid: ::gid_t) -> *mut group;
pub fn endpwent();
#[cfg_attr(target_os = "netbsd", link_name = "__getpwnam50")]
pub fn getpwnam(name: *const ::c_char) -> *mut passwd;
#[cfg_attr(target_os = "netbsd", link_name = "__getpwuid50")]
pub fn getpwuid(uid: ::uid_t) -> *mut passwd;
pub fn fprintf(stream: *mut ::FILE,
format: *const ::c_char, ...) -> ::c_int;
pub fn printf(format: *const ::c_char, ...) -> ::c_int;

View File

@ -503,6 +503,8 @@ f! {
}
extern {
pub fn setpwent();
pub fn getpwent() -> *mut passwd;
pub fn shm_open(name: *const c_char, oflag: ::c_int,
mode: mode_t) -> ::c_int;
pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int;

View File

@ -715,6 +715,11 @@ f! {
}
extern {
pub fn getpwnam_r(name: *const ::c_char,
pwd: *mut passwd,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut passwd) -> ::c_int;
pub fn getpwuid_r(uid: ::uid_t,
pwd: *mut passwd,
buf: *mut ::c_char,

View File

@ -966,10 +966,16 @@ extern {
serv: *mut ::c_char,
sevlen: ::socklen_t,
flags: ::c_int) -> ::c_int;
pub fn getpwnam_r(name: *const ::c_char,
pwd: *mut passwd,
buf: *mut ::c_char,
buflen: ::c_int) -> *const passwd;
pub fn getpwuid_r(uid: ::uid_t,
pwd: *mut passwd,
buf: *mut ::c_char,
buflen: ::size_t) -> *const passwd;
buflen: ::c_int) -> *const passwd;
pub fn setpwent();
pub fn getpwent() -> *mut passwd;
pub fn readdir(dirp: *mut ::DIR) -> *const ::dirent;
pub fn fdatasync(fd: ::c_int) -> ::c_int;
pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char;