This is dperfect.c in view mode; [Download] [Up]
#include "incl.h"
extern FILE *fpo, *fpi;
extern char *word1, *word2, buffer[], newbuf[];
extern int inlinecount, outlinecount, EndProlog;
extern int Width, Height, Vspace;
extern double width, height, top_space, bottom_space;
extern double llx, lly, urx, ury, mm2pt;
extern double xfac, yfac, scx, scy;
dperfect ()
{
double dpoffset;
/*
** Replace first line
*/
fgets (buffer, MAXBUF, fpi);
inlinecount++;
fprintf (fpo, "%s", FIRSTLINE);
outlinecount++;
scx = 1.0;
scy = 1.0;
/*
** Offset Boundingbox values.
** Picture coordinates are relative to origin of the display, which
** has an offset of DP_OFFSET mm, in x and y-direction, from the real origin.
*/
dpoffset = DP_OFFSET * mm2pt;
llx -= dpoffset;
lly -= dpoffset;
urx -= dpoffset;
ury -= dpoffset;
/*
** Adjust BoundingBox and scale values depending on width (-w)
** height (-h) and space (-s) options.
** Write BoundingBox statement to the output file.
*/
if (adj_bbox (urx - llx) == EXIT_FAILURE) return (EXIT_FAILURE);
fprintf (fpo, "%s %d %d %d %d\n", PPBOUNDINGBOXC,
(int)llx, (int)lly, (int)urx, (int)ury);
outlinecount++;
/*
** Insert next statement for use with program ``dvialw''
*/
fprintf (fpo, "%s", DVIALW_BEGIN);
outlinecount++;
for (fgets (buffer, MAXBUF, fpi); (!(feof (fpi)));
fgets (buffer, MAXBUF, fpi)) {
inlinecount++;
if (buffer[0] == '%' && buffer[1] == '%') {
strcpy (newbuf, buffer);
word1 = strtok (newbuf, " :\n");
word2 = strtok ('\0', " \n\t");
if (strcmp (word1, PPBOUNDINGBOX) == 0) {
/*
** BoundingBox statement has already been written to the output
** file with values read from the command line.
*/
sprintf (buffer, "");
}
else if (strcmp (word1, PPENDPROLOG) == 0) {
fprintf (fpo, "%s\n", PPENDPROLOG);
outlinecount++;
sprintf (buffer, "%.3lf %.3lf %s\n", scx, scy, SCALE);
EndProlog = TRUE;
}
}
fprintf (fpo, "%s", buffer);
outlinecount++;
}
if (!EndProlog) {
fprintf (stderr, "\n*** No EndProlog statement found.\n\n");
return (EXIT_FAILURE);
}
/*
** Insert next statement for use with program ``dvialw''
*/
fprintf (fpo, "%s", DVIALW_END);
outlinecount++;
fprintf (stderr, "\n%s\n%s\n%s\n%s\n\n",
" ********* WARNING ********** ",
"When using program `dvialw' the `%end(plot)'",
"statement must be >>before<< a possible",
"`showpage' statement.");
return (EXIT_SUCCESS);
}
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.