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

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