home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 152.lha / XBoot / xboot.c < prev    next >
C/C++ Source or Header  |  1988-04-26  |  2KB  |  51 lines

  1. /* Conversion of a boot-block in an executable */
  2. /* Placed in Public Domain by Francois Rouaix in 1988 */
  3. #include <libraries/dos.h>
  4. char buffer[1024] ;
  5. long header[12] = { 0x000003f3,   /* Hunk_Header */
  6.                     0x00000000,   /* no hunk_name */
  7.                     0x00000002,   /* size of hunk_table */
  8.                     0x00000000,   /* first hunk */
  9.                     0x00000001,   /* last hunk */
  10.                     0x000000fd,   /* size of hunk 0 */
  11.                     0x00000003,   /* size of hunk 1 */
  12.                     0x000003e9,   /* hunk_code */
  13.                     0x000000fd,   /* size of hunk_code = 253 */
  14.                     /* end of header */
  15.                     0x000003ea,   /* hunk_data */
  16.                     0x00000003,   /* size */
  17.                     /* end of header */
  18.                     0x000003f2
  19.                   } ;
  20. /* xboot infile outfile */
  21. main(argc,argv)
  22. int argc;
  23. char *argv[];
  24. {
  25.    struct FileHandle  *infile=0,*outfile=0 ;
  26.    int b=0;
  27.    if (argc != 3) {
  28.       printf("Usage: %s infile outfile \n",argv[0]);
  29.       Exit(0);
  30.       }
  31.    if (!(infile = (struct FileHandle *)Open(argv[1],MODE_OLDFILE))) {
  32.       printf("Can't open %s\n",argv[1]);
  33.       Exit(0);
  34.       }
  35.    if (!(outfile = (struct FileHandle *)Open(argv[2],MODE_NEWFILE))) {
  36.       Close(infile);
  37.       printf("Can't open %s\n",argv[2]);
  38.       Exit(0);
  39.       }
  40.    b = Read(infile,&buffer[0],1024);
  41.    if (b != 1024)  printf("Warning ! Bad File.\n");
  42.    Close(infile);
  43.    Write(outfile,(char *)&header[0],4*9);        /* header */
  44.    Write(outfile,(char *)&buffer[12],4*253);     /* code */
  45.    Write(outfile,(char *)&header[11],4);       /* hunk_end */
  46.    Write(outfile,(char *)&header[9],4*2);        /* header for data */
  47.    Write(outfile,(char *)&buffer[0],4*3);        /* data */
  48.    Write(outfile,(char *)&header[11],4);       /* hunk_end */
  49.   Close(outfile);
  50. }
  51.