int scan_any(char *str, int *pos, int toc) { int save = *pos; int value = scanto(str, pos, ';'); if (value == 0) { *pos = save; value = scanto(str, pos, toc); if (str[*pos] != '\0') value = 0; } return value; }
void checkinput(int pro[], int sgte[]) { if (buscar(pro)==0){ volcar(pro,sgte); scanto(volcar(pro,sgte)); } }
static void show_UDK_Status(char *report) { int pos = 0; int code = scanto(report, &pos, 'n'); const char *show; /* *INDENT-OFF* */ switch(code) { case 20: show = "UDKs unlocked"; break; case 21: show = "UDKs locked"; break; default: show = SHOW_FAILURE; } /* *INDENT-ON* */ show_result("%s", show); }
/* * Request CSI 2 $ w tab stop report * Response DCS 2 $ u Pc/Pc/...Pc ST * Pc are column numbers (from 1) where tab stops occur. Note the * separator "/" occurs in a real VT320 but should have been ";". */ static void show_DECTABSR(char *report) { int pos = 3; /* skip "2$u" */ int stop; char *buffer = (char *) malloc(strlen(report)); *buffer = '\0'; strcat(report, "/"); /* simplify scanning */ while ((stop = scanto(report, &pos, '/')) != 0) { sprintf(buffer + strlen(buffer), " %d", stop); } println(""); show_result("Tab stops:%s", buffer); free(buffer); }
static void show_PrinterStatus(char *report) { int pos = 0; int code = scanto(report, &pos, 'n'); const char *show; /* *INDENT-OFF* */ switch (code) { case 13: show = "No printer"; break; case 10: show = "Printer ready"; break; case 11: show = "Printer not ready"; break; case 18: show = "Printer busy"; break; case 19: show = "Printer assigned to other session"; break; default: show = SHOW_FAILURE; } /* *INDENT-ON* */ show_result("%s", show); }
static void show_OperatingStatus(char *report) { int pos = 0; int Ps1 = scan_any(report, &pos, 'n'); int Ps2 = scanto(report, &pos, 'n'); const char *show; switch (Ps1) { case 0: show = "Terminal is in good operating condition"; break; case 3: show = "Terminal has a malfunction"; break; default: show = SHOW_FAILURE; } show_result(show, Ps2); }
static void show_Locator_Status(char *report) { int pos = 0; int code = scanto(report, &pos, 'n'); const char *show; switch (code) { case 53: show = "No locator"; break; case 50: show = "Locator ready"; break; case 58: show = "Locator busy"; break; default: show = SHOW_FAILURE; } show_result("%s", show); }
/* * Request CSI ? 26 n keyboard dialect * Response CSI ? 27; Ps n */ static void show_KeyboardStatus(char *report) { int pos = 0; int code; int save; const char *show = SHOW_FAILURE; if ((code = scanto(report, &pos, ';')) == 27 && (code = scan_any(report, &pos, 'n')) != 0) { /* *INDENT-OFF* */ switch(code) { case 1: show = "North American/ASCII"; break; case 2: show = "British"; break; case 3: show = "Flemish"; break; case 4: show = "French Canadian"; break; case 5: show = "Danish"; break; case 6: show = "Finnish"; break; case 7: show = "German"; break; case 8: show = "Dutch"; break; case 9: show = "Italian"; break; case 10: show = "Swiss (French)"; break; case 11: show = "Swiss (German)"; break; case 12: show = "Swedish"; break; case 13: show = "Norwegian/Danish"; break; case 14: show = "French/Belgian"; break; case 15: show = "Spanish Int."; break; case 16: show = "Portugese"; break; /* vt3XX */ case 19: show = "Hebrew"; break; /* vt5XX: kermit says 14 */ case 22: show = "Greek"; break; /* vt5XX */ case 28: show = "Canadian (English)"; break; /* vt4XX */ case 29: show = "Turkish Q/Turkish"; break; /* vt5XX */ case 30: show = "Turkish F/Turkish"; break; /* vt5XX */ case 31: show = "Hungarian"; break; /* vt5XX */ case 32: show = "Spanish National"; break; /* vt4XX in PC mode */ case 33: show = "Slovak"; break; /* vt5XX */ case 34: show = "Czech"; break; /* vt5XX */ case 35: show = "Polish"; break; /* vt5XX */ case 36: show = "Romanian"; break; /* vt5XX */ case 38: show = "SCS"; break; /* vt5XX */ case 39: show = "Russian"; break; /* vt5XX */ case 40: show = "Latin American"; break; /* vt5XX */ default: show = "unknown"; } /* *INDENT-ON* */ } show_result("%s", show); /* vt420 implements additional parameters past those reported by the VT220 */ save = pos; code = scan_any(report, &pos, 'n'); if (save != pos) { vt_move(5, 10); /* *INDENT-OFF* */ switch(code) { case 0: show = "keyboard ready"; break; case 3: show = "no keyboard"; break; case 8: show = "keyboard busy"; break; default: show = "unknown keyboard status"; } /* *INDENT-ON* */ show_result("%s", show); vt_move(6, 10); /* *INDENT-OFF* */ switch (scan_any(report, &pos, 'n')) { case 0: show = "LK201"; break; case 1: show = "LK401"; break; default: show = "unknown keyboard type"; } /* *INDENT-ON* */ show_result("%s", show); } }
static void show_DECCIR(char *report) { int Pr, Pc, Pp, Srend, Satt, Sflag, Pgl, Pgr, Scss; int pos = 3; /* skip "1$u" */ int n; Pr = scanto(report, &pos, ';'); Pc = scanto(report, &pos, ';'); Pp = scanto(report, &pos, ';'); vt_move(5, 10); show_result("Cursor (%d,%d), page %d", Pr, Pc, Pp); Srend = scan_chr(report, &pos, ';'); vt_move(6, 10); if (Srend & 0x40) { show_DECCIR_flag(Srend, 0x40, "Rendition:"); if (Srend == 0) show_result(" normal"); show_DECCIR_flag(Srend, 0x08, " reverse"); show_DECCIR_flag(Srend, 0x04, " blinking"); show_DECCIR_flag(Srend, 0x02, " underline"); show_DECCIR_flag(Srend, 0x01, " bold"); } if (Srend) show_result(" -> unknown rendition (0x%x)", Srend); Satt = scan_chr(report, &pos, ';'); vt_move(7, 10); switch (Satt) { case 0x40: show_result("Selective erase: off"); break; case 0x41: show_result("Selective erase: ON"); break; default: show_result("Selective erase: unknown (0x%x)", Satt); } Sflag = scan_chr(report, &pos, ';'); vt_move(8, 10); if (Sflag & 0x40) { show_DECCIR_flag(Sflag, 0x40, "Flags:"); show_DECCIR_flag(Sflag, 0x08, " autowrap pending"); show_DECCIR_flag(Sflag, 0x04, " SS3 pending"); show_DECCIR_flag(Sflag, 0x02, " SS2 pending"); show_DECCIR_flag(Sflag, 0x01, " origin-mode on"); } else { show_result(" -> unknown flag (0x%x)", Sflag); } Pgl = scanto(report, &pos, ';'); Pgr = scanto(report, &pos, ';'); vt_move(9, 10); show_result("Char set in GL: G%d, Char set in GR: G%d", Pgl, Pgr); Scss = scan_chr(report, &pos, ';'); vt_move(10, 10); if (Scss & 0x40) { show_DECCIR_flag(Scss, 0x40, "Char set sizes:"); show_DECCIR_flag(Scss, 0x08, " G3 is 96 char"); show_DECCIR_flag(Scss, 0x04, " G2 is 96 char"); show_DECCIR_flag(Scss, 0x02, " G1 is 96 char"); show_DECCIR_flag(Scss, 0x01, " G0 is 96 char"); /* VT420 manual says this cannot happen */ } else { show_result(" -> unknown char set size (0x%x)", Scss); } n = 11; vt_move(n, 10); show_result("Character set idents for G0...G3: "); println(""); while (report[pos] != '\0') { const char *result = parse_Sdesig(report, &pos); show_result(" %s\n", result); println(""); } }