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