/* QBN4.CPP - Displays Contents of 7th QBN Section */ #include #include #include #include /* User Defined Includes */ #include "genutil.h" #include "fileutil.h" boolean main (void) { FILE *qbn_log; /* File pointers to output file */ FILE *where; FILE *null1; FILE *null2; FILE *f; /* File pointer to current input file */ struct ffblk file_block; /* DOS File Control Block Structure */ int done, i; /* Loop counters */ unsigned offset, size; unsigned char ch1, ch2, ch3, ch4; /* Open the output files */ qbn_log = openfile ("qbn4.log", "wt"); where = openfile ("where4.log", "wt"); null1 = openfile ("null4a.log", "wt"); null2 = openfile ("null4b.log", "wt"); /* Find each QBN in current directory and parse */ done = findfirst("*.qbn", &file_block, 0); while (!done) { /* Open the QBN file for input */ printf ("Reading File: '%s'\n", file_block.ff_name); f = openfile (file_block.ff_name, "rb"); /* Move to offset of 4th Offset/Size Values and read values */ fseek (f, 24, SEEK_SET); size = read_int (f); fseek (f, 44, SEEK_SET); offset = read_int (f); fprintf (qbn_log, "\n%s: #%d, offs 0x%X - ", file_block.ff_name, size, offset); fprintf (null1, "\n%s: #%d", file_block.ff_name, size); fprintf (null2, "\n%s: #%d", file_block.ff_name, size); fprintf (where, "\n%s: #%d", file_block.ff_name, size); /* Jump to offset of 1st Section */ if (size == 0) { /* fprintf (qbn_log, "NO SECTION\n"); */ } else if (!fseek (f, offset, SEEK_SET)) { /* Read in all the sections */ for (i = 0; i < size; i++) { /* Read the section index */ ch1 = fgetc (f); /* Read in 1st null section */ ch1 = fgetc (f); ch2 = fgetc (f); fprintf (null1, "\n %02X %02X", ch1, ch2); /* Read in where type #1 and #2*/ ch1 = fgetc(f); ch2 = fgetc(f); ch3 = fgetc(f); fprintf (where, "\n ( %02X ) ( %02X %02X ) ", ch1, ch2, ch3); /* Read in number 1 ??? */ ch1 = fgetc (f); ch2 = fgetc (f); fprintf (qbn_log, "\n %02X %02X", ch1, ch2); /* Read in number 2 ??? */ ch1 = fgetc (f); ch2 = fgetc (f); fprintf (qbn_log, " %02X %02X", ch1, ch2); /* Read in number 3 ??? */ ch1 = fgetc (f); ch2 = fgetc (f); fprintf (qbn_log, " %02X %02X", ch1, ch2); /* Read and ignore message hash value */ ch1 = fgetc (f); ch2 = fgetc (f); ch1 = fgetc (f); ch2 = fgetc (f); /* NULL Bytes? */ ch1 = fgetc (f); ch2 = fgetc (f); ch3 = fgetc (f); ch4 = fgetc (f); fprintf (null2, "\n %02X %02X %02X %02X", ch1, ch2, ch3, ch4); /* Ingore message values */ read_int(f); read_int(f); } /* End of for loop */ } else fprintf (qbn_log, "BAD OFFSET!\n"); fclose (f); /* Close QBN file */ done = findnext(&file_block); /* Find next QBN file */ } while (!done); fclose (qbn_log); /* Close output files */ fclose (null1); fclose (null2); fclose (where); return (TRUE); }