#include <exec/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <libraries/dos.h>
#include <dos.h>

#include <proto/dlg.h>
#include <proto/dos.h>
#include <proto/exec.h>

#include <pragmas/dlg.h>

struct Library *DLGBase = NULL;

void main(int argc,char **argv)
{
   BPTR ifd;

   char buf1[32], buf2[32], buf3[32], buf4[32];

   if(!(DLGBase = OpenLibrary("dlg.library",2L)))
   {
      printf("Could not open dlg.library!\n");
      exit(10);
   }

   printf("Copying TPT-handler to Update.dat\n");

   if(Copy("TPT-Handler","Update.dat"))
   {
      printf("Error copying handler!\n");
      exit(10);
   }

   printf("Breaking Update.dat\n");

   if ((ifd=Open("update.dat", MODE_READWRITE))==NULL)
   {
      printf("Fatal Error\n");
      exit(10);
   }

   Read(ifd,buf1,32);
   Read(ifd,buf2,32);
   Read(ifd,buf3,32);
   Read(ifd,buf4,32);

   Seek(ifd,0L,OFFSET_BEGINNING);

   Write(ifd,buf3,32);
   Write(ifd,buf1,32);
   Write(ifd,buf4,32);
   Write(ifd,buf2,32);

   Close(ifd);

   printf("Done -- successful\n");

   exit(0);
}
