1 /* $MirOS: src/usr.bin/oldroff/nroff/nii.c,v 1.4 2008/11/08 23:04:42 tg Exp $ */
2 
3 /*-
4  * Copyright (c) 1979, 1980, 1981, 1986, 1988, 1990, 1991, 1992
5  *     The Regents of the University of California.
6  * Copyright (C) Caldera International Inc.  2001-2002.
7  * Copyright (c) 2003, 2004, 2005
8  *	Thorsten "mirabilos" Glaser <tg@mirbsd.org>
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms,
12  * with or without modification, are permitted provided
13  * that the following conditions are met:
14  *
15  * Redistributions of source code and documentation must retain
16  * the above copyright notice, this list of conditions and the
17  * following disclaimer.  Redistributions in binary form must
18  * reproduce the above copyright notice, this list of conditions
19  * and the following disclaimer in the documentation and/or other
20  * materials provided with the distribution.
21  *
22  * All advertising materials mentioning features or use of this
23  * software must display the following acknowledgement:
24  *   This product includes software developed or owned by
25  *   Caldera International, Inc.
26  *
27  * Neither the name of Caldera International, Inc. nor the names
28  * of other contributors may be used to endorse or promote products
29  * derived from this software without specific prior written permission.
30  *
31  * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
32  * INTERNATIONAL, INC. AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
33  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35  * ARE DISCLAIMED.  IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE
36  * LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR
37  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
38  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
39  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
40  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
41  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
42  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43  */
44 
45 #ifndef lint
46 static char sccsid[] = "@(#)nii.c	4.3 (Berkeley) 5/2/91";
47 #endif /* not lint */
48 
49 #include "tdef.h"
50 #ifdef NROFF
51 #include "tw.h"
52 #endif
53 #include "sdef.h"
54 #include "d.h"
55 #include "v.h"
56 #include <termios.h>
57 
58 int *vlist = (int *)&v;
59 struct s *frame, *stk, *ejl;
60 struct s *nxf, *litlev;
61 
62 #ifdef NROFF
63 int pipeflg;
64 int hflg;
65 int eqflg;
66 #endif
67 
68 #ifndef NROFF
69 int xpts;
70 int verm;
71 int *pslp;
72 int psflg;
73 int ppts;
74 int pfont;
75 int paper;
76 int mpts;
77 int mfont;
78 int mcase;
79 int escm;
80 int cs;
81 int code;
82 int ccs;
83 int bd;
84 int back;
85 #endif
86 
87 int level;
88 int stdi;
89 int waitf;
90 int nofeed;
91 int quiet;
92 int stop;
93 char ibuf[IBUFSZ];
94 char xbuf[IBUFSZ];
95 char *ibufp;
96 char *xbufp;
97 char *eibuf;
98 char *xeibuf;
99 int cbuf[NC];
100 int *cp;
101 int nx;
102 int mflg;
103 int ch = 0;
104 int cps;
105 int ibf;
106 int ttyod;
107 struct termios ttys;
108 int iflg;
109 char *enda;
110 int rargc;
111 char **argp;
112 char trtab[256];
113 int lgf;
114 int copyf;
115 int ch0;
116 int cwidth;
117 filep ip;
118 int nlflg;
119 int *ap;
120 int donef;
121 int nflush;
122 int nchar;
123 int rchar;
124 int nfo;
125 int ifile;
126 int padc;
127 int raw;
128 int ifl[NSO];
129 int ifi;
130 int flss;
131 int nonumb;
132 int trap;
133 int tflg;
134 int ejf;
135 int lit;
136 int gflag;
137 int dilev;
138 int tlss;
139 filep offset;
140 int em;
141 int ds;
142 filep woff;
143 int app;
144 int ndone;
145 int lead;
146 int ralss;
147 filep nextb;
148 int *argtop;
149 int nrbits;
150 int nform;
151 int oldmn;
152 int newmn;
153 int macerr;
154 filep apptr;
155 int diflg;
156 filep roff;
157 int wbfi;
158 int inc[NN];
159 int fmt[NN];
160 int evi;
161 int vflag;
162 int noscale;
163 int po1;
164 int nlistx[NTRAP];		/* "x" added to avoid libc collisions */
165 int mlist[NTRAP];
166 int evlist[EVLSZ];
167 int ev;
168 int tty;
169 int sfont;
170 int sv;
171 int esc;
172 int widthp;
173 int xfont;
174 int setwdf;
175 int xbitf;
176 int over;
177 int nhyp;
178 int **hyp;
179 int *olinep;
180 int esct;
181 int ttysave = 0;
182 struct termios ttysavespace;
183 int dotT;
184 char *unlkp = NULL;
185 int no_out;
186