Annotation of 41BSD/cmd/vpr/prt.c, revision 1.1

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

unix.superglobalmegacorp.com

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