/* WhatTTY -- Generic WHO
UTMP Reader "Skeleton" : By Sir Hackalot / PhaZe

This is basically a skeleton program that is just a base for any UTMP
operations.

This is the skeleton that PhaZe(soft) uses for anything that deals
with reading the utmp file, such as MBS, SEND, VW, MME, and other
utilities.

Applications: You can use this when you need to do something to
everyone online, or when you need some sort of data from utmp, wtmp
or any file that is like utmp.
*/

#include <stdio.h>
#include <sys/types.h> /* This is the key to the whole thing */
#include <utmp.h>
#include <fcntl.h>


main()
{
        int handle;
        char *etc = "/etc/utmp";
        struct utmp user;

        handle = open(etc,O_RDONLY);

        while(read(handle,&user,sizeof(user)) != 0) {
                if (user.ut_type == USER_PROCESS)
                printf("%s is on %s\n",user.ut_name,user.ut_line);
        }
        close(handle);

/* Simple, Right? */
/* To see anything that is waiting for a login, change USER_PROCESS
to LOGIN_PROCESS */
}
