Annotation of researchv10no/cmd/2621.c, revision 1.1

1.1     ! root        1: /*
        !             2: _t_e_s_t _u_l _m_o_d_e
        !             3: */
        !             4: #include <sgtty.h>
        !             5: #include <signal.h>
        !             6: 
        !             7: #define ULON   "\033&dA"
        !             8: #define ULOFF  "\033&d@"
        !             9: 
        !            10: main(argc, argv)
        !            11: char *argv[];
        !            12: {
        !            13:        int i;
        !            14:        char buf[512];
        !            15:        int onintr();
        !            16:        int pos_, k, ulmode;
        !            17: 
        !            18:        if (argc > 1) {
        !            19:                if ((i = open(argv[1], 0)) < 0) {
        !            20:                        perror(argv[1]);
        !            21:                        EXIT(1);
        !            22:                }
        !            23:                close(0);
        !            24:                dup(i);
        !            25:                close(i);
        !            26:        }
        !            27:        if (signal(SIGINT, SIG_IGN) == SIG_DFL)
        !            28:                signal(SIGINT, onintr);
        !            29: 
        !            30:        pos_ = ulmode = 0;
        !            31:        while ((i = read(0, buf, sizeof(buf))) > 0) {
        !            32:                for (k = 0; k < i; k++) {
        !            33:                        if (buf[k] == '_' && pos_ == 0) {
        !            34:                                pos_ = 1;
        !            35:                                continue;
        !            36:                        }
        !            37:                        if (pos_ == 1)
        !            38:                                if (buf[k] == '\b') {
        !            39:                                        pos_ = 2;
        !            40:                                        if (ulmode)
        !            41:                                                continue;
        !            42:                                        printf("%s", ULON);
        !            43:                                        ulmode++;
        !            44:                                        continue;
        !            45:                                } else {
        !            46:                                        if (ulmode)
        !            47:                                                printf("%s", ULOFF);
        !            48:                                        putchar('_');
        !            49:                                        ulmode = 0;
        !            50:                                        pos_ = 0;
        !            51:                                }
        !            52:                        if (pos_ == 2) {
        !            53:                                putchar(buf[k]);
        !            54:                                pos_ = 0;
        !            55:                                continue;
        !            56:                        }
        !            57:                        pos_ = 0;
        !            58:                        if (ulmode)
        !            59:                                printf("%s", ULOFF);
        !            60:                        ulmode = 0;
        !            61:                        putchar(buf[k]);
        !            62:                }
        !            63:        }
        !            64:        printf("%s", ULOFF);
        !            65:        EXIT(0);
        !            66: }
        !            67: 
        !            68: onintr()
        !            69: {
        !            70:        printf("%s", ULOFF);
        !            71:        EXIT(0);
        !            72: }
        !            73: 
        !            74: EXIT(i)
        !            75: {
        !            76:        printf("%s", ULOFF);
        !            77:        exit(i);
        !            78: }

unix.superglobalmegacorp.com

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