1: /* @(#)getlogin.c 2.1 SCCS id keyword */
2: #include <utmp.h>
3:
4: static char UTMP[] = "/etc/utmp";
5: static struct utmp ubuf;
6:
7: char *
8: getlogin()
9: {
10: register me, uf;
11: register char *cp;
12:
13: if( !(me = ttyslot()) )
14: return(0);
15: if( (uf = open( UTMP, 0 )) < 0 )
16: return(0);
17: lseek( uf, (long)(me*sizeof(ubuf)), 0 );
18: if (read(uf, (char *)&ubuf, sizeof(ubuf)) != sizeof(ubuf))
19: return(0);
20: close(uf);
21: ubuf.ut_name[8] = ' ';
22: for (cp=ubuf.ut_name; *cp++!=' ';)
23: ;
24: *--cp = '\0';
25: return( ubuf.ut_name );
26: }
Defined functions
Defined variables
UTMP
defined in line
4; used 1 times
ubuf
defined in line
5; used 7 times