1: #if defined(LIBC_SCCS) && !defined(lint)
2: static char sccsid[] = "@(#)getlogin.c 5.3 (Berkeley) 5/9/86";
3: #endif LIBC_SCCS and not lint
4:
5: #include <utmp.h>
6:
7: static char UTMP[] = "/etc/utmp";
8: static struct utmp ubuf;
9:
10: char *
11: getlogin()
12: {
13: register int me, uf;
14: register char *cp;
15:
16: if (!(me = ttyslot()))
17: return(0);
18: if ((uf = open(UTMP, 0)) < 0)
19: return (0);
20: lseek (uf, (long)(me*sizeof(ubuf)), 0);
21: if (read(uf, (char *)&ubuf, sizeof (ubuf)) != sizeof (ubuf)) {
22: close(uf);
23: return (0);
24: }
25: close(uf);
26: if (ubuf.ut_name[0] == '\0')
27: return (0);
28: ubuf.ut_name[sizeof (ubuf.ut_name)] = ' ';
29: for (cp = ubuf.ut_name; *cp++ != ' '; )
30: ;
31: *--cp = '\0';
32: return (ubuf.ut_name);
33: }
Defined functions
getlogin
defined in line
10; used 57 times
- in /usr/src/bin/date.c line
52,
97
- in /usr/src/bin/mail.c line
48,
69
- in /usr/src/bin/passwd.c line
45,
100
- in /usr/src/bin/su.c line
40,
96
- in /usr/src/etc/halt.c line
38,
65
- in /usr/src/etc/reboot.c line
39,
61
- in /usr/src/etc/shutdown.c line
101,
118
- in /usr/src/games/boggle/boggle.c line
64,
524
- in /usr/src/games/snake/snake.c line
913
- in /usr/src/lib/libc/net/rexec.c line
23
- in /usr/src/lib/libc/net/ruserpass.c line
18,
30
- in /usr/src/new/mh/uip/ttym.c line
22,
32
- in /usr/src/new/news/src/recmail.c line
229,
239
- in /usr/src/new/nntp/rrn/intrp.c line
88,
109
- in /usr/src/new/rn/intrp.c line
88,
109
- in /usr/src/new/xns/examples/filing/main.c line
97
- in /usr/src/old/talk/get_names.c line
14,
44
- in /usr/src/ucb/error/errorfilter.c line
42
- in /usr/src/ucb/ftp/ftp.c line
151,
161
- in /usr/src/ucb/ftp/main.c line
39,
111
- in /usr/src/ucb/ftp/ruserpass.c line
29
- in /usr/src/ucb/talk/get_names.c line
15,
42
- in /usr/src/undoc/v6mail.c line
15,
53
- in /usr/src/usr.bin/learn/learn.c line
36-40(2)
- in /usr/src/usr.bin/tip/log.c line
32
- in /usr/src/usr.bin/tip/tip.h line
238
- in /usr/src/usr.bin/uucp/getpwinfo.c line
23-25(2)
- in /usr/src/usr.bin/xsend/enroll.c line
17
- in /usr/src/usr.bin/xsend/xget.c line
28
- in /usr/src/usr.bin/xsend/xsend.c line
22,
31
- in /usr/src/usr.lib/libU77/getlog_.c line
22-27(2)
- in /usr/src/usr.lib/sendmail/src/conf.c line
360,
367,
427,
445
Defined variables
UTMP
defined in line
7; used 1 times
sccsid
defined in line
2;
never used
ubuf
defined in line
8; used 9 times