|
|
1.1 root 1: #include <stdio.h>
2: #include <vfont.h>
3: #include <sys/types.h>
4: #include <sys/stat.h>
5:
6: char *chp;
7: char *sbrk();
8:
9: main(argc,argv)
10: char **argv;
11: {
12: struct header h;
13: struct dispatch d[256];
14: struct stat stb;
15: off_t tell();
16: int i,size;
17:
18: argc--, argv++;
19: if (argc > 0) {
20: close(0);
21: if (open(argv[0], 0) < 0)
22: perror(argv[0]), exit(1);
23: }
24: if (read(0, &h, sizeof(h)) != sizeof(h))
25: fprintf(stderr, "header read error\n"), exit(1);
26: if (h.magic != 0436)
27: fprintf(stderr, "bad magic number\n"), exit(1);
28: if (read(0, d, sizeof(d)) != sizeof(d))
29: fprintf(stderr, "dispatch read error\n"), exit(1);
30: fstat(0, &stb);
31: size = stb.st_size - tell(0);
32: fprintf(stderr, "%d bytes of characters\n", size);
33: chp = sbrk(size);
34: read(0, chp, size);
35: /* write(1, &h, sizeof (h)); */
36: for (i = 0; i < 256; i++)
37: rprt(i, &d[i], chp+d[i].addr);
38: }
39:
40: rprt(i, dp, cp)
41: int i;
42: struct dispatch *dp;
43: char *cp;
44: {
45: int bpl, j;
46:
47: if (dp->nbytes == 0)
48: return;
49: if (i >= 0200)
50: printf("M-"), i -= 0200;
51: if (i < 040)
52: printf("^%c", i|'@');
53: else if (i == 0177)
54: printf("^?");
55: else
56: printf("%c", i);
57: printf("%d bytes, l %d r %d u %d d %d:\n",
58: dp->nbytes, dp->left, dp->right, dp->up, dp->down);
59: bpl = (dp->up+dp->down+7)/8;
60: for (i = 0; i < dp->right+dp->left; i++) {
61: for (j = 0; j < bpl; j++)
62: pbits(cp[j]);
63: cp += bpl;
64: printf("\n");
65: }
66: printf("========\n");
67: }
68:
69: pbits(i)
70: register int i;
71: {
72: register int j;
73:
74: for (j = 8; j > 0; j--) {
75: printf((i & 0x80) ? " *" : " ");
76: i <<= 1;
77: }
78: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.