home *** CD-ROM | disk | FTP | other *** search
/ HaCKeRz KrOnIcKLeZ 3 / HaCKeRz_KrOnIcKLeZ.iso / ircscripts / warirc / wzap.c < prev    next >
C/C++ Source or Header  |  1996-04-23  |  972b  |  48 lines

  1.  
  2. /*  Dave's neato wtmp program  
  3.  *    wzap.c  
  4.  *    NOTE:      reads 'wtmp' from current directory and writes
  5.  *            'wtmp.out' in cuurent directory...
  6.  */
  7.  
  8. #include    <utmp.h>
  9. #include    <stdio.h>
  10. #include    <time.h>
  11. #include    <sys/time.h>
  12.  
  13. FILE *Wfile, *Wout;
  14.  
  15. struct utmp myutmp;
  16.  
  17. main(argc,argv) 
  18. int argc;
  19. char *argv[];
  20. {
  21.     char username[20];
  22.     char yesorno[5];
  23.     long thetime, posi;
  24.  
  25.     if (argc<2) {
  26.         printf("\n\n");
  27.         printf("Enter username to zap from the wtmp: ");
  28.         scanf("%s",username);
  29.     } else strcpy(username,argv[1]);
  30.  
  31.     printf("\nopening file...\n");
  32.     if ((Wfile = fopen("wtmp","r"))==NULL)
  33.         { printf("no open file\n"); exit(0); }
  34.     printf("\opening output file...\n");
  35.     if ((Wout = fopen("wtmp.out","wr"))==NULL)
  36.         { printf("no open output file...\n"); exit(0); }
  37.  
  38.     printf("working...\n");
  39.     while(!feof(Wfile)) {
  40.         fread(&myutmp,sizeof(myutmp),1,Wfile);
  41.         if (strncmp(myutmp.ut_name,username,8))
  42.             fwrite(&myutmp,sizeof(myutmp),1,Wout); 
  43.     }
  44.     fclose(Wfile);
  45.     fclose(Wout);
  46. }
  47.  
  48.