X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=support%2Fpwd.c;h=e622027458dfa806dbdaf0525b27ce10484a3473;hb=feca28835d4e3cb2be67bdcbd4f54fee62c3797a;hp=32d8f94fdd1c8abf39743af0c54547e0ac5be160;hpb=234225d112c4b018b8d1796f4c06a15812137500;p=mono.git diff --git a/support/pwd.c b/support/pwd.c index 32d8f94fdd1..e622027458d 100644 --- a/support/pwd.c +++ b/support/pwd.c @@ -4,7 +4,7 @@ * Authors: * Jonathan Pryor (jonpryor@vt.edu) * - * Copyright (C) 2004 Jonathan Pryor + * Copyright (C) 2004-2005 Jonathan Pryor */ #include @@ -13,21 +13,11 @@ #include #include +#include "map.h" #include "mph.h" G_BEGIN_DECLS -struct Mono_Posix_Syscall__Passwd { - /* string */ char *pw_name; - /* string */ char *pw_passwd; - /* uid_t */ mph_uid_t pw_uid; - /* gid_t */ mph_gid_t pw_gid; - /* string */ char *pw_gecos; - /* string */ char *pw_dir; - /* string */ char *pw_shell; - /* string */ char *_pw_buf_; -}; - static const size_t passwd_offsets[] = { offsetof (struct passwd, pw_name), @@ -119,7 +109,7 @@ Mono_Posix_Syscall_getpwuid (mph_uid_t uid, struct Mono_Posix_Syscall__Passwd *p gint32 Mono_Posix_Syscall_getpwnam_r (const char *name, struct Mono_Posix_Syscall__Passwd *pwbuf, - struct passwd **pwbufp) + void **pwbufp) { char *buf, *buf2; size_t buflen; @@ -143,7 +133,7 @@ Mono_Posix_Syscall_getpwnam_r (const char *name, } buf = buf2; errno = 0; - } while ((r = getpwnam_r (name, &_pwbuf, buf, buflen, pwbufp)) && + } while ((r = getpwnam_r (name, &_pwbuf, buf, buflen, (struct passwd**) pwbufp)) && recheck_range (r)); if (r == 0 && !(*pwbufp)) @@ -162,7 +152,7 @@ Mono_Posix_Syscall_getpwnam_r (const char *name, gint32 Mono_Posix_Syscall_getpwuid_r (mph_uid_t uid, struct Mono_Posix_Syscall__Passwd *pwbuf, - struct passwd **pwbufp) + void **pwbufp) { char *buf, *buf2; size_t buflen; @@ -186,7 +176,7 @@ Mono_Posix_Syscall_getpwuid_r (mph_uid_t uid, } buf = buf2; errno = 0; - } while ((r = getpwuid_r (uid, &_pwbuf, buf, buflen, pwbufp)) && + } while ((r = getpwuid_r (uid, &_pwbuf, buf, buflen, (struct passwd**) pwbufp)) && recheck_range (r)); if (r == 0 && copy_passwd (pwbuf, &_pwbuf) == -1) @@ -221,7 +211,7 @@ Mono_Posix_Syscall_getpwent (struct Mono_Posix_Syscall__Passwd *pwbuf) #ifdef HAVE_FGETPWENT gint32 -Mono_Posix_Syscall_fgetpwent (FILE *stream, struct Mono_Posix_Syscall__Passwd *pwbuf) +Mono_Posix_Syscall_fgetpwent (void *stream, struct Mono_Posix_Syscall__Passwd *pwbuf) { struct passwd *pw; @@ -231,7 +221,7 @@ Mono_Posix_Syscall_fgetpwent (FILE *stream, struct Mono_Posix_Syscall__Passwd *p } errno = 0; - pw = fgetpwent (stream); + pw = fgetpwent ((FILE*) stream); if (pw == NULL) return -1; @@ -243,6 +233,27 @@ Mono_Posix_Syscall_fgetpwent (FILE *stream, struct Mono_Posix_Syscall__Passwd *p } #endif /* ndef HAVE_FGETPWENT */ +int +Mono_Posix_Syscall_setpwent (void) +{ + errno = 0; + do { + setpwent (); + } while (errno == EINTR); + mph_return_if_val_in_list5(errno, EIO, EMFILE, ENFILE, ENOMEM, ERANGE); + return 0; +} + +int +Mono_Posix_Syscall_endpwent (void) +{ + errno = 0; + endpwent (); + if (errno == EIO) + return -1; + return 0; +} + G_END_DECLS /*