/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ /* From input file "asciicode.p" */ #include /* asciicode: converts ascii table to Pascal code Tom Schneider NCI/FCRDC Bldg 469. Room 144 P.O. Box B Frederick, MD 21702-1201 (301) 846-5581 (-5532 for messages) network address: toms@ncifcrf.gov National Cancer Institute Laboratory of Mathematical Biology 1993 */ /* end of program */ /* begin module version */ #define version 1.01 /* of asciicode.p 1993 January 26 origin 1993 Jan 8 */ /* end module version */ /* begin module describe.asciicode */ /* name asciicode: converts ascii table to Pascal code synopsis asciicode(ascii: in, code: out, output: out) files ascii: The ascii file must contain this table: | 0 NUL| 1 SOH| 2 STX| 3 ETX| 4 EOT| 5 ENQ| 6 ACK| 7 BEL | 8 BS | 9 HT | 10 NL | 11 VT | 12 NP | 13 CR | 14 SO | 15 SI | 16 DLE| 17 DC1| 18 DC2| 19 DC3| 20 DC4| 21 NAK| 22 SYN| 23 ETB | 24 CAN| 25 EM | 26 SUB| 27 ESC| 28 FS | 29 GS | 30 RS | 31 US | 32 SP | 33 ! | 34 " | 35 # | 36 $ | 37 % | 38 & | 39 ' | 40 ( | 41 ) | 42 * | 43 + | 44 , | 45 - | 46 . | 47 / | 48 0 | 49 1 | 50 2 | 51 3 | 52 4 | 53 5 | 54 6 | 55 7 | 56 8 | 57 9 | 58 : | 59 ; | 60 < | 61 = | 62 > | 63 ? | 64 @ | 65 A | 66 B | 67 C | 68 D | 69 E | 70 F | 71 G | 72 H | 73 I | 74 J | 75 K | 76 L | 77 M | 78 N | 79 O | 80 P | 81 Q | 82 R | 83 S | 84 T | 85 U | 86 V | 87 W | 88 X | 89 Y | 90 Z | 91 [ | 92 \ | 93 ] | 94 ^ | 95 _ | 96 ` | 97 a | 98 b | 99 c |100 d |101 e |102 f |103 g |104 h |105 i |106 j |107 k |108 l |109 m |110 n |111 o |112 p |113 q |114 r |115 s |116 t |117 u |118 v |119 w |120 x |121 y |122 z |123 { |124 | |125 } |126 ~ |127 DEL code: Pascal code that converts integers to these names. output: messages to the user description This program generates a chunk of Pascal code that is useful for detailed investigation of file characters. examples documentation see also lochas.p author Thomas Dana Schneider bugs technical notes */ /* end module describe.asciicode */ Static _TEXT ascii, code; /* a file used by this program */ Static jmp_buf _JL1; /* begin module halt */ Static Void halt() { /* stop the program. the procedure performs a goto to the end of the program. you must have a label: label 1; declared, and also the end of the program must have this label: 1: end. examples are in the module libraries. this is the only goto in the delila system. */ printf(" program halt.\n"); longjmp(_JL1, 1); } /* end module halt version = 'delmod 6.16 84 mar 12 tds/gds'; */ /* begin module asciicode.word */ Static Void word(ascii, code, count) _TEXT *ascii, *code; long *count; { /* do one word of the table */ long n; /* number of the character */ Char x, a, b, c; /* a space and the three letter name of the character */ fscanf(ascii->f, "%c%ld%c%c%c%c", &x, &n, &x, &a, &b, &c); if (x == '\n') x = ' '; if (x == '\n') x = ' '; if (a == '\n') a = ' '; if (b == '\n') b = ' '; if (c == '\n') c = ' '; if (*count != n) printf("%12ld<>%12ld\n", *count, n); fprintf(code->f, " %3ld: write(f,'%c", n, a); /* single quote! */ if (b == '\'') fprintf(code->f, "''"); /* double quote! */ else putc(b, code->f); fprintf(code->f, "%c');\n", c); /* single quote! */ (*count)++; } /* end module asciicode.word */ /* begin module asciicode.line */ Static Void line(ascii, code, count) _TEXT *ascii, *code; long *count; { /* do one line of the table */ long x; /* index to the words */ for (x = 1; x <= 8; x++) word(ascii, code, count); fscanf(ascii->f, "%*[^\n]"); getc(ascii->f); } /* end module asciicode.line */ /* begin module asciicode.themain */ Static Void themain(ascii, code) _TEXT *ascii, *code; { /* the main procedure of the program */ long count = 0; /* count of the characters done */ long y; /* index for the lines to produce */ printf("asciicode %4.2f\n", version); if (*ascii->name != '\0') { if (ascii->f != NULL) ascii->f = freopen(ascii->name, "r", ascii->f); else ascii->f = fopen(ascii->name, "r"); } else rewind(ascii->f); if (ascii->f == NULL) _EscIO2(FileNotFound, ascii->name); RESETBUF(ascii->f, Char); if (*code->name != '\0') { if (code->f != NULL) code->f = freopen(code->name, "w", code->f); else code->f = fopen(code->name, "w"); } else { if (code->f != NULL) rewind(code->f); else code->f = tmpfile(); } if (code->f == NULL) _EscIO2(FileNotFound, code->name); SETUPBUF(code->f, Char); for (y = 1; y <= 16; y++) line(ascii, code, &count); } /* end module asciicode.themain */ main(argc, argv) int argc; Char *argv[]; { PASCAL_MAIN(argc, argv); if (setjmp(_JL1)) goto _L1; code.f = NULL; strcpy(code.name, "code"); ascii.f = NULL; strcpy(ascii.name, "ascii"); themain(&ascii, &code); _L1: if (ascii.f != NULL) fclose(ascii.f); if (code.f != NULL) fclose(code.f); exit(EXIT_SUCCESS); } /* End. */