| 1 |
/* $Id: vttest.h,v 1.128 2024/11/25 01:14:50 tom Exp $ */ |
| 2 |
|
| 3 |
#ifndef VTTEST_H |
| 4 |
#define VTTEST_H 1 |
| 5 |
|
| 6 |
/* original version... */ |
| 7 |
#define VERSION "1.7b 1985-04-19" |
| 8 |
|
| 9 |
/* the actual version is here */ |
| 10 |
#include <patchlev.h> |
| 11 |
|
| 12 |
/* Choose one of these */ |
| 13 |
|
| 14 |
#ifdef HAVE_CONFIG_H |
| 15 |
#include <config.h> |
| 16 |
#define UNIX |
| 17 |
#else |
| 18 |
|
| 19 |
/* Assume ANSI and (minimal) Posix */ |
| 20 |
#define HAVE_STDLIB_H 1 |
| 21 |
#define HAVE_STRING_H 1 |
| 22 |
#define RETSIGTYPE void |
| 23 |
|
| 24 |
#endif |
| 25 |
|
| 26 |
#ifndef GCC_UNUSED |
| 27 |
#define GCC_UNUSED /* ARGSUSED */ |
| 28 |
#endif |
| 29 |
|
| 30 |
#define SIG_ARGS int sig |
| 31 |
|
| 32 |
#include <stdio.h> |
| 33 |
#include <stdarg.h> |
| 34 |
|
| 35 |
#ifdef HAVE_STDLIB_H |
| 36 |
#include <stdlib.h> |
| 37 |
#endif |
| 38 |
|
| 39 |
#ifdef HAVE_UNISTD_H |
| 40 |
#include <unistd.h> |
| 41 |
#endif |
| 42 |
|
| 43 |
#ifdef HAVE_STRING_H |
| 44 |
#include <string.h> |
| 45 |
#endif |
| 46 |
|
| 47 |
#include <ctype.h> |
| 48 |
|
| 49 |
#if defined(HAVE_TERMIOS_H) && defined(HAVE_TCGETATTR) |
| 50 |
# define USE_POSIX_TERMIOS 1 |
| 51 |
#elif defined(HAVE_TERMIO_H) |
| 52 |
# define USE_TERMIO 1 |
| 53 |
#elif defined(HAVE_SGTTY_H) |
| 54 |
# define USE_SGTTY 1 |
| 55 |
# define USE_FIONREAD 1 |
| 56 |
#elif !defined(VMS) |
| 57 |
# error please fix me |
| 58 |
#endif |
| 59 |
|
| 60 |
#ifndef USE_FIONREAD |
| 61 |
#define USE_FIONREAD 0 |
| 62 |
#endif |
| 63 |
|
| 64 |
#ifndef USE_POSIX_TERMIOS |
| 65 |
#define USE_POSIX_TERMIOS 0 |
| 66 |
#endif |
| 67 |
|
| 68 |
#ifndef USE_SGTTY |
| 69 |
#define USE_SGTTY 0 |
| 70 |
#endif |
| 71 |
|
| 72 |
#ifndef USE_TERMIO |
| 73 |
#define USE_TERMIO 0 |
| 74 |
#endif |
| 75 |
|
| 76 |
#include <signal.h> |
| 77 |
#include <setjmp.h> |
| 78 |
|
| 79 |
#if USE_POSIX_TERMIOS |
| 80 |
# include <termios.h> |
| 81 |
# define TTY struct termios |
| 82 |
#else |
| 83 |
# if USE_TERMIO |
| 84 |
# include <termio.h> |
| 85 |
/*# define TCSANOW TCSETA */ |
| 86 |
/*# define TCSADRAIN TCSETAW */ |
| 87 |
/*# define TCSAFLUSH TCSETAF */ |
| 88 |
# define TTY struct termio |
| 89 |
# define tcsetattr(fd, cmd, arg) ioctl(fd, cmd, arg) |
| 90 |
# define tcgetattr(fd, arg) ioctl(fd, TCGETA, arg) |
| 91 |
# define VDISABLE (unsigned char)(-1) |
| 92 |
# else |
| 93 |
# if USE_SGTTY |
| 94 |
# include <sgtty.h> |
| 95 |
# define TTY struct sgttyb |
| 96 |
# endif |
| 97 |
# endif |
| 98 |
#endif |
| 99 |
|
| 100 |
#ifdef HAVE_SYS_FILIO_H |
| 101 |
# include <sys/filio.h> /* FIONREAD */ |
| 102 |
#endif |
| 103 |
|
| 104 |
#ifdef HAVE_FCNTL_H |
| 105 |
#include <fcntl.h> |
| 106 |
#endif |
| 107 |
|
| 108 |
#if !defined(sun) || !defined(NL0) |
| 109 |
# ifdef HAVE_IOCTL_H |
| 110 |
# include <ioctl.h> |
| 111 |
# else |
| 112 |
# ifdef HAVE_SYS_IOCTL_H |
| 113 |
# include <sys/ioctl.h> |
| 114 |
# endif |
| 115 |
# endif |
| 116 |
#endif |
| 117 |
|
| 118 |
#include <errno.h> |
| 119 |
|
| 120 |
#define LOG_ENABLED ((log_fp != (FILE *) 0) && !log_disabled) |
| 121 |
|
| 122 |
#define CharOf(c) ((unsigned char)(c)) |
| 123 |
|
| 124 |
extern FILE *log_fp; |
| 125 |
extern int allows_utf8; |
| 126 |
extern int assume_utf8; |
| 127 |
extern int brkrd; |
| 128 |
extern int debug_level; |
| 129 |
extern int decac_bg; |
| 130 |
extern int decac_fg; |
| 131 |
extern int do_colors; |
| 132 |
extern int input_8bits; |
| 133 |
extern int log_disabled; |
| 134 |
extern int lrmm_flag; |
| 135 |
extern int max_cols; |
| 136 |
extern int max_lines; |
| 137 |
extern int min_cols; |
| 138 |
extern int origin_mode; |
| 139 |
extern int output_8bits; |
| 140 |
extern int parse_7bits; |
| 141 |
extern int reading; |
| 142 |
extern int slow_motion; |
| 143 |
extern int tty_speed; |
| 144 |
extern int use_decac; |
| 145 |
extern int use_padding; |
| 146 |
extern jmp_buf intrenv; |
| 147 |
|
| 148 |
#ifndef TRUE |
| 149 |
#define TRUE (1) |
| 150 |
#endif |
| 151 |
|
| 152 |
#ifndef FALSE |
| 153 |
#define FALSE (0) |
| 154 |
#endif |
| 155 |
|
| 156 |
#ifndef EXIT_SUCCESS |
| 157 |
#define EXIT_SUCCESS 0 |
| 158 |
#endif |
| 159 |
|
| 160 |
#ifndef EXIT_FAILURE |
| 161 |
#define EXIT_FAILURE 1 |
| 162 |
#endif |
| 163 |
|
| 164 |
#define SHOW_SUCCESS "ok" |
| 165 |
#define SHOW_FAILURE "failed" |
| 166 |
|
| 167 |
#undef __ |
| 168 |
#define __(a,b) (void)(a && b) |
| 169 |
|
| 170 |
#define TABLESIZE(table) (int)(sizeof(table)/sizeof(table[0])) |
| 171 |
|
| 172 |
#define DEFAULT_SPEED 9600 |
| 173 |
#define TABWIDTH 8 |
| 174 |
|
| 175 |
#define STR_ENABLE(flag) ((flag) ? "Disable" : "Enable") |
| 176 |
#define STR_ENABLED(flag) ((flag) ? "enabled" : "disabled") |
| 177 |
#define STR_START(flag) ((flag) ? "Stop" : "Start") |
| 178 |
|
| 179 |
#if !defined(__GNUC__) && !defined(__attribute__) |
| 180 |
#define __attribute__(p) /* nothing */ |
| 181 |
#endif |
| 182 |
|
| 183 |
#ifndef GCC_NORETURN |
| 184 |
#define GCC_NORETURN /* nothing */ |
| 185 |
#endif |
| 186 |
|
| 187 |
#ifndef GCC_PRINTFLIKE |
| 188 |
#define GCC_PRINTFLIKE(fmt,var) /* nothing */ |
| 189 |
#endif |
| 190 |
|
| 191 |
#ifndef GCC_UNUSED |
| 192 |
#define GCC_UNUSED /* nothing */ |
| 193 |
#endif |
| 194 |
|
| 195 |
#define MENU_DECL const char * the_title |
| 196 |
#define MENU_ARGS const char * the_title GCC_UNUSED |
| 197 |
#define PASS_ARGS /* const char * */the_title |
| 198 |
|
| 199 |
typedef struct { |
| 200 |
const char *description; |
| 201 |
int (*dispatch) (MENU_ARGS); |
| 202 |
} MENU; |
| 203 |
|
| 204 |
typedef struct { |
| 205 |
int cur_level; |
| 206 |
int input_8bits; |
| 207 |
int output_8bits; |
| 208 |
int parse_7bits; |
| 209 |
} VTLEVEL; |
| 210 |
|
| 211 |
typedef struct { |
| 212 |
int mode; |
| 213 |
const char *name; |
| 214 |
int level; |
| 215 |
} RQM_DATA; |
| 216 |
|
| 217 |
#define MENU_NOHOLD 0 |
| 218 |
#define MENU_HOLD 1 |
| 219 |
#define MENU_MERGE 2 |
| 220 |
|
| 221 |
#define TITLE_LINE 3 |
| 222 |
|
| 223 |
#define BUF_SIZE 1024 |
| 224 |
|
| 225 |
/* normal logging-prefixes */ |
| 226 |
#define READ_STR "Read: " /* use this for noting user-input */ |
| 227 |
#define NOTE_STR "Note: " /* use this for making notes (no data involved) */ |
| 228 |
#define SEND_STR "Send: " /* use this for control-sequences, sent */ |
| 229 |
#define DATA_STR "Data: " /* use this for test-data, sent */ |
| 230 |
#define TELL_STR "Text: " /* use this for test-instructions */ |
| 231 |
|
| 232 |
/* replay logging-prefixes */ |
| 233 |
#define WAIT_STR "Wait: " /* use this for suspending replay */ |
| 234 |
#define DONE_STR "Done: " /* use this for resuming replay */ |
| 235 |
#define SKIP_STR "Skip: " /* use this for debugging replay */ |
| 236 |
|
| 237 |
#define WHITE_ON_BLUE "0;37;44" |
| 238 |
#define WHITE_ON_GREEN "0;37;42" |
| 239 |
#define YELLOW_ON_BLACK "0;33;40" |
| 240 |
#define BLINK_REVERSE "0;5;7" |
| 241 |
|
| 242 |
extern char origin_mode_mesg[80]; |
| 243 |
extern char lrmm_mesg[80]; |
| 244 |
extern char lr_marg_mesg[80]; |
| 245 |
extern char tb_marg_mesg[80]; |
| 246 |
extern char txt_override_color[80]; |
| 247 |
extern int current_Gx[4]; |
| 248 |
extern int scs_national; |
| 249 |
|
| 250 |
extern RETSIGTYPE onbrk(SIG_ARGS); |
| 251 |
extern GCC_NORETURN RETSIGTYPE onterm(SIG_ARGS); |
| 252 |
extern char *chrformat(const char *s, int col, int first); |
| 253 |
extern char *get_reply(void); |
| 254 |
extern char *instr(void); |
| 255 |
extern char *replay_string(void); |
| 256 |
extern char *skip_csi(char *input); |
| 257 |
extern char *skip_dcs(char *input); |
| 258 |
extern char *skip_digits(char *src); |
| 259 |
extern char *skip_osc(char *input); |
| 260 |
extern char *skip_prefix(const char *prefix, char *input); |
| 261 |
extern char *skip_ss3(char *input); |
| 262 |
extern char inchar(void); |
| 263 |
extern const char *charset_name(int g, int n); |
| 264 |
extern const char *parse_Sdesig(const char *source, int *offset); |
| 265 |
extern const char *parse_upss_name(const char *source, int size); |
| 266 |
extern const char *skip_csi_2(const char *input); |
| 267 |
extern const char *skip_dcs_2(const char *input); |
| 268 |
extern const char *skip_digits_2(const char *src); |
| 269 |
extern const char *skip_prefix_2(const char *prefix, const char *input); |
| 270 |
extern const char *skip_ss3_2(const char *input); |
| 271 |
extern const char *skip_xdigits(const char *src, int *value); |
| 272 |
extern int any_DSR(MENU_ARGS, const char *text, void (*explain) (const char *report)); |
| 273 |
extern int any_RQM(MENU_ARGS, RQM_DATA * table, int tablesize, int private); |
| 274 |
extern int any_decrqpsr(MENU_ARGS, int Ps); |
| 275 |
extern int any_decrqss(const char *msg, const char *func); |
| 276 |
extern int any_decrqss2(const char *msg, const char *func, const char *expected); |
| 277 |
extern int bug_a(MENU_ARGS); |
| 278 |
extern int bug_b(MENU_ARGS); |
| 279 |
extern int bug_c(MENU_ARGS); |
| 280 |
extern int bug_d(MENU_ARGS); |
| 281 |
extern int bug_e(MENU_ARGS); |
| 282 |
extern int bug_f(MENU_ARGS); |
| 283 |
extern int bug_l(MENU_ARGS); |
| 284 |
extern int bug_s(MENU_ARGS); |
| 285 |
extern int bug_w(MENU_ARGS); |
| 286 |
extern int chrprint2(const char *s, int row, int col); |
| 287 |
extern int conv_to_utf32(unsigned *target, const char *source, unsigned limit); |
| 288 |
extern int conv_to_utf8(unsigned char *target, unsigned source, unsigned limit); |
| 289 |
extern int do_scs(int g); |
| 290 |
extern int get_bottom_margin(int n); |
| 291 |
extern int get_char(void); |
| 292 |
extern int get_left_margin(void); |
| 293 |
extern int get_level(void); |
| 294 |
extern int get_right_margin(void); |
| 295 |
extern int get_top_margin(void); |
| 296 |
extern int is_replaying(void); |
| 297 |
extern int main(int argc, char *argv[]); |
| 298 |
extern int menu(MENU *table); |
| 299 |
extern int menu2(MENU *table, int tp); |
| 300 |
extern int not_impl(MENU_ARGS); |
| 301 |
extern int parse_decrqss(char *report, const char *func); |
| 302 |
extern int print_chr(int c); |
| 303 |
extern int print_str(const char *s); |
| 304 |
extern int reset_charset(MENU_ARGS); |
| 305 |
extern int rpt_DECSTBM(MENU_ARGS); |
| 306 |
extern int sane_cs(int g); |
| 307 |
extern int scan_DA(const char *str, int *pos); |
| 308 |
extern int scan_any(const char *str, int *pos, int toc); |
| 309 |
extern int scanto(const char *str, int *pos, int toc); |
| 310 |
extern int set_DECRPM(int level); |
| 311 |
extern int set_level(int level); |
| 312 |
extern int setup_terminal(MENU_ARGS); |
| 313 |
extern int specify_G0(MENU_ARGS); |
| 314 |
extern int specify_G1(MENU_ARGS); |
| 315 |
extern int specify_G2(MENU_ARGS); |
| 316 |
extern int specify_G3(MENU_ARGS); |
| 317 |
extern int strip_suffix(char *src, const char *suffix); |
| 318 |
extern int strip_terminator(char *src); |
| 319 |
extern int terminal_id(void); |
| 320 |
extern int title(int offset); |
| 321 |
extern int toggle_DECOM(MENU_ARGS); |
| 322 |
extern int toggle_LRMM(MENU_ARGS); |
| 323 |
extern int toggle_SLRM(MENU_ARGS); |
| 324 |
extern int toggle_STBM(MENU_ARGS); |
| 325 |
extern int toggle_color_mode(MENU_ARGS); |
| 326 |
extern int toggle_nrc(MENU_ARGS); |
| 327 |
extern int tst_CBT(MENU_ARGS); |
| 328 |
extern int tst_CHA(MENU_ARGS); |
| 329 |
extern int tst_CHT(MENU_ARGS); |
| 330 |
extern int tst_CNL(MENU_ARGS); |
| 331 |
extern int tst_CPL(MENU_ARGS); |
| 332 |
extern int tst_DECRPM(MENU_ARGS); |
| 333 |
extern int tst_DECSTR(MENU_ARGS); |
| 334 |
extern int tst_DSR_cursor(MENU_ARGS); |
| 335 |
extern int tst_DSR_keyboard(MENU_ARGS); |
| 336 |
extern int tst_DSR_printer(MENU_ARGS); |
| 337 |
extern int tst_DSR_userkeys(MENU_ARGS); |
| 338 |
extern int tst_HPA(MENU_ARGS); |
| 339 |
extern int tst_HPR(MENU_ARGS); |
| 340 |
extern int tst_SD(MENU_ARGS); |
| 341 |
extern int tst_SRM(MENU_ARGS); |
| 342 |
extern int tst_SU(MENU_ARGS); |
| 343 |
extern int tst_VPA(MENU_ARGS); |
| 344 |
extern int tst_VPR(MENU_ARGS); |
| 345 |
extern int tst_bugs(MENU_ARGS); |
| 346 |
extern int tst_characters(MENU_ARGS); |
| 347 |
extern int tst_colors(MENU_ARGS); |
| 348 |
extern int tst_doublesize(MENU_ARGS); |
| 349 |
extern int tst_ecma48_curs(MENU_ARGS); |
| 350 |
extern int tst_ecma48_misc(MENU_ARGS); |
| 351 |
extern int tst_insdel(MENU_ARGS); |
| 352 |
extern int tst_keyboard(MENU_ARGS); |
| 353 |
extern int tst_keyboard_layout(const char *scs_params); |
| 354 |
extern int tst_mouse(MENU_ARGS); |
| 355 |
extern int tst_movements(MENU_ARGS); |
| 356 |
extern int tst_nonvt100(MENU_ARGS); |
| 357 |
extern int tst_printing(MENU_ARGS); |
| 358 |
extern int tst_reports(MENU_ARGS); |
| 359 |
extern int tst_rst(MENU_ARGS); |
| 360 |
extern int tst_screen(MENU_ARGS); |
| 361 |
extern int tst_setup(MENU_ARGS); |
| 362 |
extern int tst_softchars(MENU_ARGS); |
| 363 |
extern int tst_statusline(MENU_ARGS); |
| 364 |
extern int tst_tek4014(MENU_ARGS); |
| 365 |
extern int tst_upss(MENU_ARGS); |
| 366 |
extern int tst_vt220(MENU_ARGS); |
| 367 |
extern int tst_vt220_device_status(MENU_ARGS); |
| 368 |
extern int tst_vt220_reports(MENU_ARGS); |
| 369 |
extern int tst_vt220_screen(MENU_ARGS); |
| 370 |
extern int tst_vt320(MENU_ARGS); |
| 371 |
extern int tst_vt320_DECRQSS(MENU_ARGS); |
| 372 |
extern int tst_vt320_cursor(MENU_ARGS); |
| 373 |
extern int tst_vt320_device_status(MENU_ARGS); |
| 374 |
extern int tst_vt320_report_presentation(MENU_ARGS); |
| 375 |
extern int tst_vt320_reports(MENU_ARGS); |
| 376 |
extern int tst_vt320_screen(MENU_ARGS); |
| 377 |
extern int tst_vt420(MENU_ARGS); |
| 378 |
extern int tst_vt420_DECRQSS(MENU_ARGS); |
| 379 |
extern int tst_vt420_cursor(MENU_ARGS); |
| 380 |
extern int tst_vt420_device_status(MENU_ARGS); |
| 381 |
extern int tst_vt420_report_presentation(MENU_ARGS); |
| 382 |
extern int tst_vt420_reports(MENU_ARGS); |
| 383 |
extern int tst_vt52(MENU_ARGS); |
| 384 |
extern int tst_vt520(MENU_ARGS); |
| 385 |
extern int tst_vt520_DECRQSS(MENU_ARGS); |
| 386 |
extern int tst_vt520_reports(MENU_ARGS); |
| 387 |
extern int tst_xterm(MENU_ARGS); |
| 388 |
extern int vt_move(int row, int col); |
| 389 |
extern GCC_NORETURN void bye(void); |
| 390 |
extern void close_replay(void); |
| 391 |
extern void default_level(void); |
| 392 |
extern void dirty_charset(int state); |
| 393 |
extern void do_scrolling(void); |
| 394 |
extern void enable_logging(const char *filename); |
| 395 |
extern void finish_vt420_cursor(MENU_ARGS); |
| 396 |
extern void initterminal(int pn); |
| 397 |
extern void menus_vt420_cursor(void); |
| 398 |
extern void pause_replay(void); |
| 399 |
extern void reset_colors(void); |
| 400 |
extern void reset_level(void); |
| 401 |
extern void restore_level(const VTLEVEL *save); |
| 402 |
extern void resume_replay(void); |
| 403 |
extern void save_level(VTLEVEL *save); |
| 404 |
extern void scs_graphics(void); |
| 405 |
extern void scs_normal(void); |
| 406 |
extern void set_colors(const char *value); |
| 407 |
extern void setup_replay(const char *filename); |
| 408 |
extern void setup_softchars(const char *filename); |
| 409 |
extern void setup_vt420_cursor(MENU_ARGS); |
| 410 |
extern void show_mousemodes(void); |
| 411 |
extern void show_result(const char *fmt, ...) GCC_PRINTFLIKE(1,2); |
| 412 |
extern void slowly(void); |
| 413 |
extern void test_with_margins(int enable); |
| 414 |
extern void vt_clear(int code); |
| 415 |
extern void vt_el(int code); |
| 416 |
extern void vt_hilite(int flag); |
| 417 |
|
| 418 |
extern GCC_NORETURN void failed(const char *); |
| 419 |
extern GCC_NORETURN void no_memory(void); |
| 420 |
|
| 421 |
#endif /* VTTEST_H */ |