home *** CD-ROM | disk | FTP | other *** search
- /*
- The following program will reverse assemble a Nortons Guide
- database or .ngo file.
-
- After reverse assembling the output will require some
- attention as I have not completed the work due to lack of
- time and the ouptut from this program sufficed my need.
-
- The program was written due to the loss of a large text file
- input to a database going astray and, not being a masochist,
- I did not want to type the whole thing in again.
-
- All I have done is reverse the character translation performed by the NG program, why they do this I do not know.
-
- There are one or two problems in the > 128 character set but
- I have not the time to work them out.
-
- There are some control blocks embedded in the guides that I
- have not yet touched though I have a rough idea as to how
- they are interpreted.
- */
-
- #include <stdio.h>
- #include <dos.h>
-
- char Table[] =
- {
- 0x1A, // 0x00
- '', // 0x01
- '', // 0x02
- '', // 0x03
- '', // 0x04
- '', // 0x05
- '', // 0x06
- '', // 0x07
- '', // 0x08
- '', // 0x09
- '', // 0x0A
- '', // 0x0B
- '', // 0x0C
- '', // 0x0D
- '', // 0x0E
- '', // 0x0F
- '', // 0x10
- 0x0B, // 0x11
- 0x0C, // 0x12
- '', // 0x13
- '', // 0x14
- '', // 0x15
- '', // 0x16
- 0x0D, // 0x17
- '', // 0x18
- '', // 0x19
- 0x1A, // 0x1A
- '', // 0x1B
- '', // 0x1C
- '', // 0x1D
- '', // 0x1E
- '', // 0x1F
- ':', // SPACE
- ';', // !
- '8', // "
- '9', // #
- '>', // $
- '?', // %
- '<', // &
- '=', // '
- '2', // (
- '3', // )
- '0', // *
- '1', // +
- '6', // ,
- '7', // -
- '4', // .
- '5', // /
- '*', // 0
- '+', // 1
- '(', // 2
- ')', // 3
- '.', // 4
- '/', // 5
- ',', // 6
- '-', // 7
- '"', // 8
- '#', // 9
- ' ', // :
- '!', // ;
- '&', // <
- '\'', // =
- '$', // >
- '%', // ?
- 'Z', // @
- 'A', // A
- 'X', // B
- 'Y', // C
- '^', // D
- 'E', // E
- 'F', // F
- 'G', // G
- 'R', // H
- 'S', // I
- 'P', // J
- 'Q', // K
- 'V', // L
- 'W', // M
- 'T', // N
- 'U', // O
- 'J', // P
- 'K', // Q
- 'H', // R
- 'I', // S
- 'N', // T
- 'O', // U
- 'L', // V
- 'M', // W
- 'B', // X
- 'C', // Y
- 'Z', // Z
- 'A', // [
- 'F', // \
- 'G', // ]
- 'D', // ^
- 'E', // _
- 'z', // `
- 'a', // a
- 'x', // b
- 'y', // c
- 'd', // d
- 'e', // e
- 'f', // f
- 'g', // g
- 'r', // h
- 's', // i
- 'p', // j
- 'q', // k
- 'v', // l
- 'w', // m
- 't', // n
- 'u', // o
- 'j', // p
- 'k', // q
- 'h', // r
- 'i', // s
- 'n', // t
- 'o', // u
- 'l', // v
- 'm', // w
- 'b', // x
- 'c', // y
- 'z', // z
- 'a', // {
- 'f', // |
- 'g', // }
- 'd', // ~
- 'e', //
- 'Ü', // 128
- '¢', // 129
- 'ÿ', // 130
- 'Ö', // 1
- '₧', // 2
- 'ƒ', // 3
- '£', // 4
- '¥', // 5
- 'Æ', // 6
- 'ô', // 7
- 'É', // 8
- 'æ', // 9
- 'û', // 140
- 'ù', // 1
- 'ö', // 2
- 'ò', // 3
- 'è', // 4
- 'ï', // 5
- 'ê', // 6
- 'ë', // 7
- 'Ä', // 8
- 'Å', // 9
- 'î', // 150
- 'ì', // 1
- 'é', // 2
- 'â', // 3
- 'Ç', // 4
- 'ü', // 5
- 'å', // 6
- 'ç', // 7
- 'ä', // 8
- 'ç', // 9
- '║', // 160
- '╗', // 1
- '╕', // 2
- '╣', // 3
- '╛', // 4
- '┐', // 5
- '╝', // 6
- '╜', // 7
- '▓', // 8
- '│', // 9
- '░', // 170
- '▒', // 1
- '╢', // 2
- '╖', // 3
- '┤', // 4
- '╡', // 5
- '¬', // 6
- '½', // 7
- '¿', // 8
- '⌐', // 9
- '«', // 180
- '»', // 1
- '¼', // 2
- '¡', // 3
- 'ó', // 4
- 'ú', // 5
- 'á', // 6
- 'í', // 7
- 'ª', // 8
- 'º', // 9
- 'ñ', // 190
- 'Ñ', // 1
- '┌', // 2
- '█', // 3
- '╪', // 4
- '┘', // 5
- '▐', // 6
- '▀', // 7
- '▄', // 8
- '▌', // 9
- '╥', // 200
- '╙', // 1
- '╨', // 2
- '╤', // 3
- '╓', // 4
- '╫', // 5
- '╘', // 6
- '╒', // 7
- '╩', // 8
- '╦', // 9
- '╚', // 210
- '╔', // 1
- '╬', // 2
- '╧', // 3
- '╠', // 4
- '╫', // 5
- '┬', // 6
- '├', // 7
- '└', // 8
- '┴', // 9
- '╞', // 220
- '╟', // 1
- '─', // 2
- '┼', // 3
- '·', // 4
- '√', // 5
- '°', // 6
- '∙', // 7
- '■', // 8
- '\t', // 9
- 'ⁿ', // 230
- '²', // 1
- '≥', // 2
- '≤', // 3
- '≡', // 4
- '±', // 5
- '÷', // 6
- '≈', // 7
- '⌠', // 8
- '⌡', // 9
- 'Ω', // 240
- 'δ', // 1
- 'Φ', // 2
- 'Θ', // 3
- 'ε', // 4
- '∩', // 5
- '∞', // 6
- 'φ', // 7
- 'Γ', // 8
- 'π', // 9
- 'α', // 250
- 'ß', // 1
- 'µ', // 2
- 'τ', // 3
- 'Σ', // 4
- 'σ' // 5
- };
-
-
- char Output[1024];
- char Path[100];
- char OPath[100];
- FILE *fp;
- FILE *ot;
- struct find_t DTA;
-
- void strmfe ( char *, char * );
- void NGHeader ( void );
-
- void main ( argc, argv )
- int argc;
- char **argv;
- {
- register char *p;
- register int c;
- int att;
-
- while ( *++argv )
- {
- verpat ( *argv, Path ); // Builds Path From Spec
-
- verpat ( "X.X", OPath ); // Get Current Path For Output
-
- if ( _dos_findfirst ( *argv, 0xFF, &DTA ) == 0 )
- do
- {
- sprintf ( Output, "%s%s", Path, DTA.name );
-
- printf ( "\nFile : %s\n", Output );
-
- if ( ( fp = fopen ( Output, "rb" ) ) != NULL )
- {
- sprintf ( Output, "%s%s", OPath, DTA.name );
-
- strmfe ( Output, "TXT" );
-
- ot = fopen ( Output, "w" );
-
- p = Output;
-
- NGHeader ( );
-
- while ( DTA.size-- > 0L )
- {
- c = getc ( fp );
-
- c = Table[c]; // Convert Character
-
- if ( c == 0x1A ) /* 1A = CR/LF */
- {
- *p = '\0';
-
- fprintf ( ot, "%s\n", Output );
-
- p = Output;
-
- fprintf ( stderr, "%ld \r", DTA.size );
-
- memset ( Output, '\0', sizeof ( Output ) );
- }
- else
- if ( c == '\t' )
- {
- c = getc ( fp ); // Get Tab Position
-
- c = Table[c]; // Convert It
-
- DTA.size -= 1L;
-
- for ( ; c > 0; c-- ) // Insert Spaces
- *p++ = ' ';
- }
- else
- if ( c >= ' ' ) // Only Print Space & Above
- *p++ = c;
- }
-
- fprintf ( stderr, "%-20s \r", " " );
- }
- }
- while ( _dos_findnext ( &DTA ) == 0 );
- }
- }
-
-
- void NGHeader ( void )
- {
- int c;
-
- fread ( Output, 2, 1, fp );
-
- if ( Output[0] == 'N' && Output[1] == 'G' )
- {
- fread ( &c, 2, 1, fp );
-
- printf ( "I Dont Know : %d\n", c );
-
- fread ( &c, 2, 1, fp );
-
- printf ( "I Dont Know : %d\n", c );
-
- fread ( &c, 2, 1, fp );
-
- printf ( "Menu Count : %d\n", c );
-
- fread ( Output, 40, 1, fp );
-
- printf ( "Database Name : %s\n", Output );
-
- fprintf ( ot, "!name : %s\n", Output );
-
- printf ( "Credits :\n" );
-
- fprintf ( ot, "!credits:\n" );
-
- DTA.size -= 46L;
-
- for ( c = 0; c != 5; c++ )
- {
- fread ( Output, 66, 1, fp );
-
- printf ( "%s\n", Output );
-
- fprintf ( ot, "%s\n", Output );
-
- DTA.size -= 66L;
- }
- }
- }
-