1 | # include "stdio.h" |
---|
2 | # define U(x) x |
---|
3 | # define NLSTATE yyprevious=YYNEWLINE |
---|
4 | # define BEGIN yybgin = yysvec + 1 + |
---|
5 | # define INITIAL 0 |
---|
6 | # define YYLERR yysvec |
---|
7 | # define YYSTATE (yyestate-yysvec-1) |
---|
8 | # define YYOPTIM 1 |
---|
9 | # define YYLMAX 200 |
---|
10 | # define output(c) putc(c,yyout) |
---|
11 | # define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar) |
---|
12 | # define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;} |
---|
13 | # define yymore() (yymorfg=1) |
---|
14 | # define ECHO fprintf(yyout, "%s",yytext) |
---|
15 | # define REJECT { nstr = yyreject(); goto yyfussy;} |
---|
16 | int yyleng; extern char yytext[]; |
---|
17 | int yymorfg; |
---|
18 | extern char *yysptr, yysbuf[]; |
---|
19 | int yytchar; |
---|
20 | FILE *yyin ={stdin}, *yyout ={stdout}; |
---|
21 | extern int yylineno; |
---|
22 | struct yysvf { |
---|
23 | struct yywork *yystoff; |
---|
24 | struct yysvf *yyother; |
---|
25 | int *yystops;}; |
---|
26 | struct yysvf *yyestate; |
---|
27 | extern struct yysvf yysvec[], *yybgin; |
---|
28 | #include <sys/file.h> |
---|
29 | #include <signal.h> |
---|
30 | extern int sighandler(); |
---|
31 | char *reset="\033c"; /* ris */ |
---|
32 | char *land_length="\033[2550t"; |
---|
33 | char *landscape="\033[10m"; |
---|
34 | char *port_length="\033[3300t"; /* form length = 11 inches */ |
---|
35 | char *portrait="\033[11m"; |
---|
36 | char *beginunderline = "\033[4m"; |
---|
37 | char *endunderline = "\033[0m"; |
---|
38 | char *mode; |
---|
39 | char *form_length; |
---|
40 | # define YYNEWLINE 10 |
---|
41 | yylex(){ |
---|
42 | int nstr; extern int yyprevious; |
---|
43 | while((nstr = yylook()) >= 0) |
---|
44 | yyfussy: switch(nstr){ |
---|
45 | case 0: |
---|
46 | if(yywrap()) return(0); break; |
---|
47 | case 1: |
---|
48 | { |
---|
49 | printf("\f%s%s%s",reset,mode,form_length); |
---|
50 | fflush(stdout); |
---|
51 | } |
---|
52 | break; |
---|
53 | case 2: |
---|
54 | { |
---|
55 | register char *p = &yytext[0]; |
---|
56 | printf(beginunderline); |
---|
57 | while(*p) |
---|
58 | { |
---|
59 | if((*p != '_') && (*p != '\b')) |
---|
60 | { |
---|
61 | putchar(*p); |
---|
62 | } |
---|
63 | ++p; |
---|
64 | } |
---|
65 | printf(endunderline); |
---|
66 | fflush(stdout); |
---|
67 | } |
---|
68 | break; |
---|
69 | case 3: |
---|
70 | { /* ^Y^A */ |
---|
71 | /* |
---|
72 | * lpd needs to use a different filter to |
---|
73 | * print data so stop what we are doing and |
---|
74 | * wait for lpd to restart us. |
---|
75 | */ |
---|
76 | fflush(stdout); |
---|
77 | kill(getpid(), SIGSTOP); |
---|
78 | printf("%s%s%s",reset,mode,form_length); |
---|
79 | fflush(stdout); |
---|
80 | } |
---|
81 | break; |
---|
82 | case -1: |
---|
83 | break; |
---|
84 | default: |
---|
85 | fprintf(yyout,"bad switch yylook %d",nstr); |
---|
86 | } return(0); } |
---|
87 | /* end of yylex */ |
---|
88 | |
---|
89 | yywrap() |
---|
90 | { |
---|
91 | fflush(stdout); |
---|
92 | flock(1, LOCK_UN); |
---|
93 | return(1); |
---|
94 | } |
---|
95 | main(argc,argv) |
---|
96 | int argc; |
---|
97 | register char *argv[]; |
---|
98 | { |
---|
99 | register int i; |
---|
100 | flock(1, LOCK_EX); |
---|
101 | if(!strcmp(argv[0], "ln01l")) { |
---|
102 | mode = landscape; |
---|
103 | form_length = land_length; |
---|
104 | } |
---|
105 | else { |
---|
106 | mode = portrait; |
---|
107 | form_length = port_length; |
---|
108 | } |
---|
109 | setbuf(stdout, NULL); |
---|
110 | printf("%s%s%s",reset,mode,form_length); |
---|
111 | fflush(stdout); |
---|
112 | while(1) { |
---|
113 | if(yylex() <= 0) break; |
---|
114 | } |
---|
115 | } |
---|
116 | |
---|
117 | /* Local Modes: */ |
---|
118 | /* Mode:C */ |
---|
119 | /* End: */ |
---|
120 | int yyvstop[] ={ |
---|
121 | 0, |
---|
122 | |
---|
123 | 1, |
---|
124 | 0, |
---|
125 | |
---|
126 | 3, |
---|
127 | 0, |
---|
128 | |
---|
129 | 2, |
---|
130 | 0, |
---|
131 | 0}; |
---|
132 | # define YYTYPE char |
---|
133 | struct yywork { YYTYPE verify, advance; } yycrank[] ={ |
---|
134 | 0,0, 0,0, 4,6, 0,0, |
---|
135 | 0,0, 0,0, 0,0, 0,0, |
---|
136 | 0,0, 5,7, 0,0, 0,0, |
---|
137 | 0,0, 1,3, 0,0, 0,0, |
---|
138 | 0,0, 0,0, 0,0, 0,0, |
---|
139 | 0,0, 0,0, 0,0, 0,0, |
---|
140 | 0,0, 0,0, 1,4, 7,0, |
---|
141 | 7,0, 7,0, 7,0, 7,0, |
---|
142 | 7,0, 7,0, 7,0, 7,8, |
---|
143 | 7,0, 7,0, 7,0, 7,0, |
---|
144 | 7,0, 7,0, 7,0, 7,0, |
---|
145 | 7,0, 7,0, 7,0, 7,0, |
---|
146 | 7,0, 7,0, 7,0, 7,0, |
---|
147 | 7,0, 7,0, 7,0, 7,0, |
---|
148 | 7,0, 7,0, 0,0, 0,0, |
---|
149 | 0,0, 0,0, 0,0, 0,0, |
---|
150 | 0,0, 0,0, 0,0, 0,0, |
---|
151 | 0,0, 0,0, 0,0, 7,0, |
---|
152 | 0,0, 0,0, 0,0, 0,0, |
---|
153 | 0,0, 0,0, 0,0, 0,0, |
---|
154 | 0,0, 0,0, 0,0, 0,0, |
---|
155 | 0,0, 0,0, 0,0, 0,0, |
---|
156 | 0,0, 0,0, 0,0, 0,0, |
---|
157 | 0,0, 0,0, 0,0, 0,0, |
---|
158 | 1,5, 8,5, 0,0, 0,0, |
---|
159 | 0,0, 0,0, 0,0, 0,0, |
---|
160 | 0,0, 0,0, 0,0, 0,0, |
---|
161 | 0,0, 0,0, 0,0, 0,0, |
---|
162 | 0,0, 0,0, 0,0, 0,0, |
---|
163 | 0,0, 0,0, 0,0, 0,0, |
---|
164 | 0,0, 0,0, 0,0, 0,0, |
---|
165 | 0,0, 0,0, 0,0, 0,0, |
---|
166 | 0,0, 0,0, 0,0, 0,0, |
---|
167 | 0,0, 0,0, 0,0, 0,0, |
---|
168 | 0,0, 0,0, 0,0, 0,0, |
---|
169 | 0,0, 0,0, 0,0, 0,0, |
---|
170 | 0,0, 0,0, 0,0, 0,0, |
---|
171 | 0,0, 0,0, 0,0, 0,0, |
---|
172 | 0,0, 7,0, 0,0, 0,0, |
---|
173 | 0,0}; |
---|
174 | struct yysvf yysvec[] ={ |
---|
175 | 0, 0, 0, |
---|
176 | yycrank+1, 0, 0, |
---|
177 | yycrank+0, yysvec+1, 0, |
---|
178 | yycrank+0, 0, yyvstop+1, |
---|
179 | yycrank+1, 0, 0, |
---|
180 | yycrank+1, 0, 0, |
---|
181 | yycrank+0, 0, yyvstop+3, |
---|
182 | yycrank+-26, 0, 0, |
---|
183 | yycrank+2, 0, yyvstop+5, |
---|
184 | 0, 0, 0}; |
---|
185 | struct yywork *yytop = yycrank+153; |
---|
186 | struct yysvf *yybgin = yysvec+1; |
---|
187 | char yymatch[] ={ |
---|
188 | 00 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , |
---|
189 | 01 ,011 ,01 ,01 ,01 ,01 ,01 ,01 , |
---|
190 | 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , |
---|
191 | 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , |
---|
192 | 011 ,011 ,011 ,011 ,011 ,011 ,011 ,011 , |
---|
193 | 011 ,011 ,011 ,011 ,011 ,01 ,011 ,011 , |
---|
194 | 011 ,011 ,011 ,011 ,011 ,011 ,011 ,011 , |
---|
195 | 011 ,011 ,011 ,011 ,011 ,011 ,011 ,011 , |
---|
196 | 011 ,011 ,011 ,011 ,011 ,011 ,011 ,011 , |
---|
197 | 011 ,011 ,011 ,011 ,011 ,011 ,011 ,011 , |
---|
198 | 011 ,011 ,011 ,011 ,011 ,011 ,011 ,011 , |
---|
199 | 011 ,011 ,011 ,011 ,011 ,011 ,011 ,011 , |
---|
200 | 011 ,011 ,011 ,011 ,011 ,011 ,011 ,011 , |
---|
201 | 011 ,011 ,011 ,011 ,011 ,011 ,011 ,011 , |
---|
202 | 011 ,011 ,011 ,011 ,011 ,011 ,011 ,011 , |
---|
203 | 011 ,011 ,011 ,011 ,011 ,011 ,011 ,01 , |
---|
204 | 0}; |
---|
205 | char yyextra[] ={ |
---|
206 | 0,0,0,0,0,0,0,0, |
---|
207 | 0}; |
---|
208 | /* ncform 4.1 83/08/11 */ |
---|
209 | |
---|
210 | int yylineno =1; |
---|
211 | # define YYU(x) x |
---|
212 | # define NLSTATE yyprevious=YYNEWLINE |
---|
213 | char yytext[YYLMAX]; |
---|
214 | struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp; |
---|
215 | char yysbuf[YYLMAX]; |
---|
216 | char *yysptr = yysbuf; |
---|
217 | int *yyfnd; |
---|
218 | extern struct yysvf *yyestate; |
---|
219 | int yyprevious = YYNEWLINE; |
---|
220 | yylook(){ |
---|
221 | register struct yysvf *yystate, **lsp; |
---|
222 | register struct yywork *yyt; |
---|
223 | struct yysvf *yyz; |
---|
224 | int yych; |
---|
225 | struct yywork *yyr; |
---|
226 | # ifdef LEXDEBUG |
---|
227 | int debug; |
---|
228 | # endif |
---|
229 | char *yylastch; |
---|
230 | /* start off machines */ |
---|
231 | # ifdef LEXDEBUG |
---|
232 | debug = 0; |
---|
233 | # endif |
---|
234 | if (!yymorfg) |
---|
235 | yylastch = yytext; |
---|
236 | else { |
---|
237 | yymorfg=0; |
---|
238 | yylastch = yytext+yyleng; |
---|
239 | } |
---|
240 | for(;;){ |
---|
241 | lsp = yylstate; |
---|
242 | yyestate = yystate = yybgin; |
---|
243 | if (yyprevious==YYNEWLINE) yystate++; |
---|
244 | for (;;){ |
---|
245 | # ifdef LEXDEBUG |
---|
246 | if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1); |
---|
247 | # endif |
---|
248 | yyt = yystate->yystoff; |
---|
249 | if(yyt == yycrank){ /* may not be any transitions */ |
---|
250 | yyz = yystate->yyother; |
---|
251 | if(yyz == 0)break; |
---|
252 | if(yyz->yystoff == yycrank)break; |
---|
253 | } |
---|
254 | *yylastch++ = yych = input(); |
---|
255 | tryagain: |
---|
256 | # ifdef LEXDEBUG |
---|
257 | if(debug){ |
---|
258 | fprintf(yyout,"char "); |
---|
259 | allprint(yych); |
---|
260 | putchar('\n'); |
---|
261 | } |
---|
262 | # endif |
---|
263 | yyr = yyt; |
---|
264 | if ( (int)yyt > (int)yycrank){ |
---|
265 | yyt = yyr + yych; |
---|
266 | if (yyt <= yytop && yyt->verify+yysvec == yystate){ |
---|
267 | if(yyt->advance+yysvec == YYLERR) /* error transitions */ |
---|
268 | {unput(*--yylastch);break;} |
---|
269 | *lsp++ = yystate = yyt->advance+yysvec; |
---|
270 | goto contin; |
---|
271 | } |
---|
272 | } |
---|
273 | # ifdef YYOPTIM |
---|
274 | else if((int)yyt < (int)yycrank) { /* r < yycrank */ |
---|
275 | yyt = yyr = yycrank+(yycrank-yyt); |
---|
276 | # ifdef LEXDEBUG |
---|
277 | if(debug)fprintf(yyout,"compressed state\n"); |
---|
278 | # endif |
---|
279 | yyt = yyt + yych; |
---|
280 | if(yyt <= yytop && yyt->verify+yysvec == yystate){ |
---|
281 | if(yyt->advance+yysvec == YYLERR) /* error transitions */ |
---|
282 | {unput(*--yylastch);break;} |
---|
283 | *lsp++ = yystate = yyt->advance+yysvec; |
---|
284 | goto contin; |
---|
285 | } |
---|
286 | yyt = yyr + YYU(yymatch[yych]); |
---|
287 | # ifdef LEXDEBUG |
---|
288 | if(debug){ |
---|
289 | fprintf(yyout,"try fall back character "); |
---|
290 | allprint(YYU(yymatch[yych])); |
---|
291 | putchar('\n'); |
---|
292 | } |
---|
293 | # endif |
---|
294 | if(yyt <= yytop && yyt->verify+yysvec == yystate){ |
---|
295 | if(yyt->advance+yysvec == YYLERR) /* error transition */ |
---|
296 | {unput(*--yylastch);break;} |
---|
297 | *lsp++ = yystate = yyt->advance+yysvec; |
---|
298 | goto contin; |
---|
299 | } |
---|
300 | } |
---|
301 | if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){ |
---|
302 | # ifdef LEXDEBUG |
---|
303 | if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1); |
---|
304 | # endif |
---|
305 | goto tryagain; |
---|
306 | } |
---|
307 | # endif |
---|
308 | else |
---|
309 | {unput(*--yylastch);break;} |
---|
310 | contin: |
---|
311 | # ifdef LEXDEBUG |
---|
312 | if(debug){ |
---|
313 | fprintf(yyout,"state %d char ",yystate-yysvec-1); |
---|
314 | allprint(yych); |
---|
315 | putchar('\n'); |
---|
316 | } |
---|
317 | # endif |
---|
318 | ; |
---|
319 | } |
---|
320 | # ifdef LEXDEBUG |
---|
321 | if(debug){ |
---|
322 | fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1); |
---|
323 | allprint(yych); |
---|
324 | putchar('\n'); |
---|
325 | } |
---|
326 | # endif |
---|
327 | while (lsp-- > yylstate){ |
---|
328 | *yylastch-- = 0; |
---|
329 | if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){ |
---|
330 | yyolsp = lsp; |
---|
331 | if(yyextra[*yyfnd]){ /* must backup */ |
---|
332 | while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){ |
---|
333 | lsp--; |
---|
334 | unput(*yylastch--); |
---|
335 | } |
---|
336 | } |
---|
337 | yyprevious = YYU(*yylastch); |
---|
338 | yylsp = lsp; |
---|
339 | yyleng = yylastch-yytext+1; |
---|
340 | yytext[yyleng] = 0; |
---|
341 | # ifdef LEXDEBUG |
---|
342 | if(debug){ |
---|
343 | fprintf(yyout,"\nmatch "); |
---|
344 | sprint(yytext); |
---|
345 | fprintf(yyout," action %d\n",*yyfnd); |
---|
346 | } |
---|
347 | # endif |
---|
348 | return(*yyfnd++); |
---|
349 | } |
---|
350 | unput(*yylastch); |
---|
351 | } |
---|
352 | if (yytext[0] == 0 && feof(yyin) ) |
---|
353 | { |
---|
354 | yysptr=yysbuf; |
---|
355 | return(0); |
---|
356 | } |
---|
357 | yyprevious = yytext[0] = input(); |
---|
358 | if (yyprevious>0) |
---|
359 | output(yyprevious); |
---|
360 | yylastch=yytext; |
---|
361 | # ifdef LEXDEBUG |
---|
362 | if(debug)putchar('\n'); |
---|
363 | # endif |
---|
364 | } |
---|
365 | } |
---|
366 | yyback(p, m) |
---|
367 | int *p; |
---|
368 | { |
---|
369 | if (p==0) return(0); |
---|
370 | while (*p) |
---|
371 | { |
---|
372 | if (*p++ == m) |
---|
373 | return(1); |
---|
374 | } |
---|
375 | return(0); |
---|
376 | } |
---|
377 | /* the following are only used in the lex library */ |
---|
378 | yyinput(){ |
---|
379 | return(input()); |
---|
380 | } |
---|
381 | yyoutput(c) |
---|
382 | int c; { |
---|
383 | output(c); |
---|
384 | } |
---|
385 | yyunput(c) |
---|
386 | int c; { |
---|
387 | unput(c); |
---|
388 | } |
---|