Annotation of researchv10no/cmd/descrypt/alpha.c, revision 1.1

1.1     ! root        1: /*
        !             2:  *     Routines for Doing Alphanumeric Input/Output (the -a option)
        !             3:  *     D.P.Mitchell  83/07/01.
        !             4:  */
        !             5: 
        !             6: #include <stdio.h>
        !             7: #define CHAR1  '#'
        !             8: 
        !             9: extern int permutation[];
        !            10: char trans[66] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz./";
        !            11: int untrans[] = {
        !            12:  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 
        !            13:  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 
        !            14:  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 62, 63, 
        !            15: 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,  0,  0,  0,  0,  0,  0, 
        !            16:  0,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 
        !            17: 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,  0,  0,  0,  0,  0, 
        !            18:  0, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 
        !            19: 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,  0,  0,  0,  0,  0, 
        !            20:  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 
        !            21:  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 
        !            22:  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 
        !            23:  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 
        !            24:  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 
        !            25:  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 
        !            26:  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 
        !            27:  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 
        !            28: };
        !            29: 
        !            30: out_alpha(c_buffer)
        !            31: int c_buffer[128];
        !            32: {
        !            33:        int six[171];
        !            34:        register c0, c1, c2;
        !            35:        register src, dst;
        !            36: 
        !            37:        for (src = 0, dst = 0; src < 128;) {
        !            38:                c0 = c_buffer[permutation[src++]];
        !            39:                c1 = c_buffer[permutation[src++]];
        !            40:                if (src < 128)
        !            41:                        c2 = c_buffer[permutation[src++]];
        !            42:                else
        !            43:                        c2 = 0;
        !            44:                six[dst++] = trans[(c0 >> 2) & 077];
        !            45:                six[dst++] = trans[((c0 & 03) << 4) | ((c1 >> 4) & 017)];
        !            46:                six[dst++] = trans[((c1 & 017) << 2) | ((c2 >> 6) & 03)];
        !            47:                if (dst < 171)
        !            48:                        six[dst++] = trans[c2 & 077];
        !            49:        }
        !            50:        putchar(CHAR1);
        !            51:        for (src = 0; src < 57; src++)
        !            52:                putchar(six[src]);
        !            53:        putchar('\n');
        !            54:        putchar(CHAR1);
        !            55:        for (; src < 114; src++)
        !            56:                putchar(six[src]);
        !            57:        putchar('\n');
        !            58:        putchar(CHAR1);
        !            59:        for (; src < 171; src++)
        !            60:                putchar(six[src]);
        !            61:        putchar('\n');
        !            62: }
        !            63: 
        !            64: int
        !            65: in_alpha(c_buffer)
        !            66: int c_buffer[128];
        !            67: {
        !            68:        int six[171];
        !            69:        register c0, c1, c2, c3;
        !            70:        register src, dst;
        !            71:        char line[64];
        !            72:        extern char *fgets();
        !            73: 
        !            74:        for (dst = 0; dst < 171; ) {
        !            75:                do {
        !            76:                        if (fgets(line, 64, stdin) == NULL)
        !            77:                                return 0;
        !            78:                } while (line[0] != CHAR1);
        !            79:                for (src = 1; src < 58; src++)
        !            80:                        six[dst++] = line[src];
        !            81:        }
        !            82:        for (src = 0, dst = 0; src < 171; ) {
        !            83:                c0 = untrans[six[src++]];
        !            84:                c1 = untrans[six[src++]];
        !            85:                c2 = untrans[six[src++]];
        !            86:                if (src < 171)
        !            87:                        c3 = untrans[six[src++]];
        !            88:                else
        !            89:                        c3 = 0;
        !            90:                c_buffer[permutation[dst++]] = (c0 << 2) | (c1 >> 4);
        !            91:                c_buffer[permutation[dst++]] = ((c1 & 017) << 4) | (c2 >> 2);
        !            92:                if (dst < 128)
        !            93:                        c_buffer[permutation[dst++]] = ((c2 & 03) << 6) | c3;
        !            94:        }
        !            95:        return 1;
        !            96: }

unix.superglobalmegacorp.com

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