/* Rewrite for VAX: BSB 9/9/79 */ /* Compiled with V7 cc: BSB 6/2/79 */ #include #include #include #include #include #include #define CLEARPAGE write(2,"\014\000",2); #define PAUSE 0 #define NOTIFY 1 #define CLEAR 2 #define NOTICLEAR 3 int spage = 37; int page; short int width = 79; short int noclr = 0; short int first = 0; short int numop = 0; short int flagctl = 1; short int ontty = 1; /* assume we're outputting to a tty */ short int delflg; /* a was typed. */ FILE *fin; jmp_buf envir; main(argc, argv) int argc; char *argv[]; { register int i,k,n; register char *c1, *c2; int j, clrflag; int int2(), getout(); struct sgttyb sg; struct stat st; extern char _sibuf[], _sobuf[]; if(gtty(1, &sg) == -1) { ontty = 0; flagctl = 0; } c1 = c2 = argv[0]; do if(*c1++ == '/') c2 = c1; while(*c1); if(*c2 == 'c') noclr++; k=0; for( i=1; i1) { if(i && delflg <= 0) printf("\n\n"); delflg = 0; if(ontty) { printf("Press to list \"%s\"\n", argv[i]); clrflag = 1; } else printf(">>>>> File \"%s\"\n", argv[i]); } pfile(clrflag); } getout(); } int linpos, line, ct; pfile(flg) { register int c; if(flg) nextpage(NOTICLEAR); else if(!noclr && ontty) CLEARPAGE; delflg = -1; line = 1; ct = page; while (line < first) /* Dcrocker: skip to first line */ if((c = getch()) == EOF) return; else if(c == '\n') line++; linpos = 0; while ((c = getch()) != EOF) putch(c); fflush(stdout); } num(s) /* computes the internal form of a number */ register char *s; /* bad chars are ignored */ { register int c, i, sign; sign=1; i=0; while(c = *s++) { if(c=='-' && sign==1) sign = -1; c -= '0'; if(c>=0 && c<=9) i=i*10+c; } return(i*sign); } nextpage (clearpage) { char c; if(!ontty) return; if (clearpage & NOTIFY) putchar('\007'); fflush(stdout); c = 0; while(read(2, &c, 1) && c != '\n') ; if (clearpage & CLEAR && c) { CLEARPAGE; page = spage; } else { page = (spage>>1) + (spage>>3); /*** page = spage * .6; ***/ } return; } int2() { signal(SIGINT,int2); stdout->_cnt = BUFSIZ; stdout->_ptr = stdout->_base; if(delflg) putchar('\n'); delflg++; longjmp(envir, 1); } int peekc = -2; peekch() { return(peekc = getch()); } getch() { register int c; static word; if(peekc != -2) { c = peekc; peekc = -2; return(c); }; c = getc(fin); if(c != EOF) c &= 0177; return(c); } putch(c) register int c; { if(linpos == 0 && numop) { printf("%-5d | "); linpos += 8; } if(c < 040 || c == 0177) switch(c) { case '\n': line++; linpos = -1; break; case 014: goto npage; case 011: linpos += 8; linpos &= ~07; linpos--; break; default: if(flagctl) { if(c == '\7') putchar(c); putch('^'); if(c != 0177) c += '@'; else c = 'd'; } } putchar(c); linpos++; if(width && linpos >= width && peekch() != '\n') { putchar('\n'); linpos = 0; } if(linpos == 0 && --ct <= 0) { npage: nextpage(NOTICLEAR); ct = page; } } getout() { exit(0); }