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