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 /*	from OpenSolaris "ni.c	1.11	05/06/08 SMI"	*/
32 
33 /*
34  * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
35  *
36  * Sccsid @(#)ni.c	1.47 (gritter) 12/17/06
37  */
38 
39 /*
40  * University Copyright- Copyright (c) 1982, 1986, 1988
41  * The Regents of the University of California
42  * All Rights Reserved
43  *
44  * University Acknowledgment- Portions of this document are derived from
45  * software developed by the University of California, Berkeley, and its
46  * contributors.
47  */
48 
49 #include "tdef.h"
50 #include "ext.h"
51 
52 /* You may want to change these names */
53 
54 #ifdef NROFF
55 
56 char	*termtab = TABDIR "/tab.";  /* term type added in ptinit() */
57 char	*fontfile = "";		/* not used */
58 char	devname[20] = "37";
59 
60 #else
61 
62 char	*termtab = FNTDIR;              /* rest added in ptinit() */
63 char	*fontfile = FNTDIR;             /* rest added in casefp() */
64 char	devname[20]	 = "ps";	/* default typesetter */
65 int	html;
66 
67 #endif
68 char	obuf[OBUFSZ];	/* characters collected here for typesetter output */
69 char	*obufp = obuf;
70 int	NN;
71 struct numtab *numtab;
72 const struct numtab initnumtab[] = {
73 	{ PAIR('%', 0) },
74 	{ PAIR('n', 'l') },
75 	{ PAIR('y', 'r') },
76 	{ PAIR('h', 'p') },
77 	{ PAIR('c', 't') },
78 	{ PAIR('d', 'n') },
79 	{ PAIR('m', 'o') },
80 	{ PAIR('d', 'y') },
81 	{ PAIR('d', 'w') },
82 	{ PAIR('l', 'n') },
83 	{ PAIR('d', 'l') },
84 	{ PAIR('s', 't') },
85 	{ PAIR('s', 'b') },
86 	{ PAIR('c', '.') },
87 	{ PAIR('$', '$') },
88 	{ 0 }
89 };
90 
91 
92 int	pto = 10000;
93 int	pfrom = 1;
94 int	print = 1;
95 char	*nextf;
96 int	NS;
97 char	**mfiles;
98 int	nmfi = 0;
99 int	NMF;
100 #ifndef NROFF
101 int	oldbits = -1;
102 #endif
103 int	init = 1;
104 int	fc = IMP;	/* field character */
105 int	eschar = '\\';
106 int	ecs = '\\';
107 #ifdef	NROFF
108 int	pl = 11*INCH;
109 int	po = PO;
110 #else
111 int	pl;
112 int	po;
113 #endif
114 int	dfact = 1;
115 int	dfactd = 1;
116 int	res = 1;
117 int	smnt = 0;	/* beginning of special fonts */
118 int	ascii = ASCII;
119 int	ptid = PTID;
120 int	lg = LG;
121 int	pnlist[NPN] = { -1 };
122 int	vpt = 1;
123 
124 
125 int	*pnp = pnlist;
126 int	npn = 1;
127 int	npnflg = 1;
128 int	dpn = -1;
129 int	totout = 1;
130 int	ulfont = ULFONT;
131 int	tabch = TAB;
132 int	ldrch = LEADER;
133 
134 extern void	caseft(void), caseps(void), casevs(void), casefp(void),
135        		casess(void), casecs(void), casebd(void), caselg(void);
136 
137 enum warn	warn = WARN_FONT;
138 
139 int	NM;
140 struct contab *contab;
141 #define	C(a,b)	{a, 0, (void(*)(int))b, 0}
142 const struct contab initcontab[] = {
143 	C(PAIR('d', 's'), caseds),
144 	C(PAIR('a', 's'), caseas),
145 	C(PAIR('s', 'p'), casesp),
146 	C(PAIR('f', 't'), caseft),
147 	C(PAIR('p', 's'), caseps),
148 	C(PAIR('v', 's'), casevs),
149 	C(PAIR('n', 'r'), casenr),
150 	C(PAIR('i', 'f'), caseif),
151 	C(PAIR('i', 'e'), caseie),
152 	C(PAIR('e', 'l'), caseel),
153 	C(PAIR('p', 'o'), casepo),
154 	C(PAIR('t', 'l'), casetl),
155 	C(PAIR('t', 'm'), casetm),
156 	C(PAIR('b', 'p'), casebp),
157 	C(PAIR('c', 'h'), casech),
158 	C(PAIR('p', 'n'), casepn),
159 	C(PAIR('b', 'r'), tbreak),
160 	C(PAIR('t', 'i'), caseti),
161 	C(PAIR('n', 'e'), casene),
162 	C(PAIR('n', 'f'), casenf),
163 	C(PAIR('c', 'e'), casece),
164 	C(PAIR('r', 'j'), caserj),
165 	C(PAIR('f', 'i'), casefi),
166 	C(PAIR('i', 'n'), casein),
167 	C(PAIR('l', 'l'), casell),
168 	C(PAIR('n', 's'), casens),
169 	C(PAIR('m', 'k'), casemk),
170 	C(PAIR('r', 't'), casert),
171 	C(PAIR('a', 'm'), caseam),
172 	C(PAIR('d', 'e'), casede),
173 	C(PAIR('d', 'i'), casedi),
174 	C(PAIR('d', 'a'), caseda),
175 	C(PAIR('w', 'h'), casewh),
176 	C(PAIR('d', 't'), casedt),
177 	C(PAIR('i', 't'), caseit),
178 	C(PAIR('r', 'm'), caserm),
179 	C(PAIR('r', 'r'), caserr),
180 	C(PAIR('r', 'n'), casern),
181 	C(PAIR('a', 'd'), casead),
182 	C(PAIR('r', 's'), casers),
183 	C(PAIR('n', 'a'), casena),
184 	C(PAIR('p', 'l'), casepl),
185 	C(PAIR('t', 'a'), caseta),
186 	C(PAIR('t', 'r'), casetr),
187 	C(PAIR('u', 'l'), caseul),
188 	C(PAIR('c', 'u'), casecu),
189 	C(PAIR('l', 't'), caselt),
190 	C(PAIR('n', 'x'), casenx),
191 	C(PAIR('s', 'o'), caseso),
192 	C(PAIR('i', 'g'), caseig),
193 	C(PAIR('t', 'c'), casetc),
194 	C(PAIR('f', 'c'), casefc),
195 	C(PAIR('e', 'c'), caseec),
196 	C(PAIR('e', 'o'), caseeo),
197 	C(PAIR('l', 'c'), caselc),
198 	C(PAIR('e', 'v'), caseev),
199 	C(PAIR('r', 'd'), caserd),
200 	C(PAIR('a', 'b'), caseab),
201 	C(PAIR('f', 'l'), casefl),
202 	C(PAIR('e', 'x'), done),
203 	C(PAIR('s', 's'), casess),
204 	C(PAIR('f', 'p'), casefp),
205 	C(PAIR('c', 's'), casecs),
206 	C(PAIR('b', 'd'), casebd),
207 	C(PAIR('l', 'g'), caselg),
208 	C(PAIR('h', 'c'), casehc),
209 	C(PAIR('h', 'y'), casehy),
210 	C(PAIR('n', 'h'), casenh),
211 	C(PAIR('n', 'm'), casenm),
212 	C(PAIR('n', 'n'), casenn),
213 	C(PAIR('s', 'v'), casesv),
214 	C(PAIR('o', 's'), caseos),
215 	C(PAIR('l', 's'), casels),
216 	C(PAIR('c', 'c'), casecc),
217 	C(PAIR('c', '2'), casec2),
218 	C(PAIR('e', 'm'), caseem),
219 	C(PAIR('a', 'f'), caseaf),
220 	C(PAIR('h', 'w'), casehw),
221 	C(PAIR('m', 'c'), casemc),
222 	C(PAIR('p', 'm'), casepm),
223 	C(PAIR('p', 'i'), casepi),
224 	C(PAIR('u', 'f'), caseuf),
225 	C(PAIR('p', 'c'), casepc),
226 	C(PAIR('h', 't'), caseht),
227 	C(PAIR('c', 'f'), casecf),
228 	C(PAIR('s', 'y'), casesy),
229 	C(PAIR('l', 'f'), caself),
230 	C(PAIR('d', 'b'), casedb),
231 /*	C(PAIR('!', 0), casesy), */	/* synonym for .sy */
232 	C(PAIR(XFUNC, 0), caseif),	/* while loop execution */
233 	C(PAIR('c', 'p'), casecp),
234 	C(0,              0)
235 };
236 
237 
238 tchar *oline;
239 
240 /*
241  * troff environment block
242  */
243 
244 struct	env env = {
245 /* int	ics	 */	0,
246 /* int	sps	 */	0,
247 /* int	ses	 */	0,
248 /* int	spacesz	 */	0,
249 /* int	sesspsz  */	0,
250 #ifndef	NROFF
251 /* int	minsps	 */	0,
252 /* int	minspsz  */	0,
253 /* int	letspsz	 */	0,
254 /* int	letsps	 */	0,
255 /* int	lspmin	 */	0,
256 /* int	lspmax	 */	0,
257 /* int	lspnc	 */	0,
258 /* int	lsplow	 */	0,
259 /* int	lsphigh	 */	0,
260 /* int	lspcur	 */	0,
261 /* int	lsplast	 */	0,
262 /* int	lshmin	 */	0,
263 /* int	lshmax	 */	0,
264 /* int	lshwid	 */	0,
265 /* int	lshlow	 */	0,
266 /* int	lshhigh	 */	0,
267 /* int	lshcur	 */	0,
268 #endif	/* !NROFF */
269 /* int	fldcnt	 */	0,
270 /* int	lss	 */	0,
271 /* int	lss1	 */	0,
272 /* int	ll	 */	0,
273 /* int	ll1	 */	0,
274 /* int	lt	 */	0,
275 /* int	lt1	 */	0,
276 /* tchar i	*/	0, 	/* insertion character */
277 /* int	icf	 */	0,
278 /* tchar	chbits	 */	0,	/* size+font bits for current character */
279 /* tchar	spbits	 */	0,
280 /* tchar	nmbits	 */	0,
281 /* int	apts	 */	PS,	/* actual point size -- as requested by user */
282 /* int	apts1	 */	PS,	/* need not match an existent size */
283 /* int	pts	 */	PS,	/* hence, this is the size that really exists */
284 /* int	pts1	 */	PS,
285 /* int	font	 */	FT,
286 /* int	font1	 */	FT,
287 /* int	ls	 */	1,
288 /* int	ls1	 */	1,
289 /* int	ad	 */	1,
290 /* int	nms	 */	1,
291 /* int	ndf	 */	1,
292 /* int	fi	 */	1,
293 /* int	cc	 */	'.',
294 /* int	c2	 */	'\'',
295 /* int	ohc	 */	OHC,
296 /* int	tdelim	 */	IMP,
297 /* int	hyf	 */	1,
298 /* int	hyoff	 */	0,
299 /* int	hlm	 */	-1,
300 /* int	hlc	 */	0,
301 /* int	hylen	 */	5,
302 /* float hypp	 */	0,
303 /* float hypp2	 */	0,
304 /* float hypp3	 */	0,
305 /* int	un1	 */	-1,
306 /* int	tabc	 */	0,
307 /* int	dotc	 */	'.',
308 /* int	adsp	 */	0,
309 /* int	adrem	 */	0,
310 /* int	lastl	 */	0,
311 /* int	nel	 */	0,
312 /* int	admod	 */	0,
313 /* int	adflg	 */	0,
314 /* int	adspc	 */	0,
315 /* int	pa	 */	0,
316 /* tchar	*wordp	 */	0,
317 /* int	spflg	 */	0,	/* probably to indicate space after punctuation needed */
318 /* int	seflg	 */	0,
319 /* tchar	*linep	 */	0,
320 /* tchar	*wdend	 */	0,
321 /* tchar	*wdstart	 */	0,
322 /* int	wne	 */	0,
323 /* int	wsp	 */	0,
324 /* int	ne	 */	0,
325 /* int	nc	 */	0,
326 /* int	nb	 */	0,
327 /* int	lnmod	 */	0,
328 /* int	nwd	 */	0,
329 /* int	nn	 */	0,
330 /* int	ni	 */	0,
331 /* int	ul	 */	0,
332 /* int	cu	 */	0,
333 /* int	ce	 */	0,
334 /* int	rj	 */	0,
335 /* int	brnl	 */	0,
336 /* int	brpnl	 */	0,
337 /* int	in	 */	0,
338 /* int	in1	 */	0,
339 /* int	un	 */	0,
340 /* int	wch	 */	0,
341 /* int	rhang	 */	0,
342 /* int	pendt	 */	0,
343 /* tchar	*pendw	 */	(tchar *)0,
344 /* int	pendnf	 */	0,
345 /* int	spread	 */	0,
346 /* int	dpenal	 */	0,
347 /* int	it	 */	0,
348 /* int	itc	 */	0,
349 /* int	itmac	 */	0,
350 /* int	lnsize	 */	0,
351 /* int	wdsize	 */	0,
352 };
353