/* Request Terminal State Report */ static int tst_DECRQTSR(MENU_ARGS) { char *report; const char *show; vt_move(1, 1); println("Testing Terminal State Reports (DECRQTSR/DECTSR)"); set_tty_raw(TRUE); set_tty_echo(FALSE); do_csi("1$u"); report = get_reply(); vt_move(3, 10); chrprint(report); if ((report = skip_dcs(report)) != 0 && strip_terminator(report) && !strncmp(report, "1$s", (size_t) 3)) { show = SHOW_SUCCESS; } else { show = SHOW_FAILURE; } show_result("%s", show); restore_ttymodes(); vt_move(max_lines - 1, 1); return MENU_HOLD; }
/* Test User-Preferred Supplemental Set - VT320 */ static int tst_DECRQUPSS(MENU_ARGS) { char *report; const char *show; __(vt_move(1, 1), println("Testing DECRQUPSS/DECAUPSS Window Report")); set_tty_raw(TRUE); set_tty_echo(FALSE); do_csi("&u"); report = get_reply(); vt_move(3, 10); chrprint(report); if ((report = skip_dcs(report)) != 0 && strip_terminator(report)) { if (!strcmp(report, "0!u%5")) show = "DEC Supplemental Graphic"; else if (!strcmp(report, "1!uA")) show = "ISO Latin-1 supplemental"; else show = "unknown"; } else { show = SHOW_FAILURE; } show_result("%s", show); restore_ttymodes(); vt_move(max_lines - 1, 1); return MENU_HOLD; }
/* * Read a soft-character definition string from a file. Strip off garbage * at the beginning (to accommodate the "font2xx" output format). */ void setup_softchars(const char *filename) { FILE *fp; int c; size_t len = 1024; size_t use = 0; char *buffer = (char *) malloc(len); char *s; char *first = 0; char *last = 0; int save_8bits = input_8bits; input_8bits = FALSE; /* use the 7-bit input-parsing */ /* read the file into memory */ if ((fp = fopen(filename, "r")) == 0) { perror(filename); exit(EXIT_FAILURE); } while ((c = fgetc(fp)) != EOF) { if (use + 1 >= len) { buffer = (char *) realloc(buffer, len *= 2); } buffer[use++] = (char) c; } buffer[use] = '\0'; fclose(fp); /* find the DCS that begins the control string */ /* and the ST that ends the control string */ for (s = buffer; *s; s++) { if (first == 0) { if (skip_dcs(s) != 0) first = s; } else { if (!strncmp(s, st_input(), (size_t) 2)) { last = s + 2; *last = '\0'; break; } } } input_8bits = save_8bits; if (first == 0 || last == 0) { fprintf(stderr, "Not a vtXXX font description: %s\n", filename); exit(EXIT_FAILURE); } for (s = buffer; (*s++ = *first++) != '\0';) ; if (LOG_ENABLED && first != 0) fprintf(log_fp, "Font String:\n%s\n", buffer); font_string = buffer; decode_header(); }
/* * Determine the current and maximum operating levels of the terminal */ static void find_levels(void) { char *report; set_tty_raw(TRUE); set_tty_echo(FALSE); da(); report = get_reply(); if (!strcmp(report, "\033/Z")) { cur_level = max_level = 0; /* must be a VT52 */ } else if ((report = skip_csi(report)) == 0 || strncmp(report, "?6", 2) || !isdigit(report[2]) || report[3] != ';') { cur_level = max_level = 1; /* must be a VT100 */ } else { /* "CSI ? 6 x ; ..." */ cur_level = max_level = report[2] - '0'; /* VT220=2, VT320=3, VT420=4 */ if (max_level >= 4) { decrqss("\"p"); report = get_reply(); if ((report = skip_dcs(report)) != 0 && isdigit(*report++) /* 0 or 1 (by observation, though 1 is an err) */ && *report++ == '$' && *report++ == 'r' && *report++ == '6' && isdigit(*report)) cur_level = *report - '0'; } } if (LOG_ENABLED) { fprintf(log_fp, "Max Operating Level: %d\n", max_level); fprintf(log_fp, "Cur Operating Level: %d\n", cur_level); } restore_ttymodes(); }
/* Parse the contents of a report from DECRQSS, returning the data as well */ int parse_decrqss(char *report, const char *func) { int code = -1; char *parse = report; if ((parse = skip_dcs(parse)) != 0 && strip_terminator(parse) && strip_suffix(parse, func)) { if (!strncmp(parse, "1$r", (size_t) 3)) code = 1; else if (!strncmp(parse, "0$r", (size_t) 3)) code = 0; } if (code >= 0) { while ((*report++ = parse[3]) != '\0') parse++; } return code; }
int any_decrqpsr(MENU_ARGS, int Ps) { char *report; vt_move(1, 1); printf("Testing DECRQPSR: %s\n", the_title); set_tty_raw(TRUE); set_tty_echo(FALSE); do_csi("%d$w", Ps); report = get_reply(); vt_move(3, 10); chrprint(report); if ((report = skip_dcs(report)) != 0) { if (strip_terminator(report) && *report == Ps + '0' && !strncmp(report + 1, "$u", (size_t) 2)) { show_result("%s (valid request)", SHOW_SUCCESS); switch (Ps) { case 1: show_DECCIR(report); break; case 2: show_DECTABSR(report); break; } } else { show_result(SHOW_FAILURE); } } else { show_result(SHOW_FAILURE); } restore_ttymodes(); vt_move(max_lines - 1, 1); return MENU_HOLD; }