* Copyright (c) 1983 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of California at Berkeley. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
"@(#) Copyright (c) 1983 Regents of the University of California.\n\
static char sccsid
[] = "@(#)vdmp.c 5.2 (Berkeley) %G%";
* reads raster file created by cifplot and dumps it onto the
* Varian or Versatec plotter.
* Input is from device 0.
* plotter is already opened as device 1.
* error output file is device 2.
#define MAGIC_WORD 0xA5CF4DFA
static char *Sid
= "@(#)vdmp.c 5.1\t5/15/85";
int plotmd
[] = { VPLOT
};
int prtmd
[] = { VPRINT
};
int inbuf
[BLOCK
/sizeof(int)];
int varian
; /* 0 for versatec, 1 for varian. */
int BYTES_PER_LINE
; /* number of bytes per raster line. */
int PAGE_LINES
; /* number of raster lines per page. */
char *name
, *host
, *acctfile
;
BYTES_PER_LINE
= atoi(&argv
[0][2]) / 8;
varian
= BYTES_PER_LINE
== 264;
PAGE_LINES
= atoi(&argv
[0][2]);
n
= read(IN
, inbuf
, BLOCK
);
if (inbuf
[0] == MAGIC_WORD
&& n
== BLOCK
) {
/* we have a formatted dump file */
inbuf
[(BLOCK
/sizeof(int))-1] = 0; /* make sure string terminates */
ioctl(OUT
, VSETSTATE
, prtmd
);
write(OUT
, &inbuf
[4], (strlen(&inbuf
[4])+1) & ~1);
} else /* dump file not formatted */
lseek(IN
, 0L, 0); /* reset in's seek pointer and plot */
ioctl(OUT
, VSETSTATE
, prtmd
);
write(OUT
, "\n\n\n\n\n", 6);
account(name
, host
, acctfile
);
ioctl(OUT
, VSETSTATE
, plotmd
);
while ((n
= read(IN
, cp
, sizeof(buf
))) > 0) {
if (write(OUT
, cp
, n
) != n
)
* Make sure we send complete raster lines.
if ((n
= bytes
% BYTES_PER_LINE
) > 0) {
for (cp
= &buf
[n
]; cp
> buf
; )
if (write(OUT
, cp
, n
) != n
)
lines
+= bytes
/ BYTES_PER_LINE
;
account(who
, from
, acctfile
)
char *who
, *from
, *acctfile
;
if (who
== NULL
|| acctfile
== NULL
)
if (access(acctfile
, 02) || (a
= fopen(acctfile
, "a")) == NULL
)
* Varian accounting is done by 8.5 inch pages;
* Versatec accounting is by the (12 inch) foot.
fprintf(a
, "t%6.2f\t", (double)lines
/ (double)PAGE_LINES
);