source: trunk/athena/bin/lpr/filters/ln01filter.l @ 3408

Revision 3408, 1.5 KB checked in by epeisach, 34 years ago (diff)
Include sys/types.h under AUX
Line 
1/* Mode: -*- C -*- */
2%{
3#ifdef _AUX_SOURCE
4#include <sys/types.h>
5#endif
6#include <sys/file.h>
7#include <signal.h>
8extern int sighandler();
9char *reset="\033c";                    /* ris  */
10char *land_length="\033[2550t";
11char *landscape="\033[10m";
12char *port_length="\033[3300t";         /* form length = 11 inches */
13char *portrait="\033[11m";
14char *beginunderline = "\033[4m";
15char *endunderline = "\033[0m";
16char *mode;
17char *form_length;
18%}
19PRINTABLE    [0-9A-Za-z \t`\[\];'\\<,./-=~!@#$%^&*()_+{}:"|>?]
20%%
21\f                      {
22                                printf("\f%s%s%s",reset,mode,form_length);
23                                fflush(stdout);
24                        }
25(_\b{PRINTABLE})+       {
26                                register char *p = &yytext[0];
27                                printf(beginunderline);
28                                while(*p)
29                                {
30                                        if((*p != '_') && (*p != '\b'))
31                                        {
32                                                putchar(*p);
33                                        }
34                                        ++p;
35                                }
36                                printf(endunderline);
37                                fflush(stdout);
38                        }
39\031\1                  { /* ^Y^A */
40                                /*
41                                 * lpd needs to use a different filter to
42                                 * print data so stop what we are doing and
43                                 * wait for lpd to restart us.
44                                 */
45                                fflush(stdout);
46                                kill(getpid(), SIGSTOP);
47                                printf("%s%s%s",reset,mode,form_length);
48                                fflush(stdout);
49                        }
50
51%%
52
53yywrap()
54{
55        fflush(stdout);
56        flock(1, LOCK_UN);
57        return(1);
58}
59main(argc,argv)
60int argc;
61register char *argv[];
62{
63        register int i;
64        flock(1, LOCK_EX);
65        if(!strcmp(argv[0], "ln01l")) {
66                mode = landscape;
67                form_length = land_length;
68        }
69        else {
70                mode = portrait;
71                form_length = port_length;
72        }
73        setbuf(stdout, NULL);
74        printf("%s%s%s",reset,mode,form_length);
75        fflush(stdout);
76        while(1) {
77                        if(yylex() <= 0) break;
78        }
79}
80
81/* Local Modes: */
82/* Mode:C */
83/* End: */
Note: See TracBrowser for help on using the repository browser.