#include <exec/types.h>
#include <stdio.h>
#include <string.h>

struct User {
 char    Name[31],Pass[9],Location[30],PhoneNumber[13];
 USHORT  Slot_Number;
 USHORT  Sec_Status,
     Sec_Board,                   /* File or Byte Ratio */
     Sec_Library,                 /* Ratio              */
     Sec_Bulletin,                /* Computer Type      */
     Messages_Posted;
 /* Note ConfYM = the last msg you actually read, ConfRead is the same ?? */
 ULONG   NewSinceDate, ConfRead1, ConfRead2, ConfRead3, ConfRead4,
         ConfRead5,  ConfRead6,  ConfRead7,  AccountDate;
 UWORD   ScreenType, Filler1;
 char    Conference_Access[10];
 USHORT  Uploads, Downloads, ConfRJoin, Times_Called;
 long    Time_Last_On, Time_Used, Time_Limit, Time_Total;
 ULONG   Bytes_Download, Bytes_Upload, Daily_Bytes_Limit, Daily_Bytes_Dld;
 char    Expert;
 ULONG   ConfYM1, ConfYM2, ConfYM3, ConfYM4, ConfYM5, ConfYM6, ConfYM7,
         ConfYM8, ConfYM9;
 long    BeginLogCall;
 UBYTE   Protocol, UUCPA, LineLength, New_User;
 };

char username[200];
void sr(char *s);

main(int argc,char *argv[])
{
   FILE *fi,*fo;
   struct User U;
   if(argc!=2)
   {
     printf("StripUser version 1.0, written by Joseph Hodge\n");
     printf("usage: StripUser <pathname>\n");
     printf("   ie: StripUser bbs:User.Data\n");
     printf("\n");
     exit(0);
   }
   strcpy(username,argv[1]);
   sr(username);
   fi=fopen(username,"rb");
   if(fi==NULL)
   {
     printf("Error, can't open %s\n",username);
     printf("\n");
     exit(0);
   }
   strcat(username,".new");
   fo=fopen(username,"wb");
   while(fread((APTR)&U,sizeof(struct User),1,fi)!=NULL)
   {
     U.ConfYM1=U.ConfYM2=U.ConfYM3=U.ConfYM4=U.ConfYM5=U.ConfYM6=U.ConfYM7=
     U.ConfYM8=U.ConfYM9=U.ConfRead1=U.ConfRead2=U.ConfRead3=U.ConfRead4=U.ConfRead5=
     U.ConfRead6=U.ConfRead7=0L; U.AccountDate=time(NULL);
     U.ScreenType=U.Filler1=0;
     fwrite((APTR)&U,sizeof(struct User),1,fo);
   }
   fclose(fo);
   fclose(fi);
   exit(0);
}

void sr(char *s)
{
   register int i;
   i=strlen(s)-1;
   while(i>-1)
   {
     if(*(s+i)<=32) *(s+i)='\0'; else break;
     i--;
   }
}
