USG_PG3/usr/source/sccsutil1/getldr.c
char getldr_____[] "~|^`getldr.c: 2.2";
/*
Gets login directory. Argument is optional, if not present
the real user ID is used. Note that if the argument is
present it must be an integer.
Note also assumption about position of directory field in
password file.
*/
getldir(auid)
int auid;
{
char pw[200];
static int ouid;
static char ldir[33];
register int i,uid;
register char *cp;
if (nargs()==0) uid = getuid()&0377;
else uid = auid;
if (ouid!=uid || ouid==0) {
if (getpw(uid,pw)) return(0);
cp = pw;
while (*cp++ != ':') ; /* login name */
while (*cp++ != ':') ; /* passwd */
while (*cp++ != ':') ; /* user ID */
while (*cp++ != ':') ; /* comment */
for (i=0; i<32; i++) {
if ((ldir[i] = *cp)=='\0' || *cp==':') break;
cp++;
}
ldir[i] = '\0';
}
return(ldir);
}