MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / terminal_gettc

Function terminal_gettc

extern/editline/src/terminal.c:1405–1454  ·  view source on GitHub ↗

terminal_gettc(): * Get the current terminal characteristics */

Source from the content-addressed store, hash-verified

1403 * Get the current terminal characteristics
1404 */
1405protected int
1406/*ARGSUSED*/
1407terminal_gettc(EditLine *el, int argc __attribute__((__unused__)), char **argv)
1408{
1409 const struct termcapstr *ts;
1410 const struct termcapval *tv;
1411 char *what;
1412 void *how;
1413
1414 if (argv == NULL || argv[1] == NULL || argv[2] == NULL)
1415 return -1;
1416
1417 what = argv[1];
1418 how = argv[2];
1419
1420 /*
1421 * Do the strings first
1422 */
1423 for (ts = tstr; ts->name != NULL; ts++)
1424 if (strcmp(ts->name, what) == 0)
1425 break;
1426
1427 if (ts->name != NULL) {
1428 *(char **)how = el->el_terminal.t_str[ts - tstr];
1429 return 0;
1430 }
1431 /*
1432 * Do the numeric ones second
1433 */
1434 for (tv = tval; tv->name != NULL; tv++)
1435 if (strcmp(tv->name, what) == 0)
1436 break;
1437
1438 if (tv->name == NULL)
1439 return -1;
1440
1441 if (tv == &tval[T_pt] || tv == &tval[T_km] ||
1442 tv == &tval[T_am] || tv == &tval[T_xn]) {
1443 static char yes[] = "yes";
1444 static char no[] = "no";
1445 if (el->el_terminal.t_val[tv - tval])
1446 *(char **)how = yes;
1447 else
1448 *(char **)how = no;
1449 return 0;
1450 } else {
1451 *(int *)how = el->el_terminal.t_val[tv - tval];
1452 return 0;
1453 }
1454}
1455
1456/* terminal_echotc():
1457 * Print the termcap string out with variable substitution

Callers 2

el_getFunction · 0.85
FUN(el,get)Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected