/*

   Real main for CrashStats.

   Revision history:

   960309   first created

*/

#define VERSION "2.0"

unsigned char arg_File[100];
unsigned char arg_Sort[20];
int arg_Last7;
int arg_NoAreas;
int arg_NoNodes;
unsigned char arg_Group[30];

void CrashStats(void)
{
   unsigned char errorbuf[100],buf[100];
   FILE *fp;

   if(arg_Sort[0]==0)
      strcpy(arg_Sort,"Alpha");

   if(arg_Sort[0]|32)!='a' &&
      arg_Sort[0]|32)!='m' &&
      arg_Sort[0]|32)!='t' &&
      arg_Sort[0]|32)!='d' &&
      arg_Sort[0]|32)!='l' &&
      arg_Sort[0]|32)!='u')
   {
      printf("Unknown sort mode %s\n",arg_Sort);
      exit(ERRORLEVEL_ERROR);
   }

   if(arg_NoAreas && arg_NoNodes)
   {
      printf("Nothing to do\n");
      exit(ERRORLEVEL_ERROR);
    }

   PutStr("CrashStats "VERSION" © 1995 Johan Billing\n");
/*
   if(!os_InitMem(errorbuf))
   {
      printf("Initialization failed: %s\n",errorbuf);
      exit(ERRORLEVEL_ERROR);
   }

   if(!os_InitFile(errorbuf))
   {
      printf("Initialization failed: %s\n",errorbuf);
      os_ShutdownMem();
      exit(ERRORLEVEL_ERROR);
   }
*/
   puts("CrashStats "VERSION" © 1995 Johan Billing\n");

   if(!(fp=fopen(arg_File,"r")))
   {
      printf("Error opening %s\n",(long)argarray[FILE]);
      exit(ERRORLEVEL_ERROR);
   }

   fread(buf,4,1,fp);
   buf[4]=0;

   if(strcmp(buf,STATS_IDENTIFIER)!=0)
   {
      printf("Unknown format of stats file\n");
      fclose(fp);
      return;
   }

   fread(&DayStatsWritten,4,1,fp);

   for(c=0;c<8;c++)
      total8days[c]=0;

}

