| 1 |
/* $Id: reports.c,v 1.57 2024/12/05 00:37:39 tom Exp $ */ |
| 2 |
|
| 3 |
#include <vttest.h> |
| 4 |
#include <ttymodes.h> |
| 5 |
#include <esc.h> |
| 6 |
#include <ctype.h> |
| 7 |
/* *INDENT-OFF* */ |
| 8 |
static |
| 9 |
struct table { |
| 10 |
int key; |
| 11 |
const char *msg; |
| 12 |
} paritytable[] = { |
| 13 |
{ 1, "NONE" }, |
| 14 |
{ 4, "ODD" }, |
| 15 |
{ 5, "EVEN" }, |
| 16 |
{ -1, "" } |
| 17 |
},nbitstable[] = { |
| 18 |
{ 1, "8" }, |
| 19 |
{ 2, "7" }, |
| 20 |
{ -1,"" } |
| 21 |
},speedtable[] = { |
| 22 |
{ 0, "50" }, |
| 23 |
{ 8, "75" }, |
| 24 |
{ 16, "110" }, |
| 25 |
{ 24, "134.5"}, |
| 26 |
{ 32, "150" }, |
| 27 |
{ 40, "200" }, |
| 28 |
{ 48, "300" }, |
| 29 |
{ 56, "600" }, |
| 30 |
{ 64, "1200" }, |
| 31 |
{ 72, "1800" }, |
| 32 |
{ 80, "2000" }, |
| 33 |
{ 88, "2400" }, |
| 34 |
{ 96, "3600" }, |
| 35 |
{ 104, "4800" }, |
| 36 |
{ 112, "9600" }, |
| 37 |
{ 120, "19200" }, |
| 38 |
{ 128, "38400" }, |
| 39 |
{ -1, "" } |
| 40 |
},operating_level[] = { |
| 41 |
{ 6, "VT102" }, |
| 42 |
{ 12, "VT125" }, |
| 43 |
{ 61, "VT100 family" }, |
| 44 |
{ 62, "VT200 family" }, |
| 45 |
{ 63, "VT300 family" }, |
| 46 |
{ 64, "VT400 family" }, |
| 47 |
{ 65, "VT500 family" }, |
| 48 |
{ -1, "" } |
| 49 |
},extensions[] = { |
| 50 |
{ 1, "132 columns" }, /* vt400, vt382 */ |
| 51 |
{ 2, "printer port" }, /* vt400, vt382 */ |
| 52 |
{ 3, "ReGIS graphics" }, /* kermit */ |
| 53 |
{ 4, "Sixel graphics" }, /* vt382, kermit */ |
| 54 |
{ 5, "Katakana extension" }, /* vt382 */ |
| 55 |
{ 6, "selective erase" }, /* vt400, vt382 */ |
| 56 |
{ 7, "soft character set (DRCS)" }, /* vt400 */ |
| 57 |
{ 8, "user-defined keys (UDK)" }, /* vt400, vt382 */ |
| 58 |
{ 9, "national replacement character-sets" }, /* kermit */ |
| 59 |
{ 10, "Two-bytes Kanji" }, /* vt382 */ |
| 60 |
{ 11, "25th status line" }, /* ? */ |
| 61 |
{ 12, "Serbo-Croatian (SCS)" }, /* vt500 */ |
| 62 |
{ 13, "local editing mode" }, /* kermit */ |
| 63 |
{ 14, "8-bit architecture" }, /* ? */ |
| 64 |
{ 15, "DEC technical set" }, /* vt400, vt382 */ |
| 65 |
{ 16, "locator device port (ReGIS)" }, /* kermit */ |
| 66 |
{ 17, "terminal state reports" }, /* ? */ |
| 67 |
{ 18, "user windows" }, /* vt400 */ |
| 68 |
{ 19, "two sessions" }, /* vt400 */ |
| 69 |
{ 20, "APL" }, /* vt400? */ |
| 70 |
{ 21, "horizontal scrolling" }, /* vt400 */ |
| 71 |
{ 22, "color" }, /* vt500 */ |
| 72 |
{ 23, "Greek" }, /* vt500 */ |
| 73 |
{ 24, "Turkish" }, /* vt500 */ |
| 74 |
{ 25, "Arabic bilingual M1" }, /* vt400? */ |
| 75 |
{ 26, "Arabic bilingual M2" }, /* vt400? */ |
| 76 |
{ 27, "Arabic bilingual M3" }, /* vt400? */ |
| 77 |
{ 28, "rectangular editing" }, /* vt400 */ |
| 78 |
{ 29, "ANSI text locator" }, /* DXterm */ |
| 79 |
{ 30, "Hanzi" }, /* vt400? */ |
| 80 |
{ 32, "text macros" }, /* vt400? */ |
| 81 |
{ 33, "Hangul Hanja" }, /* vt400? */ |
| 82 |
{ 34, "Icelandic" }, /* vt400? */ |
| 83 |
{ 35, "Arabic bilingual TC" }, /* vt400? */ |
| 84 |
{ 36, "Arabic bilingual no TC" }, /* vt400? */ |
| 85 |
{ 36, "Arabic bilingual no TC" }, /* vt400? */ |
| 86 |
{ 37, "Thai" }, /* vt400? */ |
| 87 |
{ 38, "character outlining" }, /* vt400? */ |
| 88 |
{ 42, "ISO Latin-2" }, /* vt500 */ |
| 89 |
{ 44, "PC Term" }, /* vt500 */ |
| 90 |
{ 45, "soft key mapping" }, /* vt500 */ |
| 91 |
{ 46, "ASCII Terminal emulation (WYSE,TVI,...)" }, /* vt500 */ |
| 92 |
{ -1, "" } |
| 93 |
}; |
| 94 |
/* *INDENT-ON* */ |
| 95 |
|
| 96 |
static int |
| 97 |
legend(int n, const char *input, const char *word, const char *description) |
| 98 |
{ |
| 99 |
int i; |
| 100 |
size_t len = strlen(word); |
| 101 |
char buf[BUF_SIZE]; |
| 102 |
|
| 103 |
for (i = 0; input[i] != 0; i++) { |
| 104 |
if ((i == 0 || !isalpha(CharOf(input[i - 1]))) |
| 105 |
&& !strncmp(word, input + i, len)) { |
| 106 |
sprintf(buf, "%-8s %-3s = %s", n ? "" : "Legend:", word, description); |
| 107 |
show_result("%s", buf); |
| 108 |
putchar('\n'); |
| 109 |
return n + 1; |
| 110 |
} |
| 111 |
} |
| 112 |
return n; |
| 113 |
} |
| 114 |
|
| 115 |
static const char * |
| 116 |
lookup(struct table t[], int k) |
| 117 |
{ |
| 118 |
int i; |
| 119 |
for (i = 0; t[i].key != -1; i++) { |
| 120 |
if (t[i].key == k) |
| 121 |
return (t[i].msg); |
| 122 |
} |
| 123 |
return ("BAD VALUE"); |
| 124 |
} |
| 125 |
|
| 126 |
static void |
| 127 |
report_is(const char *report, int row, int col) |
| 128 |
{ |
| 129 |
const char *tag = "Report is:"; |
| 130 |
vt_move(row, col); |
| 131 |
vt_el(0); |
| 132 |
tprintf("%s", tag); |
| 133 |
chrprint2(report, row, col + (int) strlen(tag)); |
| 134 |
} |
| 135 |
|
| 136 |
/******************************************************************************/ |
| 137 |
|
| 138 |
static int |
| 139 |
tst_DA(MENU_ARGS) |
| 140 |
{ |
| 141 |
int found; |
| 142 |
const char *report, *cmp; |
| 143 |
/* *INDENT-OFF* */ |
| 144 |
static const char *attributes[][2] = { /* after CSI */ |
| 145 |
{ "?1;0c", "No options (vanilla VT100)" }, |
| 146 |
{ "?1;1c", "VT100 with STP" }, |
| 147 |
{ "?1;2c", "VT100 with AVO (could be a VT102)" }, |
| 148 |
{ "?1;3c", "VT100 with STP and AVO" }, |
| 149 |
{ "?1;4c", "VT100 with GPO" }, |
| 150 |
{ "?1;5c", "VT100 with STP and GPO" }, |
| 151 |
{ "?1;6c", "VT100 with AVO and GPO" }, |
| 152 |
{ "?1;7c", "VT100 with STP, AVO and GPO" }, |
| 153 |
{ "?1;11c", "VT100 with PP and AVO" }, |
| 154 |
{ "?1;15c", "VT100 with PP, GPO and AVO" }, |
| 155 |
{ "?2c", "VT102" }, |
| 156 |
{ "?4;2c", "VT132 with AVO" }, |
| 157 |
{ "?4;3c", "VT132 with AVO and STP" }, |
| 158 |
{ "?4;6c", "VT132 with GPO and AVO" }, |
| 159 |
{ "?4;7c", "VT132 with GPO, AVO, and STP" }, |
| 160 |
{ "?4;11c", "VT132 with PP and AVO" }, |
| 161 |
{ "?4;15c", "VT132 with PP, GPO and AVO" }, |
| 162 |
{ "?6c", "VT102" }, |
| 163 |
{ "?7c", "VT131" }, |
| 164 |
{ "?12;5c", "VT125" }, /* VT125 also has ROM version */ |
| 165 |
{ "?12;7c", "VT125 with AVO" }, /* number, so this won't work */ |
| 166 |
{ "?5;0c", "VK100 (GIGI)" }, |
| 167 |
{ "?5c", "VK100 (GIGI)" }, |
| 168 |
{ "?62;1;2;4;6;8;9;15c", "VT220" }, |
| 169 |
{ "?63;1;2;8;9c", "VT320" }, |
| 170 |
{ "?63;1;2;4;6;8;9;15c", "VT320" }, |
| 171 |
{ "?63;1;3;4;6;8;9;15;16;29c", "DXterm" }, |
| 172 |
{ "", "" } |
| 173 |
}; |
| 174 |
/* *INDENT-ON* */ |
| 175 |
|
| 176 |
vt_move(1, 1); |
| 177 |
println("Test of Device Attributes report (what are you)"); |
| 178 |
|
| 179 |
set_tty_raw(TRUE); |
| 180 |
da(); |
| 181 |
report = get_reply(); |
| 182 |
|
| 183 |
report_is(report, 3, 1); |
| 184 |
|
| 185 |
found = FALSE; |
| 186 |
|
| 187 |
if ((cmp = skip_csi_2(report)) != NULL) { |
| 188 |
int i; |
| 189 |
|
| 190 |
for (i = 0; *attributes[i][0] != '\0'; i++) { |
| 191 |
if (!strcmp(cmp, attributes[i][0])) { |
| 192 |
int n = 0; |
| 193 |
show_result(" -- means %s", attributes[i][1]); |
| 194 |
putchar('\n'); |
| 195 |
n = legend(n, attributes[i][1], "STP", "Processor Option"); |
| 196 |
n = legend(n, attributes[i][1], "AVO", "Advanced Video Option"); |
| 197 |
n = legend(n, attributes[i][1], "GPO", "Graphics Processor Option"); |
| 198 |
(void) legend(n, attributes[i][1], "PP", "Printer Port"); |
| 199 |
found = TRUE; |
| 200 |
break; |
| 201 |
} |
| 202 |
} |
| 203 |
} |
| 204 |
|
| 205 |
if (!found) { /* this could be a vt200+ with some options disabled */ |
| 206 |
if (cmp != NULL && *cmp == '?') { |
| 207 |
int reportpos = 1; |
| 208 |
int value = scan_DA(cmp, &reportpos); |
| 209 |
show_result("%s\n", lookup(operating_level, value)); |
| 210 |
putchar('\n'); |
| 211 |
if (value == 12) { |
| 212 |
if ((value = scan_DA(cmp, &reportpos)) >= 0) { |
| 213 |
fputs(" ", stdout); |
| 214 |
switch (value) { |
| 215 |
case 2: |
| 216 |
show_result("no STP, AVO, no GPO (ReGIS)"); |
| 217 |
break; |
| 218 |
case 3: |
| 219 |
show_result("no STP, AVO, GPO (ReGIS)"); |
| 220 |
break; |
| 221 |
case 5: |
| 222 |
show_result("no AVO"); |
| 223 |
break; |
| 224 |
case 7: |
| 225 |
show_result("with AVO"); |
| 226 |
break; |
| 227 |
default: |
| 228 |
printxx("unknown code %d", value); |
| 229 |
break; |
| 230 |
} |
| 231 |
putchar('\n'); |
| 232 |
} |
| 233 |
if ((value = scan_DA(cmp, &reportpos)) >= 0) { |
| 234 |
fputs(" ", stdout); |
| 235 |
switch (value) { |
| 236 |
case 0: |
| 237 |
show_result("no printer"); |
| 238 |
break; |
| 239 |
case 1: |
| 240 |
show_result("with printer"); |
| 241 |
break; |
| 242 |
default: |
| 243 |
printxx("unknown code %d", value); |
| 244 |
break; |
| 245 |
} |
| 246 |
putchar('\n'); |
| 247 |
} |
| 248 |
if ((value = scan_DA(cmp, &reportpos)) >= 0) { |
| 249 |
tprintf(" ROM version %d", value); |
| 250 |
putchar('\n'); |
| 251 |
} |
| 252 |
} else { |
| 253 |
while ((value = scan_DA(cmp, &reportpos)) >= 0) { |
| 254 |
fputs(" ", stdout); |
| 255 |
show_result("%d = %s\n", value, lookup(extensions, value)); |
| 256 |
putchar('\n'); |
| 257 |
} |
| 258 |
} |
| 259 |
found = TRUE; |
| 260 |
} |
| 261 |
} |
| 262 |
if (!found) |
| 263 |
show_result(" -- Unknown response, refer to the manual"); |
| 264 |
|
| 265 |
restore_ttymodes(); |
| 266 |
|
| 267 |
vt_move(max_lines - 1, 1); |
| 268 |
return MENU_HOLD; |
| 269 |
} |
| 270 |
|
| 271 |
/* |
| 272 |
* Applies to VT220 & up (probably no VT100's). |
| 273 |
* Expected reply (from VT420 manual): |
| 274 |
* CSI > 4 1 ; Pv ; 0 c (Pv = firmware version) |
| 275 |
* From kermit: |
| 276 |
* CSI > 2 4 ; Pv ; 0 c (Pv = "0 ; 0 ; 0", for "0.0") |
| 277 |
* I've seen also: |
| 278 |
* CSI > 8 3 ; Pv ; 0 c (e.g., Pv = "3 0 7 0 1") |
| 279 |
*/ |
| 280 |
static int |
| 281 |
tst_DA_2(MENU_ARGS) |
| 282 |
{ |
| 283 |
int row, col; |
| 284 |
/* *INDENT-OFF* */ |
| 285 |
static const struct { |
| 286 |
int Pp; |
| 287 |
const char *name; |
| 288 |
} tbl[] = { |
| 289 |
{ 1, "VT220" }, |
| 290 |
{ 2, "VT240" }, |
| 291 |
{ 18, "VT330" }, |
| 292 |
{ 19, "VT340" }, |
| 293 |
{ 24, "VT320" }, |
| 294 |
{ 32, "VT382" }, /* EK-VT382-RM-001, page 11-5 */ |
| 295 |
{ 48, "VT382" }, /* EK-VT38T-UG-001, page C-40 */ |
| 296 |
{ 28, "DECterm" }, |
| 297 |
{ 41, "VT420" }, |
| 298 |
{ 61, "VT510" }, |
| 299 |
{ 64, "VT520" }, |
| 300 |
{ 65, "VT525" }, |
| 301 |
}; |
| 302 |
/* *INDENT-ON* */ |
| 303 |
|
| 304 |
char *report; |
| 305 |
int Pp, Pv, Pc; |
| 306 |
char ch; |
| 307 |
const char *show = SHOW_FAILURE; |
| 308 |
|
| 309 |
vt_move(1, 1); |
| 310 |
println("Testing Secondary Device Attributes (Firmware version)"); |
| 311 |
|
| 312 |
set_tty_raw(TRUE); |
| 313 |
do_csi(">c"); /* or "CSI > 0 c" */ |
| 314 |
report = get_reply(); |
| 315 |
|
| 316 |
vt_move(row = 3, col = 10); |
| 317 |
chrprint2(report, row, col); |
| 318 |
|
| 319 |
if ((report = skip_csi(report)) != NULL) { |
| 320 |
if (sscanf(report, ">%d;%d;%d%c", &Pp, &Pv, &Pc, &ch) == 4 |
| 321 |
&& ch == 'c') { |
| 322 |
const char *name = "unknown"; |
| 323 |
size_t n; |
| 324 |
|
| 325 |
show = SHOW_SUCCESS; |
| 326 |
for (n = 0; n < TABLESIZE(tbl); n++) { |
| 327 |
if (Pp == tbl[n].Pp) { |
| 328 |
name = tbl[n].name; |
| 329 |
break; |
| 330 |
} |
| 331 |
} |
| 332 |
vt_move(4, 10); |
| 333 |
printxx("Pp=%d (%s)", Pp, name); |
| 334 |
|
| 335 |
vt_move(5, 10); |
| 336 |
printxx("Pv=%d, firmware version %d.%d", Pv, Pv / 10, Pv % 10); |
| 337 |
|
| 338 |
vt_move(6, 10); |
| 339 |
switch (Pp) { |
| 340 |
case 64: |
| 341 |
case 65: |
| 342 |
printxx("Pc=%d, %s keyboard", Pc, Pc ? "PC" : "VT"); |
| 343 |
break; |
| 344 |
default: |
| 345 |
printxx("Pc=%d, ROM cartridge registration number", Pc); |
| 346 |
break; |
| 347 |
} |
| 348 |
} |
| 349 |
} |
| 350 |
show_result("%s", show); |
| 351 |
|
| 352 |
restore_ttymodes(); |
| 353 |
|
| 354 |
vt_move(max_lines - 1, 1); |
| 355 |
return MENU_HOLD; |
| 356 |
} |
| 357 |
|
| 358 |
/* |
| 359 |
* VT400 (reply is a hexadecimal string) |
| 360 |
*/ |
| 361 |
static int |
| 362 |
tst_DA_3(MENU_ARGS) |
| 363 |
{ |
| 364 |
int row, col; |
| 365 |
char *report; |
| 366 |
const char *show; |
| 367 |
|
| 368 |
vt_move(1, 1); |
| 369 |
println("Testing Tertiary Device Attributes (unit ID)"); |
| 370 |
|
| 371 |
set_tty_raw(TRUE); |
| 372 |
do_csi("=c"); /* or "CSI = 0 c" */ |
| 373 |
report = get_reply(); |
| 374 |
|
| 375 |
vt_move(row = 3, col = 10); |
| 376 |
chrprint2(report, row, col); |
| 377 |
show = SHOW_FAILURE; |
| 378 |
if (report == NULL || *report == '\0') { |
| 379 |
if (get_level() < 4) /* vt420 and up support this */ |
| 380 |
show = "not supported"; |
| 381 |
} else { |
| 382 |
char *content; |
| 383 |
if ((content = skip_dcs(report)) != NULL |
| 384 |
&& strip_terminator(content) != 0 |
| 385 |
&& *content++ == '!' |
| 386 |
&& *content++ == '|' |
| 387 |
&& strlen(content) != 0) { |
| 388 |
char *check; |
| 389 |
if (strlen(content) == 8) { |
| 390 |
(void) strtol(content, &check, 16); |
| 391 |
if (*check == '\0') |
| 392 |
show = SHOW_SUCCESS; |
| 393 |
} |
| 394 |
} |
| 395 |
} |
| 396 |
show_result("%s", show); |
| 397 |
|
| 398 |
restore_ttymodes(); |
| 399 |
|
| 400 |
vt_move(max_lines - 1, 1); |
| 401 |
return MENU_HOLD; |
| 402 |
} |
| 403 |
|
| 404 |
/* Not supported above VT320 */ |
| 405 |
static int |
| 406 |
tst_DECREQTPARM(MENU_ARGS) |
| 407 |
{ |
| 408 |
char *report, *report2, *cmp; |
| 409 |
|
| 410 |
set_tty_raw(TRUE); |
| 411 |
set_tty_echo(FALSE); |
| 412 |
|
| 413 |
vt_move(2, 1); |
| 414 |
println("Test of the \"Request Terminal Parameters\" feature, argument 0."); |
| 415 |
|
| 416 |
vt_move(3, 1); |
| 417 |
decreqtparm(0); |
| 418 |
report = get_reply(); |
| 419 |
|
| 420 |
report_is(report, 5, 1); |
| 421 |
|
| 422 |
if ((cmp = skip_csi(report)) != NULL) |
| 423 |
report = cmp; |
| 424 |
|
| 425 |
if (strlen(report) < 14 |
| 426 |
|| report[0] != '2' |
| 427 |
|| report[1] != ';') |
| 428 |
println(" -- Bad format"); |
| 429 |
else { |
| 430 |
int reportpos = 2; |
| 431 |
/* *INDENT-EQLS* */ |
| 432 |
int parity = scanto(report, &reportpos, ';'); |
| 433 |
int nbits = scanto(report, &reportpos, ';'); |
| 434 |
int xspeed = scanto(report, &reportpos, ';'); |
| 435 |
int rspeed = scanto(report, &reportpos, ';'); |
| 436 |
int clkmul = scanto(report, &reportpos, ';'); |
| 437 |
int flags = scanto(report, &reportpos, 'x'); |
| 438 |
|
| 439 |
if (parity <= 0 || nbits <= 0 || clkmul <= 0) |
| 440 |
println(" -- Bad format"); |
| 441 |
else |
| 442 |
println(" -- OK"); |
| 443 |
|
| 444 |
show_result( |
| 445 |
"This means: Parity %s, %s bits, xmitspeed %s, recvspeed %s.\n", |
| 446 |
lookup(paritytable, parity), |
| 447 |
lookup(nbitstable, nbits), |
| 448 |
lookup(speedtable, xspeed), |
| 449 |
lookup(speedtable, rspeed)); |
| 450 |
show_result("(CLoCk MULtiplier = %d, STP option flags = %d)\n", clkmul, flags); |
| 451 |
} |
| 452 |
|
| 453 |
vt_move(10, 1); |
| 454 |
println("Test of the \"Request Terminal Parameters\" feature, argument 1."); |
| 455 |
|
| 456 |
vt_move(11, 1); |
| 457 |
decreqtparm(1); /* Does the same as decreqtparm(0), reports "3" */ |
| 458 |
report2 = get_reply(); |
| 459 |
|
| 460 |
report_is(report2, 13, 1); |
| 461 |
|
| 462 |
if ((cmp = skip_csi(report2)) != NULL) |
| 463 |
report2 = cmp; |
| 464 |
|
| 465 |
if (strlen(report2) < 1 |
| 466 |
|| report2[0] != '3') |
| 467 |
println(" -- Bad format"); |
| 468 |
else { |
| 469 |
report2[0] = '2'; |
| 470 |
if (!strcmp(report, report2)) |
| 471 |
println(" -- OK"); |
| 472 |
else |
| 473 |
println(" -- Bad format"); |
| 474 |
} |
| 475 |
vt_move(max_lines, 1); |
| 476 |
|
| 477 |
restore_ttymodes(); |
| 478 |
return MENU_HOLD; |
| 479 |
} |
| 480 |
|
| 481 |
static int |
| 482 |
tst_DSR(MENU_ARGS) |
| 483 |
{ |
| 484 |
int found; |
| 485 |
int origin; |
| 486 |
int row, col; |
| 487 |
char *report; |
| 488 |
const char *cmp; |
| 489 |
|
| 490 |
set_tty_raw(TRUE); |
| 491 |
|
| 492 |
vt_move(1, 1); |
| 493 |
printxx("Test of Device Status Report 5 (report terminal status)."); |
| 494 |
|
| 495 |
vt_move(row = 2, col = 1); |
| 496 |
dsr(5); |
| 497 |
report = get_reply(); |
| 498 |
|
| 499 |
report_is(report, row, col); |
| 500 |
|
| 501 |
if ((cmp = skip_csi(report)) != NULL) |
| 502 |
found = !strcmp(cmp, "0n") || !strcmp(cmp, "3n"); |
| 503 |
else |
| 504 |
found = 0; |
| 505 |
|
| 506 |
if (found) |
| 507 |
show_result(" -- means \"TERMINAL OK\""); |
| 508 |
else |
| 509 |
show_result(" -- Unknown response!"); |
| 510 |
|
| 511 |
vt_move(4, 1); |
| 512 |
println("Test of Device Status Report 6 (report cursor position)."); |
| 513 |
|
| 514 |
for (origin = 0; origin < 2; ++origin) { |
| 515 |
if (origin) { |
| 516 |
sm("?6"); |
| 517 |
decstbm(4, max_lines - 6); |
| 518 |
} |
| 519 |
vt_move(row = 5, col = 1); |
| 520 |
dsr(6); |
| 521 |
report = get_reply(); |
| 522 |
|
| 523 |
report_is(report, row, col); |
| 524 |
|
| 525 |
if ((cmp = skip_csi(report)) != NULL) { |
| 526 |
found = (!strcmp(cmp, "5;1R") |
| 527 |
? 1 |
| 528 |
: ((!strcmp(cmp, "8;1R") && origin) |
| 529 |
? 2 |
| 530 |
: 0)); |
| 531 |
} else { |
| 532 |
found = 0; |
| 533 |
} |
| 534 |
|
| 535 |
switch (found) { |
| 536 |
case 2: |
| 537 |
show_result(" -- Ignores origin mode"); |
| 538 |
break; |
| 539 |
case 1: |
| 540 |
show_result(" -- OK"); |
| 541 |
break; |
| 542 |
default: |
| 543 |
show_result(" -- Unknown response!"); |
| 544 |
break; |
| 545 |
} |
| 546 |
} |
| 547 |
|
| 548 |
rm("?6"); |
| 549 |
decstbm(0, 0); |
| 550 |
|
| 551 |
vt_move(max_lines - 1, 1); |
| 552 |
restore_ttymodes(); |
| 553 |
return MENU_HOLD; |
| 554 |
} |
| 555 |
|
| 556 |
static int |
| 557 |
tst_ENQ(MENU_ARGS) |
| 558 |
{ |
| 559 |
int row, col; |
| 560 |
const char *report; |
| 561 |
|
| 562 |
vt_move(5, 1); |
| 563 |
println("This is a test of the ANSWERBACK MESSAGE. (To load the A.B.M."); |
| 564 |
println("see the TEST KEYBOARD part of this program). Below here, the"); |
| 565 |
println("current answerback message in your terminal should be"); |
| 566 |
println("displayed. Finish this test with RETURN."); |
| 567 |
|
| 568 |
vt_move(10, 1); |
| 569 |
|
| 570 |
set_tty_raw(TRUE); |
| 571 |
set_tty_echo(FALSE); |
| 572 |
inflush(); |
| 573 |
tprintf("%c", 5); /* ENQ */ |
| 574 |
report = get_reply(); |
| 575 |
|
| 576 |
vt_move(row = 10, col = 1); |
| 577 |
chrprint2(report, row, col); |
| 578 |
|
| 579 |
vt_move(12, 1); |
| 580 |
|
| 581 |
restore_ttymodes(); |
| 582 |
return MENU_HOLD; |
| 583 |
} |
| 584 |
|
| 585 |
static int |
| 586 |
tst_NLM(MENU_ARGS) |
| 587 |
{ |
| 588 |
int row, col; |
| 589 |
const char *report; |
| 590 |
|
| 591 |
vt_move(1, 1); |
| 592 |
println("Test of LineFeed/NewLine mode."); |
| 593 |
|
| 594 |
vt_move(3, 1); |
| 595 |
sm("20"); |
| 596 |
set_tty_crmod(FALSE); |
| 597 |
tprintf("NewLine mode set. Push the RETURN key: "); |
| 598 |
report = instr(); |
| 599 |
|
| 600 |
vt_move(row = 4, col = 1); |
| 601 |
vt_el(0); |
| 602 |
chrprint2(report, row, col); |
| 603 |
|
| 604 |
if (!strcmp(report, "\015\012")) |
| 605 |
show_result(" -- OK"); |
| 606 |
else |
| 607 |
show_result(" -- Not expected"); |
| 608 |
|
| 609 |
vt_move(6, 1); |
| 610 |
rm("20"); |
| 611 |
tprintf("NewLine mode reset. Push the RETURN key: "); |
| 612 |
report = instr(); |
| 613 |
|
| 614 |
vt_move(row = 7, col = 1); |
| 615 |
vt_el(0); |
| 616 |
chrprint2(report, row, col); |
| 617 |
|
| 618 |
if (!strcmp(report, "\015")) |
| 619 |
show_result(" -- OK"); |
| 620 |
else |
| 621 |
show_result(" -- Not expected"); |
| 622 |
|
| 623 |
vt_move(9, 1); |
| 624 |
|
| 625 |
restore_ttymodes(); |
| 626 |
return MENU_HOLD; |
| 627 |
} |
| 628 |
|
| 629 |
/******************************************************************************/ |
| 630 |
int |
| 631 |
tst_reports(MENU_ARGS) |
| 632 |
{ |
| 633 |
/* *INDENT-OFF* */ |
| 634 |
static MENU my_menu[] = { |
| 635 |
{ "Exit", NULL }, |
| 636 |
{ "<ENQ> (AnswerBack Message)", tst_ENQ }, |
| 637 |
{ "Set/Reset Mode - LineFeed / Newline", tst_NLM }, |
| 638 |
{ "Device Status Report (DSR) VT100 & up", tst_DSR }, |
| 639 |
{ "Primary Device Attributes (DA) VT100 & up", tst_DA }, |
| 640 |
{ "Secondary Device Attributes (DA) VT220 & up", tst_DA_2 }, |
| 641 |
{ "Tertiary Device Attributes (DA) VT420", tst_DA_3 }, |
| 642 |
{ "Request Terminal Parameters (DECREQTPARM) VT100", tst_DECREQTPARM }, |
| 643 |
{ "", NULL } |
| 644 |
}; |
| 645 |
/* *INDENT-ON* */ |
| 646 |
|
| 647 |
do { |
| 648 |
vt_clear(2); |
| 649 |
__(title(0), printxx("Terminal Reports/Responses")); |
| 650 |
__(title(2), println("Choose test type:")); |
| 651 |
} while (menu(my_menu)); |
| 652 |
return MENU_NOHOLD; |
| 653 |
} |