static void
copy(Biobufhdr *fin, Biobufhdr *fout, Section *s) {
int cond;
if (s->end <= s->start)
return;
Bseek(fin, s->start, 0);
while (Bseek(fin, 0L, 1) < s->end && (buf=Brdline(fin, '\n')) != NULL){
/*
* We have to be careful here, because % can legitimately appear
* in Ascii85 encodings, and must not be elided.
* The goal here is to make any DSC comments impotent without
* actually changing the behavior of the Postscript.
* Since stripping ``comments'' breaks Ascii85, we can instead just
* indent comments a space, which turns DSC comments into non-DSC comments
* and has no effect on binary encodings, which are whitespace-blind.
*/
if(buf[0] == '%')
Bputc(fout, ' ');
Bwrite(fout, buf, Blinelen(fin));
}
}
/*
*
* Reads a PostScript file (*fin), and uses structuring comments to locate the
* prologue, trailer, global definitions, and the requested page. After the whole
* file is scanned, the special ps_include PostScript definitions are copied to
* *fout, followed by the prologue, global definitions, the requested page, and
* the trailer. Before returning the initial environment (saved in PS_head) is
* restored.
*
* By default we assume the picture is 8.5 by 11 inches, but the BoundingBox
* comment, if found, takes precedence.
*
*/
/* *fin, *fout; /* input and output files */
/* page_no; /* physical page number from *fin */
/* whiteout; /* erase picture area */
/* outline; /* draw a box around it and */
/* scaleboth; /* scale both dimensions - if not zero */
/* cx, cy; /* center of the picture and */
/* sx, sy; /* its size - in current coordinates */
/* ax, ay; /* left-right, up-down adjustment */
/* rot; /* rotation - in clockwise degrees */
void
ps_include(Biobufhdr *fin, Biobufhdr *fout, int page_no, int whiteout,
int outline, int scaleboth, double cx, double cy, double sx, double sy,
double ax, double ay, double rot) {
char **strp;
int foundpage = 0; /* found the page when non zero */
int foundpbox = 0; /* found the page bounding box */
int nglobal = 0; /* number of global defs so far */
int maxglobal = 0; /* and the number we've got room for */
Section prolog, page, trailer; /* prologue, page, and trailer offsets */
Section *global; /* offsets for all global definitions */
double llx, lly; /* lower left and */
double urx, ury; /* upper right corners - default coords */
double w = whiteout != 0; /* mostly for the var() macro */
double o = outline != 0;
double s = scaleboth != 0;
int i; /* loop index */