#include <utmp.h>

main()
{
	int i, j, fd;
	struct utmp ubuf[256];	

	if ((fd = open("/etc/utmp", 0)) < 0) {
		printf("Cannot open utmp\en");
		exit(1);
	}
	j = read(fd, ubuf, 256 * sizeof(struct utmp));
	j /= sizeof(struct utmp);
	close(fd);

	for (i=0; i < j; i++) {
		/*
		 * If no one is there, skip it.
		 */
		if (ubuf[i].ut\(ulname[0] == 0) 
			continue;

		printf("%8.8s %s\en", ubuf[i].ut\(ulname, ubuf[i].ut\(ulline);
	}
}
