|
|
1.1 root 1: #ifndef lint
2: static char sccsid[] = "@(#)t1.c 4.3 5/11/89";
3: #endif
4:
5: /* t1.c: main control and input switching */
6: #
7: # include "t..c"
8: #include <signal.h>
9: #include "pathnames.h"
10:
11: # ifdef gcos
12: /* required by GCOS because file is passed to "tbl" by troff preprocessor */
13: # define _f1 _f
14: extern FILE *_f[];
15: # endif
16:
17: # define ever (;;)
18:
19: main(argc,argv)
20: char *argv[];
21: {
22: # ifdef unix
23: int badsig();
24: signal(SIGPIPE, badsig);
25: # endif
26: # ifdef gcos
27: if(!intss()) tabout = fopen("qq", "w"); /* default media code is type 5 */
28: # endif
29: exit(tbl(argc,argv));
30: }
31:
32:
33: tbl(argc,argv)
34: char *argv[];
35: {
36: char line[BUFSIZ];
37: /* required by GCOS because "stdout" is set by troff preprocessor */
38: tabin=stdin; tabout=stdout;
39: setinp(argc,argv);
40: while (gets1(line))
41: {
42: fprintf(tabout, "%s\n",line);
43: if (prefix(".TS", line))
44: tableput();
45: }
46: fclose(tabin);
47: return(0);
48: }
49: int sargc;
50: char **sargv;
51: setinp(argc,argv)
52: char **argv;
53: {
54: sargc = argc;
55: sargv = argv;
56: sargc--; sargv++;
57: if (sargc>0)
58: swapin();
59: }
60: swapin()
61: {
62: while (sargc>0 && **sargv=='-') /* Mem fault if no test on sargc */
63: {
64: if (sargc<=0) return(0);
65: if (match("-ms", *sargv))
66: {
67: *sargv = _PATH_MACROS;
68: break;
69: }
70: if (match("-mm", *sargv))
71: {
72: *sargv = _PATH_PYMACS;
73: break;
74: }
75: if (match("-TX", *sargv))
76: pr1403=1;
77: sargc--; sargv++;
78: }
79: if (sargc<=0) return(0);
80: # ifdef unix
81: /* file closing is done by GCOS troff preprocessor */
82: if (tabin!=stdin) fclose(tabin);
83: # endif
84: tabin = fopen(ifile= *sargv, "r");
85: iline=1;
86: # ifdef unix
87: /* file names are all put into f. by the GCOS troff preprocessor */
88: fprintf(tabout, ".ds f. %s\n",ifile);
89: # endif
90: if (tabin==NULL)
91: error("Can't open file");
92: sargc--;
93: sargv++;
94: return(1);
95: }
96: # ifdef unix
97: badsig()
98: {
99: signal(SIGPIPE, SIG_IGN);
100: exit(0);
101: }
102: # endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.