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