11927Swollman/* 21927Swollman** Copyright (C) 1991, 1997 Free Software Foundation, Inc. 31927Swollman** 41927Swollman** This file is part of TACK. 51927Swollman** 61927Swollman** TACK is free software; you can redistribute it and/or modify 71927Swollman** it under the terms of the GNU General Public License as published by 81927Swollman** the Free Software Foundation; either version 2, or (at your option) 91927Swollman** any later version. 101927Swollman** 111927Swollman** TACK is distributed in the hope that it will be useful, 121927Swollman** but WITHOUT ANY WARRANTY; without even the implied warranty of 131927Swollman** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 141927Swollman** GNU General Public License for more details. 151927Swollman** 161927Swollman** You should have received a copy of the GNU General Public License 171927Swollman** along with TACK; see the file COPYING. If not, write to 181927Swollman** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 191927Swollman** Boston, MA 02110-1301, USA 201927Swollman*/ 211927Swollman 221927Swollman/* $Id: tack.h,v 1.14 2005/09/17 19:49:16 tom Exp $ */ 231927Swollman 241927Swollman#ifndef NCURSES_TACK_H_incl 251927Swollman#define NCURSES_TACK_H_incl 1 261927Swollman 271927Swollman/* terminfo action checker include file */ 281927Swollman 291927Swollman#define MAJOR_VERSION 1 301927Swollman#define MINOR_VERSION 1 318857Srgrimes 321927Swollman#ifdef HAVE_CONFIG_H 331927Swollman#include <ncurses_cfg.h> 341927Swollman#else 351927Swollman#define RETSIGTYPE void 368091Swpaul#define GCC_UNUSED /*nothing*/ 371927Swollman#define HAVE_GETTIMEOFDAY 1 381927Swollman#define HAVE_SELECT 1 391927Swollman#define HAVE_SYS_TIME_H 1 401927Swollman#define HAVE_SYS_TIME_SELECT 1 411927Swollman#endif 428091Swpaul 431927Swollman#include <sys/types.h> 446478Swpaul#include <stdlib.h> 451927Swollman#include <unistd.h> 461927Swollman#include <ctype.h> 471927Swollman#include <string.h> 481927Swollman 491927Swollman#include <curses.h> 501927Swollman#include <term_entry.h> 511927Swollman 521927Swollman#if USE_RCS_IDS 531927Swollman#define MODULE_ID(id) static const char Ident[] = id; 546732Swpaul#else 551927Swollman#define MODULE_ID(id) /*nothing*/ 561927Swollman#endif 571927Swollman 581927Swollman#if !HAVE_STRSTR 591927Swollmanextern char *_nc_strstr(const char *, const char *); 608091Swpaul#define strstr(h,n) _nc_strstr(h,n) 611927Swollman#endif 621927Swollman 631927Swollman#define UChar(c) ((unsigned char)(c)) 641927Swollman 651927Swollmanextern FILE *log_fp; 661927Swollmanextern FILE *debug_fp; 671927Swollmanextern int debug_level; 688474Swpaulextern char temp[]; 698474Swpaulextern char tty_basename[]; 708474Swpaulextern char tty_shortname[]; 718474Swpaul 721927Swollman#define SYNC_FAILED 0 731927Swollman#define SYNC_TESTED 1 741927Swollman#define SYNC_NOT_TESTED 2 751927Swollman#define SYNC_NEEDED 3 761927Swollman 771927Swollmanextern int tty_can_sync; 781927Swollmanextern int total_pads_sent; /* count pad characters sent */ 798755Swpaulextern int total_caps_sent; /* count caps sent */ 808755Swpaulextern int total_printing_characters; /* count printing characters sent */ 818091Swpaulextern int no_alarm_event; /* TRUE if the alarm has not gone off yet */ 821927Swollmanextern unsigned long usec_run_time; /* length of last test in microseconds */ 831927Swollmanextern int raw_characters_sent; /* Total output characters */ 848755Swpaul 858755Swpaul/* Stopwatch event timers */ 868755Swpaul#define TIME_TEST 0 878755Swpaul#define TIME_SYNC 1 881927Swollman#define TIME_FLUSH 2 891927Swollman#define MAX_TIMERS 3 901927Swollman 911927Swollman/* definitions for pad.c */ 928091Swpaul 938091Swpaul#define EXIT_CONDITION (no_alarm_event && (tt_delay_used < tt_delay_max)) 948755Swpaul#define SLOW_TERMINAL_EXIT if (!test_complete && !EXIT_CONDITION) { break; } 958091Swpaul#define CAP_NOT_FOUND if (auto_pad_mode) return 968091Swpaul 978425Swpaulextern char letters[26+1]; 988755Swpaul#define NEXT_LETTER letter = letters[letter_number =\ 998853Swpaul letters[letter_number + 1] ? letter_number + 1 : 0] 1008425Swpaul 1018425Swpaulextern int test_complete; /* counts number of tests completed */ 1028091Swpaulextern char letter; 1031927Swollmanextern int letter_number; 1041927Swollmanextern int augment, repeats; 1058755Swpaulextern long char_sent; 1061927Swollmanextern const char *pad_repeat_test; /* commands that force repeat */ 1071927Swollman 1081927Swollmanextern int replace_mode; 1091927Swollmanextern int char_count, line_count, expand_chars; 1101927Swollmanextern int can_go_home, can_clear_screen; 1116732Swpaul 1126732Swpaulextern int translate_mode, scan_mode; 1138091Swpaulextern int auto_pad_mode; /* TRUE for auto time tests */ 1148755Swpaulextern int char_mask; 1158091Swpaulextern int hex_out; /* Display output in hex */ 1168755Swpaul 1178425Swpaul/* Parity bit macros */ 1188755Swpaul#define STRIP_PARITY 0x7f 1198425Swpaul#define ALLOW_PARITY 0xff 1208755Swpaul 1218755Swpaul/* select_delay_type: 0 -> reset all delays 1228425Swpaul 1 -> force long delays 1238755Swpaul 2 -> do not change the delays */ 1248425Swpaulextern int select_delay_type; 1258425Swpaul 1268091Swpaul/* select_xon_xoff: 0 -> reset xon/xoff 1278425Swpaul 1 -> set xon/xoff 1288474Swpaul 2 -> do not change xon/xoff */ 1298755Swpaulextern int select_xon_xoff; 1308091Swpaul 1311927Swollmanextern int tty_frame_size; 1321927Swollmanextern unsigned tty_baud_rate; 1331927Swollmanextern unsigned long tty_cps; /* The number of characters per second */ 1341927Swollmanextern int not_a_tty, nodelay_read; 1351927Swollmanextern int send_reset_init; 1361927Swollman 1371927Swollman/* definitions for stty_query() and initial_stty_query() */ 1381927Swollman#define TTY_CHAR_MODE 0 1391927Swollman#define TTY_NOECHO 1 1401927Swollman#define TTY_OUT_TRANS 2 1411927Swollman#define TTY_8_BIT 3 1421927Swollman#define TTY_XON_XOFF 4 1431927Swollman 1441927Swollman/* scan code definitions */ 1451927Swollman#define MAX_SCAN 256 1461927Swollman 1471927Swollman/* translate mode default strings */ 1481927Swollmanstruct default_string_list { 1491927Swollman const char *name; /* terminfo name */ 1501927Swollman const char *value; /* value of default string */ 1511927Swollman int index; /* index into the strfname[] array */ 1521927Swollman}; 1531927Swollman 1541927Swollman#define TM_last 8 1551927Swollmanextern struct default_string_list TM_string[TM_last]; 1561927Swollman 1577982Swpaul/* attribute structure definition */ 1581927Swollmanstruct mode_list { 1598755Swpaul const char *name; 1601927Swollman const char *begin_mode; 1611927Swollman const char *end_mode; 1628755Swpaul int number; 1631927Swollman}; 1641927Swollman 1658474Swpaulextern const struct mode_list alt_modes[]; 1668425Swpaulextern const int mode_map[]; 1678425Swpaul 1688425Swpaul/* Test data base */ 1698428Swpaul 1708425Swpaul#define FLAG_CAN_TEST 1 1711927Swollman#define FLAG_TESTED 2 1728857Srgrimes#define FLAG_LABEL 4 1738246Swpaul#define FLAG_FUNCTION_KEY 8 1748246Swpaul 1758428Swpaul/* caps under test data base */ 1768246Swpaul 1771927Swollman#define TT_MAX 8 1781927Swollman#define MAX_CHANGES (TT_MAX+2) 1791927Swollman 1801927Swollmanextern int tt_delay_max; /* max number of milliseconds we can delay */ 1818091Swpaulextern int tt_delay_used; /* number of milliseconds consumed in delay */ 1821927Swollmanextern const char *tt_cap[TT_MAX]; /* value of string */ 1838425Swpaulextern int tt_affected[TT_MAX]; /* lines or columns effected (repetition 1848425Swpaul factor) */ 1851927Swollmanextern int tt_count[TT_MAX]; /* Number of times sent */ 1861927Swollmanextern int tt_delay[TT_MAX]; /* Number of milliseconds delay */ 1871927Swollmanextern int ttp; /* number of entries used */ 1888425Swpaul 1891927Swollmanextern const char *tx_cap[TT_MAX]; /* value of string */ 1901927Swollmanextern int tx_affected[TT_MAX]; /* lines or columns effected (repetition 1918755Swpaul factor) */ 1927982Swpaulextern int tx_count[TT_MAX]; /* Number of times sent */ 1938755Swpaulextern int tx_delay[TT_MAX]; /* Number of milliseconds delay */ 1941927Swollmanextern int tx_index[TT_MAX]; /* String index */ 1951927Swollmanextern int txp; /* number of entries used */ 1968246Swpaulextern int tx_characters; /* printing characters sent by test */ 1971927Swollmanextern unsigned long tx_cps; /* characters per second */ 1981927Swollman 1991927Swollman/* 2008091Swpaul Menu control for tack. 2011927Swollman*/ 2021927Swollman 2031927Swollmanstruct test_results { 2041927Swollman struct test_results *next; /* point to next entry */ 2051927Swollman struct test_list *test; /* Test which got these results */ 2061927Swollman int reps; /* repeat count */ 2078755Swpaul int delay; /* delay times 10 */ 2081927Swollman}; 2091927Swollman 2101927Swollmanstruct test_list { 2111927Swollman int flags; /* Test description flags */ 2121927Swollman int lines_needed; /* Lines needed for test (0->no action) */ 2131927Swollman const char *caps_done; /* Caps shown in Done message */ 2141927Swollman const char *caps_tested; /* Other caps also being tested */ 2151927Swollman const char *menu_entry; /* Menu entry text (optional) */ 2161927Swollman /* Function that does testing */ 2171927Swollman void (*test_procedure)(struct test_list *, int *, int *); 2181927Swollman struct test_menu *sub_menu; /* Nested sub-menu */ 2198755Swpaul}; 2208755Swpaul 2218755Swpaulstruct test_menu { 2228755Swpaul int flags; /* Menu feature flag */ 2231927Swollman int default_action; /* Default command if <cr> <lf> entered */ 2241927Swollman const char *menu_text; /* Describe this test_menu */ 2251927Swollman const char *menu_title; /* Title for the menu */ 2261927Swollman const char *ident; /* short menu name */ 2271927Swollman const char *standard_tests; /* Standard test text */ 2288755Swpaul /* print current settings (optional) */ 2298755Swpaul void (*menu_function)(struct test_menu *); 2301927Swollman struct test_list *tests; /* Pointer to the menu/function pairs */ 2311927Swollman struct test_list *resume_tests; /* Standard test resume point */ 2328755Swpaul int resume_state; /* resume state of test group */ 2338755Swpaul int resume_char; /* resume ch of test group */ 2348755Swpaul}; 2358755Swpaul 2361927Swollman 2378755Swpaul/* menu flags */ 2388755Swpaul#define MENU_100c 0x00001a00 /* Augment 100% of columns */ 2398755Swpaul#define MENU_90c 0x00001900 /* Augment 90% of columns */ 2408755Swpaul#define MENU_80c 0x00001800 /* Augment 80% of columns */ 2411927Swollman#define MENU_70c 0x00001700 /* Augment 70% of columns */ 2421927Swollman#define MENU_60c 0x00001600 /* Augment 60% of columns */ 2431927Swollman#define MENU_50c 0x00001500 /* Augment 50% of columns */ 2441927Swollman#define MENU_40c 0x00001400 /* Augment 40% of columns */ 2451927Swollman#define MENU_30c 0x00001300 /* Augment 30% of columns */ 2461927Swollman#define MENU_20c 0x00001200 /* Augment 20% of columns */ 2471927Swollman#define MENU_10c 0x00001100 /* Augment 10% of columns */ 2488755Swpaul#define MENU_LM1 0x00002e00 /* Augment lines - 1 */ 2491927Swollman#define MENU_100l 0x00002a00 /* Augment 100% of lines */ 2501927Swollman#define MENU_90l 0x00002900 /* Augment 90% of lines */ 2511927Swollman#define MENU_50l 0x00002500 /* Augment 50% of lines */ 2521927Swollman#define MENU_lines 0x00002000 /* Augment of lines */ 2531927Swollman#define MENU_columns 0x00001000 /* Augment of columns */ 2541927Swollman#define MENU_LC_MASK 0x00003000 /* Augment mask for lines and columns */ 2551927Swollman#define MENU_1L 0x00002f00 /* Augment == one */ 2561927Swollman#define MENU_1C 0x00001f00 /* Augment == one */ 2571927Swollman#define MENU_ONE 0x00000f00 /* Augment == one */ 2581927Swollman#define MENU_ONE_MASK 0x00000f00 /* Augment == one mask */ 2591927Swollman#define MENU_REP_MASK 0x00003f00 /* Augment mask */ 2601927Swollman 2611927Swollman#define MENU_CLEAR 0x00010000 /* clear screen */ 2621927Swollman#define MENU_INIT 0x00020000 /* Initialization function */ 2631927Swollman#define MENU_NEXT 0x00040000 /* Next test in sequence */ 2641927Swollman#define MENU_LAST 0x00080000 /* End of menu list */ 2651927Swollman#define MENU_STOP 0x00100000 /* Stop testing next-in-sequence */ 2661927Swollman#define MENU_COMPLETE 0x00200000 /* Test complete after this */ 2671927Swollman#define MENU_MENU 0x00400000 /* Pass the menu name not test name */ 2681927Swollman 2691927Swollman#define REQUEST_PROMPT 256 2701927Swollman 2711927Swollman/* tack.c */ 2721927Swollmanextern struct test_menu edit_menu; 2731927Swollmanextern void show_usage(char *); 2741927Swollmanextern void print_version(void); 2751927Swollman 2761927Swollman/* output.c */ 2771927Swollmanextern char *expand(const char *); 2781927Swollmanextern char *expand_command(const char *); 2791927Swollmanextern char *expand_to(char *, int); 2801927Swollmanextern char *hex_expand_to(char *, int); 2811927Swollmanextern char *print_expand(char *); 2821927Swollmanextern int getchp(int); 2831927Swollmanextern int getnext(int); 2841927Swollmanextern int tc_putch(int); 2851927Swollmanextern int tc_putp(const char *); 2861927Swollmanextern int wait_here(void); 2871927Swollmanextern void go_home(void); 2881927Swollmanextern void home_down(void); 2891927Swollmanextern void maybe_wait(int); 2901927Swollmanextern void ptext(const char *); 2911927Swollmanextern void ptextln(const char *); 2921927Swollmanextern void put_clear(void); 2931927Swollmanextern void put_columns(const char *, int, int); 2941927Swollmanextern void put_cr(void); 2951927Swollmanextern void put_crlf(void); 2961927Swollmanextern void put_dec(char *, int); 2971927Swollmanextern void put_ind(void); 2981927Swollmanextern void put_lf(void); 2991927Swollmanextern void put_newlines(int); 3001927Swollmanextern void put_str(const char *); 3011927Swollmanextern void put_this(int); 3021927Swollmanextern void putchp(int); 3031927Swollmanextern void putln(const char *); 3041927Swollmanextern void read_string(char *, int); 3051927Swollmanextern void three_digit(char *, int); 3061927Swollmanextern void tt_putp(const char *); 3071927Swollmanextern void tt_putparm(NCURSES_CONST char *, int, int, int); 3081927Swollmanextern void tt_tputs(const char *, int); 3091927Swollman 3101927Swollman#define put_that(n) put_this((int) (n)) 3111927Swollman 3121927Swollman/* control.c */ 3138091Swpaulextern struct test_list color_test_list[]; 3148091Swpaulextern char *liberated(char *); 3158091Swpaulextern char txt_longer_augment[80]; 3168091Swpaulextern char txt_longer_test_time[80]; 3178091Swpaulextern char txt_shorter_augment[80]; 3188091Swpaulextern char txt_shorter_test_time[80]; 3198091Swpaulextern int msec_cost(const char *const, int); 3208091Swpaulextern int skip_pad_test(struct test_list *, int *, int *, const char *); 3218091Swpaulextern int sliding_scale(int, int, unsigned long); 3228425Swpaulextern int still_testing(void); 3238425Swpaulextern long event_time(int); 3248425Swpaulextern void control_init(void); 3258425Swpaulextern void dump_test_stats(struct test_list *, int *, int *); 3268425Swpaulextern void event_start(int); 3278425Swpaulextern void longer_augment(struct test_list *, int *, int *); 3288425Swpaulextern void longer_test_time(struct test_list *, int *, int *); 3298425Swpaulextern void pad_test_shutdown(struct test_list *, int); 3308755Swpaulextern void pad_test_startup(int); 3318755Swpaulextern void page_loop(void); 3328425Swpaulextern void set_augment_txt(void); 3338425Swpaulextern void shorter_augment(struct test_list *, int *, int *); 3348425Swpaulextern void shorter_test_time(struct test_list *, int *, int *); 3358425Swpaul 3368474Swpaul/* charset.c */ 3378474Swpaulextern struct test_list acs_test_list[]; 3388425Swpaulextern void set_attr(int); 3398425Swpaulextern void eat_cookie(void); 3408425Swpaulextern void put_mode(char *); 3418857Srgrimes 3428091Swpaul/* crum.c */ 3431927Swollmanextern struct test_list crum_test_list[]; 3448091Swpaul 3451927Swollman/* ansi.c */ 3461927Swollmanextern void tools_status(struct test_list *, int *, int *); 3471927Swollmanextern void tools_charset(struct test_list *, int *, int *); 3481927Swollmanextern void tools_sgr(struct test_list *, int *, int *); 3491927Swollman 3508425Swpaul/* edit.c */ 3518425Swpaulextern struct test_menu change_pad_menu; 3528755Swpaulextern struct test_list edit_test_list[]; 3531927Swollmanextern char *get_string_cap_byname(const char *, const char **); 3548474Swpaulextern int cap_match(const char *names, const char *cap); 3558474Swpaulextern int get_string_cap_byvalue(const char *); 3568474Swpaulextern int user_modified(void); 3578474Swpaulextern void can_test(const char *, int); 3588474Swpaulextern void cap_index(const char *, int *); 3598474Swpaulextern void edit_init(void); 3608474Swpaulextern void save_info(struct test_list *, int *, int *); 3618474Swpaulextern void show_report(struct test_list *, int *, int *); 3628474Swpaul 3638474Swpaul/* fun.c */ 3648474Swpaulextern struct test_list funkey_test_list[]; 3651927Swollmanextern struct test_list printer_test_list[]; 3661927Swollmanextern void enter_key(const char *, char *, char *); 3671927Swollmanextern int tty_meta_prep(void); 3681927Swollmanextern void tools_report(struct test_list *, int *, int *); 3691927Swollman 3701927Swollman/* init.c */ 3711927Swollmanextern void reset_init(void); 3721927Swollmanextern void display_basic(void); 3731927Swollmanextern void put_name(const char *, const char *); 3741927Swollmanextern void charset_can_test(void); 3756732Swpaulextern void curses_setup(char *); 3766732Swpaulextern void bye_kids(int); 3776732Swpaul 3781927Swollman/* scan.c */ 3791927Swollmanextern char **scan_up, **scan_down, **scan_name; 3808425Swpaulextern int scan_key(void); 3811927Swollmanextern unsigned scan_max; /* length of longest scan code */ 3828425Swpaulextern unsigned *scan_tested, *scan_length; 3838425Swpaulextern void scan_init(char *fn); 3848425Swpaul 3858425Swpaul/* sysdep.c */ 3868425Swpaulextern int initial_stty_query(int); 3878425Swpaulextern int stty_query(int); 3888425Swpaulextern void ignoresig(void); 3898425Swpaulextern void read_key(char *, int); 3908425Swpaulextern void set_alarm_clock(int); 3918425Swpaulextern void spin_flush(void); 3921927Swollmanextern void tty_init(void); 3931927Swollmanextern void tty_raw(int, int); 3948425Swpaulextern void tty_reset(void); 3951927Swollmanextern void tty_set(void); 3961927Swollman 3971927Swollman/* menu.c */ 3981927Swollmanextern char prompt_string[80]; /* menu prompt storage */ 3991927Swollmanextern int subtest_menu(struct test_list *, int *, int *); 4001927Swollmanextern struct test_list *augment_test; 4011927Swollmanextern void generic_done_message(struct test_list *, int *, int *); 4021927Swollmanextern void menu_can_scan(const struct test_menu *); 4031927Swollmanextern void menu_clear_screen(struct test_list *, int *, int *); 4048425Swpaulextern void menu_display(struct test_menu *, int *); 4051927Swollmanextern void menu_prompt(void); 4061927Swollmanextern void menu_reset_init(struct test_list *, int *, int *); 4071927Swollmanextern void pad_done_message(struct test_list *, int *, int *); 4081927Swollman 4098425Swpaul/* modes.c */ 4101927Swollmanextern struct test_list mode_test_list[]; 4111927Swollman 4121927Swollman/* pad.c */ 4131927Swollmanextern struct test_list pad_test_list[]; 4141927Swollman 4158425Swpaul/* sync.c */ 4161927Swollmanextern struct test_menu sync_menu; 4171927Swollmanextern int tty_sync_error(void); 4181927Swollmanextern void flush_input(void); 4191927Swollmanextern void sync_handshake(struct test_list *, int *, int *); 4201927Swollmanextern void sync_test(struct test_menu *); 4218425Swpaulextern void verify_time(void); 4221927Swollman 4231927Swollman#endif /* NCURSES_TACK_H_incl */ 4241927Swollman