date and time created 88/07/21 17:35:50 by marc
[unix-history] / usr / src / local / sccscmds / sccscmds.ok / util / username.c
CommitLineData
7c9c5d18 1static char Sccsid[] = "@(#)username.c 1.2 %G%";
d5766fc0
JL
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
11username(uid)
12register 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}