1: /*
2: * Copyright (c) 1983 Regents of the University of California.
3: * All rights reserved. The Berkeley software License Agreement
4: * specifies the terms and conditions for redistribution.
5: */
6:
7: #ifndef lint
8: static char sccsid[] = "@(#)vpltdmp.c 5.1 (Berkeley) 5/15/85";
9: #endif not lint
10:
11: /*
12: * Copyright (C) 1981, Regents of the University of California
13: * All rights reserved
14: *
15: * reads raster file created by vplot and dumps it onto the
16: * Varian or Versatec plotter.
17: * Input comes from file descriptor 0, output is to file descriptor 1.
18: */
19: #include <stdio.h>
20: #include <sys/vcmd.h>
21:
22: #define IN 0
23: #define OUT 1
24:
25: static char *Sid = "@(#)vpltdmp.c 5.1\t5/15/85";
26:
27: int plotmd[] = { VPLOT };
28: int prtmd[] = { VPRINT };
29:
30: char buf[BUFSIZ]; /* output buffer */
31:
32: int lines; /* number of raster lines printed */
33: int varian; /* 0 for versatec, 1 for varian. */
34: int BYTES_PER_LINE; /* number of bytes per raster line. */
35: int PAGE_LINES; /* number of raster lines per page. */
36:
37: char *name, *host, *acctfile;
38:
39: main(argc, argv)
40: int argc;
41: char *argv[];
42: {
43: register int n;
44:
45: while (--argc) {
46: if (**++argv == '-') {
47: switch (argv[0][1]) {
48: case 'x':
49: BYTES_PER_LINE = atoi(&argv[0][2]) / 8;
50: varian = BYTES_PER_LINE == 264;
51: break;
52:
53: case 'y':
54: PAGE_LINES = atoi(&argv[0][2]);
55: break;
56:
57: case 'n':
58: argc--;
59: name = *++argv;
60: break;
61:
62: case 'h':
63: argc--;
64: host = *++argv;
65: }
66: } else
67: acctfile = *argv;
68: }
69:
70: n = putplot();
71:
72: ioctl(OUT, VSETSTATE, prtmd);
73: if (varian)
74: write(OUT, "\f", 2);
75: else
76: write(OUT, "\n\n\n\n\n", 6);
77: account(name, host, *argv);
78: exit(n);
79: }
80:
81: putplot()
82: {
83: register char *cp;
84: register int bytes, n;
85:
86: cp = buf;
87: bytes = 0;
88: ioctl(OUT, VSETSTATE, plotmd);
89: while ((n = read(IN, cp, sizeof(buf))) > 0) {
90: if (write(OUT, cp, n) != n)
91: return(1);
92: bytes += n;
93: }
94: /*
95: * Make sure we send complete raster lines.
96: */
97: if ((n = bytes % BYTES_PER_LINE) > 0) {
98: n = BYTES_PER_LINE - n;
99: for (cp = &buf[n]; cp > buf; )
100: *--cp = 0;
101: if (write(OUT, cp, n) != n)
102: return(1);
103: bytes += n;
104: }
105: lines += bytes / BYTES_PER_LINE;
106: return(0);
107: }
108:
109: account(who, from, acctfile)
110: char *who, *from, *acctfile;
111: {
112: register FILE *a;
113:
114: if (who == NULL || acctfile == NULL)
115: return;
116: if (access(acctfile, 02) || (a = fopen(acctfile, "a")) == NULL)
117: return;
118: /*
119: * Varian accounting is done by 8.5 inch pages;
120: * Versatec accounting is by the (12 inch) foot.
121: */
122: fprintf(a, "t%6.2f\t", (double)lines / (double)PAGE_LINES);
123: if (from != NULL)
124: fprintf(a, "%s:", from);
125: fprintf(a, "%s\n", who);
126: fclose(a);
127: }
Defined functions
main
defined in line
39;
never used
Defined variables
Sid
defined in line
25;
never used
buf
defined in line
30; used 4 times
host
defined in line
37; used 2 times
lines
defined in line
32; used 2 times
name
defined in line
37; used 2 times
prtmd
defined in line
28; used 1 times
sccsid
defined in line
8;
never used
Defined macros
IN
defined in line
22; used 1 times
OUT
defined in line
23; used 6 times