Annotation of 43BSDReno/old/vpr/vtools/rotprt.c, revision 1.1

1.1     ! root        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: #ifndef lint
        !             8: static char sccsid[] = "@(#)rotprt.c   5.1 (Berkeley) 5/15/85";
        !             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 tell();
        !            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 - tell(0);
        !            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: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.