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> |
---|
5 | extern int sighandler(); |
---|
6 | char *reset="\033c"; /* ris */ |
---|
7 | char *land_length="\033[2550t"; |
---|
8 | char *landscape="\033[10m"; |
---|
9 | char *port_length="\033[3300t"; /* form length = 11 inches */ |
---|
10 | char *portrait="\033[11m"; |
---|
11 | char *beginunderline = "\033[4m"; |
---|
12 | char *endunderline = "\033[0m"; |
---|
13 | char *mode; |
---|
14 | char *form_length; |
---|
15 | %} |
---|
16 | PRINTABLE [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 | |
---|
50 | yywrap() |
---|
51 | { |
---|
52 | fflush(stdout); |
---|
53 | flock(1, LOCK_UN); |
---|
54 | return(1); |
---|
55 | } |
---|
56 | main(argc,argv) |
---|
57 | int argc; |
---|
58 | register 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.