|
|
1.1 root 1: #
2: /*
3: * tell vcat which fonts are loaded on the "typesetter"
4: */
5: #define MAGIC_NUMBER 0436
6: #define RAILMAG_FILE "/usr/lib/vfont/railmag"
7:
8: char *concat();
9: int rmfd;
10: char *rm[4];
11: char tbuf[256];
12:
13: main(argc, argv)
14: int argc;
15: char *argv[];
16: {
17: register int fnum;
18: char cbuf[4][50];
19:
20: readrm();
21: if(argc <= 1)
22: {
23: printrm();
24: exit(0);
25: }
26: while(--argc)
27: {
28: argv++;
29: fnum = argv[0][0]-'0';
30: if(fnum < 1 || fnum > 4)
31: error("Invalid font number");
32: checkfont(argv[1]);
33: if(argv[1][0] == '/')
34: rm[fnum-1] = argv[1];
35: else
36: rm[fnum-1] = concat(cbuf[fnum-1], "/usr/lib/vfont/", argv[1]);
37: argv++; argc--;
38: }
39: writerm();
40: }
41:
42:
43: error(str)
44: char *str;
45: {
46:
47: write(2, "Railmag: ", 9);
48: write(2, str, strlen(str));
49: write(2, "\n", 1);
50: exit();
51: }
52:
53:
54: checkfont(file)
55: char *file;
56: {
57: register int fd;
58: char cbuf[80];
59: char cbuf2[80];
60: short word;
61:
62: if((fd = open(concat(cbuf, file, ".10"), 0)) < 0)
63: if((fd = open(concat(cbuf2, "/usr/lib/vfont/", cbuf), 0)) < 0)
64: error("cant open font");
65: if(read(fd, &word, 2) != 2)
66: error("cant read font");
67: if(word != MAGIC_NUMBER)
68: error("font has no magic number");
69: close(fd);
70: }
71:
72: readrm()
73: {
74: register int i;
75: register char *cp;
76: char c;
77:
78: if((rmfd = open(RAILMAG_FILE, 0)) < 0)
79: error("No railmag file");
80: cp = tbuf;
81: for(i = 0; i < 4; i++)
82: {
83: rm[i] = cp;
84: while(read(rmfd, &c, 1) == 1 && c != '\n')
85: *cp++ = c;
86: *cp++ = '\0';
87: }
88: }
89:
90: printrm()
91: {
92: register int i;
93:
94: for(i = 0; i < 4; i++)
95: printf("%s on %d\n", rm[i], i+1);
96: }
97:
98: writerm()
99: {
100: register int i;
101: register char *cp;
102:
103: unlink(RAILMAG_FILE);
104: if((rmfd = creat(RAILMAG_FILE, 0644)) < 0)
105: error("cant recreate railmag file");
106: for(i = 0; i < 4; i++)
107: {
108: cp = rm[i];
109: while(*cp != '\0')
110: write(rmfd, cp++, 1);
111: write(rmfd, "\n", 1);
112: }
113: }
114:
115: char *
116: concat(outbuf,in1,in2)
117: char *outbuf,*in1,*in2;
118: {
119: char *save;
120:
121: save = outbuf;
122: while(*in1)
123: *outbuf++ = *in1++;
124: while(*in2)
125: *outbuf++ = *in2++;
126: return(save);
127: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.