1 static char Sccsid[] = "@(#)username.c	1.2	02/15/87";
2 /*
3 	Gets user's login name.
4 	Note that the argument must be an integer.
5 	Returns pointer to login name on success,
6 	pointer to string representation of used ID on failure.
7 
8 	Remembers user ID and login name for subsequent calls.
9 */
10 
11 username(uid)
12 register int uid;
13 {
14 	char pw[200];
15 	static int ouid;
16 	static char lnam[9], *lptr;
17 	register int i;
18 
19 	if (ouid!=uid || ouid==0) {
20 		if (getpw(uid,pw))
21 			sprintf(lnam,"%d",uid);
22 		else {
23 			for (i=0; i<8; i++)
24 				if ((lnam[i] = pw[i])==':') break;
25 			lnam[i] = '\0';
26 		}
27 		lptr = lnam;
28 		ouid = uid;
29 	}
30 	return(lptr);
31 }
32