xref: /csrg-svn/old/vpr/vtools/rotprt.c (revision 13945)
1*13945Ssam #ifndef lint
2*13945Ssam static char sccsid[] = "@(#)rotprt.c	4.2 (Berkeley) 07/16/83";
3*13945Ssam #endif
4*13945Ssam 
512086Sralph /*
612086Sralph  * Print a rotated font.
712086Sralph  */
812086Sralph 
912086Sralph #include <stdio.h>
1012086Sralph #include <vfont.h>
1112086Sralph #include <sys/types.h>
1212086Sralph #include <sys/stat.h>
1312086Sralph 
1412086Sralph char	*chp;
1512086Sralph char	*sbrk();
1612086Sralph 
1712086Sralph main(argc,argv)
1812086Sralph char **argv;
1912086Sralph {
2012086Sralph 	struct header h;
2112086Sralph 	struct dispatch d[256];
2212086Sralph 	struct stat stb;
2312086Sralph 	off_t tell();
2412086Sralph 	int i,size;
2512086Sralph 
2612086Sralph 	argc--, argv++;
2712086Sralph 	if (argc > 0) {
2812086Sralph 		close(0);
2912086Sralph 		if (open(argv[0], 0) < 0)
3012086Sralph 			perror(argv[0]), exit(1);
3112086Sralph 	}
3212086Sralph 	if (read(0, &h, sizeof(h)) != sizeof(h))
3312086Sralph 		fprintf(stderr, "header read error\n"), exit(1);
3412086Sralph 	if (h.magic != 0436)
3512086Sralph 		fprintf(stderr, "bad magic number\n"), exit(1);
3612086Sralph 	if (read(0, d, sizeof(d)) != sizeof(d))
3712086Sralph 		fprintf(stderr, "dispatch read error\n"), exit(1);
3812086Sralph 	fstat(0, &stb);
3912086Sralph 	size = stb.st_size - tell(0);
4012086Sralph 	fprintf(stderr, "%d bytes of characters\n", size);
4112086Sralph 	chp = sbrk(size);
4212086Sralph 	read(0, chp, size);
4312086Sralph 	/* write(1, &h, sizeof (h)); */
4412086Sralph 	for (i = 0; i < 256; i++)
4512086Sralph 		rprt(i, &d[i], chp+d[i].addr);
4612086Sralph }
4712086Sralph 
4812086Sralph rprt(i, dp, cp)
4912086Sralph 	int i;
5012086Sralph 	struct dispatch *dp;
5112086Sralph 	char *cp;
5212086Sralph {
5312086Sralph 	int bpl, j;
5412086Sralph 
5512086Sralph 	if (dp->nbytes == 0)
5612086Sralph 		return;
5712086Sralph 	if (i >= 0200)
5812086Sralph 		printf("M-"), i -= 0200;
5912086Sralph 	if (i < 040)
6012086Sralph 		printf("^%c", i|'@');
6112086Sralph 	else if (i == 0177)
6212086Sralph 		printf("^?");
6312086Sralph 	else
6412086Sralph 		printf("%c", i);
6512086Sralph 	printf("%d bytes, l %d r %d u %d d %d:\n",
6612086Sralph 	    dp->nbytes, dp->left, dp->right, dp->up, dp->down);
6712086Sralph 	bpl = (dp->up+dp->down+7)/8;
6812086Sralph 	for (i = 0; i < dp->right+dp->left; i++) {
6912086Sralph 		for (j = 0; j < bpl; j++)
7012086Sralph 			pbits(cp[j]);
7112086Sralph 		cp += bpl;
7212086Sralph 		printf("\n");
7312086Sralph 	}
7412086Sralph 	printf("========\n");
7512086Sralph }
7612086Sralph 
7712086Sralph pbits(i)
7812086Sralph 	register int i;
7912086Sralph {
8012086Sralph 	register int j;
8112086Sralph 
8212086Sralph 	for (j = 8; j > 0; j--) {
8312086Sralph 		printf((i & 0x80) ? " *" : "  ");
8412086Sralph 		i <<= 1;
8512086Sralph 	}
8612086Sralph }
87