|
|
1.1 root 1: /*
2: * pclfont.c
3: *
4: * Prepare a font for downloading to a PCL printer via lp.
5: *
6: * Usage: pclfont [-f n] font [... font] > outputfile
7: *
8: * where -f indicates to begin loading the fonts into memory beginning with
9: * slot n
10: *
11: * by fwb, 8/13/93 (Friday the 13th)
12: */
13: #include <fcntl.h>
14: #include <stdlib.h>
15: #include <string.h>
16: #include <unistd.h>
17:
18: char *usage = "Usage: pclfont [-f n] font [... font]";
19: char buffer[600];
20:
21: void fatal(message)
22: char * message;
23: {
24: sprintf(buffer, "%s", message);
25: write (STDOUT_FILENO, buffer, strlen(buffer));
26: exit(EXIT_FAILURE);
27: }
28:
29: void beginstring(slot)
30: int slot;
31: {
32: sprintf(buffer, "\033*c%dD", slot);
33: write (STDOUT_FILENO, buffer, strlen(buffer));
34: }
35:
36: void endstring()
37: {
38: sprintf(buffer, "\033*c5F");
39: write(STDOUT_FILENO, buffer, strlen(buffer));
40: }
41:
42: void copyfont (indev)
43: int indev;
44: {
45: int numread;
46:
47: while (1) {
48: numread = read(indev, buffer, 512);
49:
50: if (numread == -1)
51: fatal("Error on reading font file");
52:
53: write(STDOUT_FILENO, buffer, numread);
54:
55: if (numread < 512)
56: return;
57: }
58: }
59:
60: main (argc, argv)
61: int argc; char *argv[1];
62: {
63: int indev, i, baseslot;
64:
65: /* find the base slot */
66: if (!strncmp(argv[1], "-f", 2)) {
67: baseslot = atoi(argv[2]);
68: if (baseslot < 1)
69: fatal ("Font slot must be at least 1");
70: i = 3;
71: } else {
72: i = 1;
73: baseslot = 1;
74: }
75:
76: if (i == argc) {
77: beginstring (baseslot);
78: copyfont(STDIN_FILENO);
79: endstring();
80: exit(EXIT_SUCCESS);
81: }
82:
83: for ( ; i < argc; baseslot++, i++) {
84: if ((indev = open(argv[i], O_RDONLY, 0)) == -1)
85: fatal("Could not open font file");
86: beginstring (baseslot);
87: copyfont(indev);
88: endstring();
89: }
90: exit(EXIT_SUCCESS);
91: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.