DataMuseum.dk

Presents historical artifacts from the history of:

Commodore CBM-900

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Commodore CBM-900

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦1bc71f6c1⟧ TextFile

    Length: 668 (0x29c)
    Types: TextFile
    Notes: UNIX file
    Names: »getlogin.c«

Derivation

└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
    └─⟦f4b8d8c84⟧ UNIX V7 Filesystem
        └─ ⟦this⟧ »libc/gen/getlogin.c« 

TextFile

/*
 * 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);
}