#include <exec/exec.h>
#include <stdio.h>
#include <stdlib.h>
#include "dh1:source/doors/romconf/doorheader.h"
#define gu getuserstring
long enc[100];
void LastCommand(void);
void end(void);
main(int argc,char *argv[])
{
  char name[200];
  char Date[200];
  long thedate;
  long total=0L;
  FILE *fi;
  register int i=0;
  Register(argv[1][0]-'0');
  gu(name,DT_NAME);
  gu(Date,DT_CURR_TIME);
  thedate=atol(Date);
  while(name[i]!='\0')
  {
     enc[i]=thedate+(LONG)name[i];
     total +=(LONG)name[i];
     i++;
  }
  fi=fopen("CODE:Encrypt.h","w");
  fprintf(fi,"long CheckSum = %ldL;\n",thedate);
  fprintf(fi,"long CodeName[] = { ");
  while(i)
  {
    fprintf(fi,"\t%ldL,\n",enc[i-1]);
    i--;
  }
  fprintf(fi,"\t0L };\n");
  fprintf(fi,"long CodeTotal = %ldL;\n",total);
  strcpy(name,"[44m[36m/X[0m [32mRegistered to [33m");
  i=0;
    while(name[i]!='\0')
  {
     enc[i]=thedate+(LONG)name[i];
     total +=(LONG)name[i];
     i++;
  }
    fprintf(fi,"long Legal[] = { ");
  while(i)
  {
    fprintf(fi,"\t%ldL,\n",enc[i-1]);
    i--;
  }
  fprintf(fi,"\t0L };\n");

  fclose(fi);
  ShutDown();
  end();
}
void LastCommand(void)
{
}
void end(void)
{
  exit(0);
}