/local/sccscmds/sccscmds.2/util/username.c
C | 31 lines | 21 code | 2 blank | 8 comment | 6 complexity | 0bdeefd75a374c14764e0b3fd9f60c80 MD5 | raw file
Possible License(s): MPL-2.0, LGPL-2.0
- static char Sccsid[] = "@(#)username.c 1.2 02/15/87";
- /*
- Gets user's login name.
- Note that the argument must be an integer.
- Returns pointer to login name on success,
- pointer to string representation of used ID on failure.
- Remembers user ID and login name for subsequent calls.
- */
- username(uid)
- register int uid;
- {
- char pw[200];
- static int ouid;
- static char lnam[9], *lptr;
- register int i;
- if (ouid!=uid || ouid==0) {
- if (getpw(uid,pw))
- sprintf(lnam,"%d",uid);
- else {
- for (i=0; i<8; i++)
- if ((lnam[i] = pw[i])==':') break;
- lnam[i] = '\0';
- }
- lptr = lnam;
- ouid = uid;
- }
- return(lptr);
- }