1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
#ifndef lint
static char *rcs = "$Header: if.c,v 1.1 88/01/15 13:04:16 simpson Rel $";
#endif
/*
$Log: if.c,v $
* Revision 1.1 88/01/15 13:04:16 simpson
* initial release
*
* Revision 0.1 87/12/11 18:30:58 simpson
* beta test
*
*/
/* "if" filter
* This doesn't filter the input at all if the -c option is given. If the
* -c option is not given, then it converts \n into \r\n if it is not in
* QUIC mode. It performs accounting if an accounting file is given. It
* makes educated guesses as to the number of pages printed. Here is the
* page count algorithm:
* if -c option given then {
* if input string equals "^,"
* increment page count
* else if input character is formfeed and not free format
* increment page count
* } else
* if not in QUIC mode {
* if input character is \n and line count is greater than the
* length of the page
* increment page count
* } else
* if input string equals "^,"
* increment page count
* else if input character is formfeed and not free format
* increment page count
*/
#include <stdio.h>
#include <signal.h>
#include <local/qms.h>
#include <local/standard.h>
#include <local/profile.h>
#include "fontnode.h"
char *WhoAmI; /* argv[0] */
char *Model;
Boolean EnteredQuic = FALSE;
Boolean QuicMode = FALSE;
Boolean FreeForm = FALSE;
Boolean Raw = FALSE;
int LineNum = 1;
int CharCount = 1;
int Length;
int Width;
int Indent = 0;
int PortraitFont = 1204;
int LandscapeFont = 1217;
struct sigvec SigStruct;
extern char *User;
extern char *Host;
extern Boolean Accounting;
extern int NumPages;
extern FILE *Accting;
main(argc, argv)
int argc;
char *argv[];
{
extern int optind;
extern char *optarg;
PROFILE_VALUE *v, *getbindingvalue();
int c, callcleanup();
void sanestate();
void cleanup();
WhoAmI = argv[0];
while ((c = getopt(argc, argv, "cw:l:i:n:h:")) != EOF)
switch (c) {
case 'c':
Raw = TRUE;
break;
case 'l':
Length = atoi(optarg);
break;
case 'w':
Width = atoi(optarg);
break;
case 'i':
Indent = atoi(optarg);
break;
case 'n':
User = optarg;
break;
case 'h':
Host = optarg;
break;
case '?': /* This should not happen */
exit(2);
}
if (optind < argc) {
Accounting = TRUE;
if (!(Accting = fopen(argv[optind], "a"))) {
fprintf(stderr, "%s: cannot open accounting file %s\n", WhoAmI,
argv[optind]);
Accounting = FALSE;
}
}
if (!(v = getbindingvalue("model")) || v->class != PROFILE_STRING &&
v->class != PROFILE_OTHER) {
fprintf(stderr,
"%s: model binding missing or invalid in configuration file\n",
WhoAmI);
exit(2);
}
Model = v->value.s;
if (Width > 80) {
if ((v = getbindingvalue("landscapefont")) && v->class ==
PROFILE_INTEGER)
LandscapeFont = v->value.i;
} else
if ((v = getbindingvalue("portraitfont")) && v->class ==
PROFILE_INTEGER)
PortraitFont = v->value.i;
SigStruct.sv_handler = callcleanup;
SigStruct.sv_mask = 0;
SigStruct.sv_onstack = 0;
(void)sigvec(SIGINT, &SigStruct, (struct sigvec *)NULL);
fputs(QUICON, stdout);
fputs(Width > 80 ? LANDSCAPE : PORTRAIT, stdout);
printf("%s00000", SYNTAX);
if (Raw) {
printf("%s00000%05d", INITMARGVERT, Width > 80 ? (int)(8.5 * 1000) :
11 * 1000);
printf("%s00000%05d", INITMARGHORZ, Width > 80 ? 11 * 1000 : (int)(8.5
* 1000));
} else {
/* Different print engines can print in different parts of the page.
* For example, the Canon engine (QMS 800) cannot print in the top
* 1/4 inch of the page. The QMS 1500 uses a Ricoh engine. The
* 1200 and 2400 use a Xerox engine. We have to account for each
* by having different spacing.
*/
if (EQ(Model, "QMS800"))
if (Width > 80) {
printf("%s%05d%05d", INITMARGVERT, (int)(.4 * 1000),
(int)(8.5 * 1000));
printf("%s%05d%05d", INITMARGHORZ, (int)(.325 * 1000),
11 * 1000);
printf("%s%04d", LINESPACING, (int)(8.2 * 100));
} else {
printf("%s%05d%05d", INITMARGVERT, (int)(.3 * 1000),
11 * 1000);
printf("%s%05d%05d", INITMARGHORZ, (int)(.325 * 1000),
(int)(8.5 * 1000));
printf("%s%04d", LINESPACING, (int)(6.1 * 100));
}
else if (EQ(Model, "QMS1500"))
if (Width > 80) {
printf("%s%05d%05d", INITMARGVERT, (int)(.1 * 1000),
(int)(8.2 * 1000));
printf("%s%05d%05d", INITMARGHORZ, (int)(.325 * 1000),
11 * 1000);
printf("%s%04d", LINESPACING, (int)(8.2 * 100));
} else {
printf("%s%05d%05d", INITMARGVERT, (int)(.1 * 1000),
(int)(10.85 * 1000));
printf("%s%05d%05d", INITMARGHORZ, (int)(.325 * 1000),
(int)(8.5 * 1000));
printf("%s%04d", LINESPACING, (int)(6.1 * 100));
}
else /* Models 1200 and 2400 */
if (Width > 80) {
printf("%s%05d%05d", INITMARGVERT, (int)(.32 * 1000),
(int)(8.5 * 1000));
printf("%s%05d%05d", INITMARGHORZ, (int)(.325 * 1000),
11 * 1000);
printf("%s%04d", LINESPACING, (int)(7.95 * 100));
} else {
printf("%s%05d%05d", INITMARGVERT, (int)(.22 * 1000),
11 * 1000);
printf("%s%05d%05d", INITMARGHORZ, (int)(.325 * 1000),
(int)(8.5 * 1000));
printf("%s%04d", LINESPACING, (int)(6.02 * 100));
}
if (Width > 80) {
if ((v = getbindingvalue("landscapepitch")) && (v->class ==
PROFILE_INTEGER || v->class == PROFILE_FLOAT))
if (v->class == PROFILE_INTEGER)
printf("%s%04d", CHARSPACING, v->value.i * 100);
else
printf("%s%04d", CHARSPACING, (int)(v->value.f * 100));
} else
if ((v = getbindingvalue("portraitpitch")) && (v->class ==
PROFILE_INTEGER || v->class == PROFILE_FLOAT))
if (v->class == PROFILE_INTEGER)
printf("%s%04d", CHARSPACING, v->value.i * 100);
else
printf("%s%04d", CHARSPACING, (int)(v->value.f * 100));
}
printf("%s%d%s", DEFFONT, Width > 80 ? LandscapeFont : PortraitFont,
ENDCMD);
fputs(FREEOFF, stdout);
fputs(QUICOFF, stdout);
while (yylex())
;
(void)sigblock(SIGINT);
if (Raw || EnteredQuic || LineNum != 1 || CharCount != 1) {
(void)putchar('\f');
NumPages++;
}
fputs(QUICON, stdout);
cleanup((struct FontNode *)NULL, SUCCEED);
}
int callcleanup()
{
void cleanup();
fputs(QUICON, stdout);
fputs(FORMFEED, stdout), NumPages++;
cleanup((struct FontNode *)NULL, SUCCEED);
}
#include "quic.c"
|