17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate * with the License.
87c478bd9Sstevel@tonic-gate *
97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate * and limitations under the License.
137c478bd9Sstevel@tonic-gate *
147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate *
207c478bd9Sstevel@tonic-gate * CDDL HEADER END
217c478bd9Sstevel@tonic-gate */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
247c478bd9Sstevel@tonic-gate * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
287c478bd9Sstevel@tonic-gate /* All Rights Reserved */
297c478bd9Sstevel@tonic-gate
307c478bd9Sstevel@tonic-gate /*
317c478bd9Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988
327c478bd9Sstevel@tonic-gate * The Regents of the University of California
337c478bd9Sstevel@tonic-gate * All Rights Reserved
347c478bd9Sstevel@tonic-gate *
357c478bd9Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from
367c478bd9Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its
377c478bd9Sstevel@tonic-gate * contributors.
387c478bd9Sstevel@tonic-gate */
397c478bd9Sstevel@tonic-gate
40*e5190c10Smuffin #pragma ident "%Z%%M% %I% %E% SMI"
41*e5190c10Smuffin
427c478bd9Sstevel@tonic-gate /*
437c478bd9Sstevel@tonic-gate * drive hp2621 terminal
447c478bd9Sstevel@tonic-gate * just to see stuff quickly. like troff -a
457c478bd9Sstevel@tonic-gate */
467c478bd9Sstevel@tonic-gate
477c478bd9Sstevel@tonic-gate /*
487c478bd9Sstevel@tonic-gate output language from troff:
497c478bd9Sstevel@tonic-gate all numbers are character strings
507c478bd9Sstevel@tonic-gate
517c478bd9Sstevel@tonic-gate sn size in points
527c478bd9Sstevel@tonic-gate fn font as number from 1-n
537c478bd9Sstevel@tonic-gate cx ascii character x
547c478bd9Sstevel@tonic-gate Cxyz funny char xyz. terminated by white space
557c478bd9Sstevel@tonic-gate Hn go to absolute horizontal position n
567c478bd9Sstevel@tonic-gate Vn go to absolute vertical position n (down is positive)
577c478bd9Sstevel@tonic-gate hn go n units horizontally (relative)
587c478bd9Sstevel@tonic-gate vn ditto vertically
597c478bd9Sstevel@tonic-gate nnc move right nn (exactly 2 digits!), then print c
607c478bd9Sstevel@tonic-gate (this wart is an optimization that shrinks output file size
617c478bd9Sstevel@tonic-gate about 35% and run-time about 15% while preserving ascii-ness)
627c478bd9Sstevel@tonic-gate w paddable word space - no action needed
637c478bd9Sstevel@tonic-gate nb a end of line (information only -- no action needed)
647c478bd9Sstevel@tonic-gate b = space before line, a = after
657c478bd9Sstevel@tonic-gate pn begin page n
667c478bd9Sstevel@tonic-gate #...\n comment
677c478bd9Sstevel@tonic-gate Dt ...\n draw operation 't':
687c478bd9Sstevel@tonic-gate Dl x y line from here by x,y
697c478bd9Sstevel@tonic-gate Dc d circle of diameter d with left side here
707c478bd9Sstevel@tonic-gate De x y ellipse of axes x,y with left side here
717c478bd9Sstevel@tonic-gate Da x y u v arc counter-clockwise from here to u,v from center
727c478bd9Sstevel@tonic-gate with center x,y from here
737c478bd9Sstevel@tonic-gate D~ x y x y ... wiggly line by x,y then x,y ...
747c478bd9Sstevel@tonic-gate x ...\n device control functions:
757c478bd9Sstevel@tonic-gate x i init
767c478bd9Sstevel@tonic-gate x T s name of device is s
777c478bd9Sstevel@tonic-gate x r n h v resolution is n/inch
787c478bd9Sstevel@tonic-gate h = min horizontal motion, v = min vert
797c478bd9Sstevel@tonic-gate x p pause (can restart)
807c478bd9Sstevel@tonic-gate x s stop -- done for ever
817c478bd9Sstevel@tonic-gate x t generate trailer
827c478bd9Sstevel@tonic-gate x f n s font position n contains font s
837c478bd9Sstevel@tonic-gate x H n set character height to n
847c478bd9Sstevel@tonic-gate x S n set character slant to n
857c478bd9Sstevel@tonic-gate
867c478bd9Sstevel@tonic-gate Subcommands like "i" are often spelled out like "init".
877c478bd9Sstevel@tonic-gate */
887c478bd9Sstevel@tonic-gate
897c478bd9Sstevel@tonic-gate #include <stdio.h>
907c478bd9Sstevel@tonic-gate #include <signal.h>
917c478bd9Sstevel@tonic-gate #include <ctype.h>
927c478bd9Sstevel@tonic-gate
937c478bd9Sstevel@tonic-gate #include "dev.h"
947c478bd9Sstevel@tonic-gate #define NFONT 10
957c478bd9Sstevel@tonic-gate
967c478bd9Sstevel@tonic-gate int output = 0; /* do we do output at all? */
977c478bd9Sstevel@tonic-gate int nolist = 0; /* output page list if > 0 */
987c478bd9Sstevel@tonic-gate int olist[20]; /* pairs of page numbers */
997c478bd9Sstevel@tonic-gate
1007c478bd9Sstevel@tonic-gate int erase = 1;
1017c478bd9Sstevel@tonic-gate float aspect = 1.5; /* default aspect ratio */
1027c478bd9Sstevel@tonic-gate int wflag = 0; /* wait, looping, for new input if on */
1037c478bd9Sstevel@tonic-gate void (*sigint)();
1047c478bd9Sstevel@tonic-gate void (*sigquit)();
1057c478bd9Sstevel@tonic-gate void done();
1067c478bd9Sstevel@tonic-gate
1077c478bd9Sstevel@tonic-gate struct dev dev;
1087c478bd9Sstevel@tonic-gate struct font *fontbase[NFONT];
1097c478bd9Sstevel@tonic-gate short psizes[] ={ 11, 16, 22, 36, 0}; /* approx sizes available */
1107c478bd9Sstevel@tonic-gate short *pstab = psizes;
1117c478bd9Sstevel@tonic-gate int nsizes = 1;
1127c478bd9Sstevel@tonic-gate int nfonts;
1137c478bd9Sstevel@tonic-gate int smnt; /* index of first special font */
1147c478bd9Sstevel@tonic-gate int nchtab;
1157c478bd9Sstevel@tonic-gate char *chname;
1167c478bd9Sstevel@tonic-gate short *chtab;
1177c478bd9Sstevel@tonic-gate char *fitab[NFONT];
1187c478bd9Sstevel@tonic-gate char *widthtab[NFONT]; /* widtab would be a better name */
1197c478bd9Sstevel@tonic-gate char *codetab[NFONT]; /* device codes */
1207c478bd9Sstevel@tonic-gate
1217c478bd9Sstevel@tonic-gate #define FATAL 1
1227c478bd9Sstevel@tonic-gate #define BMASK 0377
1237c478bd9Sstevel@tonic-gate int dbg = 0;
1247c478bd9Sstevel@tonic-gate int res = 972; /* input assumed computed according to this resolution */
1257c478bd9Sstevel@tonic-gate /* initial value to avoid 0 divide */
1267c478bd9Sstevel@tonic-gate FILE *tf = stdout; /* output file */
1277c478bd9Sstevel@tonic-gate char *fontdir = "/usr/lib/font";
1287c478bd9Sstevel@tonic-gate extern char devname[];
1297c478bd9Sstevel@tonic-gate
1307c478bd9Sstevel@tonic-gate FILE *fp = stdin; /* input file pointer */
1317c478bd9Sstevel@tonic-gate
1327c478bd9Sstevel@tonic-gate int nowait = 0; /* 0 => wait at bottom of each page */
1337c478bd9Sstevel@tonic-gate
134*e5190c10Smuffin int
main(int argc,char ** argv)135*e5190c10Smuffin main(int argc, char **argv)
1367c478bd9Sstevel@tonic-gate {
1377c478bd9Sstevel@tonic-gate char buf[BUFSIZ];
1387c478bd9Sstevel@tonic-gate
1397c478bd9Sstevel@tonic-gate setbuf(stdout, buf);
1407c478bd9Sstevel@tonic-gate while (argc > 1 && argv[1][0] == '-') {
1417c478bd9Sstevel@tonic-gate switch (argv[1][1]) {
1427c478bd9Sstevel@tonic-gate case 'a':
1437c478bd9Sstevel@tonic-gate aspect = atof(&argv[1][2]);
1447c478bd9Sstevel@tonic-gate break;
1457c478bd9Sstevel@tonic-gate case 'e':
1467c478bd9Sstevel@tonic-gate erase = 0;
1477c478bd9Sstevel@tonic-gate break;
1487c478bd9Sstevel@tonic-gate case 'o':
1497c478bd9Sstevel@tonic-gate outlist(&argv[1][2]);
1507c478bd9Sstevel@tonic-gate break;
1517c478bd9Sstevel@tonic-gate case 'd':
1527c478bd9Sstevel@tonic-gate dbg = atoi(&argv[1][2]);
1537c478bd9Sstevel@tonic-gate if (dbg == 0) dbg = 1;
1547c478bd9Sstevel@tonic-gate break;
1557c478bd9Sstevel@tonic-gate case 'w': /* no wait at bottom of page */
1567c478bd9Sstevel@tonic-gate nowait = 1;
1577c478bd9Sstevel@tonic-gate break;
1587c478bd9Sstevel@tonic-gate }
1597c478bd9Sstevel@tonic-gate argc--;
1607c478bd9Sstevel@tonic-gate argv++;
1617c478bd9Sstevel@tonic-gate }
1627c478bd9Sstevel@tonic-gate
1637c478bd9Sstevel@tonic-gate if (argc <= 1)
1647c478bd9Sstevel@tonic-gate conv(stdin);
1657c478bd9Sstevel@tonic-gate else
1667c478bd9Sstevel@tonic-gate while (--argc > 0) {
1677c478bd9Sstevel@tonic-gate if (strcmp(*++argv, "-") == 0)
1687c478bd9Sstevel@tonic-gate fp = stdin;
1697c478bd9Sstevel@tonic-gate else if ((fp = fopen(*argv, "r")) == NULL)
1707c478bd9Sstevel@tonic-gate error(FATAL, "can't open %s", *argv);
1717c478bd9Sstevel@tonic-gate conv(fp);
1727c478bd9Sstevel@tonic-gate fclose(fp);
1737c478bd9Sstevel@tonic-gate }
1747c478bd9Sstevel@tonic-gate done();
175*e5190c10Smuffin
176*e5190c10Smuffin return (0);
1777c478bd9Sstevel@tonic-gate }
1787c478bd9Sstevel@tonic-gate
179*e5190c10Smuffin int
outlist(s)1807c478bd9Sstevel@tonic-gate outlist(s) /* process list of page numbers to be printed */
1817c478bd9Sstevel@tonic-gate char *s;
1827c478bd9Sstevel@tonic-gate {
1837c478bd9Sstevel@tonic-gate int n1, n2, i;
1847c478bd9Sstevel@tonic-gate
1857c478bd9Sstevel@tonic-gate nolist = 0;
1867c478bd9Sstevel@tonic-gate while (*s) {
1877c478bd9Sstevel@tonic-gate n1 = 0;
1887c478bd9Sstevel@tonic-gate if (isdigit((unsigned char)*s))
1897c478bd9Sstevel@tonic-gate do
1907c478bd9Sstevel@tonic-gate n1 = 10 * n1 + *s++ - '0';
1917c478bd9Sstevel@tonic-gate while (isdigit((unsigned char)*s));
1927c478bd9Sstevel@tonic-gate else
1937c478bd9Sstevel@tonic-gate n1 = -9999;
1947c478bd9Sstevel@tonic-gate n2 = n1;
1957c478bd9Sstevel@tonic-gate if (*s == '-') {
1967c478bd9Sstevel@tonic-gate s++;
1977c478bd9Sstevel@tonic-gate n2 = 0;
1987c478bd9Sstevel@tonic-gate if (isdigit((unsigned char)*s))
1997c478bd9Sstevel@tonic-gate do
2007c478bd9Sstevel@tonic-gate n2 = 10 * n2 + *s++ - '0';
2017c478bd9Sstevel@tonic-gate while (isdigit((unsigned char)*s));
2027c478bd9Sstevel@tonic-gate else
2037c478bd9Sstevel@tonic-gate n2 = 9999;
2047c478bd9Sstevel@tonic-gate }
2057c478bd9Sstevel@tonic-gate olist[nolist++] = n1;
2067c478bd9Sstevel@tonic-gate olist[nolist++] = n2;
2077c478bd9Sstevel@tonic-gate if (*s != '\0')
2087c478bd9Sstevel@tonic-gate s++;
2097c478bd9Sstevel@tonic-gate }
2107c478bd9Sstevel@tonic-gate olist[nolist] = 0;
2117c478bd9Sstevel@tonic-gate if (dbg)
2127c478bd9Sstevel@tonic-gate for (i=0; i<nolist; i += 2)
2137c478bd9Sstevel@tonic-gate printf("%3d %3d\n", olist[i], olist[i+1]);
214*e5190c10Smuffin
215*e5190c10Smuffin return (0);
2167c478bd9Sstevel@tonic-gate }
2177c478bd9Sstevel@tonic-gate
218*e5190c10Smuffin int
in_olist(n)2197c478bd9Sstevel@tonic-gate in_olist(n) /* is n in olist? */
2207c478bd9Sstevel@tonic-gate int n;
2217c478bd9Sstevel@tonic-gate {
2227c478bd9Sstevel@tonic-gate int i;
2237c478bd9Sstevel@tonic-gate
2247c478bd9Sstevel@tonic-gate if (nolist == 0)
2257c478bd9Sstevel@tonic-gate return(1); /* everything is included */
2267c478bd9Sstevel@tonic-gate for (i = 0; i < nolist; i += 2)
2277c478bd9Sstevel@tonic-gate if (n >= olist[i] && n <= olist[i+1])
2287c478bd9Sstevel@tonic-gate return(1);
2297c478bd9Sstevel@tonic-gate return(0);
2307c478bd9Sstevel@tonic-gate }
2317c478bd9Sstevel@tonic-gate
232*e5190c10Smuffin int
conv(fp)2337c478bd9Sstevel@tonic-gate conv(fp)
234*e5190c10Smuffin FILE *fp;
2357c478bd9Sstevel@tonic-gate {
236*e5190c10Smuffin int c, k;
2377c478bd9Sstevel@tonic-gate int m, n, i, n1, m1;
2387c478bd9Sstevel@tonic-gate char str[100], buf[300];
2397c478bd9Sstevel@tonic-gate
2407c478bd9Sstevel@tonic-gate while ((c = getc(fp)) != EOF) {
2417c478bd9Sstevel@tonic-gate switch (c) {
2427c478bd9Sstevel@tonic-gate case '\n': /* when input is text */
2437c478bd9Sstevel@tonic-gate case ' ':
2447c478bd9Sstevel@tonic-gate case 0: /* occasional noise creeps in */
2457c478bd9Sstevel@tonic-gate break;
2467c478bd9Sstevel@tonic-gate case '{': /* push down current environment */
2477c478bd9Sstevel@tonic-gate t_push();
2487c478bd9Sstevel@tonic-gate break;
2497c478bd9Sstevel@tonic-gate case '}':
2507c478bd9Sstevel@tonic-gate t_pop();
2517c478bd9Sstevel@tonic-gate break;
2527c478bd9Sstevel@tonic-gate case '0': case '1': case '2': case '3': case '4':
2537c478bd9Sstevel@tonic-gate case '5': case '6': case '7': case '8': case '9':
2547c478bd9Sstevel@tonic-gate /* two motion digits plus a character */
2557c478bd9Sstevel@tonic-gate hmot((c-'0')*10 + getc(fp)-'0');
2567c478bd9Sstevel@tonic-gate put1(getc(fp));
2577c478bd9Sstevel@tonic-gate break;
2587c478bd9Sstevel@tonic-gate case 'c': /* single ascii character */
2597c478bd9Sstevel@tonic-gate put1(getc(fp));
2607c478bd9Sstevel@tonic-gate break;
2617c478bd9Sstevel@tonic-gate case 'C':
2627c478bd9Sstevel@tonic-gate fscanf(fp, "%s", str);
2637c478bd9Sstevel@tonic-gate put1s(str);
2647c478bd9Sstevel@tonic-gate break;
2657c478bd9Sstevel@tonic-gate case 't': /* straight text */
2667c478bd9Sstevel@tonic-gate fgets(buf, sizeof(buf), fp);
2677c478bd9Sstevel@tonic-gate t_text(buf);
2687c478bd9Sstevel@tonic-gate break;
2697c478bd9Sstevel@tonic-gate case 'D': /* draw function */
2707c478bd9Sstevel@tonic-gate fgets(buf, sizeof(buf), fp);
2717c478bd9Sstevel@tonic-gate switch (buf[0]) {
2727c478bd9Sstevel@tonic-gate case 'l': /* draw a line */
2737c478bd9Sstevel@tonic-gate sscanf(buf+1, "%d %d", &n, &m);
2747c478bd9Sstevel@tonic-gate drawline(n, m, ".");
2757c478bd9Sstevel@tonic-gate break;
2767c478bd9Sstevel@tonic-gate case 'c': /* circle */
2777c478bd9Sstevel@tonic-gate sscanf(buf+1, "%d", &n);
2787c478bd9Sstevel@tonic-gate drawcirc(n);
2797c478bd9Sstevel@tonic-gate break;
2807c478bd9Sstevel@tonic-gate case 'e': /* ellipse */
2817c478bd9Sstevel@tonic-gate sscanf(buf+1, "%d %d", &m, &n);
2827c478bd9Sstevel@tonic-gate drawellip(m, n);
2837c478bd9Sstevel@tonic-gate break;
2847c478bd9Sstevel@tonic-gate case 'a': /* arc */
2857c478bd9Sstevel@tonic-gate sscanf(buf+1, "%d %d %d %d", &n, &m, &n1, &m1);
2867c478bd9Sstevel@tonic-gate drawarc(n, m, n1, m1);
2877c478bd9Sstevel@tonic-gate break;
2887c478bd9Sstevel@tonic-gate case '~': /* wiggly line */
2897c478bd9Sstevel@tonic-gate drawwig(buf+1);
2907c478bd9Sstevel@tonic-gate break;
2917c478bd9Sstevel@tonic-gate default:
2927c478bd9Sstevel@tonic-gate error(FATAL, "unknown drawing function %s\n", buf);
2937c478bd9Sstevel@tonic-gate break;
2947c478bd9Sstevel@tonic-gate }
2957c478bd9Sstevel@tonic-gate break;
2967c478bd9Sstevel@tonic-gate case 's':
2977c478bd9Sstevel@tonic-gate fscanf(fp, "%d", &n); /* ignore fractional sizes */
2987c478bd9Sstevel@tonic-gate setsize(t_size(n));
2997c478bd9Sstevel@tonic-gate break;
3007c478bd9Sstevel@tonic-gate case 'f':
3017c478bd9Sstevel@tonic-gate fscanf(fp, "%s", str);
3027c478bd9Sstevel@tonic-gate setfont(t_font(str));
3037c478bd9Sstevel@tonic-gate break;
3047c478bd9Sstevel@tonic-gate case 'H': /* absolute horizontal motion */
3057c478bd9Sstevel@tonic-gate /* fscanf(fp, "%d", &n); */
3067c478bd9Sstevel@tonic-gate while ((c = getc(fp)) == ' ')
3077c478bd9Sstevel@tonic-gate ;
3087c478bd9Sstevel@tonic-gate k = 0;
3097c478bd9Sstevel@tonic-gate do {
3107c478bd9Sstevel@tonic-gate k = 10 * k + c - '0';
3117c478bd9Sstevel@tonic-gate } while (isdigit(c = getc(fp)));
3127c478bd9Sstevel@tonic-gate ungetc(c, fp);
3137c478bd9Sstevel@tonic-gate hgoto(k);
3147c478bd9Sstevel@tonic-gate break;
3157c478bd9Sstevel@tonic-gate case 'h': /* relative horizontal motion */
3167c478bd9Sstevel@tonic-gate /* fscanf(fp, "%d", &n); */
3177c478bd9Sstevel@tonic-gate while ((c = getc(fp)) == ' ')
3187c478bd9Sstevel@tonic-gate ;
3197c478bd9Sstevel@tonic-gate k = 0;
3207c478bd9Sstevel@tonic-gate do {
3217c478bd9Sstevel@tonic-gate k = 10 * k + c - '0';
3227c478bd9Sstevel@tonic-gate } while (isdigit(c = getc(fp)));
3237c478bd9Sstevel@tonic-gate ungetc(c, fp);
3247c478bd9Sstevel@tonic-gate hmot(k);
3257c478bd9Sstevel@tonic-gate break;
3267c478bd9Sstevel@tonic-gate case 'w': /* word space */
3277c478bd9Sstevel@tonic-gate putc(' ', stdout);
3287c478bd9Sstevel@tonic-gate break;
3297c478bd9Sstevel@tonic-gate case 'V':
3307c478bd9Sstevel@tonic-gate fscanf(fp, "%d", &n);
3317c478bd9Sstevel@tonic-gate vgoto(n);
3327c478bd9Sstevel@tonic-gate break;
3337c478bd9Sstevel@tonic-gate case 'v':
3347c478bd9Sstevel@tonic-gate fscanf(fp, "%d", &n);
3357c478bd9Sstevel@tonic-gate vmot(n);
3367c478bd9Sstevel@tonic-gate break;
3377c478bd9Sstevel@tonic-gate case 'p': /* new page */
3387c478bd9Sstevel@tonic-gate fscanf(fp, "%d", &n);
3397c478bd9Sstevel@tonic-gate t_page(n);
3407c478bd9Sstevel@tonic-gate break;
3417c478bd9Sstevel@tonic-gate case 'n': /* end of line */
3427c478bd9Sstevel@tonic-gate while (getc(fp) != '\n')
3437c478bd9Sstevel@tonic-gate ;
3447c478bd9Sstevel@tonic-gate t_newline();
3457c478bd9Sstevel@tonic-gate break;
3467c478bd9Sstevel@tonic-gate case '#': /* comment */
3477c478bd9Sstevel@tonic-gate while (getc(fp) != '\n')
3487c478bd9Sstevel@tonic-gate ;
3497c478bd9Sstevel@tonic-gate break;
3507c478bd9Sstevel@tonic-gate case 'x': /* device control */
3517c478bd9Sstevel@tonic-gate devcntrl(fp);
3527c478bd9Sstevel@tonic-gate break;
3537c478bd9Sstevel@tonic-gate default:
3547c478bd9Sstevel@tonic-gate error(!FATAL, "unknown input character %o %c\n", c, c);
3557c478bd9Sstevel@tonic-gate done();
3567c478bd9Sstevel@tonic-gate }
3577c478bd9Sstevel@tonic-gate }
358*e5190c10Smuffin
359*e5190c10Smuffin return (0);
3607c478bd9Sstevel@tonic-gate }
3617c478bd9Sstevel@tonic-gate
362*e5190c10Smuffin int
devcntrl(fp)3637c478bd9Sstevel@tonic-gate devcntrl(fp) /* interpret device control functions */
3647c478bd9Sstevel@tonic-gate FILE *fp;
3657c478bd9Sstevel@tonic-gate {
3667c478bd9Sstevel@tonic-gate char str[20];
3677c478bd9Sstevel@tonic-gate int c, n;
3687c478bd9Sstevel@tonic-gate
3697c478bd9Sstevel@tonic-gate fscanf(fp, "%s", str);
3707c478bd9Sstevel@tonic-gate switch (str[0]) { /* crude for now */
3717c478bd9Sstevel@tonic-gate case 'i': /* initialize */
3727c478bd9Sstevel@tonic-gate fileinit();
3737c478bd9Sstevel@tonic-gate t_init(0);
3747c478bd9Sstevel@tonic-gate break;
3757c478bd9Sstevel@tonic-gate case 'T': /* device name */
3767c478bd9Sstevel@tonic-gate fscanf(fp, "%s", devname);
3777c478bd9Sstevel@tonic-gate break;
3787c478bd9Sstevel@tonic-gate case 't': /* trailer */
3797c478bd9Sstevel@tonic-gate t_trailer();
3807c478bd9Sstevel@tonic-gate break;
3817c478bd9Sstevel@tonic-gate case 'p': /* pause -- can restart */
3827c478bd9Sstevel@tonic-gate t_reset('p');
3837c478bd9Sstevel@tonic-gate break;
3847c478bd9Sstevel@tonic-gate case 's': /* stop */
3857c478bd9Sstevel@tonic-gate t_reset('s');
3867c478bd9Sstevel@tonic-gate break;
3877c478bd9Sstevel@tonic-gate case 'r': /* resolution assumed when prepared */
3887c478bd9Sstevel@tonic-gate fscanf(fp, "%d", &res);
3897c478bd9Sstevel@tonic-gate break;
3907c478bd9Sstevel@tonic-gate case 'f': /* font used */
3917c478bd9Sstevel@tonic-gate fscanf(fp, "%d %s", &n, str);
3927c478bd9Sstevel@tonic-gate loadfont(n, str);
3937c478bd9Sstevel@tonic-gate break;
3947c478bd9Sstevel@tonic-gate }
3957c478bd9Sstevel@tonic-gate while (getc(fp) != '\n') /* skip rest of input line */
3967c478bd9Sstevel@tonic-gate ;
397*e5190c10Smuffin
398*e5190c10Smuffin return (0);
3997c478bd9Sstevel@tonic-gate }
4007c478bd9Sstevel@tonic-gate
401*e5190c10Smuffin int
fileinit()4027c478bd9Sstevel@tonic-gate fileinit() /* read in font and code files, etc. */
4037c478bd9Sstevel@tonic-gate {
404*e5190c10Smuffin return (0);
4057c478bd9Sstevel@tonic-gate }
4067c478bd9Sstevel@tonic-gate
407*e5190c10Smuffin int
fontprint(i)4087c478bd9Sstevel@tonic-gate fontprint(i) /* debugging print of font i (0,...) */
4097c478bd9Sstevel@tonic-gate {
410*e5190c10Smuffin return (0);
4117c478bd9Sstevel@tonic-gate }
4127c478bd9Sstevel@tonic-gate
413*e5190c10Smuffin int
loadcode(n,nw)4147c478bd9Sstevel@tonic-gate loadcode(n, nw) /* load codetab on position n (0...); #chars is nw */
4157c478bd9Sstevel@tonic-gate int n, nw;
4167c478bd9Sstevel@tonic-gate {
417*e5190c10Smuffin return (0);
4187c478bd9Sstevel@tonic-gate }
4197c478bd9Sstevel@tonic-gate
420*e5190c10Smuffin int
loadfont(n,s)4217c478bd9Sstevel@tonic-gate loadfont(n, s) /* load font info for font s on position n (1...) */
4227c478bd9Sstevel@tonic-gate int n;
4237c478bd9Sstevel@tonic-gate char *s;
4247c478bd9Sstevel@tonic-gate {
425*e5190c10Smuffin return (0);
4267c478bd9Sstevel@tonic-gate }
4277c478bd9Sstevel@tonic-gate
428*e5190c10Smuffin int
error(f,s,a1,a2,a3,a4,a5,a6,a7)4297c478bd9Sstevel@tonic-gate error(f, s, a1, a2, a3, a4, a5, a6, a7)
4307c478bd9Sstevel@tonic-gate char *s;
4317c478bd9Sstevel@tonic-gate {
4327c478bd9Sstevel@tonic-gate fprintf(stderr, "ta: ");
4337c478bd9Sstevel@tonic-gate fprintf(stderr, s, a1, a2, a3, a4, a5, a6, a7);
4347c478bd9Sstevel@tonic-gate fprintf(stderr, "\n");
4357c478bd9Sstevel@tonic-gate if (f)
4367c478bd9Sstevel@tonic-gate exit(1);
437*e5190c10Smuffin
438*e5190c10Smuffin return (0);
4397c478bd9Sstevel@tonic-gate }
4407c478bd9Sstevel@tonic-gate
4417c478bd9Sstevel@tonic-gate
4427c478bd9Sstevel@tonic-gate /*
4437c478bd9Sstevel@tonic-gate Here beginneth all the stuff that really depends
4447c478bd9Sstevel@tonic-gate on the 202 (we hope).
4457c478bd9Sstevel@tonic-gate */
4467c478bd9Sstevel@tonic-gate
4477c478bd9Sstevel@tonic-gate
4487c478bd9Sstevel@tonic-gate char devname[20] = "hp2621";
4497c478bd9Sstevel@tonic-gate
4507c478bd9Sstevel@tonic-gate #define ESC 033
4517c478bd9Sstevel@tonic-gate #define HOME 'H'
4527c478bd9Sstevel@tonic-gate #define CLEAR 'J'
4537c478bd9Sstevel@tonic-gate #define FF 014
4547c478bd9Sstevel@tonic-gate
4557c478bd9Sstevel@tonic-gate int size = 1;
4567c478bd9Sstevel@tonic-gate int font = 1; /* current font */
4577c478bd9Sstevel@tonic-gate int hpos; /* horizontal position where we are supposed to be next (left = 0) */
4587c478bd9Sstevel@tonic-gate int vpos; /* current vertical position (down positive) */
4597c478bd9Sstevel@tonic-gate
4607c478bd9Sstevel@tonic-gate int horig; /* h origin of current block; hpos rel to this */
4617c478bd9Sstevel@tonic-gate int vorig; /* v origin of current block; vpos rel to this */
4627c478bd9Sstevel@tonic-gate
4637c478bd9Sstevel@tonic-gate int DX = 10; /* step size in x for drawing */
4647c478bd9Sstevel@tonic-gate int DY = 10; /* step size in y for drawing */
4657c478bd9Sstevel@tonic-gate int drawdot = '.'; /* draw with this character */
4667c478bd9Sstevel@tonic-gate int drawsize = 1; /* shrink by this factor when drawing */
4677c478bd9Sstevel@tonic-gate
468*e5190c10Smuffin int
t_init(reinit)4697c478bd9Sstevel@tonic-gate t_init(reinit) /* initialize device */
4707c478bd9Sstevel@tonic-gate int reinit;
4717c478bd9Sstevel@tonic-gate {
4727c478bd9Sstevel@tonic-gate int i, j;
4737c478bd9Sstevel@tonic-gate
4747c478bd9Sstevel@tonic-gate fflush(stdout);
4757c478bd9Sstevel@tonic-gate hpos = vpos = 0;
476*e5190c10Smuffin
477*e5190c10Smuffin return (0);
4787c478bd9Sstevel@tonic-gate }
4797c478bd9Sstevel@tonic-gate
4807c478bd9Sstevel@tonic-gate #define MAXSTATE 5
4817c478bd9Sstevel@tonic-gate
4827c478bd9Sstevel@tonic-gate struct state {
4837c478bd9Sstevel@tonic-gate int ssize;
4847c478bd9Sstevel@tonic-gate int sfont;
4857c478bd9Sstevel@tonic-gate int shpos;
4867c478bd9Sstevel@tonic-gate int svpos;
4877c478bd9Sstevel@tonic-gate int shorig;
4887c478bd9Sstevel@tonic-gate int svorig;
4897c478bd9Sstevel@tonic-gate };
4907c478bd9Sstevel@tonic-gate struct state state[MAXSTATE];
4917c478bd9Sstevel@tonic-gate struct state *statep = state;
4927c478bd9Sstevel@tonic-gate
493*e5190c10Smuffin int
t_push()4947c478bd9Sstevel@tonic-gate t_push() /* begin a new block */
4957c478bd9Sstevel@tonic-gate {
4967c478bd9Sstevel@tonic-gate hflush();
4977c478bd9Sstevel@tonic-gate statep->ssize = size;
4987c478bd9Sstevel@tonic-gate statep->sfont = font;
4997c478bd9Sstevel@tonic-gate statep->shorig = horig;
5007c478bd9Sstevel@tonic-gate statep->svorig = vorig;
5017c478bd9Sstevel@tonic-gate statep->shpos = hpos;
5027c478bd9Sstevel@tonic-gate statep->svpos = vpos;
5037c478bd9Sstevel@tonic-gate horig = hpos;
5047c478bd9Sstevel@tonic-gate vorig = vpos;
5057c478bd9Sstevel@tonic-gate hpos = vpos = 0;
5067c478bd9Sstevel@tonic-gate if (statep++ >= state+MAXSTATE)
5077c478bd9Sstevel@tonic-gate error(FATAL, "{ nested too deep");
5087c478bd9Sstevel@tonic-gate hpos = vpos = 0;
509*e5190c10Smuffin
510*e5190c10Smuffin return (0);
5117c478bd9Sstevel@tonic-gate }
5127c478bd9Sstevel@tonic-gate
513*e5190c10Smuffin int
t_pop()5147c478bd9Sstevel@tonic-gate t_pop() /* pop to previous state */
5157c478bd9Sstevel@tonic-gate {
5167c478bd9Sstevel@tonic-gate if (--statep < state)
5177c478bd9Sstevel@tonic-gate error(FATAL, "extra }");
5187c478bd9Sstevel@tonic-gate size = statep->ssize;
5197c478bd9Sstevel@tonic-gate font = statep->sfont;
5207c478bd9Sstevel@tonic-gate hpos = statep->shpos;
5217c478bd9Sstevel@tonic-gate vpos = statep->svpos;
5227c478bd9Sstevel@tonic-gate horig = statep->shorig;
5237c478bd9Sstevel@tonic-gate vorig = statep->svorig;
524*e5190c10Smuffin
525*e5190c10Smuffin return (0);
5267c478bd9Sstevel@tonic-gate }
5277c478bd9Sstevel@tonic-gate
5287c478bd9Sstevel@tonic-gate int np; /* number of pages seen */
5297c478bd9Sstevel@tonic-gate int npmax; /* high-water mark of np */
5307c478bd9Sstevel@tonic-gate int pgnum[40]; /* their actual numbers */
5317c478bd9Sstevel@tonic-gate long pgadr[40]; /* their seek addresses */
5327c478bd9Sstevel@tonic-gate
533*e5190c10Smuffin int
t_page(n)5347c478bd9Sstevel@tonic-gate t_page(n) /* do whatever new page functions */
5357c478bd9Sstevel@tonic-gate {
5367c478bd9Sstevel@tonic-gate long ftell();
5377c478bd9Sstevel@tonic-gate int c, m, i;
5387c478bd9Sstevel@tonic-gate char buf[100], *bp;
5397c478bd9Sstevel@tonic-gate
5407c478bd9Sstevel@tonic-gate pgnum[np++] = n;
5417c478bd9Sstevel@tonic-gate pgadr[np] = ftell(fp);
5427c478bd9Sstevel@tonic-gate if (np > npmax)
5437c478bd9Sstevel@tonic-gate npmax = np;
5447c478bd9Sstevel@tonic-gate if (output == 0) {
5457c478bd9Sstevel@tonic-gate output = in_olist(n);
5467c478bd9Sstevel@tonic-gate t_init(1);
547*e5190c10Smuffin return (0);
5487c478bd9Sstevel@tonic-gate }
5497c478bd9Sstevel@tonic-gate /* have just printed something, and seen p<n> for next one */
5507c478bd9Sstevel@tonic-gate putpage();
5517c478bd9Sstevel@tonic-gate fflush(stdout);
5527c478bd9Sstevel@tonic-gate if (nowait)
553*e5190c10Smuffin return (0);
5547c478bd9Sstevel@tonic-gate
5557c478bd9Sstevel@tonic-gate next:
5567c478bd9Sstevel@tonic-gate for (bp = buf; (*bp = readch()); )
5577c478bd9Sstevel@tonic-gate if (*bp++ == '\n')
5587c478bd9Sstevel@tonic-gate break;
5597c478bd9Sstevel@tonic-gate *bp = 0;
5607c478bd9Sstevel@tonic-gate switch (buf[0]) {
5617c478bd9Sstevel@tonic-gate case 0:
5627c478bd9Sstevel@tonic-gate done();
5637c478bd9Sstevel@tonic-gate break;
5647c478bd9Sstevel@tonic-gate case '\n':
5657c478bd9Sstevel@tonic-gate output = in_olist(n);
5667c478bd9Sstevel@tonic-gate t_init(1);
567*e5190c10Smuffin return (0);
5687c478bd9Sstevel@tonic-gate case '!':
5697c478bd9Sstevel@tonic-gate callunix(&buf[1]);
5707c478bd9Sstevel@tonic-gate fputs("!\n", stderr);
5717c478bd9Sstevel@tonic-gate break;
5727c478bd9Sstevel@tonic-gate case 'e':
5737c478bd9Sstevel@tonic-gate erase = 1 - erase;
5747c478bd9Sstevel@tonic-gate break;
5757c478bd9Sstevel@tonic-gate case 'w':
5767c478bd9Sstevel@tonic-gate wflag = 1 - wflag;
5777c478bd9Sstevel@tonic-gate break;
5787c478bd9Sstevel@tonic-gate case 'a':
5797c478bd9Sstevel@tonic-gate aspect = atof(&buf[1]);
5807c478bd9Sstevel@tonic-gate break;
5817c478bd9Sstevel@tonic-gate case '-':
5827c478bd9Sstevel@tonic-gate case 'p':
5837c478bd9Sstevel@tonic-gate m = atoi(&buf[1]) + 1;
5847c478bd9Sstevel@tonic-gate if (fp == stdin) {
5857c478bd9Sstevel@tonic-gate fputs("you can't; it's not a file\n", stderr);
5867c478bd9Sstevel@tonic-gate break;
5877c478bd9Sstevel@tonic-gate }
5887c478bd9Sstevel@tonic-gate if (np - m <= 0) {
5897c478bd9Sstevel@tonic-gate fputs("too far back\n", stderr);
5907c478bd9Sstevel@tonic-gate break;
5917c478bd9Sstevel@tonic-gate }
5927c478bd9Sstevel@tonic-gate np -= m;
5937c478bd9Sstevel@tonic-gate fseek(fp, pgadr[np], 0);
5947c478bd9Sstevel@tonic-gate output = 1;
5957c478bd9Sstevel@tonic-gate t_init(1);
596*e5190c10Smuffin return (0);
5977c478bd9Sstevel@tonic-gate case '0': case '1': case '2': case '3': case '4':
5987c478bd9Sstevel@tonic-gate case '5': case '6': case '7': case '8': case '9':
5997c478bd9Sstevel@tonic-gate m = atoi(&buf[0]);
6007c478bd9Sstevel@tonic-gate for (i = 0; i < npmax; i++)
6017c478bd9Sstevel@tonic-gate if (m == pgnum[i])
6027c478bd9Sstevel@tonic-gate break;
6037c478bd9Sstevel@tonic-gate if (i >= npmax || fp == stdin) {
6047c478bd9Sstevel@tonic-gate fputs("you can't\n", stderr);
6057c478bd9Sstevel@tonic-gate break;
6067c478bd9Sstevel@tonic-gate }
6077c478bd9Sstevel@tonic-gate np = i + 1;
6087c478bd9Sstevel@tonic-gate fseek(fp, pgadr[np], 0);
6097c478bd9Sstevel@tonic-gate output = 1;
6107c478bd9Sstevel@tonic-gate t_init(1);
611*e5190c10Smuffin return (0);
6127c478bd9Sstevel@tonic-gate case 'o':
6137c478bd9Sstevel@tonic-gate outlist(&buf[1]);
6147c478bd9Sstevel@tonic-gate output = 0;
6157c478bd9Sstevel@tonic-gate t_init(1);
616*e5190c10Smuffin return (0);
6177c478bd9Sstevel@tonic-gate case '?':
6187c478bd9Sstevel@tonic-gate fputs("!cmd unix cmd\n", stderr);
6197c478bd9Sstevel@tonic-gate fputs("p print this page again\n", stderr);
6207c478bd9Sstevel@tonic-gate fputs("-n go back n pages\n", stderr);
6217c478bd9Sstevel@tonic-gate fputs("n print page n (previously printed)\n", stderr);
6227c478bd9Sstevel@tonic-gate fputs("o... set the -o output list to ...\n", stderr);
6237c478bd9Sstevel@tonic-gate fputs("en n=0 -> don't erase; n=1 -> erase\n", stderr);
6247c478bd9Sstevel@tonic-gate fputs("an sets aspect ratio to n\n", stderr);
6257c478bd9Sstevel@tonic-gate break;
6267c478bd9Sstevel@tonic-gate default:
6277c478bd9Sstevel@tonic-gate fputs("?\n", stderr);
6287c478bd9Sstevel@tonic-gate break;
6297c478bd9Sstevel@tonic-gate }
6307c478bd9Sstevel@tonic-gate goto next;
6317c478bd9Sstevel@tonic-gate }
6327c478bd9Sstevel@tonic-gate
633*e5190c10Smuffin int
putpage()6347c478bd9Sstevel@tonic-gate putpage()
6357c478bd9Sstevel@tonic-gate {
6367c478bd9Sstevel@tonic-gate int i, j, k;
6377c478bd9Sstevel@tonic-gate
6387c478bd9Sstevel@tonic-gate fflush(stdout);
639*e5190c10Smuffin
640*e5190c10Smuffin return (0);
6417c478bd9Sstevel@tonic-gate }
6427c478bd9Sstevel@tonic-gate
643*e5190c10Smuffin int
t_newline()6447c478bd9Sstevel@tonic-gate t_newline() /* do whatever for the end of a line */
6457c478bd9Sstevel@tonic-gate {
6467c478bd9Sstevel@tonic-gate printf("\n");
6477c478bd9Sstevel@tonic-gate hpos = 0;
648*e5190c10Smuffin
649*e5190c10Smuffin return (0);
6507c478bd9Sstevel@tonic-gate }
6517c478bd9Sstevel@tonic-gate
652*e5190c10Smuffin int
t_size(n)6537c478bd9Sstevel@tonic-gate t_size(n) /* convert integer to internal size number*/
6547c478bd9Sstevel@tonic-gate int n;
6557c478bd9Sstevel@tonic-gate {
656*e5190c10Smuffin return (0);
6577c478bd9Sstevel@tonic-gate }
6587c478bd9Sstevel@tonic-gate
659*e5190c10Smuffin int
t_font(s)6607c478bd9Sstevel@tonic-gate t_font(s) /* convert string to internal font number */
6617c478bd9Sstevel@tonic-gate char *s;
6627c478bd9Sstevel@tonic-gate {
663*e5190c10Smuffin return (0);
6647c478bd9Sstevel@tonic-gate }
6657c478bd9Sstevel@tonic-gate
666*e5190c10Smuffin int
t_text(s)6677c478bd9Sstevel@tonic-gate t_text(s) /* print string s as text */
6687c478bd9Sstevel@tonic-gate char *s;
6697c478bd9Sstevel@tonic-gate {
6707c478bd9Sstevel@tonic-gate int c, w=0;
6717c478bd9Sstevel@tonic-gate char str[100];
6727c478bd9Sstevel@tonic-gate
6737c478bd9Sstevel@tonic-gate if (!output)
674*e5190c10Smuffin return (0);
6757c478bd9Sstevel@tonic-gate while ((c = *s++) != '\n') {
6767c478bd9Sstevel@tonic-gate if (c == '\\') {
6777c478bd9Sstevel@tonic-gate switch (c = *s++) {
6787c478bd9Sstevel@tonic-gate case '\\':
6797c478bd9Sstevel@tonic-gate case 'e':
6807c478bd9Sstevel@tonic-gate put1('\\');
6817c478bd9Sstevel@tonic-gate break;
6827c478bd9Sstevel@tonic-gate case '(':
6837c478bd9Sstevel@tonic-gate str[0] = *s++;
6847c478bd9Sstevel@tonic-gate str[1] = *s++;
6857c478bd9Sstevel@tonic-gate str[2] = '\0';
6867c478bd9Sstevel@tonic-gate put1s(str);
6877c478bd9Sstevel@tonic-gate break;
6887c478bd9Sstevel@tonic-gate }
6897c478bd9Sstevel@tonic-gate } else {
6907c478bd9Sstevel@tonic-gate put1(c);
6917c478bd9Sstevel@tonic-gate }
6927c478bd9Sstevel@tonic-gate hmot(w);
6937c478bd9Sstevel@tonic-gate }
694*e5190c10Smuffin
695*e5190c10Smuffin return (0);
6967c478bd9Sstevel@tonic-gate }
6977c478bd9Sstevel@tonic-gate
698*e5190c10Smuffin int
t_reset(c)6997c478bd9Sstevel@tonic-gate t_reset(c)
7007c478bd9Sstevel@tonic-gate {
7017c478bd9Sstevel@tonic-gate int n;
7027c478bd9Sstevel@tonic-gate
7037c478bd9Sstevel@tonic-gate output = 1;
7047c478bd9Sstevel@tonic-gate fflush(stdout);
7057c478bd9Sstevel@tonic-gate if (c == 's')
7067c478bd9Sstevel@tonic-gate t_page(9999);
707*e5190c10Smuffin
708*e5190c10Smuffin return (0);
7097c478bd9Sstevel@tonic-gate }
7107c478bd9Sstevel@tonic-gate
711*e5190c10Smuffin int
t_trailer()7127c478bd9Sstevel@tonic-gate t_trailer()
7137c478bd9Sstevel@tonic-gate {
714*e5190c10Smuffin return (0);
7157c478bd9Sstevel@tonic-gate }
7167c478bd9Sstevel@tonic-gate
717*e5190c10Smuffin int
hgoto(n)7187c478bd9Sstevel@tonic-gate hgoto(n)
7197c478bd9Sstevel@tonic-gate {
7207c478bd9Sstevel@tonic-gate hpos = n; /* this is where we want to be */
7217c478bd9Sstevel@tonic-gate /* before printing a character, */
7227c478bd9Sstevel@tonic-gate /* have to make sure it's true */
723*e5190c10Smuffin
724*e5190c10Smuffin return (0);
7257c478bd9Sstevel@tonic-gate }
7267c478bd9Sstevel@tonic-gate
727*e5190c10Smuffin int
hmot(n)7287c478bd9Sstevel@tonic-gate hmot(n) /* generate n units of horizontal motion */
7297c478bd9Sstevel@tonic-gate int n;
7307c478bd9Sstevel@tonic-gate {
7317c478bd9Sstevel@tonic-gate hgoto(hpos + n);
732*e5190c10Smuffin
733*e5190c10Smuffin return (0);
7347c478bd9Sstevel@tonic-gate }
7357c478bd9Sstevel@tonic-gate
736*e5190c10Smuffin int
hflush()7377c478bd9Sstevel@tonic-gate hflush() /* actual horizontal output occurs here */
7387c478bd9Sstevel@tonic-gate {
739*e5190c10Smuffin return (0);
7407c478bd9Sstevel@tonic-gate }
7417c478bd9Sstevel@tonic-gate
742*e5190c10Smuffin int
vgoto(n)7437c478bd9Sstevel@tonic-gate vgoto(n)
7447c478bd9Sstevel@tonic-gate {
7457c478bd9Sstevel@tonic-gate vpos = n;
746*e5190c10Smuffin
747*e5190c10Smuffin return (0);
7487c478bd9Sstevel@tonic-gate }
7497c478bd9Sstevel@tonic-gate
750*e5190c10Smuffin int
vmot(n)7517c478bd9Sstevel@tonic-gate vmot(n) /* generate n units of vertical motion */
7527c478bd9Sstevel@tonic-gate int n;
7537c478bd9Sstevel@tonic-gate {
7547c478bd9Sstevel@tonic-gate vgoto(vpos + n); /* ignores rounding */
755*e5190c10Smuffin
756*e5190c10Smuffin return (0);
7577c478bd9Sstevel@tonic-gate }
7587c478bd9Sstevel@tonic-gate
759*e5190c10Smuffin int
put1s(s)7607c478bd9Sstevel@tonic-gate put1s(s) /* s is a funny char name */
7617c478bd9Sstevel@tonic-gate char *s;
7627c478bd9Sstevel@tonic-gate {
7637c478bd9Sstevel@tonic-gate int i;
7647c478bd9Sstevel@tonic-gate char *p;
7657c478bd9Sstevel@tonic-gate extern char *spectab[];
7667c478bd9Sstevel@tonic-gate static char prev[10] = "";
7677c478bd9Sstevel@tonic-gate static int previ;
7687c478bd9Sstevel@tonic-gate
7697c478bd9Sstevel@tonic-gate if (!output)
770*e5190c10Smuffin return (0);
7717c478bd9Sstevel@tonic-gate if (strcmp(s, prev) != 0) {
7727c478bd9Sstevel@tonic-gate previ = -1;
7737c478bd9Sstevel@tonic-gate for (i = 0; spectab[i] != 0; i += 2)
7747c478bd9Sstevel@tonic-gate if (strcmp(spectab[i], s) == 0) {
7757c478bd9Sstevel@tonic-gate strcpy(prev, s);
7767c478bd9Sstevel@tonic-gate previ = i;
7777c478bd9Sstevel@tonic-gate break;
7787c478bd9Sstevel@tonic-gate }
7797c478bd9Sstevel@tonic-gate }
7807c478bd9Sstevel@tonic-gate if (previ >= 0) {
7817c478bd9Sstevel@tonic-gate for (p = spectab[previ+1]; *p; p++)
7827c478bd9Sstevel@tonic-gate putc(*p, stdout);
7837c478bd9Sstevel@tonic-gate } else
7847c478bd9Sstevel@tonic-gate prev[0] = 0;
785*e5190c10Smuffin
786*e5190c10Smuffin return (0);
7877c478bd9Sstevel@tonic-gate }
7887c478bd9Sstevel@tonic-gate
789*e5190c10Smuffin int
put1(c)7907c478bd9Sstevel@tonic-gate put1(c) /* output char c */
7917c478bd9Sstevel@tonic-gate int c;
7927c478bd9Sstevel@tonic-gate {
7937c478bd9Sstevel@tonic-gate if (!output)
794*e5190c10Smuffin return (0);
7957c478bd9Sstevel@tonic-gate putc(c, stdout);
796*e5190c10Smuffin
797*e5190c10Smuffin return (0);
7987c478bd9Sstevel@tonic-gate }
7997c478bd9Sstevel@tonic-gate
800*e5190c10Smuffin int
setsize(n)8017c478bd9Sstevel@tonic-gate setsize(n) /* set point size to n (internal) */
8027c478bd9Sstevel@tonic-gate int n;
8037c478bd9Sstevel@tonic-gate {
804*e5190c10Smuffin return (0);
8057c478bd9Sstevel@tonic-gate }
8067c478bd9Sstevel@tonic-gate
807*e5190c10Smuffin int
t_fp(n,s)8087c478bd9Sstevel@tonic-gate t_fp(n, s) /* font position n now contains font s */
8097c478bd9Sstevel@tonic-gate int n;
8107c478bd9Sstevel@tonic-gate char *s;
8117c478bd9Sstevel@tonic-gate {
812*e5190c10Smuffin return (0);
8137c478bd9Sstevel@tonic-gate }
8147c478bd9Sstevel@tonic-gate
815*e5190c10Smuffin int
setfont(n)8167c478bd9Sstevel@tonic-gate setfont(n) /* set font to n */
8177c478bd9Sstevel@tonic-gate int n;
8187c478bd9Sstevel@tonic-gate {
819*e5190c10Smuffin return (0);
8207c478bd9Sstevel@tonic-gate }
8217c478bd9Sstevel@tonic-gate
done()8227c478bd9Sstevel@tonic-gate void done()
8237c478bd9Sstevel@tonic-gate {
8247c478bd9Sstevel@tonic-gate output = 1;
8257c478bd9Sstevel@tonic-gate putpage();
8267c478bd9Sstevel@tonic-gate fflush(stdout);
8277c478bd9Sstevel@tonic-gate exit(0);
8287c478bd9Sstevel@tonic-gate }
8297c478bd9Sstevel@tonic-gate
830*e5190c10Smuffin int
callunix(line)8317c478bd9Sstevel@tonic-gate callunix(line)
8327c478bd9Sstevel@tonic-gate char line[];
8337c478bd9Sstevel@tonic-gate {
8347c478bd9Sstevel@tonic-gate int rc, status, unixpid;
8357c478bd9Sstevel@tonic-gate if( (unixpid=fork())==0 ) {
8367c478bd9Sstevel@tonic-gate signal(SIGINT,sigint); signal(SIGQUIT,sigquit);
8377c478bd9Sstevel@tonic-gate close(0); dup(2);
8387c478bd9Sstevel@tonic-gate execl("/bin/sh", "-sh", "-c", line, 0);
8397c478bd9Sstevel@tonic-gate exit(255);
8407c478bd9Sstevel@tonic-gate }
8417c478bd9Sstevel@tonic-gate else if(unixpid == -1)
842*e5190c10Smuffin return (0);
8437c478bd9Sstevel@tonic-gate else{ signal(SIGINT, SIG_IGN); signal(SIGQUIT, SIG_IGN);
8447c478bd9Sstevel@tonic-gate while( (rc = wait(&status)) != unixpid && rc != -1 ) ;
8457c478bd9Sstevel@tonic-gate signal(SIGINT,(void(*)())done); signal(SIGQUIT,(void(*)())sigquit);
8467c478bd9Sstevel@tonic-gate }
847*e5190c10Smuffin
848*e5190c10Smuffin return (0);
8497c478bd9Sstevel@tonic-gate }
8507c478bd9Sstevel@tonic-gate
851*e5190c10Smuffin int
readch()8527c478bd9Sstevel@tonic-gate readch(){
8537c478bd9Sstevel@tonic-gate char c;
8547c478bd9Sstevel@tonic-gate if (read(2,&c,1)<1) c=0;
8557c478bd9Sstevel@tonic-gate return(c);
8567c478bd9Sstevel@tonic-gate }
8577c478bd9Sstevel@tonic-gate
8587c478bd9Sstevel@tonic-gate char *spectab[] ={
8597c478bd9Sstevel@tonic-gate "em", "-",
8607c478bd9Sstevel@tonic-gate "hy", "-",
8617c478bd9Sstevel@tonic-gate "en", "-",
8627c478bd9Sstevel@tonic-gate "ru", "_",
8637c478bd9Sstevel@tonic-gate "l.", ".",
8647c478bd9Sstevel@tonic-gate "br", "|",
8657c478bd9Sstevel@tonic-gate "vr", "|",
8667c478bd9Sstevel@tonic-gate "fm", "'",
8677c478bd9Sstevel@tonic-gate "or", "|",
8687c478bd9Sstevel@tonic-gate 0, 0,
8697c478bd9Sstevel@tonic-gate };
870