📄 tack.c
字号:
** tty_show_state()**** Display the current state on the tty driver settings*/static voidtty_show_state( struct test_menu *menu GCC_UNUSED){ put_crlf(); (void) sprintf(temp, "Accepting %d bits, UNIX delays %d, XON/XOFF %sabled, speed %ld, translate %s, scan-code mode %s.", (char_mask == ALLOW_PARITY) ? 8 : 7, select_delay_type, select_xon_xoff ? "en" : "dis", tty_baud_rate, translate_mode ? "on" : "off", scan_mode ? "on" : "off"); ptextln(temp); put_crlf();}/*** tty_width(testlist, state, ch)**** Change the character width*/static voidtty_width( struct test_list *t GCC_UNUSED, int *state GCC_UNUSED, int *ch GCC_UNUSED){ if (char_mask == STRIP_PARITY) { char_mask = ALLOW_PARITY; strcpy(tty_width_menu, "7) treat terminal as 7-bit"); } else { char_mask = STRIP_PARITY; strcpy(tty_width_menu, "8) treat terminal as 8-bit"); }}/*** tty_delay(testlist, state, ch)**** Change the delay for <cr><lf> in the TTY driver*/static voidtty_delay( struct test_list *t GCC_UNUSED, int *state GCC_UNUSED, int *ch GCC_UNUSED){ if (select_delay_type) { select_delay_type = FALSE; strcpy(tty_delay_menu, "d) enable UNIX tty driver delays for <cr><lf>"); } else { select_delay_type = TRUE; strcpy(tty_delay_menu, "d) disable UNIX tty driver delays for <cr><lf>"); }}/*** tty_xon(testlist, state, ch)**** Change the XON/XOFF flags in the TTY driver*/static voidtty_xon( struct test_list *t GCC_UNUSED, int *state GCC_UNUSED, int *ch GCC_UNUSED){ if (select_xon_xoff) { if (needs_xon_xoff) { ptextln("This terminal is marked as needing XON/XOFF protocol with (nxon)"); } if (exit_xon_mode) { tc_putp(exit_xon_mode); } xon_xoff = select_xon_xoff = FALSE; strcpy(tty_xon_menu, enable_xon_xoff); } else { if (enter_xon_mode) { tc_putp(enter_xon_mode); } xon_xoff = select_xon_xoff = TRUE; strcpy(tty_xon_menu, disable_xon_xoff); } tty_set();}/*** tty_trans(testlist, state, ch)**** Change the translation mode for special characters*/static voidtty_trans( struct test_list *t GCC_UNUSED, int *state GCC_UNUSED, int *ch GCC_UNUSED){ if (translate_mode) { translate_mode = FALSE; strcpy(tty_trans_menu, "t) use terminfo values for \\b\\f\\n\\r\\t"); } else { translate_mode = TRUE; strcpy(tty_trans_menu, "t) override terminfo values for \\b\\f\\n\\r\\t"); }}/*** pad_gen(testlist, state, ch)**** Menu function for automatic pad generation*/static voidpad_gen( struct test_list *t, int *state GCC_UNUSED, int *ch){ control_init(); if (tty_can_sync == SYNC_NOT_TESTED) { verify_time(); } auto_pad_mode = TRUE; menu_display(t->sub_menu, ch); auto_pad_mode = FALSE;}/*** start_modes(testlist, state, ch)**** Change the TTY modes*/static voidstart_modes( struct test_list *t GCC_UNUSED, int *state GCC_UNUSED, int *ch GCC_UNUSED){ if (select_delay_type) { strcpy(tty_delay_menu, "d) disable UNIX tty driver delays for <cr><lf>"); } else { strcpy(tty_delay_menu, "d) enable UNIX tty driver delays for <cr><lf>"); } if (char_mask == ALLOW_PARITY) { strcpy(tty_width_menu, "7) treat terminal as 7-bit"); } else { strcpy(tty_width_menu, "8) treat terminal as 8-bit"); } if (select_xon_xoff) { strcpy(tty_xon_menu, disable_xon_xoff); } else { strcpy(tty_xon_menu, enable_xon_xoff); } if (translate_mode) { strcpy(tty_trans_menu, "t) override terminfo values for \\b\\f\\n\\r\\t"); } else { strcpy(tty_trans_menu, "t) use terminfo values for \\b\\f\\n\\r\\t"); } menu_display(&tty_menu, 0); tty_set();}/*** start_basic(testlist, state, ch)**** Display basic terminal information*/static voidstart_basic( struct test_list *t GCC_UNUSED, int *state GCC_UNUSED, int *ch){ display_basic(); *ch = REQUEST_PROMPT;}/*** start_log(testlist, state, ch)**** Start/stop in logging function*/static voidstart_log( struct test_list *t GCC_UNUSED, int *state GCC_UNUSED, int *ch GCC_UNUSED){ if (logging_menu_entry[5] == 'a') { ptextln("The log file will capture all characters sent to the terminal."); if ((log_fp = fopen("tack.log", "w"))) { ptextln("Start logging to file: tack.log"); strcpy(logging_menu_entry, "l) stop logging"); } else { ptextln("File open error: tack.log"); } } else { if (log_fp) { fclose(log_fp); log_fp = 0; } ptextln("Terminal output logging stopped."); strcpy(logging_menu_entry, "l) start logging"); }}/*** show_usage()**** Tell the user how its done.*/voidshow_usage( char *name){ (void) fprintf(stderr, "usage: %s [-itV] [term]\n", name);}/*** print_version()**** Print version and other useful information.*/voidprint_version(void){ printf("tack version %d.%02d\n", MAJOR_VERSION, MINOR_VERSION); printf("Copyright (C) 1997 Free Software Foundation, Inc.\n"); printf("Tack comes with NO WARRANTY, to the extent permitted by law.\n"); printf("You may redistribute copies of Tack under the terms of the\n"); printf("GNU General Public License. For more information about\n"); printf("these matters, see the file named COPYING.\n");}/***************************************************************************** * * Main sequence * *****************************************************************************/intmain(int argc, char *argv[]){ int i, j; char *term_variable; /* scan the option flags */ send_reset_init = TRUE; translate_mode = FALSE; term_variable = getenv("TERM"); tty_can_sync = SYNC_NOT_TESTED; for (i = 1; i < argc; i++) { if (argv[i][0] == '-') { for (j = 1; argv[i][j]; j++) { switch (argv[i][j]) { case 'V': print_version(); return (1); case 'i': send_reset_init = FALSE; break; case 't': translate_mode = FALSE; break; default: show_usage(argv[0]); return (0); } } } else { term_variable = argv[i]; } } (void) strcpy(tty_basename, term_variable); curses_setup(argv[0]); menu_can_scan(&normal_menu); /* extract which caps can be tested */ menu_display(&start_menu, 0); if (user_modified()) { sprintf(temp, "Hit y to save changes to file: %s ? ", tty_basename); ptext(temp); if (wait_here() == 'y') { save_info(write_terminfo_list, &i, &j); } } put_str("\nTerminal test complete\n"); bye_kids(0); return (0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -