ta.c revision e5190c108bde19ca4d7c03b1d1eab7b00bd3a1ed
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* University Copyright- Copyright (c) 1982, 1986, 1988
* The Regents of the University of California
* All Rights Reserved
*
* University Acknowledgment- Portions of this document are derived from
* software developed by the University of California, Berkeley, and its
* contributors.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* drive hp2621 terminal
* just to see stuff quickly. like troff -a
*/
/*
output language from troff:
all numbers are character strings
sn size in points
fn font as number from 1-n
cx ascii character x
Cxyz funny char xyz. terminated by white space
Hn go to absolute horizontal position n
Vn go to absolute vertical position n (down is positive)
hn go n units horizontally (relative)
vn ditto vertically
nnc move right nn (exactly 2 digits!), then print c
(this wart is an optimization that shrinks output file size
about 35% and run-time about 15% while preserving ascii-ness)
w paddable word space - no action needed
nb a end of line (information only -- no action needed)
b = space before line, a = after
pn begin page n
#...\n comment
Dt ...\n draw operation 't':
Dl x y line from here by x,y
Dc d circle of diameter d with left side here
De x y ellipse of axes x,y with left side here
Da x y u v arc counter-clockwise from here to u,v from center
with center x,y from here
D~ x y x y ... wiggly line by x,y then x,y ...
x ...\n device control functions:
x i init
x T s name of device is s
h = min horizontal motion, v = min vert
x p pause (can restart)
x s stop -- done for ever
x t generate trailer
x f n s font position n contains font s
x H n set character height to n
x S n set character slant to n
Subcommands like "i" are often spelled out like "init".
*/
#include <stdio.h>
#include <signal.h>
#include <ctype.h>
#include "dev.h"
#define NFONT 10
int output = 0; /* do we do output at all? */
int nolist = 0; /* output page list if > 0 */
int erase = 1;
int wflag = 0; /* wait, looping, for new input if on */
void (*sigint)();
void (*sigquit)();
void done();
int nsizes = 1;
int nfonts;
int smnt; /* index of first special font */
int nchtab;
char *chname;
short *chtab;
#define FATAL 1
#define BMASK 0377
int dbg = 0;
/* initial value to avoid 0 divide */
extern char devname[];
int nowait = 0; /* 0 => wait at bottom of each page */
int
{
case 'a':
break;
case 'e':
erase = 0;
break;
case 'o':
break;
case 'd':
break;
case 'w': /* no wait at bottom of page */
nowait = 1;
break;
}
argc--;
argv++;
}
if (argc <= 1)
else
while (--argc > 0) {
}
done();
return (0);
}
int
outlist(s) /* process list of page numbers to be printed */
char *s;
{
nolist = 0;
while (*s) {
n1 = 0;
if (isdigit((unsigned char)*s))
do
while (isdigit((unsigned char)*s));
else
n1 = -9999;
if (*s == '-') {
s++;
n2 = 0;
if (isdigit((unsigned char)*s))
do
while (isdigit((unsigned char)*s));
else
n2 = 9999;
}
if (*s != '\0')
s++;
}
if (dbg)
for (i=0; i<nolist; i += 2)
return (0);
}
int
in_olist(n) /* is n in olist? */
int n;
{
int i;
if (nolist == 0)
return(1); /* everything is included */
for (i = 0; i < nolist; i += 2)
return(1);
return(0);
}
int
{
int c, k;
switch (c) {
case '\n': /* when input is text */
case ' ':
case 0: /* occasional noise creeps in */
break;
case '{': /* push down current environment */
t_push();
break;
case '}':
t_pop();
break;
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
/* two motion digits plus a character */
break;
case 'c': /* single ascii character */
break;
case 'C':
break;
case 't': /* straight text */
break;
case 'D': /* draw function */
switch (buf[0]) {
case 'l': /* draw a line */
drawline(n, m, ".");
break;
case 'c': /* circle */
drawcirc(n);
break;
case 'e': /* ellipse */
drawellip(m, n);
break;
case 'a': /* arc */
break;
case '~': /* wiggly line */
break;
default:
break;
}
break;
case 's':
break;
case 'f':
break;
case 'H': /* absolute horizontal motion */
/* fscanf(fp, "%d", &n); */
;
k = 0;
do {
k = 10 * k + c - '0';
hgoto(k);
break;
case 'h': /* relative horizontal motion */
/* fscanf(fp, "%d", &n); */
;
k = 0;
do {
k = 10 * k + c - '0';
hmot(k);
break;
case 'w': /* word space */
break;
case 'V':
vgoto(n);
break;
case 'v':
vmot(n);
break;
case 'p': /* new page */
t_page(n);
break;
case 'n': /* end of line */
;
t_newline();
break;
case '#': /* comment */
;
break;
case 'x': /* device control */
break;
default:
done();
}
}
return (0);
}
int
{
char str[20];
int c, n;
switch (str[0]) { /* crude for now */
case 'i': /* initialize */
fileinit();
t_init(0);
break;
case 'T': /* device name */
break;
case 't': /* trailer */
t_trailer();
break;
case 'p': /* pause -- can restart */
t_reset('p');
break;
case 's': /* stop */
t_reset('s');
break;
case 'r': /* resolution assumed when prepared */
break;
case 'f': /* font used */
break;
}
;
return (0);
}
int
fileinit() /* read in font and code files, etc. */
{
return (0);
}
int
fontprint(i) /* debugging print of font i (0,...) */
{
return (0);
}
int
int n, nw;
{
return (0);
}
int
loadfont(n, s) /* load font info for font s on position n (1...) */
int n;
char *s;
{
return (0);
}
int
char *s;
{
if (f)
exit(1);
return (0);
}
/*
Here beginneth all the stuff that really depends
on the 202 (we hope).
*/
#define ESC 033
#define HOME 'H'
#define CLEAR 'J'
#define FF 014
int size = 1;
int hpos; /* horizontal position where we are supposed to be next (left = 0) */
int vpos; /* current vertical position (down positive) */
int horig; /* h origin of current block; hpos rel to this */
int vorig; /* v origin of current block; vpos rel to this */
int
int reinit;
{
int i, j;
return (0);
}
#define MAXSTATE 5
struct state {
int ssize;
int sfont;
int shpos;
int svpos;
int shorig;
int svorig;
};
int
t_push() /* begin a new block */
{
hflush();
return (0);
}
int
t_pop() /* pop to previous state */
{
return (0);
}
int np; /* number of pages seen */
int npmax; /* high-water mark of np */
int
t_page(n) /* do whatever new page functions */
{
long ftell();
int c, m, i;
if (output == 0) {
t_init(1);
return (0);
}
/* have just printed something, and seen p<n> for next one */
putpage();
if (nowait)
return (0);
next:
if (*bp++ == '\n')
break;
*bp = 0;
switch (buf[0]) {
case 0:
done();
break;
case '\n':
t_init(1);
return (0);
case '!':
break;
case 'e':
break;
case 'w':
break;
case 'a':
break;
case '-':
case 'p':
break;
}
if (np - m <= 0) {
break;
}
np -= m;
output = 1;
t_init(1);
return (0);
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
for (i = 0; i < npmax; i++)
if (m == pgnum[i])
break;
break;
}
np = i + 1;
output = 1;
t_init(1);
return (0);
case 'o':
output = 0;
t_init(1);
return (0);
case '?':
break;
default:
break;
}
goto next;
}
int
putpage()
{
int i, j, k;
return (0);
}
int
t_newline() /* do whatever for the end of a line */
{
printf("\n");
hpos = 0;
return (0);
}
int
t_size(n) /* convert integer to internal size number*/
int n;
{
return (0);
}
int
t_font(s) /* convert string to internal font number */
char *s;
{
return (0);
}
int
t_text(s) /* print string s as text */
char *s;
{
int c, w=0;
char str[100];
if (!output)
return (0);
while ((c = *s++) != '\n') {
if (c == '\\') {
switch (c = *s++) {
case '\\':
case 'e':
put1('\\');
break;
case '(':
str[0] = *s++;
str[1] = *s++;
break;
}
} else {
put1(c);
}
hmot(w);
}
return (0);
}
int
t_reset(c)
{
int n;
output = 1;
if (c == 's')
t_page(9999);
return (0);
}
int
{
return (0);
}
int
hgoto(n)
{
hpos = n; /* this is where we want to be */
/* before printing a character, */
/* have to make sure it's true */
return (0);
}
int
hmot(n) /* generate n units of horizontal motion */
int n;
{
return (0);
}
int
hflush() /* actual horizontal output occurs here */
{
return (0);
}
int
vgoto(n)
{
vpos = n;
return (0);
}
int
vmot(n) /* generate n units of vertical motion */
int n;
{
return (0);
}
int
put1s(s) /* s is a funny char name */
char *s;
{
int i;
char *p;
extern char *spectab[];
static int previ;
if (!output)
return (0);
previ = -1;
for (i = 0; spectab[i] != 0; i += 2)
previ = i;
break;
}
}
if (previ >= 0) {
} else
prev[0] = 0;
return (0);
}
int
put1(c) /* output char c */
int c;
{
if (!output)
return (0);
return (0);
}
int
setsize(n) /* set point size to n (internal) */
int n;
{
return (0);
}
int
t_fp(n, s) /* font position n now contains font s */
int n;
char *s;
{
return (0);
}
int
setfont(n) /* set font to n */
int n;
{
return (0);
}
void done()
{
output = 1;
putpage();
exit(0);
}
int
char line[];
{
exit(255);
}
else if(unixpid == -1)
return (0);
}
return (0);
}
int
readch(){
char c;
return(c);
}
char *spectab[] ={
"em", "-",
"hy", "-",
"en", "-",
"ru", "_",
"l.", ".",
"br", "|",
"vr", "|",
"fm", "'",
"or", "|",
0, 0,
};