📄 rvcat.c
字号:
/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */#ifndef lintstatic char sccsid[] = "@(#)rvcat.c 1.1 92/07/30 SMI"; /* from UCB 5.1 5/15/85 */#endif not lint/* * Cat Simulator for Versatec and Varian * Modified for Varian with rotated fonts: wnj 5/30/80. * * Takes two extra special codes defined by rvsort: * 0115 - break for new page, goto (0,0) * 0116 - lead 64* following byte */ #include <stdio.h>#include <sys/vcmd.h>#include <vfont.h>int prtmode[] = {VPRINT};int pltmode[] = {VPLOT};#define DISPATCHSIZE 256 /* must be a power of two */#define CHARMASK (DISPATCHSIZE-1)#define NFONTS 25#define SPECIALFONT 3#define DSIZ ((sizeof *dispatch)*DISPATCHSIZE)#define MAXF 4#define LOCAL_RAILMAG ".railmag"#define GLOBAL_RAILMAG "/usr/lib/vfont/railmag"/* * Here we make up for the fact that we only have 2112 * bits vertically when we need 2200 (11''*200/in), by * a 4% vertical size squashing. */#define CONVERT(n) ((n*(200./432.))*(2112./2200.))#define RECONVERT(n) ((n*(432./200.))*(2200./2112.))#define NLINES 110#define FF_LINES 1600 /* Scan lines to output before formfeeding. */#define min(a,b) (a<b ? a : b)char buffer[NLINES * 264]; /* Big enough for varain */char *buf0p = &buffer[0]; /* Zero origin in circular buffer */char *calloc();char *nalloc();char *allpanic();struct header header;struct dispatch *dispatch;struct fontdes { int fnum; int psize; struct dispatch *disp; char *bits;} fontdes[NFONTS] = { -1, -1};struct point_sizes { int stupid_code; int real_code;} point_sizes[] = { 010, 6, 0, 7, 01, 8, 07, 9, 02, 10, 03, 11, 04, 12, 05, 14, 0211, 16, 06, 18, 0212, 20, 0213, 22, 0214, 24, 0215, 28, 0216, 36, 0, 0};int lines;int vc = 1; /* varian/versatec output file descriptor */int varian = 1; /* 0 for versatec, 1 for varian. */int BYTES_PER_LINE = 264; /* number of bytes per raster line. */int PAGE_LINES = 1700; /* number of raster lines per page. */int BUFFER_SIZE = NLINES * 264; /* buffer size. */int cfnum = -1;int cpsize = 10;int cfont = 1;char *bits;int nfontnum = -1;int fontwanted = 1;int npsize = 10;int last_ssize = 02;int xpos, ypos;int esc, lead, back, verd, mcase, railmag;double row, col;char *fontname[MAXF];char fnbuf[120];char *scanline;int linecount;char asctab[128] = { '\0', /*blank*/ 'h', /*h*/ 't', /*t*/ 'n', /*n*/ 'm', /*m*/ 'l', /*l*/ 'i', /*i*/ 'z', /*z*/ 's', /*s*/ 'd', /*d*/ 'b', /*b*/ 'x', /*x*/ 'f', /*f*/ 'j', /*j*/ 'u', /*u*/ 'k', /*k*/ '\0', /*blank*/ 'p', /*p*/ '\06', /*_ 3/4 em dash*/ ';', /*;*/ '\0', /*blank*/ 'a', /*a*/ '\05', /*rule*/ 'c', /*c*/ '`', /*` open*/ 'e', /*e*/ '\'', /*' close*/ 'o', /*o*/ '\021', /*1/4*/ 'r', /*r*/ '\022', /*1/2*/ 'v', /*v*/ '-', /*- hyphen*/ 'w', /*w*/ 'q', /*q*/ '/', /*/*/ '.', /*.*/ 'g', /*g*/ '\023', /*3/4*/ ',', /*,*/ '&', /*&*/ 'y', /*y*/ '\0', /*blank*/ '%', /*%*/ '\0', /*blank*/ 'Q', /*Q*/ 'T', /*T*/ 'O', /*O*/ 'H', /*H*/ 'N', /*N*/ 'M', /*M*/ 'L', /*L*/ 'R', /*R*/ 'G', /*G*/ 'I', /*I*/ 'P', /*P*/ 'C', /*C*/ 'V', /*V*/ 'E', /*E*/ 'Z', /*Z*/ 'D', /*D*/ 'B', /*B*/ 'S', /*S*/ 'Y', /*Y*/ '\0', /*blank*/ 'F', /*F*/ 'X', /*X*/ 'A', /*A*/ 'W', /*W*/ 'J', /*J*/ 'U', /*U*/ 'K', /*K*/ '0', /*0*/ '1', /*1*/ '2', /*2*/ '3', /*3*/ '4', /*4*/ '5', /*5*/ '6', /*6*/ '7', /*7*/ '8', /*8*/ '9', /*9*/ '*', /***/ '\04', /*minus*/ '\01', /*fi*/ '\02', /*fl*/ '\03', /*ff*/ '\020', /* cent sign */ '\012', /*ffl*/ '\011', /*ffi*/ '(', /*(*/ ')', /*)*/ '[', /*[*/ ']', /*]*/ '\013', /* degree */ '\014', /* dagger */ '=', /*=*/ '\017', /* registered */ ':', /*:*/ '+', /*+*/ '\0', /*blank*/ '!', /*!*/ '\07', /* bullet */ '?', /*?*/ '\015', /*foot mark*/ '|', /*|*/ '\0', /*blank*/ '\016', /* copyright */ '\010', /* square */ '$', /*$*/ '\0', '\0', '"', /*"*/ '#', /*#*/ '<', /*<*/ '>', /*>*/ '@', /*@*/ '\\', /*\\*/ '^', /*^*/ '{', /*{*/ '}', /*}*/ '~' /*~*/};char spectab[128] = { '\0', /*blank*/ 'w', /*psi*/ 'h', /*theta*/ 'm', /*nu*/ 'l', /*mu*/ 'k', /*lambda*/ 'i', /*iota*/ 'f', /*zeta*/ 'r', /*sigma*/ 'd', /*delta*/ 'b', /*beta*/ 'n', /*xi*/ 'g', /*eta*/ 'u', /*phi*/ 't', /*upsilon*/ 'j', /*kappa*/ '\0', /*blank*/ 'p', /*pi*/ '@', /*at-sign*/ '7', /*down arrow*/ '\0', /*blank*/ 'a', /*alpha*/ '|', /*or*/ 'v', /*chi*/ '"', /*"*/ 'e', /*epsilon*/ '=', /*=*/ 'o', /*omicron*/ '4', /*left arrow*/ 'q', /*rho*/ '6', /*up arrow*/ 's', /*tau*/ '_', /*underrule*/ '\\', /*\*/ 'W', /*Psi*/ '\07', /*bell system sign*/ '\001', /*infinity*/ 'c', /*gamma*/ '\002', /*improper superset*/ '\003', /*proportional to*/ '\004', /*right hand*/ 'x', /*omega*/ '\0', /*blank*/ '(', /*gradient*/ '\0', /*blank*/ 'U', /*Phi*/ 'H', /*Theta*/ 'X', /*Omega*/ '\005', /*cup (union)*/ '\006', /*root en*/ '\014', /*terminal sigma*/ 'K', /*Lambda*/ '-', /*minus*/ 'C', /*Gamma*/ '\015', /*integral sign*/ 'P', /*Pi*/ '\032', /*subset of*/ '\033', /*superset of*/ '2', /*approximates*/ 'y', /*partial derivative*/ 'D', /*Delta*/ '\013', /*square root*/ 'R', /*Sigma*/ '1', /*approx =*/ '\0', /*blank*/ '>', /*>*/ 'N', /*Xi*/ '<', /*<*/ '\016', /*slash (longer)*/ '\034', /*cap (intersection)*/ 'T', /*Upsilon*/ '\035', /*not*/ '\023', /*right ceiling (rt of ")*/ '\024', /*left top (of big curly)*/ '\017', /*bold vertical*/ '\030', /*left center of big curly bracket*/ '\025', /*left bottom*/ '\026', /*right top*/ '\031', /*right center of big curly bracket*/ '\027', /*right bot*/ '\021', /*right floor (rb of ")*/ '\020', /*left floor (left bot of big sq bract)*/ '\022', /*left ceiling (lt of ")*/ '*', /*multiply*/ '/', /*divide*/ '\010', /*plus-minus*/ '\011', /*<=*/ '\012', /*>=*/ '0', /*identically equal*/ '3', /*not equal*/ '{', /*{*/ '}', /*}*/ '\'', /*' acute accent*/ '\`', /*` grave accent*/ '^', /*^*/ '#', /*sharp*/ '\036', /*left hand*/ '\037', /*member of*/ '~', /*~*/ 'z', /*empty set*/ '\0', /*blank*/ 'Y', /*dbl dagger*/ 'Z', /*box rule*/ '9', /*asterisk*/ '[', /*improper subset*/ ']', /*circle*/ '\0', /*blank*/ '+', /*eqn plus*/ '5', /*right arrow*/ '8' /*section mark*/};main(argc, argv) int argc; char *argv[];{ char *namearg = NULL; char *hostarg = NULL; char *acctfile = NULL; while (--argc) { if (*(*++argv) == '-') switch (argv[0][1]) { case 'x': BYTES_PER_LINE = atoi(&argv[0][2]) / 8; BUFFER_SIZE = NLINES * BYTES_PER_LINE; break; case 'y': PAGE_LINES = atoi(&argv[0][2]); break; case 'n': if (argc > 1) { argc--; namearg = *++argv; } break; case 'h': if (argc > 1) { argc--; hostarg = *++argv; } break; } else acctfile = *argv; } ioctl(vc, VSETSTATE, pltmode); readrm(); ofile(); ioctl(vc, VSETSTATE, prtmode); if (varian) write(vc, "\f", 2); else write(vc, "\n\n\n\n\n", 6); account(namearg, hostarg, acctfile); exit(0); /* NOTREACHED */}readrm(){ register int i; register char *cp; register int rmfd; char c; if ((rmfd = open(LOCAL_RAILMAG, 0)) < 0) if ((rmfd = open(GLOBAL_RAILMAG, 0)) < 0) { fprintf(stderr, "rvcat: No railmag file\n"); exit(2); } cp = fnbuf; for (i = 0; i < MAXF; i++) { fontname[i] = cp; while (read(rmfd, &c, 1) == 1 && c != '\n') *cp++ = c; *cp++ = '\0'; } close(rmfd);}ofile(){ register int c; register int i; double scol; static int initialized; lines = 0; while ((c = getchar()) != EOF) { if (!c) continue; if (c & 0200) { esc += (~c) & 0177; continue; } if (esc) { if (back) esc = -esc; col += esc; esc = 0; i = CONVERT(col); while (i >= NLINES) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -