/* * Word Processor * similar to Unix NROFF or RSX-11M RNO - * adaptation of text processor given in * "Software Tools", Kernighan and Plauger. * * Stephen L. Browning * 5723 North Parker Avenue * Indianapolis, Indiana 46220 */ #include #include "nro.h" #define EXTERN #include "nroxtrn.h" abs(foo) int foo; { return( (foo > 0) ? foo : -foo); } main(argc,argv) int argc; char *argv[]; { int i; int swflg; int ifp, ofp; swflg = FALSE; pout = stdout; ifp = ofp = 0; init(); for (i=1; i') { if (ofp == 0) { if (!strcmp(argv[i]+1,"$P")) { ofp = 1; co.lpr = TRUE; } else if ((oub = fopen(argv[i]+1,"w")) == NULL) { printf("nro: cannot create %s\n",argv[i]+1); exit(-1); } else { pout = oub; } } else { puts("nro: too many output files\n"); exit(-1); } } } for (i=1; ioutfile]\n"); exit(-1); } if (pout != stdout) { putc(CPMEOF,pout); fflush(pout); fclose(pout); } } /* * retrieve one line of input text */ getlin(p,in_buf) char *p; FILE *in_buf; { int i; int c; char *q; q = p; for (i=0; i= &mac.pbb[0]) { c = *mac.ppb--; } else { c = getc(infp); } return(c); } /* * process input files from command line */ profile() { char ibuf[MAXLINE]; for (dc.flevel=0; dc.flevel>=0; --dc.flevel) { while (getlin(ibuf,sofile[dc.flevel]) != EOF) { if (ibuf[0] == dc.cmdchr) comand(ibuf); else text(ibuf); } if (dc.flevel > 0) fclose(sofile[dc.flevel]); } if (pg.lineno > 0) space(HUGE); } /* * process switch values from command line */ pswitch(p,q) char *p; int *q; { int swgood; swgood = TRUE; if (*p == '-') { switch (tolower(*++p)) { case 'b': dc.bsflg = TRUE; break; case 'm': if ((sofile[0] = fopen(++p,"r")) == NULL) { printf("***nro: unable to open file %s\n",p); exit(-1); } profile(); fclose(sofile[0]); break; case 'p': set(&pg.offset,ctod(++p),'1',0,0,HUGE); break; case 'v': printf("NRO version 1.0\n"); *q = TRUE; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': pg.lastpg = ctod(p); break; default: swgood = FALSE; break; } } else if (*p == '+') { pg.frstpg = ctod(++p); } else { swgood = FALSE; } if (swgood == FALSE) { printf("nro: illegal switch %s\n",p); return(ERR); } return(OK); }