1 /* 2 * Copyright (c) 1980 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)getname.c 5.9 (Berkeley) 06/26/92"; 10 #endif /* not lint */ 11 12 #include "rcv.h" 13 #include <pwd.h> 14 #include "extern.h" 15 16 /* Getname / getuserid for those with hashed passwd data base). */ 17 18 /* 19 * Search the passwd file for a uid. Return name through ref parameter 20 * if found, indicating success with 0 return. Return -1 on error. 21 */ 22 char * 23 getname(uid) 24 int uid; 25 { 26 struct passwd *pw; 27 28 if ((pw = getpwuid(uid)) == NULL) 29 return NOSTR; 30 return pw->pw_name; 31 } 32 33 /* 34 * Convert the passed name to a user id and return it. Return -1 35 * on error. 36 */ 37 int 38 getuserid(name) 39 char name[]; 40 { 41 struct passwd *pw; 42 43 if ((pw = getpwnam(name)) == NULL) 44 return -1; 45 return pw->pw_uid; 46 } 47