12 double aspectratio = 1.0;
15 double magnification = 1.0;
16 int linesperpage = 66;
20 char *passthrough = 0;
22 Biobuf binp, *bstdout, bstderr;
23 Biobufhdr *Bstdin, *Bstdout, *Bstderr;
26 char tmpfilename[MAXTOKENSIZE];
30 struct charent **build_char_list = 0;
31 int build_char_cnt = 0;
36 char charlibname[MAXTOKENSIZE];
38 Bprint(Bstdout, "%s", CONFORMING);
39 Bprint(Bstdout, "%s %s\n", VERSION, PROGRAMVERSION);
40 Bprint(Bstdout, "%s %s\n", CREATOR, PROGRAMNAME);
41 Bprint(Bstdout, "%s %s\n", DOCUMENTFONTS, ATEND);
42 Bprint(Bstdout, "%s %s\n", PAGES, ATEND);
43 Bprint(Bstdout, "%s", ENDCOMMENTS);
46 Bprint(Bstderr, "can't read %s\n", DPOST);
47 exits("dpost prologue");
52 Bprint(Bstderr, "can't read %s\n", DRAW);
53 exits("draw prologue");
60 Bprint(Bstdout, "%s", ENDPROLOG);
61 Bprint(Bstdout, "%s", BEGINSETUP);
62 Bprint(Bstdout, "mark\n");
63 if (formsperpage > 1) {
64 Bprint(Bstdout, "%s %d\n", FORMSPERPAGE, formsperpage);
65 Bprint(Bstdout, "/formsperpage %d def\n", formsperpage);
67 if (aspectratio != 1) Bprint(Bstdout, "/aspectratio %g def\n", aspectratio);
68 if (copies != 1) Bprint(Bstdout, "/#copies %d store\n", copies);
69 if (landscape) Bprint(Bstdout, "/landscape true def\n");
70 if (magnification != 1) Bprint(Bstdout, "/magnification %g def\n", magnification);
71 if (pointsize != 10) Bprint(Bstdout, "/pointsize %d def\n", pointsize);
72 if (xoffset != .25) Bprint(Bstdout, "/xoffset %g def\n", xoffset);
73 if (yoffset != .25) Bprint(Bstdout, "/yoffset %g def\n", yoffset);
74 cat(ENCODINGDIR"/Latin1.enc");
75 if (passthrough != 0) Bprint(Bstdout, "%s\n", passthrough);
77 Bprint(Bstdout, "setup\n");
78 if (formsperpage > 1) {
80 Bprint(Bstdout, "%d setupforms \n", formsperpage);
82 /* output Build character info from charlib if necessary. */
84 for (i=0; i<build_char_cnt; i++) {
85 sprint(charlibname, "%s/%s", CHARLIB, build_char_list[i]->name);
87 Bprint(Bstderr, "cannot open %s\n", charlibname);
90 Bprint(Bstdout, "%s", ENDSETUP);
99 main(int argc, char *argv[]) {
105 programname = argv[0];
106 if (Binit(&bstderr, 2, OWRITE) == Beof) {
109 Bstderr = &bstderr.Biobufhdr;
112 if ((bstdout=Bopen(tmpfilename, OWRITE)) == 0) {
113 Bprint(Bstderr, "cannot open temporary file %s\n", tmpfilename);
117 Bstdout = &bstdout->Biobufhdr;
120 case 'a': /* aspect ratio */
121 aspectratio = atof(ARGF());
123 case 'c': /* copies */
124 copies = atoi(ARGF());
129 case 'm': /* magnification */
130 magnification = atof(ARGF());
132 case 'n': /* forms per page */
133 formsperpage = atoi(ARGF());
135 case 'o': /* output page list */
138 case 'p': /* landscape or portrait mode */
139 if ( ARGF()[0] == 'l' )
144 case 'x': /* shift things horizontally */
145 xoffset = atof(ARGF());
147 case 'y': /* and vertically on the page */
148 yoffset = atof(ARGF());
150 case 'P': /* PostScript pass through */
153 passthrough = malloc(i);
154 if (passthrough == 0) {
155 Bprint(Bstderr, "cannot allocate memory for argument string\n");
158 strncpy(passthrough, t, i);
160 default: /* don't know what to do for ch */
161 Bprint(Bstderr, "unknown option %C\n", ARGC());
166 if ((binp = (Biobuf *)malloc(sizeof(Biobuf))) == nil) {
167 Bprint(Bstderr, "malloc failed.\n");
170 if (Binit(binp, 0, OREAD) == Beof) {
171 Bprint(Bstderr, "Binit of <stdin> failed.\n");
174 Binp = &(binp->Biobufhdr);
175 if (debug) Bprint(Bstderr, "using standard input\n");
179 for (i=0; i<argc; i++) {
180 if ((binp=Bopen(argv[i], OREAD)) == 0) {
181 Bprint(Bstderr, "cannot open file %s\n", argv[i]);
184 Binp = &(binp->Biobufhdr);
185 inputfilename = argv[i];
191 if ((ifd=open(tmpfilename, OREAD)) < 0) {
192 Bprint(Bstderr, "open of %s failed.\n", tmpfilename);
196 bstdout = galloc(0, sizeof(Biobuf), "bstdout");
197 if (Binit(bstdout, 1, OWRITE) == Beof) {
198 Bprint(Bstderr, "Binit of <stdout> failed.\n");
201 Bstdout = &(bstdout->Biobufhdr);
205 while ((i=read(ifd, copybuf, BUFSIZ)) > 0) {
206 if (write(1, copybuf, i) != i) {
207 Bprint(Bstderr, "write error on copying from temp file.\n");
212 if (debug) Bprint(Bstderr, "copied %d bytes to final output i=%d\n", tot, i);
214 Bprint(Bstderr, "read error on copying from temp file.\n");