BSD 4_3_Tahoe release
[unix-history] / usr / src / ucb / Mail / getname.c
index 29ead08..a14b367 100644 (file)
@@ -1,12 +1,18 @@
 /*
  * Copyright (c) 1980 Regents of the University of California.
 /*
  * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that this notice is preserved and that due credit is given
+ * to the University of California at Berkeley. The name of the University
+ * may not be used to endorse or promote products derived from this
+ * software without specific prior written permission. This software
+ * is provided ``as is'' without express or implied warranty.
  */
 
  */
 
-#ifndef lint
-static char *sccsid = "@(#)getname.c   5.2 (Berkeley) 6/21/85";
-#endif not lint
+#ifdef notdef
+static char sccsid[] = "@(#)getname.c  5.4 (Berkeley) 2/18/88";
+#endif /* notdef */
 
 #include <pwd.h>
 
 
 #include <pwd.h>
 
@@ -21,7 +27,6 @@ static char *sccsid = "@(#)getname.c  5.2 (Berkeley) 6/21/85";
 /*
  * Search the passwd file for a uid.  Return name through ref parameter
  * if found, indicating success with 0 return.  Return -1 on error.
 /*
  * Search the passwd file for a uid.  Return name through ref parameter
  * if found, indicating success with 0 return.  Return -1 on error.
- * If -1 is passed as the user id, close the passwd file.
  */
 
 getname(uid, namebuf)
  */
 
 getname(uid, namebuf)
@@ -29,18 +34,15 @@ getname(uid, namebuf)
 {
        struct passwd *pw;
 
 {
        struct passwd *pw;
 
-       if (uid == -1) {
-               return(0);
-       }
        if ((pw = getpwuid(uid)) == NULL)
        if ((pw = getpwuid(uid)) == NULL)
-               return(-1);
+               return -1;
        strcpy(namebuf, pw->pw_name);
        return 0;
 }
 
 /*
  * Convert the passed name to a user id and return it.  Return -1
        strcpy(namebuf, pw->pw_name);
        return 0;
 }
 
 /*
  * Convert the passed name to a user id and return it.  Return -1
- * on error.  Iff the name passed is -1 (yech) close the pwfile.
+ * on error.
  */
 
 getuserid(name)
  */
 
 getuserid(name)
@@ -48,10 +50,7 @@ getuserid(name)
 {
        struct passwd *pw;
 
 {
        struct passwd *pw;
 
-       if (name == (char *) -1) {
-               return(0);
-       }
        if ((pw = getpwnam(name)) == NULL)
        if ((pw = getpwnam(name)) == NULL)
-               return 0;
+               return -1;
        return pw->pw_uid;
 }
        return pw->pw_uid;
 }