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

⟦89c9355f4⟧ TextFile

    Length: 621 (0x26d)
    Types: TextFile
    Notes: UNIX file
    Names: »getpw.c«

Derivation

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

TextFile

/*
 * Coherent I/O Library
 * getpw -- get line from password file for a given `uid'.
 */
#include <stdio.h>


getpw(uid, buf)
short	uid;
char	*buf;
{
	register int	c;
	register char 	*cp;
	register FILE 	*fp;

	fp = fopen("/etc/passwd", "r");
	if (fp == NULL)
		return (1);
	while (!feof(fp)) {
		for (cp=buf; (c=getc(fp)) != EOF && c != '\n';)
			*cp++ = c;
		*cp = '\0';
		for (cp=buf; *cp != ':' && *cp != '\0'; ++cp)
			;
		if (*cp == '\0')
			continue;
		do {
			++cp;
		} while (*cp != ':' && *cp != '\0');
		if (*cp++ != '\0' && uid == atoi(cp)) {
			fclose(fp);
			return (0);
		}
	}
	fclose(fp);
	return (1);
}