|
|
DataMuseum.dkPresents historical artifacts from the history of: Commodore CBM-900 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Commodore CBM-900 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 668 (0x29c)
Types: TextFile
Notes: UNIX file
Names: »getlogin.c«
└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
└─⟦f4b8d8c84⟧ UNIX Filesystem
└─⟦this⟧ »libc/gen/getlogin.c«
/*
* Coherent I/O Library.
* Get login name from the utmp file.
*/
#include <stdio.h>
#include <utmp.h>
char *ttyname();
char *
getlogin()
{
register struct utmp *up;
register int n;
register char *tname;
register int ufd;
char iobuf[BUFSIZ+1];
static char uname[DIRSIZ];
if ((ufd = open("/etc/utmp", 0))>=0
&& (tname = ttyname(fileno(stderr)))!=NULL) {
tname += 5; /* Skip over "/dev/" */
while ((n = read(ufd, iobuf, BUFSIZ)) > 0)
for (up = iobuf; up < &iobuf[n]; up++)
if (strncmp(up->ut_line, tname, 8) == 0) {
close(ufd);
strncpy(uname, up->ut_name, DIRSIZ);
return (uname);
}
close(ufd);
}
return (NULL);
}