1 #include <stdio.h> 2 #include <unistd.h> 3 #include <string.h> 4 #include <stdlib.h> 5 #include <errno.h> 6 #include "lt_types.h" 7 #include "wchar.h" 8 9 #define ENVBUF_SIZE 4096 10 typedef struct EnvBuf { 11 char** env_list; 12 char* env_estr; 13 char* env_buf[ENVBUF_SIZE/sizeof(char*)]; 14 } EnvBuf; 15 16 typedef struct TestSetup { 17 char* setup_name; 18 char* textfile; 19 char** argv; 20 int argc; 21 EnvBuf env; 22 } TestSetup; 23 24 typedef struct LessPipeline { 25 int less_in; 26 int screen_out; 27 int screen_width; 28 int screen_height; 29 pid_t less_pid; 30 pid_t screen_pid; 31 const char* tempfile; 32 int less_in_pipe[2]; 33 int screen_in_pipe[2]; 34 int screen_out_pipe[2]; 35 } LessPipeline; 36 37 typedef struct TermInfo { 38 char backspace_key; 39 char* enter_underline; 40 char* exit_underline; 41 char* enter_bold; 42 char* exit_bold; 43 char* enter_blink; 44 char* exit_blink; 45 char* enter_standout; 46 char* exit_standout; 47 char* clear_screen; 48 char* cursor_move; 49 char* key_right; 50 char* key_left; 51 char* key_up; 52 char* key_down; 53 char* key_home; 54 char* key_end; 55 char* enter_keypad; 56 char* exit_keypad; 57 char* init_term; 58 char* deinit_term; 59 } TermInfo; 60 61 int log_open(char const* logfile); 62 void log_close(void); 63 int log_file_header(void); 64 int log_test_header(char* const* argv, int argc, const char* textfile); 65 int log_test_footer(void); 66 int log_env(const char* name, int namelen, const char* value); 67 int log_tty_char(wchar ch); 68 int log_screen(byte const* img, int len); 69 LessPipeline* create_less_pipeline(char* const* argv, int argc, char* const* envp); 70 void destroy_less_pipeline(LessPipeline* pipeline); 71 void print_strings(const char* title, char* const* strings); 72 void free_test_setup(TestSetup* setup); 73 TestSetup* read_test_setup(FILE* fd, char const* less); 74 int read_zline(FILE* fd, char* line, int line_len); 75 void raw_mode(int tty, int on); 76 int setup_term(void); 77 void display_screen(const byte* img, int imglen, int screen_width, int screen_height); 78 void display_screen_debug(const byte* img, int imglen, int screen_width, int screen_height); 79 const char* get_envp(char* const* envp, const char* name); 80 int run_interactive(char* const* argv, int argc, char* const* envp); 81 int run_testfile(const char* testfile, const char* less); 82 void env_init(EnvBuf* env); 83 void env_addpair(EnvBuf* env, const char* name, const char* value); 84 char* const* less_envp(char* const* envp, int interactive); 85