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