install correct aliases file
[unix-history] / usr / src / usr.bin / mail / getname.c
index a873b26..bbb096f 100644 (file)
@@ -1,12 +1,23 @@
 /*
  * 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 the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, 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'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)getname.c   5.2 (Berkeley) %G%";
-#endif not lint
+static char sccsid[] = "@(#)getname.c  5.6 (Berkeley) %G%";
+#endif /* not lint */
 
 #include <pwd.h>
 
 
 #include <pwd.h>
 
@@ -21,37 +32,27 @@ static char *sccsid = "@(#)getname.c        5.2 (Berkeley) %G%";
 /*
  * 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)
-       char namebuf[];
+char *
+getname(uid)
 {
        struct passwd *pw;
 
 {
        struct passwd *pw;
 
-       if (uid == -1) {
-               return(0);
-       }
        if ((pw = getpwuid(uid)) == NULL)
        if ((pw = getpwuid(uid)) == NULL)
-               return(-1);
-       strcpy(namebuf, pw->pw_name);
-       return 0;
+               return NOSTR;
+       return pw->pw_name;
 }
 
 /*
  * Convert the passed name to a user id and return it.  Return -1
 }
 
 /*
  * 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)
        char name[];
 {
        struct passwd *pw;
 
 getuserid(name)
        char name[];
 {
        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;
 }