Annotation of researchv10dc/ncurses/screen/nttychktrm.c, revision 1.1

1.1     ! root        1: #include "curses.ext"
        !             2: /*     @(#) nttychktrm.c: 1.1 10/15/83 1/5/83  */
        !             3: 
        !             4: char *_c_why_not = NULL;
        !             5: static char *
        !             6: _stupid = "Sorry, I don't know how to deal with your '%s' terminal.\r\n";
        !             7: static char *
        !             8: _unknown = "Sorry, I need to know a more specific terminal type than '%s'.\r\n";
        !             9: 
        !            10: struct screen *
        !            11: _new_tty(type, fd)
        !            12: char   *type;
        !            13: FILE   *fd;
        !            14: {
        !            15:        int retcode;
        !            16:        struct map *_init_keypad();
        !            17:        char *calloc();
        !            18: 
        !            19: #ifdef DEBUG
        !            20:        if(outf) fprintf(outf, "__new_tty: type %s, fd %x\n", type, fd);
        !            21: #endif
        !            22:        /*
        !            23:         * Allocate an SP structure if there is none, or if SP is
        !            24:         * still pointing to an old structure from a previous call
        !            25:         * to this routine.  But don't allocate one if we are being
        !            26:         * called from a higher level curses routine.  Since it's our
        !            27:         * job to initialize the phys_scr field and higher level routines
        !            28:         * aren't supposed to, we check that field to figure which to do.
        !            29:         */
        !            30:        if (SP == NULL || SP->cur_body!=0)
        !            31:                SP = (struct screen *) calloc(1, sizeof (struct screen));
        !            32:        SP->term_file = fd;
        !            33:        if (type == 0)
        !            34:                type = "unknown";
        !            35:        _setbuffered(fd);
        !            36:        setupterm(type, fileno(fd), &retcode);
        !            37:        if (retcode < 0) {
        !            38:                /*
        !            39:                 * This happens if /usr/lib/terminfo doesn't exist, there is
        !            40:                 * no such terminal type, or the file is corrupted.
        !            41:                 * This would be a good place to print an error message.
        !            42:                 */
        !            43:                return NULL;
        !            44:        }
        !            45:        savetty();      /* as a "useful default" - hanging up is nasty. */
        !            46:        if (chk_trm() == ERR)
        !            47:                return NULL;
        !            48:        SP->tcap = cur_term;
        !            49:        SP->doclear = 1;
        !            50:        SP->cur_body = (struct line **) calloc(lines+2, sizeof (struct line *));
        !            51:        SP->std_body = (struct line **) calloc(lines+2, sizeof (struct line *));
        !            52: #ifdef KEYPAD
        !            53:        SP->kp = _init_keypad();
        !            54: #endif
        !            55:        SP->input_queue = (short *) calloc(20, sizeof (short));
        !            56:        SP->input_queue[0] = -1;
        !            57: 
        !            58:        SP->virt_x = 0;         /* X and Y coordinates of the SP->curptr */
        !            59:        SP->virt_y = 0;         /* between updates. */
        !            60:        _init_costs();
        !            61:        return SP;
        !            62: }
        !            63: 
        !            64: static int
        !            65: chk_trm()
        !            66: {
        !            67: #ifdef DEBUG
        !            68:        if(outf) fprintf(outf, "chk_trm().\n");
        !            69: #endif
        !            70: 
        !            71:        if (generic_type) {
        !            72:                _c_why_not = _unknown;
        !            73:                return ERR;
        !            74:        }
        !            75:        if (clear_screen == 0 || hard_copy || over_strike) {
        !            76:                _c_why_not = _stupid;
        !            77:                return ERR;
        !            78:        }
        !            79:        if (cursor_address) {
        !            80:                /* we can handle it */
        !            81:        } else 
        !            82:        if ( (cursor_up || cursor_home) /* some way to move up */
        !            83:            && cursor_down              /* some way to move down */
        !            84:            && (cursor_left || carriage_return) /* ... move left */
        !            85:                                        /* printing chars moves right */
        !            86:                ) {
        !            87:                /* we can handle it */
        !            88:        } else {
        !            89:                _c_why_not = _stupid;
        !            90:                return ERR;
        !            91:        }
        !            92:        return OK;
        !            93: }

unix.superglobalmegacorp.com

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