summaryrefslogtreecommitdiff
path: root/graphics/hpgl2ps/hpgl2ps.c
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /graphics/hpgl2ps/hpgl2ps.c
Initial commit
Diffstat (limited to 'graphics/hpgl2ps/hpgl2ps.c')
-rw-r--r--graphics/hpgl2ps/hpgl2ps.c90
1 files changed, 90 insertions, 0 deletions
diff --git a/graphics/hpgl2ps/hpgl2ps.c b/graphics/hpgl2ps/hpgl2ps.c
new file mode 100644
index 0000000000..6460248044
--- /dev/null
+++ b/graphics/hpgl2ps/hpgl2ps.c
@@ -0,0 +1,90 @@
+#include "defn.h"
+
+#define USAGE "Usage: hpgl2ps [-amr] [-l line sizes] [-s scale] [-x offset] [-y offset] [file]\n"
+
+main(argc, argv)
+int argc;
+char *argv[];
+{
+ extern int optind;
+ extern char *optarg;
+
+ char op;
+ int MANUAL_FEED = 0; /* DEFAULT: No manual feed */
+
+ PaperSize = "A3";
+ Mode = "HPGL";
+ plotcoords();
+
+ plotinit(); /* Get other initialiasations */
+
+ while ((ch = getopt(argc, argv, "al:ms:x:y:r")) != EOF)
+ {
+ switch (ch)
+ {
+ case 'a': /* HP-GL ISO A4 297mm * 210mm */
+ PaperSize = "A4";
+ plotcoords();
+ break;
+
+ case 'l':
+ changesizes(optarg);
+ break;
+
+ case 'm':
+ MANUAL_FEED = 1;
+ break;
+
+ case 'r':
+ LANDSCAPE = 0;
+ break;
+
+ case 's':
+ SCALE = atof(optarg);
+ if (SCALE < 0.1)
+ SCALE = 0.1;
+ else
+ if (SCALE > 3)
+ SCALE = 3;
+ break;
+
+ case 'x':
+ xoffset = atof(optarg);
+ break;
+
+ case 'y':
+ yoffset = atof(optarg);
+ break;
+
+ default:
+ fprintf(stderr, "%s\n", USAGE);
+ exit(1);
+ }
+ }
+ if (optind == argc)
+ stream = stdin;
+ else if ((stream = fopen(argv[optind], "r")) == NULL)
+ {
+ fprintf(stderr, "ERROR: cannot open \"%s\"\n", argv[optind]);
+ exit(1);
+ }
+ ps_macros(); /* Output PostScript Macros */
+
+ viewport(); /* Scale the viewport for the plot */
+
+ printf("/%s %g Font\n", font, char_height);
+
+ if (MANUAL_FEED)
+ manualfeed(1);
+
+ while ((op = getc(stream)) != EOF)
+ if (isalpha(op) > 0)
+ hpglcom(op);
+
+ end_draw();
+
+ printf("showpage\n");
+
+ if (MANUAL_FEED)
+ manualfeed(0);
+}