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