1*20200Sdist /*
2*20200Sdist * Copyright (c) 1983 Regents of the University of California.
3*20200Sdist * All rights reserved. The Berkeley software License Agreement
4*20200Sdist * specifies the terms and conditions for redistribution.
5*20200Sdist */
6*20200Sdist
713945Ssam #ifndef lint
8*20200Sdist static char sccsid[] = "@(#)rotprt.c 5.1 (Berkeley) 05/15/85";
9*20200Sdist #endif not lint
1013945Ssam
1112086Sralph /*
1212086Sralph * Print a rotated font.
1312086Sralph */
1412086Sralph
1512086Sralph #include <stdio.h>
1612086Sralph #include <vfont.h>
1712086Sralph #include <sys/types.h>
1812086Sralph #include <sys/stat.h>
1912086Sralph
2012086Sralph char *chp;
2112086Sralph char *sbrk();
2212086Sralph
main(argc,argv)2312086Sralph main(argc,argv)
2412086Sralph char **argv;
2512086Sralph {
2612086Sralph struct header h;
2712086Sralph struct dispatch d[256];
2812086Sralph struct stat stb;
2912086Sralph off_t tell();
3012086Sralph int i,size;
3112086Sralph
3212086Sralph argc--, argv++;
3312086Sralph if (argc > 0) {
3412086Sralph close(0);
3512086Sralph if (open(argv[0], 0) < 0)
3612086Sralph perror(argv[0]), exit(1);
3712086Sralph }
3812086Sralph if (read(0, &h, sizeof(h)) != sizeof(h))
3912086Sralph fprintf(stderr, "header read error\n"), exit(1);
4012086Sralph if (h.magic != 0436)
4112086Sralph fprintf(stderr, "bad magic number\n"), exit(1);
4212086Sralph if (read(0, d, sizeof(d)) != sizeof(d))
4312086Sralph fprintf(stderr, "dispatch read error\n"), exit(1);
4412086Sralph fstat(0, &stb);
4512086Sralph size = stb.st_size - tell(0);
4612086Sralph fprintf(stderr, "%d bytes of characters\n", size);
4712086Sralph chp = sbrk(size);
4812086Sralph read(0, chp, size);
4912086Sralph /* write(1, &h, sizeof (h)); */
5012086Sralph for (i = 0; i < 256; i++)
5112086Sralph rprt(i, &d[i], chp+d[i].addr);
5212086Sralph }
5312086Sralph
rprt(i,dp,cp)5412086Sralph rprt(i, dp, cp)
5512086Sralph int i;
5612086Sralph struct dispatch *dp;
5712086Sralph char *cp;
5812086Sralph {
5912086Sralph int bpl, j;
6012086Sralph
6112086Sralph if (dp->nbytes == 0)
6212086Sralph return;
6312086Sralph if (i >= 0200)
6412086Sralph printf("M-"), i -= 0200;
6512086Sralph if (i < 040)
6612086Sralph printf("^%c", i|'@');
6712086Sralph else if (i == 0177)
6812086Sralph printf("^?");
6912086Sralph else
7012086Sralph printf("%c", i);
7112086Sralph printf("%d bytes, l %d r %d u %d d %d:\n",
7212086Sralph dp->nbytes, dp->left, dp->right, dp->up, dp->down);
7312086Sralph bpl = (dp->up+dp->down+7)/8;
7412086Sralph for (i = 0; i < dp->right+dp->left; i++) {
7512086Sralph for (j = 0; j < bpl; j++)
7612086Sralph pbits(cp[j]);
7712086Sralph cp += bpl;
7812086Sralph printf("\n");
7912086Sralph }
8012086Sralph printf("========\n");
8112086Sralph }
8212086Sralph
pbits(i)8312086Sralph pbits(i)
8412086Sralph register int i;
8512086Sralph {
8612086Sralph register int j;
8712086Sralph
8812086Sralph for (j = 8; j > 0; j--) {
8912086Sralph printf((i & 0x80) ? " *" : " ");
9012086Sralph i <<= 1;
9112086Sralph }
9212086Sralph }
93