1 | /*
|
---|
2 | ** Copyright (C) 1991, 1997 Free Software Foundation, Inc.
|
---|
3 | **
|
---|
4 | ** This file is part of TACK.
|
---|
5 | **
|
---|
6 | ** TACK is free software; you can redistribute it and/or modify
|
---|
7 | ** it under the terms of the GNU General Public License as published by
|
---|
8 | ** the Free Software Foundation; either version 2, or (at your option)
|
---|
9 | ** any later version.
|
---|
10 | **
|
---|
11 | ** TACK is distributed in the hope that it will be useful,
|
---|
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | ** GNU General Public License for more details.
|
---|
15 | **
|
---|
16 | ** You should have received a copy of the GNU General Public License
|
---|
17 | ** along with TACK; see the file COPYING. If not, write to
|
---|
18 | ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
---|
19 | ** Boston, MA 02110-1301, USA
|
---|
20 | */
|
---|
21 |
|
---|
22 | /* $Id: tack.h,v 1.14 2005/09/17 19:49:16 tom Exp $ */
|
---|
23 |
|
---|
24 | #ifndef NCURSES_TACK_H_incl
|
---|
25 | #define NCURSES_TACK_H_incl 1
|
---|
26 |
|
---|
27 | /* terminfo action checker include file */
|
---|
28 |
|
---|
29 | #define MAJOR_VERSION 1
|
---|
30 | #define MINOR_VERSION 1
|
---|
31 |
|
---|
32 | #ifdef HAVE_CONFIG_H
|
---|
33 | #include <ncurses_cfg.h>
|
---|
34 | #else
|
---|
35 | #define RETSIGTYPE void
|
---|
36 | #define GCC_UNUSED /*nothing*/
|
---|
37 | #define HAVE_GETTIMEOFDAY 1
|
---|
38 | #define HAVE_SELECT 1
|
---|
39 | #define HAVE_SYS_TIME_H 1
|
---|
40 | #define HAVE_SYS_TIME_SELECT 1
|
---|
41 | #endif
|
---|
42 |
|
---|
43 | #include <sys/types.h>
|
---|
44 | #include <stdlib.h>
|
---|
45 | #include <unistd.h>
|
---|
46 | #include <ctype.h>
|
---|
47 | #include <string.h>
|
---|
48 |
|
---|
49 | #include <curses.h>
|
---|
50 | #include <term_entry.h>
|
---|
51 |
|
---|
52 | #if USE_RCS_IDS
|
---|
53 | #define MODULE_ID(id) static const char Ident[] = id;
|
---|
54 | #else
|
---|
55 | #define MODULE_ID(id) /*nothing*/
|
---|
56 | #endif
|
---|
57 |
|
---|
58 | #if !HAVE_STRSTR
|
---|
59 | extern char *_nc_strstr(const char *, const char *);
|
---|
60 | #define strstr(h,n) _nc_strstr(h,n)
|
---|
61 | #endif
|
---|
62 |
|
---|
63 | #define UChar(c) ((unsigned char)(c))
|
---|
64 |
|
---|
65 | extern FILE *log_fp;
|
---|
66 | extern FILE *debug_fp;
|
---|
67 | extern int debug_level;
|
---|
68 | extern char temp[];
|
---|
69 | extern char tty_basename[];
|
---|
70 | extern char tty_shortname[];
|
---|
71 |
|
---|
72 | #define SYNC_FAILED 0
|
---|
73 | #define SYNC_TESTED 1
|
---|
74 | #define SYNC_NOT_TESTED 2
|
---|
75 | #define SYNC_NEEDED 3
|
---|
76 |
|
---|
77 | extern int tty_can_sync;
|
---|
78 | extern int total_pads_sent; /* count pad characters sent */
|
---|
79 | extern int total_caps_sent; /* count caps sent */
|
---|
80 | extern int total_printing_characters; /* count printing characters sent */
|
---|
81 | extern int no_alarm_event; /* TRUE if the alarm has not gone off yet */
|
---|
82 | extern unsigned long usec_run_time; /* length of last test in microseconds */
|
---|
83 | extern int raw_characters_sent; /* Total output characters */
|
---|
84 |
|
---|
85 | /* Stopwatch event timers */
|
---|
86 | #define TIME_TEST 0
|
---|
87 | #define TIME_SYNC 1
|
---|
88 | #define TIME_FLUSH 2
|
---|
89 | #define MAX_TIMERS 3
|
---|
90 |
|
---|
91 | /* definitions for pad.c */
|
---|
92 |
|
---|
93 | #define EXIT_CONDITION (no_alarm_event && (tt_delay_used < tt_delay_max))
|
---|
94 | #define SLOW_TERMINAL_EXIT if (!test_complete && !EXIT_CONDITION) { break; }
|
---|
95 | #define CAP_NOT_FOUND if (auto_pad_mode) return
|
---|
96 |
|
---|
97 | extern char letters[26+1];
|
---|
98 | #define NEXT_LETTER letter = letters[letter_number =\
|
---|
99 | letters[letter_number + 1] ? letter_number + 1 : 0]
|
---|
100 |
|
---|
101 | extern int test_complete; /* counts number of tests completed */
|
---|
102 | extern char letter;
|
---|
103 | extern int letter_number;
|
---|
104 | extern int augment, repeats;
|
---|
105 | extern long char_sent;
|
---|
106 | extern const char *pad_repeat_test; /* commands that force repeat */
|
---|
107 |
|
---|
108 | extern int replace_mode;
|
---|
109 | extern int char_count, line_count, expand_chars;
|
---|
110 | extern int can_go_home, can_clear_screen;
|
---|
111 |
|
---|
112 | extern int translate_mode, scan_mode;
|
---|
113 | extern int auto_pad_mode; /* TRUE for auto time tests */
|
---|
114 | extern int char_mask;
|
---|
115 | extern int hex_out; /* Display output in hex */
|
---|
116 |
|
---|
117 | /* Parity bit macros */
|
---|
118 | #define STRIP_PARITY 0x7f
|
---|
119 | #define ALLOW_PARITY 0xff
|
---|
120 |
|
---|
121 | /* select_delay_type: 0 -> reset all delays
|
---|
122 | 1 -> force long delays
|
---|
123 | 2 -> do not change the delays */
|
---|
124 | extern int select_delay_type;
|
---|
125 |
|
---|
126 | /* select_xon_xoff: 0 -> reset xon/xoff
|
---|
127 | 1 -> set xon/xoff
|
---|
128 | 2 -> do not change xon/xoff */
|
---|
129 | extern int select_xon_xoff;
|
---|
130 |
|
---|
131 | extern int tty_frame_size;
|
---|
132 | extern unsigned tty_baud_rate;
|
---|
133 | extern unsigned long tty_cps; /* The number of characters per second */
|
---|
134 | extern int not_a_tty, nodelay_read;
|
---|
135 | extern int send_reset_init;
|
---|
136 |
|
---|
137 | /* definitions for stty_query() and initial_stty_query() */
|
---|
138 | #define TTY_CHAR_MODE 0
|
---|
139 | #define TTY_NOECHO 1
|
---|
140 | #define TTY_OUT_TRANS 2
|
---|
141 | #define TTY_8_BIT 3
|
---|
142 | #define TTY_XON_XOFF 4
|
---|
143 |
|
---|
144 | /* scan code definitions */
|
---|
145 | #define MAX_SCAN 256
|
---|
146 |
|
---|
147 | /* translate mode default strings */
|
---|
148 | struct default_string_list {
|
---|
149 | const char *name; /* terminfo name */
|
---|
150 | const char *value; /* value of default string */
|
---|
151 | int index; /* index into the strfname[] array */
|
---|
152 | };
|
---|
153 |
|
---|
154 | #define TM_last 8
|
---|
155 | extern struct default_string_list TM_string[TM_last];
|
---|
156 |
|
---|
157 | /* attribute structure definition */
|
---|
158 | struct mode_list {
|
---|
159 | const char *name;
|
---|
160 | const char *begin_mode;
|
---|
161 | const char *end_mode;
|
---|
162 | int number;
|
---|
163 | };
|
---|
164 |
|
---|
165 | extern const struct mode_list alt_modes[];
|
---|
166 | extern const int mode_map[];
|
---|
167 |
|
---|
168 | /* Test data base */
|
---|
169 |
|
---|
170 | #define FLAG_CAN_TEST 1
|
---|
171 | #define FLAG_TESTED 2
|
---|
172 | #define FLAG_LABEL 4
|
---|
173 | #define FLAG_FUNCTION_KEY 8
|
---|
174 |
|
---|
175 | /* caps under test data base */
|
---|
176 |
|
---|
177 | #define TT_MAX 8
|
---|
178 | #define MAX_CHANGES (TT_MAX+2)
|
---|
179 |
|
---|
180 | extern int tt_delay_max; /* max number of milliseconds we can delay */
|
---|
181 | extern int tt_delay_used; /* number of milliseconds consumed in delay */
|
---|
182 | extern const char *tt_cap[TT_MAX]; /* value of string */
|
---|
183 | extern int tt_affected[TT_MAX]; /* lines or columns effected (repetition
|
---|
184 | factor) */
|
---|
185 | extern int tt_count[TT_MAX]; /* Number of times sent */
|
---|
186 | extern int tt_delay[TT_MAX]; /* Number of milliseconds delay */
|
---|
187 | extern int ttp; /* number of entries used */
|
---|
188 |
|
---|
189 | extern const char *tx_cap[TT_MAX]; /* value of string */
|
---|
190 | extern int tx_affected[TT_MAX]; /* lines or columns effected (repetition
|
---|
191 | factor) */
|
---|
192 | extern int tx_count[TT_MAX]; /* Number of times sent */
|
---|
193 | extern int tx_delay[TT_MAX]; /* Number of milliseconds delay */
|
---|
194 | extern int tx_index[TT_MAX]; /* String index */
|
---|
195 | extern int txp; /* number of entries used */
|
---|
196 | extern int tx_characters; /* printing characters sent by test */
|
---|
197 | extern unsigned long tx_cps; /* characters per second */
|
---|
198 |
|
---|
199 | /*
|
---|
200 | Menu control for tack.
|
---|
201 | */
|
---|
202 |
|
---|
203 | struct test_results {
|
---|
204 | struct test_results *next; /* point to next entry */
|
---|
205 | struct test_list *test; /* Test which got these results */
|
---|
206 | int reps; /* repeat count */
|
---|
207 | int delay; /* delay times 10 */
|
---|
208 | };
|
---|
209 |
|
---|
210 | struct test_list {
|
---|
211 | int flags; /* Test description flags */
|
---|
212 | int lines_needed; /* Lines needed for test (0->no action) */
|
---|
213 | const char *caps_done; /* Caps shown in Done message */
|
---|
214 | const char *caps_tested; /* Other caps also being tested */
|
---|
215 | const char *menu_entry; /* Menu entry text (optional) */
|
---|
216 | /* Function that does testing */
|
---|
217 | void (*test_procedure)(struct test_list *, int *, int *);
|
---|
218 | struct test_menu *sub_menu; /* Nested sub-menu */
|
---|
219 | };
|
---|
220 |
|
---|
221 | struct test_menu {
|
---|
222 | int flags; /* Menu feature flag */
|
---|
223 | int default_action; /* Default command if <cr> <lf> entered */
|
---|
224 | const char *menu_text; /* Describe this test_menu */
|
---|
225 | const char *menu_title; /* Title for the menu */
|
---|
226 | const char *ident; /* short menu name */
|
---|
227 | const char *standard_tests; /* Standard test text */
|
---|
228 | /* print current settings (optional) */
|
---|
229 | void (*menu_function)(struct test_menu *);
|
---|
230 | struct test_list *tests; /* Pointer to the menu/function pairs */
|
---|
231 | struct test_list *resume_tests; /* Standard test resume point */
|
---|
232 | int resume_state; /* resume state of test group */
|
---|
233 | int resume_char; /* resume ch of test group */
|
---|
234 | };
|
---|
235 |
|
---|
236 |
|
---|
237 | /* menu flags */
|
---|
238 | #define MENU_100c 0x00001a00 /* Augment 100% of columns */
|
---|
239 | #define MENU_90c 0x00001900 /* Augment 90% of columns */
|
---|
240 | #define MENU_80c 0x00001800 /* Augment 80% of columns */
|
---|
241 | #define MENU_70c 0x00001700 /* Augment 70% of columns */
|
---|
242 | #define MENU_60c 0x00001600 /* Augment 60% of columns */
|
---|
243 | #define MENU_50c 0x00001500 /* Augment 50% of columns */
|
---|
244 | #define MENU_40c 0x00001400 /* Augment 40% of columns */
|
---|
245 | #define MENU_30c 0x00001300 /* Augment 30% of columns */
|
---|
246 | #define MENU_20c 0x00001200 /* Augment 20% of columns */
|
---|
247 | #define MENU_10c 0x00001100 /* Augment 10% of columns */
|
---|
248 | #define MENU_LM1 0x00002e00 /* Augment lines - 1 */
|
---|
249 | #define MENU_100l 0x00002a00 /* Augment 100% of lines */
|
---|
250 | #define MENU_90l 0x00002900 /* Augment 90% of lines */
|
---|
251 | #define MENU_50l 0x00002500 /* Augment 50% of lines */
|
---|
252 | #define MENU_lines 0x00002000 /* Augment of lines */
|
---|
253 | #define MENU_columns 0x00001000 /* Augment of columns */
|
---|
254 | #define MENU_LC_MASK 0x00003000 /* Augment mask for lines and columns */
|
---|
255 | #define MENU_1L 0x00002f00 /* Augment == one */
|
---|
256 | #define MENU_1C 0x00001f00 /* Augment == one */
|
---|
257 | #define MENU_ONE 0x00000f00 /* Augment == one */
|
---|
258 | #define MENU_ONE_MASK 0x00000f00 /* Augment == one mask */
|
---|
259 | #define MENU_REP_MASK 0x00003f00 /* Augment mask */
|
---|
260 |
|
---|
261 | #define MENU_CLEAR 0x00010000 /* clear screen */
|
---|
262 | #define MENU_INIT 0x00020000 /* Initialization function */
|
---|
263 | #define MENU_NEXT 0x00040000 /* Next test in sequence */
|
---|
264 | #define MENU_LAST 0x00080000 /* End of menu list */
|
---|
265 | #define MENU_STOP 0x00100000 /* Stop testing next-in-sequence */
|
---|
266 | #define MENU_COMPLETE 0x00200000 /* Test complete after this */
|
---|
267 | #define MENU_MENU 0x00400000 /* Pass the menu name not test name */
|
---|
268 |
|
---|
269 | #define REQUEST_PROMPT 256
|
---|
270 |
|
---|
271 | /* tack.c */
|
---|
272 | extern struct test_menu edit_menu;
|
---|
273 | extern void show_usage(char *);
|
---|
274 | extern void print_version(void);
|
---|
275 |
|
---|
276 | /* output.c */
|
---|
277 | extern char *expand(const char *);
|
---|
278 | extern char *expand_command(const char *);
|
---|
279 | extern char *expand_to(char *, int);
|
---|
280 | extern char *hex_expand_to(char *, int);
|
---|
281 | extern char *print_expand(char *);
|
---|
282 | extern int getchp(int);
|
---|
283 | extern int getnext(int);
|
---|
284 | extern int tc_putch(int);
|
---|
285 | extern int tc_putp(const char *);
|
---|
286 | extern int wait_here(void);
|
---|
287 | extern void go_home(void);
|
---|
288 | extern void home_down(void);
|
---|
289 | extern void maybe_wait(int);
|
---|
290 | extern void ptext(const char *);
|
---|
291 | extern void ptextln(const char *);
|
---|
292 | extern void put_clear(void);
|
---|
293 | extern void put_columns(const char *, int, int);
|
---|
294 | extern void put_cr(void);
|
---|
295 | extern void put_crlf(void);
|
---|
296 | extern void put_dec(char *, int);
|
---|
297 | extern void put_ind(void);
|
---|
298 | extern void put_lf(void);
|
---|
299 | extern void put_newlines(int);
|
---|
300 | extern void put_str(const char *);
|
---|
301 | extern void put_this(int);
|
---|
302 | extern void putchp(int);
|
---|
303 | extern void putln(const char *);
|
---|
304 | extern void read_string(char *, int);
|
---|
305 | extern void three_digit(char *, int);
|
---|
306 | extern void tt_putp(const char *);
|
---|
307 | extern void tt_putparm(NCURSES_CONST char *, int, int, int);
|
---|
308 | extern void tt_tputs(const char *, int);
|
---|
309 |
|
---|
310 | #define put_that(n) put_this((int) (n))
|
---|
311 |
|
---|
312 | /* control.c */
|
---|
313 | extern struct test_list color_test_list[];
|
---|
314 | extern char *liberated(char *);
|
---|
315 | extern char txt_longer_augment[80];
|
---|
316 | extern char txt_longer_test_time[80];
|
---|
317 | extern char txt_shorter_augment[80];
|
---|
318 | extern char txt_shorter_test_time[80];
|
---|
319 | extern int msec_cost(const char *const, int);
|
---|
320 | extern int skip_pad_test(struct test_list *, int *, int *, const char *);
|
---|
321 | extern int sliding_scale(int, int, unsigned long);
|
---|
322 | extern int still_testing(void);
|
---|
323 | extern long event_time(int);
|
---|
324 | extern void control_init(void);
|
---|
325 | extern void dump_test_stats(struct test_list *, int *, int *);
|
---|
326 | extern void event_start(int);
|
---|
327 | extern void longer_augment(struct test_list *, int *, int *);
|
---|
328 | extern void longer_test_time(struct test_list *, int *, int *);
|
---|
329 | extern void pad_test_shutdown(struct test_list *, int);
|
---|
330 | extern void pad_test_startup(int);
|
---|
331 | extern void page_loop(void);
|
---|
332 | extern void set_augment_txt(void);
|
---|
333 | extern void shorter_augment(struct test_list *, int *, int *);
|
---|
334 | extern void shorter_test_time(struct test_list *, int *, int *);
|
---|
335 |
|
---|
336 | /* charset.c */
|
---|
337 | extern struct test_list acs_test_list[];
|
---|
338 | extern void set_attr(int);
|
---|
339 | extern void eat_cookie(void);
|
---|
340 | extern void put_mode(char *);
|
---|
341 |
|
---|
342 | /* crum.c */
|
---|
343 | extern struct test_list crum_test_list[];
|
---|
344 |
|
---|
345 | /* ansi.c */
|
---|
346 | extern void tools_status(struct test_list *, int *, int *);
|
---|
347 | extern void tools_charset(struct test_list *, int *, int *);
|
---|
348 | extern void tools_sgr(struct test_list *, int *, int *);
|
---|
349 |
|
---|
350 | /* edit.c */
|
---|
351 | extern struct test_menu change_pad_menu;
|
---|
352 | extern struct test_list edit_test_list[];
|
---|
353 | extern char *get_string_cap_byname(const char *, const char **);
|
---|
354 | extern int cap_match(const char *names, const char *cap);
|
---|
355 | extern int get_string_cap_byvalue(const char *);
|
---|
356 | extern int user_modified(void);
|
---|
357 | extern void can_test(const char *, int);
|
---|
358 | extern void cap_index(const char *, int *);
|
---|
359 | extern void edit_init(void);
|
---|
360 | extern void save_info(struct test_list *, int *, int *);
|
---|
361 | extern void show_report(struct test_list *, int *, int *);
|
---|
362 |
|
---|
363 | /* fun.c */
|
---|
364 | extern struct test_list funkey_test_list[];
|
---|
365 | extern struct test_list printer_test_list[];
|
---|
366 | extern void enter_key(const char *, char *, char *);
|
---|
367 | extern int tty_meta_prep(void);
|
---|
368 | extern void tools_report(struct test_list *, int *, int *);
|
---|
369 |
|
---|
370 | /* init.c */
|
---|
371 | extern void reset_init(void);
|
---|
372 | extern void display_basic(void);
|
---|
373 | extern void put_name(const char *, const char *);
|
---|
374 | extern void charset_can_test(void);
|
---|
375 | extern void curses_setup(char *);
|
---|
376 | extern void bye_kids(int);
|
---|
377 |
|
---|
378 | /* scan.c */
|
---|
379 | extern char **scan_up, **scan_down, **scan_name;
|
---|
380 | extern int scan_key(void);
|
---|
381 | extern unsigned scan_max; /* length of longest scan code */
|
---|
382 | extern unsigned *scan_tested, *scan_length;
|
---|
383 | extern void scan_init(char *fn);
|
---|
384 |
|
---|
385 | /* sysdep.c */
|
---|
386 | extern int initial_stty_query(int);
|
---|
387 | extern int stty_query(int);
|
---|
388 | extern void ignoresig(void);
|
---|
389 | extern void read_key(char *, int);
|
---|
390 | extern void set_alarm_clock(int);
|
---|
391 | extern void spin_flush(void);
|
---|
392 | extern void tty_init(void);
|
---|
393 | extern void tty_raw(int, int);
|
---|
394 | extern void tty_reset(void);
|
---|
395 | extern void tty_set(void);
|
---|
396 |
|
---|
397 | /* menu.c */
|
---|
398 | extern char prompt_string[80]; /* menu prompt storage */
|
---|
399 | extern int subtest_menu(struct test_list *, int *, int *);
|
---|
400 | extern struct test_list *augment_test;
|
---|
401 | extern void generic_done_message(struct test_list *, int *, int *);
|
---|
402 | extern void menu_can_scan(const struct test_menu *);
|
---|
403 | extern void menu_clear_screen(struct test_list *, int *, int *);
|
---|
404 | extern void menu_display(struct test_menu *, int *);
|
---|
405 | extern void menu_prompt(void);
|
---|
406 | extern void menu_reset_init(struct test_list *, int *, int *);
|
---|
407 | extern void pad_done_message(struct test_list *, int *, int *);
|
---|
408 |
|
---|
409 | /* modes.c */
|
---|
410 | extern struct test_list mode_test_list[];
|
---|
411 |
|
---|
412 | /* pad.c */
|
---|
413 | extern struct test_list pad_test_list[];
|
---|
414 |
|
---|
415 | /* sync.c */
|
---|
416 | extern struct test_menu sync_menu;
|
---|
417 | extern int tty_sync_error(void);
|
---|
418 | extern void flush_input(void);
|
---|
419 | extern void sync_handshake(struct test_list *, int *, int *);
|
---|
420 | extern void sync_test(struct test_menu *);
|
---|
421 | extern void verify_time(void);
|
---|
422 |
|
---|
423 | #endif /* NCURSES_TACK_H_incl */
|
---|