This is gem.c in view mode; [Download] [Up]
#include "incl.h"
extern FILE *fpo, *fpi;
extern char *word1, *word2;
extern char buffer[], newbuf[];
extern int inlinecount, outlinecount;
extern int pagesOK, EndComments;
extern int userdictFOUND, initclipFOUND, landscapeFOUND;
extern double llx, lly, urx, ury, mm2pt, scx, scy;
gem ()
{
char str1[MAXWORD+1];
double gemoffset;
/*
** Replace first line
*/
fgets (buffer, MAXBUF, fpi);
inlinecount++;
fprintf (fpo, "%s", FIRSTLINE);
outlinecount++;
scx = 1.0;
scy = 1.0;
for (fgets (buffer, MAXBUF, fpi); (!(feof (fpi)));
fgets (buffer, MAXBUF, fpi)) {
inlinecount++;
sscanf (buffer, "%s", str1);
if (buffer[0] == '%' && buffer[1] == '%') {
strcpy (newbuf, buffer);
word1 = strtok (newbuf, " :\n");
word2 = strtok ('\0', " \n\t");
if (strcmp (word1, PPBOUNDINGBOX) == 0) {
gemoffset = mm2pt * 3.0;
llx += gemoffset;
lly += gemoffset;
urx += gemoffset;
ury += gemoffset;
/*
** Adjust BoundingBox and scale values depending on width (-w)
** height (-h) and space (-s) options.
*/
if (adj_bbox (urx - llx) == EXIT_FAILURE) return (EXIT_FAILURE);
sprintf (buffer, "%s %d %d %d %d\n",
PPBOUNDINGBOXC,
(int)llx, (int)lly, (int)urx, (int)ury);
}
else if (strcmp (word1, PPPAGES) == 0) {
if (strcmp (word2, ATEND) == 0)
sprintf (buffer, "%s: 0 1\n", PPPAGES);
else sprintf (buffer, "\n");
pagesOK = TRUE;
}
else if (strcmp (word1, PPENDCOMMENTS) == 0) {
fprintf (fpo, "%s", buffer);
EndComments = TRUE;
/*
** Insert next statement for use with program ``dvialw''
*/
fprintf (fpo, "%s", DVIALW_BEGIN);
outlinecount += 2;
sprintf (buffer, "");
}
else if (strcmp (word1, PPBEGINEXITSERVER) == 0) {
do {
fgets (buffer, MAXBUF, fpi);
inlinecount++;
} while (strcmp (buffer, PPEOF) != 0);
fgets (buffer, MAXBUF, fpi); /* get line with ^D */
inlinecount++;
sprintf (buffer, "\n");
}
else if (strcmp (word1, PPENDPROLOG) == 0) {
fprintf (fpo, "%s", buffer);
outlinecount++;
sprintf (buffer, "%.3lf %.3lf %s\n", scx, scy, SCALE);
}
}
else if (!EndComments) {
fprintf (fpo, "%s\n", PPENDCOMMENTS);
EndComments = TRUE;
/*
** Insert next statement for use with program ``dvialw''
*/
fprintf (fpo, "%%begin(plot)\n");
outlinecount += 2;
sprintf (buffer, "");
}
if (!userdictFOUND && (strcmp (str1, BEGINUSERDICT)) == 0)
userdict (buffer);
else if (!initclipFOUND && (strcmp (str1, INITCLIP)) == 0) {
fprintf (fpo, "%s %s", PPP, buffer);
outlinecount++;
initclipFOUND = TRUE;
}
else if (!landscapeFOUND && (strcmp (str1, LANDSCAPE)) == 0) {
fprintf (fpo, "%s %s", PPP, buffer);
outlinecount++;
fprintf (fpo, " pop %s this line added\n", PPP);
outlinecount++;
landscapeFOUND = TRUE;
}
else if ((strcmp (str1, SHOWPAGE)) == 0) {
/*
** Insert next statement for use with program ``dvialw''
*/
fprintf (fpo, "%s", DVIALW_END);
fprintf (fpo, "%s", buffer);
outlinecount += 2;
}
else {
fprintf (fpo, "%s", buffer);
outlinecount++;
}
}
return (EXIT_SUCCESS);
}
userdict ()
{
char str[MAXBUF+1];
int k, n;
fprintf (fpo, "%s %s", PPP, buffer);
outlinecount++;
for (fgets (buffer, MAXBUF, fpi);
(!(k = feof (fpi)));
fgets (buffer, MAXBUF, fpi)) {
fprintf (fpo, "%s %s", PPP, buffer);
outlinecount++;
n = sscanf (buffer, "%*s%*s%*s%*s%s", str);
if (n != EOF && (strcmp (str, ENDUSERDICT)) == 0) {
userdictFOUND = TRUE;
fprintf (fpo, "gemdict begin geminit %s%s\n",
PPP, " this line added");
outlinecount++;
break;
}
}
if (k) {
fprintf (stderr, "\n*** No statement found with %s\n\n", ENDUSERDICT);
return (EXIT_FAILURE);
}
return (EXIT_SUCCESS);
}
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.