this version uses remote line printer software.
authorRalph Campbell <ralph@ucbvax.Berkeley.EDU>
Thu, 3 Mar 1983 05:51:15 +0000 (21:51 -0800)
committerRalph Campbell <ralph@ucbvax.Berkeley.EDU>
Thu, 3 Mar 1983 05:51:15 +0000 (21:51 -0800)
SCCS-vsn: local/ditroff/ditroff.old.okeeffe/gremlin.aed/gprint/gprint.h 1.2
SCCS-vsn: local/ditroff/ditroff.old.okeeffe/gremlin.aed/gprint/hgraph.c 1.2
SCCS-vsn: local/ditroff/ditroff.old.okeeffe/gremlin.aed/gprint/hpoint.c 1.2
SCCS-vsn: local/ditroff/ditroff.old.okeeffe/gremlin.aed/gprint/main.c 1.2
SCCS-vsn: local/ditroff/ditroff.old.okeeffe/gremlin.aed/gprint/Makefile 1.2

usr/src/local/ditroff/ditroff.old.okeeffe/gremlin.aed/gprint/Makefile
usr/src/local/ditroff/ditroff.old.okeeffe/gremlin.aed/gprint/gprint.h
usr/src/local/ditroff/ditroff.old.okeeffe/gremlin.aed/gprint/hgraph.c
usr/src/local/ditroff/ditroff.old.okeeffe/gremlin.aed/gprint/main.c

index 26dd5fa..fb451b6 100644 (file)
@@ -1,23 +1,9 @@
+CFLAGS = -O
+LDFLAGS = -lm
+OBJS = hdb.o hpoint.o hgraph.o main.o
 
 
-OBJ= hdb.o hpoint.o hgraph.o main.o getlogin.o
+gprint:  ${OBJS}
+       cc -o gprint ${OBJS} ${LDFLAGS}
 
 
-all:   $(OBJ) gprint
-
-hdb.o:   hdb.c 
-       cc -c -g hdb.c 
-
-hgraph.o:      hgraph.c
-       cc -c -g hgraph.c
-
-hpoint.o:      hpoint.c
-       cc -c -g hpoint.c
-
-
-main.o:   main.c 
-       cc -c -g main.c 
-
-gprint:  $(OBJ)
-       cc -o gprint -g $(OBJ) -lm 
-
-gdump: gdump.o getlogin.o
-       cc -o gdump -g gdump.o getlogin.o
+clean:
+       rm -f *.o
index 7d8ced4..e88e7c4 100644 (file)
@@ -1,5 +1,4 @@
-/* gprint.h -
- *
+/*     gprint.h        1.2     83/03/02
  *
  * This file contains standard definitions used by the gprint program.
  */
  *
  * This file contains standard definitions used by the gprint program.
  */
@@ -9,29 +8,28 @@
 #define Xmax 511
 #define xorn(x,y) Orientation ? (y) : (x) 
 #define yorn(x,y) Orientation ? (Ymax - ((x) - poffset)) : (y) 
 #define Xmax 511
 #define xorn(x,y) Orientation ? (y) : (x) 
 #define yorn(x,y) Orientation ? (Ymax - ((x) - poffset)) : (y) 
-#define    mapx(x)    ((DevRange*(((x) * scale)-botx)/del)+centx)
-#define    mapy(y)    ((DevRange*(del-((y) * scale)+boty)/del)-centy)
+#define mapx(x) ((DevRange*(((x) * scale)-botx)/del)+centx)
+#define mapy(y) ((DevRange*(del-((y) * scale)+boty)/del)-centy)
 #define STYLES 6
 #define SIZES 4
 #define FONTS 4
 #define SOLID -1
 #define STYLES 6
 #define SIZES 4
 #define FONTS 4
 #define SOLID -1
-#define DOTTED 004   /* 014 */
-#define DASHED 020   /* 034 */
-#define DOTDASHED 024 /* 054 */
+#define DOTTED 004     /* 014 */
+#define DASHED 020     /* 034 */
+#define DOTDASHED 024  /* 054 */
 #define LONGDASHED 074
 #define LONGDASHED 074
-#define    SETSTATE    (('v'<<8)+1)
 
 #include <stdio.h>
 #include <math.h>
 
 
 #include <stdio.h>
 #include <math.h>
 
-#define TRUE  1
-#define FALSE 0
+#define TRUE   1
+#define FALSE  0
 
 
-#define nullelt -1
-#define nullpt  -1
-#define nullun   NULL
+#define nullelt        -1
+#define nullpt -1
+#define nullun NULL
 
 
-#define BOTLEFT 0
+#define BOTLEFT        0
 #define BOTRIGHT 1
 #define CENTCENT 2
 #define VECTOR 3
 #define BOTRIGHT 1
 #define CENTCENT 2
 #define VECTOR 3
 #define DELETE 2
 #define MOD 3
 
 #define DELETE 2
 #define MOD 3
 
-typedef struct point
-        {
-               float x, y;
-               struct point *nextpt;
-        } POINT;
-
-typedef struct elmt
-        {
-               int type, brushf, size, textlength;
-               char *textpt;
-               POINT *ptlist;
-               struct elmt *nextelt, *setnext;
-        } ELT;
+typedef struct point {
+       float x, y;
+       struct point *nextpt;
+} POINT;
 
 
+typedef struct elmt {
+       int type, brushf, size, textlength;
+       char *textpt;
+       POINT *ptlist;
+       struct elmt *nextelt, *setnext;
+} ELT;
 
 
-typedef struct unlt
-        {
-             int action;
-             ELT *(*dbase), *oldelt, *newelt;
-             struct unlt *nextun;
-        } UNELT;
+typedef struct unlt {
+       int action;
+       ELT *(*dbase), *oldelt, *newelt;
+       struct unlt *nextun;
+} UNELT;
 
 typedef struct {
 
 typedef struct {
-    int tx_x;          /* First column of field */
-    int tx_y;          /* Row containing field */
-    int tx_size;       /* Size of field in characters */
-    } TXFIELD;
+       int tx_x;       /* First column of field */
+       int tx_y;       /* Row containing field */
+       int tx_size;    /* Size of field in characters */
+} TXFIELD;
index ac88b72..4ec8f95 100644 (file)
@@ -34,7 +34,6 @@ extern char *fontdir ;
 /* imports from main.c */
 
 extern double scale;
 /* imports from main.c */
 
 extern double scale;
-extern char device;
 extern point();
 extern int    linethickness;
 extern int    linmod;
 extern point();
 extern int    linethickness;
 extern int    linmod;
@@ -50,9 +49,10 @@ extern double    delx;
 extern double    dely;
 extern double    del;
 extern int DevRange;
 extern double    dely;
 extern double    del;
 extern int DevRange;
+extern char device;
+
 
 
 
 
-\f
 line(x0, y0, x1, y1)
 int x0, y0, x1, y1;
 
 line(x0, y0, x1, y1)
 int x0, y0, x1, y1;
 
@@ -111,7 +111,7 @@ int x0, y0, x1, y1;
     if((x1+slope*y1)&linmod) point(x1, y1);
 }
 
     if((x1+slope*y1)&linmod) point(x1, y1);
 }
 
-\f
+
 HGPrintElt(element)
 ELT *element;
 
 HGPrintElt(element)
 ELT *element;
 
@@ -172,7 +172,7 @@ ELT *element;
     }  /* end if */
 }  /* end PrintElt */
 
     }  /* end if */
 }  /* end PrintElt */
 
-\f
+
 HGPutText(justify,pnt,string)
 int justify;
 POINT pnt;
 HGPutText(justify,pnt,string)
 int justify;
 POINT pnt;
@@ -295,7 +295,7 @@ char string[];
     }
 } /* end HGPutText */;
 
     }
 } /* end HGPutText */;
 
-\f
+
 #define pi 3.14159265357
 #define log2_10 3.321915
 
 #define pi 3.14159265357
 #define log2_10 3.321915
 
@@ -343,7 +343,7 @@ int angle;
     }   /* end for */;
 }  /* end HGArc */;
 
     }   /* end for */;
 }  /* end HGArc */;
 
-\f
+
 RoundEnd(x, y, radius, filled)
 int x, y, radius;
 int filled;                /* indicates whether the circle is filled */
 RoundEnd(x, y, radius, filled)
 int x, y, radius;
 int filled;                /* indicates whether the circle is filled */
@@ -406,7 +406,7 @@ int filled;                /* indicates whether the circle is filled */
     }  /* end for i */;
 }  /* end RoundEnd */;
 
     }  /* end for i */;
 }  /* end RoundEnd */;
 
-\f
+
 #define MAXPOINTS 200
 
 static Paramaterize(x, y, h, n)
 #define MAXPOINTS 200
 
 static Paramaterize(x, y, h, n)
@@ -514,7 +514,7 @@ int npoints;                                /* number of valid points */
        }
 }  /* end PeriodicSpline */
 
        }
 }  /* end PeriodicSpline */
 
-\f
+
 static NaturalEndSpline(h, z, dz, d2z, d3z, npoints)
 float h[MAXPOINTS], z[MAXPOINTS];      /* Point list and parameterization */
 float dz[MAXPOINTS];                   /* to return the 1st derivative */
 static NaturalEndSpline(h, z, dz, d2z, d3z, npoints)
 float h[MAXPOINTS], z[MAXPOINTS];      /* Point list and parameterization */
 float dz[MAXPOINTS];                   /* to return the 1st derivative */
@@ -576,7 +576,7 @@ int npoints;                                /* number of valid points */
        }
 }  /* end NaturalEndSpline */
 
        }
 }  /* end NaturalEndSpline */
 
-\f
+
 #define PointsPerInterval 32
 
 HGCurve(pointlist,style)
 #define PointsPerInterval 32
 
 HGCurve(pointlist,style)
@@ -651,7 +651,7 @@ int   style;
 }  /* end HGCurve */
 
 
 }  /* end HGCurve */
 
 
-\f
+
 HGplotch(ch)
 char ch;
 
 HGplotch(ch)
 char ch;
 
@@ -686,7 +686,7 @@ char ch;
           lasty += dispatch[ (ch == ' ') ? 'a' : ch ].width;
 }
 
           lasty += dispatch[ (ch == ' ') ? 'a' : ch ].width;
 }
 
-\f
+
 HGInitFont(fontFile)
 char *fontFile;
 
 HGInitFont(fontFile)
 char *fontFile;
 
@@ -744,7 +744,7 @@ char *fontFile;
     }
 }
 
     }
 }
 
-\f
+
 HGtline(x0, y0, x1, y1)
 int x0, y0, x1, y1;
 /*
 HGtline(x0, y0, x1, y1)
 int x0, y0, x1, y1;
 /*
@@ -803,7 +803,7 @@ int x0, y0, x1, y1;
         RoundEnd(x1, y1, (int) morelen, TRUE);    /* add rounded end */
 }  /* end HGtline */
 
         RoundEnd(x1, y1, (int) morelen, TRUE);    /* add rounded end */
 }  /* end HGtline */
 
-\f
+
 HGMove(p)
 POINT p;
 {
 HGMove(p)
 POINT p;
 {
index 05888e2..6296c22 100644 (file)
@@ -1,9 +1,8 @@
-
 /* gprint.c-
  *
  * Copyright -C- 1982 Barry S. Roitblat
  *
 /* gprint.c-
  *
  * Copyright -C- 1982 Barry S. Roitblat
  *
- *      This file contains the main and file system dependent routines
+ *     This file contains the main and file system dependent routines
  * for producing hard copy from gremlin files.  It is extensively modified
  * from the vplot source.
  */
  * for producing hard copy from gremlin files.  It is extensively modified
  * from the vplot source.
  */
 #include <signal.h>
 #include <vfont.h>
 
 #include <signal.h>
 #include <vfont.h>
 
+#define LPR "/usr/ucb/lpr"
+#define VAX
 
 
-#define VDAEMON        "/usr/lib/vad"
-#define WDAEMON        "/usr/lib/vpd"
-
-#define NB    1024        /* Number of blocks in virtual memory */
-#define BSIZ    512        /* Size of blocks */
-#define    SETSTATE    (('v'<<8)+1)
+#ifdef VAX
+#define NB     1024            /* Number of blocks in virtual memory */
+#else
+#define NB     88              /* Number of blocks kept in memory */
+#endif
+#define BSIZ   512             /* Size of blocks */
+#define LOGBSIZ        9               /* log base 2 of BSIZ */
 
 extern char *mktemp();
 
 extern char *mktemp();
-extern char *getname(); /* get login name or user name */
+extern char *malloc();
+extern char *rindex();
 
 /* imports */
 extern HGtline(), HGArc(), HGPutText(), HGMove(), HGSetFont();
 
 /* imports */
 extern HGtline(), HGArc(), HGPutText(), HGMove(), HGSetFont();
@@ -35,380 +38,382 @@ extern char *tfont[], *tsize[];
 extern ELT *DBInit(), *DBRead();
 extern POINT *PTInit(), *PTMakePoint();
 
 extern ELT *DBInit(), *DBRead();
 extern POINT *PTInit(), *PTMakePoint();
 
-int     linethickness = 0;       /* brush styles */
-int    linmod    = SOLID;
-char    chrtab[][16];
-char    blocks    [NB][BSIZ];
-int    lastx;
-int    lasty;
-int    angle, startx, starty, endx, endy;
-double     scale = 4.0;     /* Variables used to map gremlin screen */
-double    topx;             /* coordinates into output device coordinates */
-double    topy;
-double    botx;
-double    boty;
-int    centx = 0;
-int    centy = 0;
-double    delx;
-double    dely;
-double    del;
+int    linethickness = 0;      /* brush styles */
+int    linmod  = SOLID;
+char   chrtab[][16];
+char   blocks[NB][BSIZ];
+int    lastx;
+int    lasty;
+int    angle, startx, starty, endx, endy;
+double scale = 4.0;    /* Variables used to map gremlin screen */
+double topx;           /* coordinates into output device coordinates */
+double topy;
+double botx;
+double boty;
+int    centx = 0;
+int    centy = 0;
+double delx;
+double dely;
+double del;
 
 
-char *vspoolr = "/usr/spool/vad/dfxXXXXXX";
-char *wspoolr = "/usr/spool/vpd/dfxXXXXXX";
-char *vfilen = "/usr/spool/vad/tmpXXXXXX";
-char *wfilen = "/usr/spool/vad/tmpXXXXXX";
+#ifdef VAX
+char   dirty[NB];              /* marks if a block has been written into */
+#else
+struct buf {
+       int     bno;
+       char    *block;
+} bufs[NB];
+#endif
 
 
-int DevRange = 1536;        /* Bits per line for output device */
-
-struct    buf 
-{
-    int    bno;
-    char    *block;
-};
-struct    buf    bufs;
+int    fd;                     /* file descriptor of current picture */
+char   picture[] = "/usr/tmp/rastAXXXXXX";
+int    run = 13;               /* index of 'a' in picture[] */
+int    DevRange = 1536;        /* Bits per line for output device */
+int    BytesPerLine = 264;     /* Bytes per raster line (different from range
+                                  due to non-square paper). */
+char   device = 'V';           /* default device */
+int    lparg = 6;              /* index into lpargs */
 
 
-int dirty[NB];         /* marks if a block has been written into */
-int    in, out;
-char picture[64];
-char *run = "a";     /* gives uniqueness for multiple pictures */
-char device = 'V';
-char *banner = "gremlin";
+char   *lpargs[50] = { "lpr", "-Pvarian", "-v", "-s", "-r", "-J", };
 
 /* variables used to print from font file */
 
 /* variables used to print from font file */
-int Orientation;
-int cfont = 0;
-int csize = 0;
-struct header header;
-struct dispatch dispatch[256];
-char *bits = NULL;
-char *fontdir = "/usr/lib/vfont/";
+int    Orientation;
+int    cfont = 0;
+int    csize = 0;
+struct header header;
+struct dispatch dispatch[256];
+char   *bits = NULL;
+char   *fontdir = "/usr/lib/vfont/";
 
 main(argc, argv)
 int argc;
 char *argv[];
 {
 
 main(argc, argv)
 int argc;
 char *argv[];
 {
-    FILE *fp, *fopen();
-    ELT *PICTURE, *e;
-    POINT *p1, pos;
-    char *file[50], sw, string[10], *arg;
-    char c, string1[50], string2[50], string3[50], string4[50], 
-            string5[50], string6[50], string7[50], string8[50]; 
-    extern int onintr();
-    float mult;
-    int WriteRaster = FALSE;
-    int i, j, gfil = 0;
-    int b, brsh;
-    int k;
+       FILE *fp, *fopen();
+       ELT *PICTURE, *e;
+       POINT *p1, pos;
+       char *file[50], string[10], *arg;
+       char c, string1[50], string2[50], string3[50], string4[50], 
+               string5[50], string6[50], string7[50], string8[50]; 
+       extern int cleanup();
+       float mult;
+       int WriteRaster = FALSE;
+       register int i, j, k;
+       int brsh, gfil = 0;
 
 
-    /* Parse the command line. */
+       /* Parse the command line. */
 
 
-    argc -= 1;  argv++;                /* Skip program name. */
-    while (argc > 0)
-    {
-        argc -= 1;
-        arg = *argv++;
-        if (arg[0] != '-') file[gfil++] = arg;
-        else
-        {
-            sw = *++arg;
-            switch (sw)
-            {
-            case 'W':       /* Print to wide (versatec) device */
-                  device = 'W';
-                  DevRange = 2047;
-                  break;
-            case 'V':       /* Print to narrow (varian) device */
-                  device = 'V';
-                  DevRange = 1536;
-                  break;
-            case '1':      /* select size 1 */
-                  if (*++arg == '\0')
-                  if (argc-- > 0) arg = *argv++;
-                  tsize[0] = arg;
-                  break;
-            case '2':      /* select size 2 */
-                  if (*++arg == '\0')
-                  if (argc-- > 0) arg = *argv++;
-                  tsize[1] = arg;
-                  break;
-            case '3':      /* select size 3 */
-                  if (*++arg == '\0')
-                  if (argc-- > 0) arg = *argv++;
-                  tsize[2] = arg;
-                  break;
-            case '4':      /* select size 4 */
-                  if (*++arg == '\0')
-                  if (argc-- > 0) arg = *argv++;
-                  tsize[3] = arg;
-                  break;
-            case 'R':      /* select Roman font */
-                  if (*++arg == '\0')
-                  if (argc-- > 0) arg = *argv++;
-                  tfont[0] = arg;
-                  break;
-            case 'I':     /* select italics font */
-                  if (*++arg == '\0')
-                  if (argc-- > 0) arg = *argv++;
-                  tfont[1] = arg;
-                  break;
-            case 'B':     /* select bold font */
-                  if (*++arg == '\0')
-                  if (argc-- > 0) arg = *argv++;
-                  tfont[2] = arg;
-                  break;
-            case 'S':     /* select special font */
-                  if (*++arg == '\0')
-                  if (argc-- > 0) arg = *argv++;
-                  tfont[3] = arg;
-                  break;
-            case 'N':     /* select narrow brush width */
-                  if (*++arg == '\0')
-                  if (argc-- > 0) arg = *argv++;
-                  (void) sscanf(arg, "%d", &brsh);
-                  thick[0] = thick[1] = thick[3] = thick[4] = brsh;
-                  break;
-            case 'T':     /* select thick brush width */
-                  if (*++arg == '\0')
-                  if (argc-- > 0) arg = *argv++;
-                  (void) sscanf(arg, "%d", &brsh);
-                  thick[2] = brsh;
-                  break;
-            case 'M':     /* select medium brush width */
-                  if (*++arg == '\0')
-                  if (argc-- > 0) arg = *argv++;
-                  (void) sscanf(arg, "%d", &brsh);
-                  thick[5] = brsh;
-                  break;
-            case 't':     /* send raster to standard output */
-                  WriteRaster = TRUE;
-                  break;
-            case 'x':     /* select scale */
-                  if (*++arg == '\0')
-                  if (argc-- > 0) arg = *argv++;
-                  sscanf(arg,"%f",&mult);
-                  scale *= mult;
-                  break;
-            case 'p':     /* prompt for font and size parameters */
-                  printf("Roman font name? (%s): ", tfont[0]);
-                  gets(string1);
-                  if (*string1 != '\0') tfont[0] = string1;
-                  printf("Italic font name? (%s): ", tfont[1]);
-                  gets(string2);
-                  if (*string2 != '\0') tfont[1] = string2;
-                  printf("Bold font name? (%s): ", tfont[2]);
-                  gets(string3);
-                  if (*string3 != '\0') tfont[2] = string3;
-                  printf("Special font name? (%s): ", tfont[3]);
-                  gets(string4);
-                  if (*string4 != '\0') tfont[3] = string4;
-                  printf("font size 1? (%s): ", tsize[0]);
-                  gets(string5);
-                  if (*string5 != '\0') tsize[0] = string5;
-                  printf("font size 2? (%s): ", tsize[1]);
-                  gets(string6);
-                  if (*string6 != '\0') tsize[1] = string6;
-                  printf("font size 3? (%s): ", tsize[2]);
-                  gets(string7);
-                  if (*string7 != '\0') tsize[2] = string7;
-                  printf("font size 4? (%s): ", tsize[3]);
-                  gets(string8);
-                  if (*string8 != '\0') tsize[3] = string8;
-                  printf("narrow brush size? (%d): ", thick[0]);
-                  gets(string);
-                  if (*string != '\0') 
-                  {
-                       sscanf(string, "%d", &brsh);
-                       thick[0] = thick[1] = thick[3] = thick[4] = brsh;
-                  }
-                  printf("medium brush size? (%d): ", thick[5]);
-                  gets(string);
-                  if (*string != '\0') 
-                  {
-                       sscanf(string, "%d", &brsh);
-                       thick[5] = brsh;
-                  }
-                  printf("thick brush size? (%d): ", thick[2]);
-                  gets(string);
-                  if (*string != '\0') 
-                  {
-                       sscanf(string, "%d", &brsh);
-                       thick[2] = brsh;
-                  }
-                  break;
-            default:
-                  (void) printf("unknown switch: %c", sw);
-            }
-        }
-    }
+       argc--;
+       argv++;
+       while (argc--) {
+               if (*(arg = *argv++) != '-')
+                       file[gfil++] = arg;
+               else switch (*++arg) {
+               case 'W':       /* Print to wide (versatec) device */
+                       device = 'W';
+                       DevRange = 2047;
+                       BytesPerLine = 880;
+                       lpargs[1] = "-Pversatec";
+                       break;
+               case 'V':       /* Print to narrow (varian) device */
+                       device = 'V';
+                       DevRange = 1536;
+                       BytesPerLine = 264;
+                       lpargs[1] = "-Pvarian";
+                       break;
+               case '1':       /* select size 1 */
+                       if (*++arg == '\0' && argc--)
+                               arg = *argv++;
+                       tsize[0] = arg;
+                       break;
+               case '2':       /* select size 2 */
+                       if (*++arg == '\0' && argc--)
+                               arg = *argv++;
+                       tsize[1] = arg;
+                       break;
+               case '3':       /* select size 3 */
+                       if (*++arg == '\0' && argc--)
+                               arg = *argv++;
+                       tsize[2] = arg;
+                       break;
+               case '4':       /* select size 4 */
+                       if (*++arg == '\0' && argc--)
+                               arg = *argv++;
+                       tsize[3] = arg;
+                       break;
+               case 'R':       /* select Roman font */
+                       if (*++arg == '\0' && argc--)
+                               arg = *argv++;
+                       tfont[0] = arg;
+                       break;
+               case 'I':       /* select italics font */
+                       if (*++arg == '\0' && argc--)
+                               arg = *argv++;
+                       tfont[1] = arg;
+                       break;
+               case 'B':       /* select bold font */
+                       if (*++arg == '\0' && argc--)
+                               arg = *argv++;
+                       tfont[2] = arg;
+                       break;
+               case 'S':       /* select special font */
+                       if (*++arg == '\0' && argc--)
+                               arg = *argv++;
+                       tfont[3] = arg;
+                       break;
+               case 'N':       /* select narrow brush width */
+                       if (*++arg == '\0' && argc--)
+                               arg = *argv++;
+                       (void) sscanf(arg, "%d", &brsh);
+                       thick[0] = thick[1] = thick[3] = thick[4] = brsh;
+                       break;
+               case 'T':       /* select thick brush width */
+                       if (*++arg == '\0' && argc--)
+                               arg = *argv++;
+                       (void) sscanf(arg, "%d", &brsh);
+                       thick[2] = brsh;
+                       break;
+               case 'M':       /* select medium brush width */
+                       if (*++arg == '\0' && argc--)
+                               arg = *argv++;
+                       (void) sscanf(arg, "%d", &brsh);
+                       thick[5] = brsh;
+                       break;
+               case 't':       /* send raster to standard output */
+                       WriteRaster = TRUE;
+                       break;
+               case 'x':       /* select scale */
+                       if (*++arg == '\0' && argc--)
+                               arg = *argv++;
+                       sscanf(arg,"%f", &mult);
+                       scale *= mult;
+                       break;
+               case 'p':       /* prompt for font and size parameters */
+                       printf("Roman font name? (%s): ", tfont[0]);
+                       gets(string1);
+                       if (*string1 != '\0') tfont[0] = string1;
+                       printf("Italic font name? (%s): ", tfont[1]);
+                       gets(string2);
+                       if (*string2 != '\0') tfont[1] = string2;
+                       printf("Bold font name? (%s): ", tfont[2]);
+                       gets(string3);
+                       if (*string3 != '\0') tfont[2] = string3;
+                       printf("Special font name? (%s): ", tfont[3]);
+                       gets(string4);
+                       if (*string4 != '\0') tfont[3] = string4;
+                       printf("font size 1? (%s): ", tsize[0]);
+                       gets(string5);
+                       if (*string5 != '\0') tsize[0] = string5;
+                       printf("font size 2? (%s): ", tsize[1]);
+                       gets(string6);
+                       if (*string6 != '\0') tsize[1] = string6;
+                       printf("font size 3? (%s): ", tsize[2]);
+                       gets(string7);
+                       if (*string7 != '\0') tsize[2] = string7;
+                       printf("font size 4? (%s): ", tsize[3]);
+                       gets(string8);
+                       if (*string8 != '\0') tsize[3] = string8;
+                       printf("narrow brush size? (%d): ", thick[0]);
+                       gets(string);
+                       if (*string != '\0') {
+                               sscanf(string, "%d", &brsh);
+                               thick[0] = thick[1] = thick[3] = thick[4] = brsh;
+                       }
+                       printf("medium brush size? (%d): ", thick[5]);
+                       gets(string);
+                       if (*string != '\0') {
+                               sscanf(string, "%d", &brsh);
+                               thick[5] = brsh;
+                       }
+                       printf("thick brush size? (%d): ", thick[2]);
+                       gets(string);
+                       if (*string != '\0') {
+                               sscanf(string, "%d", &brsh);
+                               thick[2] = brsh;
+                       }
+                       break;
+               default:
+                       (void) printf("unknown switch: %c", *arg);
+               }
+       }
 
 
-    /* init constants for scaling */
-    topx = topy = DevRange;
-    botx = boty = 0;
-    delx = dely = del = DevRange;
-    centx = (DevRange - mapx(topx/scale))/2;
-    centy = mapy(topy/scale)/2;
-    signal(SIGTERM, onintr);
-    if (signal(SIGINT, SIG_IGN) != SIG_IGN)
-        signal(SIGINT, onintr);
-    if (gfil == 0)   /* no filename, use standard input */
-    {
-        file[0] = "stdin";
-        ++gfil;
-    }
-    for (j=0; j<gfil; ++j)
-    {
-        if (strcmp(file[j], "stdin") != 0) fp = fopen(file[j],"r");
-        else  fp = stdin;
-        if (fp == NULL)
-        {
-            fprintf(stderr, "can't open %s",file[j]);
-            continue;
-        }
-        PICTURE = DBRead(fp,&Orientation, &pos);    /* read picture file */
-        if (DBNullelt(PICTURE)) continue;
+       /* init constants for scaling */
+       topx = topy = DevRange;
+       botx = boty = 0;
+       delx = dely = del = DevRange;
+       centx = (DevRange - mapx(topx/scale))/2;
+       centy = mapy(topy/scale)/2;
+       signal(SIGTERM, cleanup);
+       if (signal(SIGINT, SIG_IGN) != SIG_IGN)
+               signal(SIGINT, cleanup);
+       mktemp(picture);
+       if (gfil == 0) {        /* no filename, use standard input */
+               file[0] = NULL;
+               gfil++;
+       }
+       for (k=0; k<gfil; k++) {
+               if (file[k] != NULL) {
+                       if ((fp = fopen(file[k], "r")) == NULL) {
+                               fprintf(stderr, "gprint: can't open %s", file[k]);
+                               continue;
+                       }
+                       if (k == 0) {
+                               if ((arg = rindex(file[k], '/')) == NULL)
+                                       arg = file[k];
+                               else
+                                       arg++;
+                               lpargs[lparg++] = arg;
+                       }
+               } else {
+                       fp = stdin;
+                       lpargs[lparg++] = "gremlin";
+               }
+               /* read picture file */
+               PICTURE = DBRead(fp, &Orientation, &pos);
+               if (DBNullelt(PICTURE))
+                       continue;
 
 
-        banner = file[j];
-        picture[0] = '\0';    /* picture equals null string */
-        strcat(picture,mktemp("/usr/tmp/#rastXXXXX"));
-        strcat(picture, run);
-        (*run)++;
-        bufs.bno = -1;      /* no current block */
-        for (i=0; i<NB; i++) 
-        {
-            dirty[i] = FALSE;     /* no blocks written yet */
-            for (k=0; k<BSIZ; ++k)     /* Zero out memory area for picture */
-                  blocks[i][k] = 0;
-        }
-        out = creat(picture, 0666);
-        in = open(picture, 0);
-        zseek(out, NB);               /* seek to end of file and write */
-        write(out, blocks[0], BSIZ);  /* intervening hole will be 0-filled */
+               if ((fd = creat(picture, 0666)) < 0) {
+                       fprintf(stderr, "gprint: can't create %s\n", picture);
+                       cleanup();
+               }
+#ifndef VAX
+               close(fd);
+               if ((fd = open(picture, 2)) < 0) {
+                       fprintf(stderr, "gprint: can't reopen %s\n", picture);
+                       cleanup();
+               }
+#endif
+               i = strlen(picture) + 1;
+               if ((arg = malloc(i)) == NULL) {
+                       fprintf(stderr, "gprint: ran out of memory\n");
+                       cleanup();
+               }
+               strcpy(arg, picture);
+               lpargs[lparg++] = arg;
+               picture[run]++;
+               for (i=0; i<NB; i++) {
+#ifdef VAX
+                       dirty[i] = FALSE;
+                       for (j=0; j<BSIZ; ++j)
+                               blocks[i][j] = 0;
+#else
+                       bufs[i].bno = -1;
+                       bufs[i].block = blocks[i];
+#endif
+               }
+#ifdef NOHOLES
+               /* clear the entire file */
+               for (i=0; i<BSIZ; i++)
+                       blocks[0][i] = '\0';
+               for (i=0; i<1024; i++)
+                       write(fd, blocks[0], BSIZ);
+#endif
 
 
-        e = PICTURE;
-        while (!DBNullelt(e))
-        {
-               HGPrintElt(e);     /* traverse picture, printing elements */
-               e = DBNextElt(e);
-        }
-
-        for (i=0; i<NB; i++) 
-        {
-            if (WriteRaster == TRUE)   /* put picture to standard output */
-            {
-                for (j=0; j<BSIZ; ++j)
-                    putchar(blocks[i][j]);
-            }
-            if (dirty[i] == TRUE)      /* write out only those blocks which */
-            {                          /* which have been written into, the */
-                zseek(out,i);          /* rest will default to be zeroes    */
-                write(out, blocks[i], BSIZ);
-            }
-        }
-        fclose(fp);
-        close(out);
-        if (WriteRaster == FALSE) 
-            putpict(picture);
-        close(in);
-        close(out);
-    }  /* end for j */
-    exit(0);
-}  /* end main */
-
-putpict(picture)
-char *picture;
-{
-    FILE *temp;
-    char *fileName,*spoolerName;
+               e = PICTURE;
+               while (!DBNullelt(e)) {
+                       HGPrintElt(e);  /* traverse picture, printing elements */
+                       e = DBNextElt(e);
+               }
 
 
-    if((temp = fopen(picture,"r")) == NULL)   /* picture image doesnt exist */
-    {
-        perror(picture);
-        exit(1);
-    }
-    fclose(temp);
-    if(device == 'V')     /* writing to varian */
-    {
-        fileName = (char *) malloc(strlen(vfilen) + 1);
-        strcpy(fileName,vfilen);
-        fileName = mktemp(fileName);
-        spoolerName = (char *) malloc(strlen(vspoolr) + 1);
-        strcpy(spoolerName,vspoolr);
-        spoolerName = mktemp(spoolerName);
-    }
-    else                 /* writing to versatec */
-    {
-        fileName = (char *) malloc(strlen(wfilen) + 1);
-        strcpy(fileName,wfilen);
-        fileName = mktemp(fileName);
-        spoolerName = (char *) malloc(strlen(wspoolr) + 1);
-        strcpy(spoolerName,wspoolr);
-        spoolerName = mktemp(spoolerName);
-    }
-    if((temp = fopen(fileName,"w")) == NULL) 
-    {
-        fprintf(stderr,"Can't make temporary spooling file\n");
-        exit(1);
-    }
-           /* write file and command information to printer daemon */
-
-    fprintf(temp,"L%s\n",getname());  /* login name (for banner) */
-    fprintf(temp,"B%s\n",banner);      /* gremlin file name (for banner) */
-    fprintf(temp,"V%s\n",picture);     /* raster image file name  */
-    fprintf(temp,"U%s\n",picture);     /* unlink file when through */
-    fclose(temp);
-    if(link(fileName,spoolerName) != 0) 
-    {
-        perror(spoolerName);
-        exit(2);
-    }
-    unlink(fileName);
-
-            /* Spawn daemon process */
-
-    if(vfork() == 0) 
-    {
-        if(device == 'V')
-            execl(VDAEMON,VDAEMON);
-        else
-            execl(WDAEMON,WDAEMON);
-    }
+               for (i=0; i<NB; i++) {
+                       if (WriteRaster) {
+                               fwrite(blocks[i], sizeof(char), BSIZ, stdout);
+                               continue;
+                       }
+#ifdef VAX
+                       if (dirty[i]) { /* write out non-zero blocks */
+                               zseek(fd, i);
+                               write(fd, blocks[i], BSIZ);
+                       }
+#else
+                       if (bufs[i].bno != -1) {
+                               zseek(fd, bufs[i].bno);
+                               write(fd, bufs[i].blocks[i], BSIZ);
+                       }
+#endif
+               }
+               fclose(fp);
+               close(fd);
+       }
+       if (!WriteRaster) {
+               lpargs[lparg] = 0;
+               execv(LPR, lpargs);
+               fprintf(stderr, "gprint: can't exec %s\n", LPR);
+               cleanup();
+       }
+       exit(0);
 }
 
 }
 
+#ifndef VAX
 getblk(b)
 getblk(b)
-int b;
+register b;
 {
 {
-    if(b < 0 || NB <= b)   /* bad block number */
-    {
-        fprintf(stderr,"vplot: internal error, b out of range in getblk\n");
-        abort();
-    }
-    dirty[b] = TRUE;    /* assume that present block has been written into */
-    bufs.bno = b;
-    bufs.block = blocks[b];  /* get new block to write */
+       register struct buf *bp1;
+       register char *tp;
+
+       if (b < 0 || b >= NB) {         /* bad block number */
+               fprintf(stderr, "gprint: internal error, b out of range in getblk\n");
+               cleanup();
+       }
+loop:
+       for (bp1 = bufs; bp1 < &bufs[NB]; bp1++) {
+               if (bp1->bno == b || bp1->bno == -1) {
+                       tp = bp1->block;
+                       while (bp1 > bufs) {
+                               bp1->bno = (bp1-1)->bno;
+                               bp1->block = (bp1-1)->block;
+                               bp1--;
+                       }
+                       bp1->bno = b;
+                       bp1->block = tp;
+                       return;
+               }
+       }
+       zseek(fd, bufs[NB-1].bno);
+       write(fd, bufs[NB-1].block, BSIZ);
+       zseek(fd, b);
+       read(fd, bufs[NB-1].block, BSIZ);
+       bufs[NB-1].bno = b;
+       goto loop;
 }
 }
+#endif
 
 
-onintr()
+cleanup()
 {
 {
-    exit(1);
+       while (picture[run] != 'a') {
+               unlink(picture);
+               picture[run]--;
+       }
+       exit(1);
 }
 
 }
 
+/*
+ * Points should be in the range 0 <= x (or y) <= DevRange.
+ * The origin is the top left-hand corner with increasing x towards the
+ * right and increasing y going down.
+ */
 point(x, y)
 point(x, y)
-int x, y;
+register int x, y;
 {
 {
-    int bno;
+       register unsigned bno, byte;
 
 
-    bno = ((x&03700)>>6) + ((y&03700)>>1);  /* calculate block number */
-    if (bno != bufs.bno)     /* get appropriate block if necessary */
-    {
-        if (bno < 0 || bno >= 1024)
-            return;
-        getblk(bno);
-    }
-    bufs.block[((y&077)<<3)+((x>>3)&07)] |= 1 << (7-(x&07));  /* set bit */
+       byte = y * BytesPerLine + (x >> 3);
+       bno = byte >> LOGBSIZ;
+       byte &= BSIZ - 1;
+       if (bno >= 1024)
+               return;
+#ifndef VAX
+       if (bno != bufs[0].bno)
+               getblk(bno);
+       bufs[0].block[byte] |= 1 << (7 - (x & 07));
+#else
+       blocks[bno][byte] |= 1 << (7 - (x & 07));
+       dirty[bno] = TRUE;
+#endif
 }
 
 zseek(a, b)
 {
 }
 
 zseek(a, b)
 {
-    return(lseek(a, (long)b*512, 0));
+       return(lseek(a, (long)b*BSIZ, 0));
 }
 }