int getcaps(int fildes) { char *cap; int status; cap = GETENV("TERM"); if (!cap) cap = "unknown"; SETUPTERM(cap, fildes, &status); if (1 == status) { #ifdef __MVS__ #pragma convlit(suspend) #endif AUTO_RIGHT_MARGIN = tigetflag("am"); CLR_EOS = tigetstr("ed"); CLR_EOL = tigetstr("el"); COLUMNS = tigetnum("cols"); CURSOR_ADDRESS = tigetstr("cup"); CURSOR_DOWN = tigetstr("cud1"); CURSOR_LEFT = tigetstr("cub1"); CURSOR_RIGHT = tigetstr("cuf1"); CURSOR_UP = tigetstr("cuu1"); EAT_NEWLINE_GLITCH = tigetflag("xenl"); KEY_BACKSPACE = tigetstr("kbs"); KEY_DC = tigetstr("kdch1"); KEY_DOWN = tigetstr("kcud1"); KEY_LEFT = tigetstr("kcub1"); KEY_RIGHT = tigetstr("kcuf1"); KEY_UP = tigetstr("kcuu1"); KEY_INSERT = tigetstr("kich1"); KEYPAD_LOCAL = tigetstr("rmkx"); KEYPAD_XMIT = tigetstr("smkx"); GTM_LINES = tigetnum("lines"); #ifdef __MVS__ #pragma convlit(resume) #endif assert(-1 != AUTO_RIGHT_MARGIN); if (0 == AUTO_RIGHT_MARGIN) AUTO_RIGHT_MARGIN = gtm_auto_right_margin; assert((char *)-1L != CLR_EOS); if (NULL == CLR_EOS) CLR_EOS = gtm_clr_eos; assert((char *)-1L != CLR_EOL); if (NULL == CLR_EOL) CLR_EOL = gtm_clr_eol; assert(-2 != COLUMNS); if (-1 == COLUMNS) COLUMNS = gtm_columns; assert((char *)-1L != CURSOR_ADDRESS); if (NULL == CURSOR_ADDRESS) CURSOR_ADDRESS = gtm_cursor_address; assert((char *)-1L != CURSOR_DOWN); if (NULL == CURSOR_DOWN) CURSOR_DOWN = gtm_cursor_down; assert((char *)-1L != CURSOR_LEFT); if (NULL == CURSOR_LEFT) CURSOR_LEFT = gtm_cursor_left; assert((char *)-1L != CURSOR_RIGHT); if (NULL == CURSOR_RIGHT) CURSOR_RIGHT = gtm_cursor_right; assert((char *)-1L != CURSOR_UP); if (NULL == CURSOR_UP) CURSOR_UP = gtm_cursor_up; assert((char *)-1L != KEY_BACKSPACE); if (NULL == KEY_BACKSPACE) KEY_BACKSPACE = gtm_key_backspace; assert((char *)-1L != KEY_DC); if (NULL == KEY_DC) KEY_DC = gtm_key_dc; assert((char *)-1L != KEY_DOWN); if (NULL == KEY_DOWN) KEY_DOWN = gtm_key_down; assert((char *)-1L != KEY_LEFT); if (NULL == KEY_LEFT) KEY_LEFT = gtm_key_left; assert((char *)-1L != KEY_RIGHT); if (NULL == KEY_RIGHT) KEY_RIGHT = gtm_key_right; assert((char *)-1L != KEY_UP); if (NULL == KEY_UP) KEY_UP = gtm_key_up; assert((char *)-1L != KEY_INSERT); if (NULL == KEY_INSERT) KEY_INSERT = gtm_key_insert; assert((char *)-1L != KEYPAD_LOCAL); if (NULL == KEYPAD_LOCAL) KEYPAD_LOCAL = gtm_keypad_local; assert((char *)-1L != KEYPAD_XMIT); if (NULL == KEYPAD_XMIT) KEYPAD_XMIT = gtm_keypad_xmit; assert(-2 != GTM_LINES); if (-1 == GTM_LINES) GTM_LINES = gtm_lines; } else { AUTO_RIGHT_MARGIN = gtm_auto_right_margin; CLR_EOS = gtm_clr_eos; CLR_EOL = gtm_clr_eol; COLUMNS = gtm_columns; CURSOR_ADDRESS = gtm_cursor_address; CURSOR_DOWN = gtm_cursor_down; CURSOR_LEFT = gtm_cursor_left; CURSOR_RIGHT = gtm_cursor_right; CURSOR_UP = gtm_cursor_up; EAT_NEWLINE_GLITCH = gtm_eat_newline_glitch; KEY_BACKSPACE = gtm_key_backspace; KEY_DC = gtm_key_dc; KEY_DOWN = gtm_key_down; KEY_LEFT = gtm_key_left; KEY_RIGHT = gtm_key_right; KEY_UP = gtm_key_up; KEY_INSERT = gtm_key_insert; KEYPAD_LOCAL = gtm_keypad_local; KEYPAD_XMIT = gtm_keypad_xmit; GTM_LINES = gtm_lines; } return status; }
int getcaps(int fildes) { char *cap; #if defined(__MVS__) && __CHARSET_LIB==1 /* -qascii */ char cap_ebcdic[128]; /* more than enough for terminal name */ int ebc_len, gtm_cap_index = 0; #endif int status; cap = GETENV("TERM"); if (!cap) cap = "unknown"; #if defined(__MVS__) && __CHARSET_LIB==1 /* -qascii */ ebc_len = strlen(cap); if (SIZEOF(cap_ebcdic) < ebc_len) ebc_len = SIZEOF(cap_ebcdic) - 1; asc_to_ebc((unsigned char *)cap_ebcdic, (unsigned char *)cap, ebc_len); cap_ebcdic[ebc_len] = '\0'; cap = cap_ebcdic; #endif SETUPTERM(cap, fildes, &status); if (1 == status) { #ifdef KEEP_zOS_EBCDIC #pragma convlit(suspend) #endif #if defined(__MVS__) && __CHARSET_LIB==1 /* -qascii */ /* assumes source is EBCDIC and curses/terminfo entries expect EBCDIC */ #pragma convert(source) #endif AUTO_RIGHT_MARGIN = tigetflag("am"); CLR_EOS = tigetstr("ed"); CLR_EOL = tigetstr("el"); COLUMNS = tigetnum("cols"); CURSOR_ADDRESS = tigetstr("cup"); CURSOR_DOWN = tigetstr("cud1"); CURSOR_LEFT = tigetstr("cub1"); CURSOR_RIGHT = tigetstr("cuf1"); CURSOR_UP = tigetstr("cuu1"); EAT_NEWLINE_GLITCH = tigetflag("xenl"); KEY_BACKSPACE = tigetstr("kbs"); KEY_DC = tigetstr("kdch1"); KEY_DOWN = tigetstr("kcud1"); KEY_LEFT = tigetstr("kcub1"); KEY_RIGHT = tigetstr("kcuf1"); KEY_UP = tigetstr("kcuu1"); KEY_INSERT = tigetstr("kich1"); KEYPAD_LOCAL = tigetstr("rmkx"); KEYPAD_XMIT = tigetstr("smkx"); GTM_LINES = tigetnum("lines"); #if defined(__MVS__) && __CHARSET_LIB==1 /* -qascii */ #pragma convert(pop) #endif #ifdef KEEP_zOS_EBCDIC #pragma convlit(resume) #endif assert(-1 != AUTO_RIGHT_MARGIN); assert((char *)-1 != CLR_EOS); CAP2ASCII(CLR_EOS); assert((char *)-1 != CLR_EOL); CAP2ASCII(CLR_EOL); assert(-2 != COLUMNS); assert((char *)-1 != CURSOR_ADDRESS); CAP2ASCII(CURSOR_ADDRESS); assert((char *)-1 != CURSOR_DOWN); CAP2ASCII(CURSOR_DOWN); assert((char *)-1 != CURSOR_LEFT); CAP2ASCII(CURSOR_LEFT); assert((char *)-1 != CURSOR_RIGHT); CAP2ASCII(CURSOR_RIGHT); assert((char *)-1 != CURSOR_UP); CAP2ASCII(CURSOR_UP); assert((char *)-1 != KEY_BACKSPACE); CAP2ASCII(KEY_BACKSPACE); assert((char *)-1 != KEY_DC); CAP2ASCII(KEY_DC); assert((char *)-1 != KEY_DOWN); CAP2ASCII(KEY_DOWN); assert((char *)-1 != KEY_LEFT); CAP2ASCII(KEY_LEFT); assert((char *)-1 != KEY_RIGHT); CAP2ASCII(KEY_RIGHT); assert((char *)-1 != KEY_UP); CAP2ASCII(KEY_UP); assert((char *)-1 != KEY_INSERT); CAP2ASCII(KEY_INSERT); assert((char *)-1 != KEYPAD_LOCAL); CAP2ASCII(KEYPAD_LOCAL); assert((char *)-1 != KEYPAD_XMIT); CAP2ASCII(KEYPAD_XMIT); assert(-2 != GTM_LINES); } else { AUTO_RIGHT_MARGIN = gtm_auto_right_margin; CLR_EOS = gtm_clr_eos; CLR_EOL = gtm_clr_eol; COLUMNS = gtm_columns; CURSOR_ADDRESS = gtm_cursor_address; CURSOR_DOWN = gtm_cursor_down; CURSOR_LEFT = gtm_cursor_left; CURSOR_RIGHT = gtm_cursor_right; CURSOR_UP = gtm_cursor_up; EAT_NEWLINE_GLITCH = gtm_eat_newline_glitch; KEY_BACKSPACE = gtm_key_backspace; KEY_DC = gtm_key_dc; KEY_DOWN = gtm_key_down; KEY_LEFT = gtm_key_left; KEY_RIGHT = gtm_key_right; KEY_UP = gtm_key_up; KEY_INSERT = gtm_key_insert; KEYPAD_LOCAL = gtm_keypad_local; KEYPAD_XMIT = gtm_keypad_xmit; GTM_LINES = gtm_lines; } return status; }