15 static int formsperpage
= 1;
16 static double aspectratio
= 1.0;
17 static int copies
= 1;
18 static int landscape
= 0;
19 static double magnification
= 1.0;
20 static int pointsize
= 10;
21 static char *passthrough
= 0;
29 static char tmpfilename
[MAXTOKENSIZE
];
30 static char copybuf
[BUFSIZ
];
32 static struct charent
*build_char_list
[MAXBCHARS
];
33 static int build_char_cnt
= 0;
36 * stash charent pointer in a list so that we can
37 * print these character definitions in the prologue.
39 void build_char(struct charent
*cp
)
42 for (i
= 0; i
< build_char_cnt
; i
++)
43 if (cp
== build_char_list
[i
])
45 if (i
== build_char_cnt
)
46 build_char_list
[build_char_cnt
++] = cp
;
52 char charlibname
[MAXTOKENSIZE
];
54 fprintf(fout
, "%s", CONFORMING
);
55 fprintf(fout
, "%s %s\n", VERSION
, PROGVER
);
56 fprintf(fout
, "%s %s\n", CREATOR
, PROGNAME
);
57 fprintf(fout
, "%s %s\n", DOCUMENTFONTS
, ATEND
);
58 fprintf(fout
, "%s %s\n", PAGES
, ATEND
);
59 fprintf(fout
, "%s", ENDCOMMENTS
);
62 fprintf(ferr
, "can't read %s\n", DPOST
);
68 fprintf(ferr
, "can't read %s\n", DRAW
);
75 fprintf(fout
, "%s", ENDPROLOG
);
76 fprintf(fout
, "%s", BEGINSETUP
);
77 fprintf(fout
, "mark\n");
78 if (formsperpage
> 1) {
79 fprintf(fout
, "%s %d\n", FORMSPERPAGE
, formsperpage
);
80 fprintf(fout
, "/formsperpage %d def\n", formsperpage
);
83 fprintf(fout
, "/aspectratio %g def\n", aspectratio
);
85 fprintf(fout
, "/#copies %d store\n", copies
);
87 fprintf(fout
, "/landscape true def\n");
88 if (magnification
!= 1)
89 fprintf(fout
, "/magnification %g def\n", magnification
);
91 fprintf(fout
, "/pointsize %d def\n", pointsize
);
93 fprintf(fout
, "/xoffset %g def\n", xoffset
);
95 fprintf(fout
, "/yoffset %g def\n", yoffset
);
97 fprintf(fout
, "%s\n", passthrough
);
99 fprintf(fout
, "setup\n");
100 if (formsperpage
> 1) {
102 fprintf(fout
, "%d setupforms \n", formsperpage
);
104 /* output Build character info from charlib if necessary. */
105 for (i
= 0; i
< build_char_cnt
; i
++) {
106 sprintf(charlibname
, "%s/dev%s/charlib/%s",
107 FONTDIR
, devname
, build_char_list
[i
]->name
);
108 if (cat(charlibname
))
109 fprintf(fout
, "cannot open %s\n", charlibname
);
112 fprintf(fout
, "%s", ENDSETUP
);
120 int main(int argc
, char *argv
[])
126 programname
= argv
[0];
129 if (!(fout
= fopen(tmpfilename
, "w"))) {
130 fprintf(ferr
, "cannot open temporary file %s\n", tmpfilename
);
136 while (i
< argc
&& argv
[i
][0] == '-') {
137 switch (argv
[i
][1]) {
138 case 'a': /* aspect ratio */
139 aspectratio
= atof(argv
[++i
]);
141 case 'c': /* copies */
142 copies
= atoi(argv
[++i
]);
147 case 'm': /* magnification */
148 magnification
= atof(argv
[++i
]);
150 case 'n': /* forms per page */
151 formsperpage
= atoi(argv
[++i
]);
153 case 'o': /* output page list */
156 case 'p': /* landscape or portrait mode */
157 if (argv
[++i
][0] == 'l')
162 case 'x': /* shift things horizontally */
163 xoffset
= atof(argv
[++i
]);
165 case 'y': /* and vertically on the page */
166 yoffset
= atof(argv
[++i
]);
168 case 'P': /* PostScript pass through */
169 passthrough
= argv
[++i
];
171 default: /* don't know what to do for ch */
172 fprintf(ferr
, "unknown option %s\n", argv
[i
]);
179 fprintf(ferr
, "using standard input\n");
183 for (; i
< argc
; i
++) {
184 int fd
= open(argv
[i
], O_RDONLY
);
186 fprintf(ferr
, "cannot open file %s\n", argv
[i
]);
196 if ((ifd
= open(tmpfilename
, O_RDONLY
)) < 0) {
197 fprintf(ferr
, "open of %s failed.\n", tmpfilename
);
206 while ((i
= read(ifd
, copybuf
, BUFSIZ
)) > 0) {
207 if (write(1, copybuf
, i
) != i
) {
208 fprintf(ferr
, "write error on copying from temp file.\n");
214 fprintf(ferr
, "copied %d bytes to final output i=%d\n", tot
, i
);
216 fprintf(ferr
, "read error on copying from temp file.\n");