Fix for statements ending with a colon
[mono.git] / support / pwd.c
index 37fd9bb6ff507efc37d1330878f0fa7b83ddd969..809934777e252d920333a2f0350326cb7af9a0cb 100644 (file)
@@ -80,6 +80,7 @@ Mono_Posix_Syscall_getpwnam (const char *name, struct Mono_Posix_Syscall__Passwd
                return -1;
        }
 
+       errno = 0;
        pw = getpwnam (name);
        if (pw == NULL)
                return -1;
@@ -118,7 +119,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;
@@ -141,9 +142,14 @@ Mono_Posix_Syscall_getpwnam_r (const char *name,
                        return -1;
                }
                buf = buf2;
-       } while ((r = getpwnam_r (name, &_pwbuf, buf, buflen, pwbufp)) && 
+               errno = 0;
+       } while ((r = getpwnam_r (name, &_pwbuf, buf, buflen, (struct passwd**) pwbufp)) && 
                        recheck_range (r));
 
+       if (r == 0 && !(*pwbufp))
+               /* On solaris, this function returns 0 even if the entry was not found */
+               r = errno = ENOENT;
+
        if (r == 0 && copy_passwd (pwbuf, &_pwbuf) == -1)
                r = errno = ENOMEM;
        free (buf);
@@ -156,7 +162,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;
@@ -179,7 +185,8 @@ Mono_Posix_Syscall_getpwuid_r (mph_uid_t uid,
                        return -1;
                }
                buf = buf2;
-       } while ((r = getpwuid_r (uid, &_pwbuf, buf, buflen, pwbufp)) && 
+               errno = 0;
+       } while ((r = getpwuid_r (uid, &_pwbuf, buf, buflen, (struct passwd**) pwbufp)) && 
                        recheck_range (r));
 
        if (r == 0 && copy_passwd (pwbuf, &_pwbuf) == -1)
@@ -200,6 +207,7 @@ Mono_Posix_Syscall_getpwent (struct Mono_Posix_Syscall__Passwd *pwbuf)
                return -1;
        }
 
+       errno = 0;
        pw = getpwent ();
        if (pw == NULL)
                return -1;
@@ -213,7 +221,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;
 
@@ -222,7 +230,8 @@ Mono_Posix_Syscall_fgetpwent (FILE *stream, struct Mono_Posix_Syscall__Passwd *p
                return -1;
        }
 
-       pw = fgetpwent (stream);
+       errno = 0;
+       pw = fgetpwent ((FILE*) stream);
        if (pw == NULL)
                return -1;