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

Defined functions

main defined in line 23; never used
pbits defined in line 83; used 1 times
  • in line 76
rprt defined in line 54; used 1 times
  • in line 51

Defined variables

chp defined in line 20; used 3 times
sccsid defined in line 8; never used
Last modified: 1995-01-22
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 816
Valid CSS Valid XHTML 1.0 Strict