DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

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

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦47fa4d15e⟧ TextFile

    Length: 337 (0x151)
    Types: TextFile
    Names: »user_count.c«

Derivation

└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki
    └─ ⟦this⟧ »EUUGD11/euug-87hel/sec8/mon/user_count.c« 

TextFile

#include <stdio.h>
#include <utmp.h>

int user_count()
{
	static int first = 1;
	static FILE *strm;
	struct utmp utmp;
	int count = 0;

	if (first)
	{
	    strm = fopen("/etc/utmp", "r");
	    first = 0;
	}

	rewind(strm);
	while(fread(&utmp, sizeof(utmp), 1, strm))
	{
	    if (utmp.ut_name[0] != '\0')
		count++;
	}

	return(count);
}