This is pspice.c in view mode; [Download] [Up]
#include "incl.h" extern FILE *fpo, *fpi; extern char buffer[]; extern int inlinecount, outlinecount; extern int DateTempLine; extern double scx, scy, mm2pt, defaultwidth; extern double llx, lly, urx, ury; pspice () { char str[MAXWORD+1]; int translaterotateflag, datetemplinesflag; translaterotateflag = datetemplinesflag = FALSE; /* ** Default BoundingBox and scale values for default width. ** ** In the PS file from Pspice there is no BoundingBox statement. ** The boundingbox dimensions always are that of an A4 page in ** landscape position. ** The picture is transformed to default dimensions in portrait ** position by commenting out the 'rotate' and 'translate' statements ** in the Pspice PS file and inserting a scale statement. */ llx = PSPICE_BBOX_LLX * mm2pt; lly = PSPICE_BBOX_LLY * mm2pt; urx = PSPICE_BBOX_URX * mm2pt; ury = PSPICE_BBOX_URY * mm2pt; scx = PSPICE_SCX; scy = PSPICE_SCY; /* ** Adjust BoundingBox and scale values depending on width (-w) ** height (-h) and space (-s) options. */ if (adj_bbox (defaultwidth) == EXIT_FAILURE) return (EXIT_FAILURE); /* ** Replace first line */ fgets (buffer, MAXBUF, fpi); inlinecount++; fprintf (fpo, "%s", FIRSTLINE); fprintf (fpo, "%s %d %d %d %d\n", PPBOUNDINGBOXC, (int)llx, (int)lly, (int)urx, (int)ury); fprintf (fpo, "%s: 0 1\n", PPPAGES); fprintf (fpo, "%s\n", PPENDCOMMENTS); /* ** Insert next statement for use with program ``dvialw'' */ fprintf (fpo, "%s\n", "%begin(plot)"); outlinecount += 5; for (fgets (buffer, MAXBUF, fpi); (!(feof (fpi))); fgets (buffer, MAXBUF, fpi)) { inlinecount++; sscanf (buffer, "%s", str); if ((strcmp (str, "612")) == 0) { sscanf (buffer, "%*s%s", str); if ((strcmp (str, "0")) == 0) { sscanf (buffer, "%*s%*s%s", str); if ((strcmp (str, TRANSLATE)) == 0) { fprintf (fpo, "%s%s", PPP, buffer); fgets (buffer, MAXBUF, fpi); inlinecount++; fprintf (fpo, "%s%s", PPP, buffer); outlinecount += 2; translaterotateflag = TRUE; fprintf (fpo, "%.3lf %.3lf %s\n", scx, scy, SCALE); outlinecount++; break; } } } if (!translaterotateflag) { fprintf (fpo, "%s", buffer); outlinecount++; } } for (fgets (buffer, MAXBUF, fpi); (!(feof (fpi))); fgets (buffer, MAXBUF, fpi)) { inlinecount++; if (DateTempLine || datetemplinesflag) { /* ** Insert next statement for use with program ``dvialw'' */ sscanf (buffer, "%s", str); if ((strcmp (str, SHOWPAGE)) == 0) fprintf (fpo, "%s", DVIALW_END); fprintf (fpo, "%s", buffer); outlinecount++; } else { sscanf (buffer, "%s", str); if ((strcmp (str, "36")) == 0) { sscanf (buffer, "%*s%s", str); if ((strcmp (str, "545")) == 0) { sscanf (buffer, "%*s%*s%s", str); if ((strcmp (str, MOVETO)) == 0) { fprintf (fpo, "%s%s", PPP, buffer); fgets (buffer, MAXBUF, fpi); inlinecount++; fprintf (fpo, "%s%s", PPP, buffer); outlinecount += 2; datetemplinesflag = TRUE; } } } if (!datetemplinesflag) { fprintf (fpo, "%s", buffer); outlinecount++; } } } if (!translaterotateflag) { fprintf (stderr, "\n*** Didn't find statement: 612 0 translate\n\n"); 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.