Listing 3: lpjthin.c--Sets the line style to the thinnest width
8 February 1991
This is an output filter for the HP PaintJet to be
used in conjunction with the HP/GL2 cartridge and
AutoCAD on the Sun. AutoCAD is set up to create HP/GL
plot files through the HP7550 plot driver. Each plot
made includes an IN; statement as the first HP/GL
statement (after some apparent device init. commands).
This filter does nothing more than search the first
MAXCOUNT bytes for the IN; command then includes a
PW0; command to set the pen width to the absolute
smallest it can be. The rest of the plot file is sent
to the plotter without any changes.
To use this filter on the command line, use the
lpjthin < infile > outfile
cat infile | lpjthin | print
cc lpjthin.c -o lpjthin
#define BUFSIZE 4
#define MAXCOUNT 50
#define NUL '\0'
#define INITSTR "\033%-1B"
#define RESETSTR "\033%A"
static char buf[BUFSIZE];
int c, j, count;
/* switch to HP-GL/2 mode */
for(count = 0;
(c = getchar()) != EOF && count < MAXCOUNT;
if (c == 'I')
for (buf = c,j=1;
(j < 3) &&
((buf[j] = getchar()) != EOF); j++) ;
buf[j] = NUL;
while ((c = getchar()) != EOF)
/* switch back to PCL mode */