First Commit of my working state
[simh.git] / PDP11 / txt2cbn.c
1 #include <stdio.h>
2
3 #define ERROR 00404
4 #include "pdp11_cr_dat.h"
5
6 static int colStart = 1; /* starting column */
7 static int colEnd = 80; /* ending column */
8
9 main ()
10 {
11 int col, c;
12
13 while (1) {
14 for (col = colStart; col <= colEnd; ) {
15 switch (c = fgetc (stdin)) {
16 case EOF:
17 /* fall through */
18 case '\n':
19 while (col <= colEnd) {
20 fputc (o29_code[' '] & 077, stdout);
21 fputc ((o29_code[' '] >> 6) & 077, stdout);
22 col++;
23 }
24 break;
25 case '\t':
26 do {
27 fputc (o29_code[' '] & 077, stdout);
28 fputc ((o29_code[' '] >> 6) & 077, stdout);
29 col++;
30 } while (((col & 07) != 1) && (col <= colEnd));
31 break;
32 default:
33 fputc (o29_code[c] & 077, stdout);
34 fputc ((o29_code[c] >> 6) & 077, stdout);
35 col++;
36 break;
37 }
38 }
39 /* flush long lines, or flag over-length card */
40 if (c != '\n' && c != EOF) {
41 printf ("overlength line\n");
42 do c = fgetc (stdin);
43 while ((c != EOF) && (c != '\n'));
44 }
45 if (c == EOF)
46 break;
47 }
48 exit (1);
49 }