xref: /titanic_51/usr/src/cmd/troff/ni.c (revision 8eea8e29cc4374d1ee24c25a07f45af132db3499)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28 /*	  All Rights Reserved  	*/
29 
30 
31 #pragma ident	"%Z%%M%	%I%	%E% SMI"
32 
33 /*
34  * University Copyright- Copyright (c) 1982, 1986, 1988
35  * The Regents of the University of California
36  * All Rights Reserved
37  *
38  * University Acknowledgment- Portions of this document are derived from
39  * software developed by the University of California, Berkeley, and its
40  * contributors.
41  */
42 
43 #include "tdef.h"
44 
45 /* You may want to change these names */
46 
47 #ifdef NROFF
48 
49 char	termtab[NS] = "/usr/share/lib/nterm/tab.";  /* term type added in ptinit() */
50 char	fontfile[NS] = "";	/* not used */
51 char	devname[20] = "37";
52 
53 #else
54 
55 char	termtab[NS] = "/usr/lib/font"; /* rest added in ptinit() */
56 char	fontfile[NS] = "/usr/lib/font";/* rest added in casefp() */
57 char	devname[20]	 = "post";	/* default typesetter */
58 
59 #endif
60 char	tmp_name[] = "/usr/tmp/trtmpXXXXXX";
61 char	obuf[OBUFSZ];	/* characters collected here for typesetter output */
62 char	*obufp = obuf;
63 struct numtab numtab[NN] = {
64 	{ PAIR('%', 0) },
65 	{ PAIR('n', 'l') },
66 	{ PAIR('y', 'r') },
67 	{ PAIR('h', 'p') },
68 	{ PAIR('c', 't') },
69 	{ PAIR('d', 'n') },
70 	{ PAIR('m', 'o') },
71 	{ PAIR('d', 'y') },
72 	{ PAIR('d', 'w') },
73 	{ PAIR('l', 'n') },
74 	{ PAIR('d', 'l') },
75 	{ PAIR('s', 't') },
76 	{ PAIR('s', 'b') },
77 	{ PAIR('c', '.') },
78 	{ PAIR('$', '$') },
79 };
80 
81 
82 int	pto = 10000;
83 int	pfrom = 1;
84 int	print = 1;
85 char	nextf[NS] = "/usr/share/lib/tmac/";
86 char	mfiles[NMF][NS];
87 int	nmfi = 0;
88 #ifndef NROFF
89 int	oldbits = -1;
90 #endif
91 int	init = 1;
92 int	fc = IMP;	/* field character */
93 int	eschar = '\\';
94 #ifdef	NROFF
95 int	pl = 11*INCH;
96 int	po = PO;
97 #else
98 int	pl;
99 int	po;
100 #endif
101 int	dfact = 1;
102 int	dfactd = 1;
103 int	res = 1;
104 int	smnt = 0;	/* beginning of special fonts */
105 int	ascii = ASCII;
106 int	ptid = PTID;
107 int	lg = LG;
108 int	pnlist[NPN] = { -1 };
109 
110 
111 int	*pnp = pnlist;
112 int	npn = 1;
113 int	npnflg = 1;
114 int	dpn = -1;
115 int	totout = 1;
116 int	ulfont = ULFONT;
117 int	tabch = TAB;
118 int	ldrch = LEADER;
119 extern caseds(), caseas(), casesp(), caseft(), caseps(), casevs(),
120 casenr(), caseif(), casepo(), casetl(), casetm(), casebp(), casech(),
121 casepn(), tbreak(), caseti(), casene(), casenf(), casece(), casefi(),
122 casein(), casell(), casens(), casemk(), casert(), caseam(),
123 casede(), casedi(), caseda(), casewh(), casedt(), caseit(), caserm(),
124 casern(), casead(), casers(), casena(), casepl(), caseta(), casetr(),
125 caseul(), caselt(), casenx(), caseso(), caseig(), casetc(), casefc(),
126 caseec(), caseeo(), caselc(), caseev(), caserd(), caseab(), casefl(),
127 done(), casess(), casefp(), casecs(), casebd(), caselg(), casehc(),
128 casehy(), casenh(), casenm(), casenn(), casesv(), caseos(), casels(),
129 casecc(), casec2(), caseem(), caseaf(), casehw(), casemc(), casepm(),
130 casecu(), casepi(), caserr(), caseuf(), caseie(), caseel(), casepc(),
131 caseht(), casecf(), casesy(), caself(), casedb();
132 
133 #define	C(a,b)	{a, 0, b, 0}
134 struct contab contab[NM] = {
135 	C(PAIR('d', 's'), caseds),
136 	C(PAIR('a', 's'), caseas),
137 	C(PAIR('s', 'p'), casesp),
138 	C(PAIR('f', 't'), caseft),
139 	C(PAIR('p', 's'), caseps),
140 	C(PAIR('v', 's'), casevs),
141 	C(PAIR('n', 'r'), casenr),
142 	C(PAIR('i', 'f'), caseif),
143 	C(PAIR('i', 'e'), caseie),
144 	C(PAIR('e', 'l'), caseel),
145 	C(PAIR('p', 'o'), casepo),
146 	C(PAIR('t', 'l'), casetl),
147 	C(PAIR('t', 'm'), casetm),
148 	C(PAIR('b', 'p'), casebp),
149 	C(PAIR('c', 'h'), casech),
150 	C(PAIR('p', 'n'), casepn),
151 	C(PAIR('b', 'r'), tbreak),
152 	C(PAIR('t', 'i'), caseti),
153 	C(PAIR('n', 'e'), casene),
154 	C(PAIR('n', 'f'), casenf),
155 	C(PAIR('c', 'e'), casece),
156 	C(PAIR('f', 'i'), casefi),
157 	C(PAIR('i', 'n'), casein),
158 	C(PAIR('l', 'l'), casell),
159 	C(PAIR('n', 's'), casens),
160 	C(PAIR('m', 'k'), casemk),
161 	C(PAIR('r', 't'), casert),
162 	C(PAIR('a', 'm'), caseam),
163 	C(PAIR('d', 'e'), casede),
164 	C(PAIR('d', 'i'), casedi),
165 	C(PAIR('d', 'a'), caseda),
166 	C(PAIR('w', 'h'), casewh),
167 	C(PAIR('d', 't'), casedt),
168 	C(PAIR('i', 't'), caseit),
169 	C(PAIR('r', 'm'), caserm),
170 	C(PAIR('r', 'r'), caserr),
171 	C(PAIR('r', 'n'), casern),
172 	C(PAIR('a', 'd'), casead),
173 	C(PAIR('r', 's'), casers),
174 	C(PAIR('n', 'a'), casena),
175 	C(PAIR('p', 'l'), casepl),
176 	C(PAIR('t', 'a'), caseta),
177 	C(PAIR('t', 'r'), casetr),
178 	C(PAIR('u', 'l'), caseul),
179 	C(PAIR('c', 'u'), casecu),
180 	C(PAIR('l', 't'), caselt),
181 	C(PAIR('n', 'x'), casenx),
182 	C(PAIR('s', 'o'), caseso),
183 	C(PAIR('i', 'g'), caseig),
184 	C(PAIR('t', 'c'), casetc),
185 	C(PAIR('f', 'c'), casefc),
186 	C(PAIR('e', 'c'), caseec),
187 	C(PAIR('e', 'o'), caseeo),
188 	C(PAIR('l', 'c'), caselc),
189 	C(PAIR('e', 'v'), caseev),
190 	C(PAIR('r', 'd'), caserd),
191 	C(PAIR('a', 'b'), caseab),
192 	C(PAIR('f', 'l'), casefl),
193 	C(PAIR('e', 'x'), done),
194 	C(PAIR('s', 's'), casess),
195 	C(PAIR('f', 'p'), casefp),
196 	C(PAIR('c', 's'), casecs),
197 	C(PAIR('b', 'd'), casebd),
198 	C(PAIR('l', 'g'), caselg),
199 	C(PAIR('h', 'c'), casehc),
200 	C(PAIR('h', 'y'), casehy),
201 	C(PAIR('n', 'h'), casenh),
202 	C(PAIR('n', 'm'), casenm),
203 	C(PAIR('n', 'n'), casenn),
204 	C(PAIR('s', 'v'), casesv),
205 	C(PAIR('o', 's'), caseos),
206 	C(PAIR('l', 's'), casels),
207 	C(PAIR('c', 'c'), casecc),
208 	C(PAIR('c', '2'), casec2),
209 	C(PAIR('e', 'm'), caseem),
210 	C(PAIR('a', 'f'), caseaf),
211 	C(PAIR('h', 'w'), casehw),
212 	C(PAIR('m', 'c'), casemc),
213 	C(PAIR('p', 'm'), casepm),
214 	C(PAIR('p', 'i'), casepi),
215 	C(PAIR('u', 'f'), caseuf),
216 	C(PAIR('p', 'c'), casepc),
217 	C(PAIR('h', 't'), caseht),
218 	C(PAIR('c', 'f'), casecf),
219 	C(PAIR('s', 'y'), casesy),
220 	C(PAIR('l', 'f'), caself),
221 	C(PAIR('d', 'b'), casedb),
222 /*	C(PAIR('!', 0), casesy), */	/* synonym for .sy */
223 };
224 
225 
226 tchar oline[LNSIZE+1];
227 
228 /*
229  * troff environment block
230  */
231 
232 struct	env env = {
233 /* int	ics	 */	0,
234 /* int	sps	 */	0,
235 /* int	spacesz	 */	0,
236 /* int	lss	 */	0,
237 /* int	lss1	 */	0,
238 /* int	ll	 */	0,
239 /* int	ll1	 */	0,
240 /* int	lt	 */	0,
241 /* int	lt1	 */	0,
242 /* tchar i	*/	0, 	/* insertion character */
243 /* int	icf	 */	0,
244 /* tchar	chbits	 */	0,	/* size+font bits for current character */
245 /* tchar	spbits	 */	0,
246 /* tchar	nmbits	 */	0,
247 /* int	apts	 */	PS,	/* actual point size -- as requested by user */
248 /* int	apts1	 */	PS,	/* need not match an existent size */
249 /* int	pts	 */	PS,	/* hence, this is the size that really exists */
250 /* int	pts1	 */	PS,
251 /* int	font	 */	FT,
252 /* int	font1	 */	FT,
253 /* int	ls	 */	1,
254 /* int	ls1	 */	1,
255 /* int	ad	 */	1,
256 /* int	nms	 */	1,
257 /* int	ndf	 */	1,
258 /* int	fi	 */	1,
259 /* int	cc	 */	'.',
260 /* int	c2	 */	'\'',
261 /* int	ohc	 */	OHC,
262 /* int	tdelim	 */	IMP,
263 /* int	hyf	 */	0,
264 /* int	hyoff	 */	0,
265 /* int	un1	 */	-1,
266 /* int	tabc	 */	0,
267 /* int	dotc	 */	'.',
268 /* int	adsp	 */	0,
269 /* int	adrem	 */	0,
270 /* int	lastl	 */	0,
271 /* int	nel	 */	0,
272 /* int	admod	 */	0,
273 /* tchar	*wordp	 */	0,
274 /* int	spflg	 */	0,	/* probably to indicate space after punctuation needed */
275 /* tchar	*linep	 */	0,
276 /* tchar	*wdend	 */	0,
277 /* tchar	*wdstart	 */	0,
278 /* int	wne	 */	0,
279 /* int	ne	 */	0,
280 /* int	nc	 */	0,
281 /* int	nb	 */	0,
282 /* int	lnmod	 */	0,
283 /* int	nwd	 */	0,
284 /* int	nn	 */	0,
285 /* int	ni	 */	0,
286 /* int	ul	 */	0,
287 /* int	cu	 */	0,
288 /* int	ce	 */	0,
289 /* int	in	 */	0,
290 /* int	in1	 */	0,
291 /* int	un	 */	0,
292 /* int	wch	 */	0,
293 /* int	pendt	 */	0,
294 /* tchar	*pendw	 */	(tchar *)0,
295 /* int	pendnf	 */	0,
296 /* int	spread	 */	0,
297 /* int	it	 */	0,
298 /* int	itmac	 */	0,
299 /* int	lnsize	 */	LNSIZE,
300 };
301