1 // Tnconfig.h 2 // Written by Paul Brannan <pbranna@clemson.edu> 3 // 4 // This is a class designed for use with Brad Johnson's Console Telnet 5 // It reads an ini file and keeps the settings for later retrieval. 6 // It does not store any information about the current settings, only default 7 // or recommended settings. 8 9 #pragma once 10 11 // Ioannou 2 June 98: Borland needs them - quick hack 12 #ifdef __BORLANDC__ 13 #define bool BOOL 14 #define true TRUE 15 #define false FALSE 16 #endif // __BORLANDC__ 17 18 #include "tnerror.h" 19 20 #define ENV_TELNET_CFG "TELNET_CFG" 21 #define ENV_TELNET_REDIR "TELNET_REDIR" 22 #define ENV_INPUT_REDIR "TELNET_INPUT_REDIR" 23 #define ENV_OUTPUT_REDIR "TENLET_OUTPUT_REDIR" 24 #define ENV_TELNET_INI "TELNET_INI" 25 26 class TConfig { 27 public: 28 TConfig(); 29 ~TConfig(); 30 31 // Miscellaneous strings get_startdir()32 const char *get_startdir() const {return startdir;} get_exename()33 const char *get_exename() const {return exename;} get_keyfile()34 const char *get_keyfile() const {return keyfile;} get_inifile()35 const char *get_inifile() const {return inifile;} get_dumpfile()36 const char *get_dumpfile() const {return dumpfile;} get_term()37 const char *get_term() const {return term;} get_printer_name()38 const char *get_printer_name() const {return printer_name;} get_default_config()39 const char *get_default_config() const {return default_config;} 40 41 // Terminal settings get_input_redir()42 int get_input_redir() const {return input_redir;} get_output_redir()43 int get_output_redir() const {return output_redir;} get_strip_redir()44 bool get_strip_redir() const {return strip_redir;} get_dstrbksp()45 bool get_dstrbksp() const {return dstrbksp;} get_eightbit_ansi()46 bool get_eightbit_ansi() const {return eightbit_ansi;} get_vt100_mode()47 bool get_vt100_mode() const {return vt100_mode;} get_disable_break()48 bool get_disable_break() const {return disable_break;} get_speaker_beep()49 bool get_speaker_beep() const {return speaker_beep;} get_do_beep()50 bool get_do_beep() const {return do_beep;} get_preserve_colors()51 bool get_preserve_colors() const {return preserve_colors;} get_wrapline()52 bool get_wrapline() const {return wrapline;} get_fast_write()53 bool get_fast_write() const {return fast_write;} get_lock_linewrap()54 bool get_lock_linewrap() const {return lock_linewrap;} get_set_title()55 bool get_set_title() const { return set_title;} get_term_width()56 int get_term_width() const {return term_width;} get_term_height()57 int get_term_height() const {return term_height;} get_window_width()58 int get_window_width() const {return window_width;} get_window_height()59 int get_window_height() const {return window_height;} get_wide_enable()60 bool get_wide_enable() const {return wide_enable;} get_control_break_as_c()61 bool get_control_break_as_c() const {return ctrlbreak_as_ctrlc;} get_buffer_size()62 int get_buffer_size() const {return buffer_size;} 63 64 // Colors get_blink_bg()65 int get_blink_bg() const {return blink_bg;} get_blink_fg()66 int get_blink_fg() const {return blink_fg;} get_underline_bg()67 int get_underline_bg() const {return underline_bg;} get_underline_fg()68 int get_underline_fg() const {return underline_fg;} get_ulblink_bg()69 int get_ulblink_bg() const {return ulblink_bg;} get_ulblink_fg()70 int get_ulblink_fg() const {return ulblink_fg;} get_normal_bg()71 int get_normal_bg() const {return normal_bg;} get_normal_fg()72 int get_normal_fg() const {return normal_fg;} get_scroll_bg()73 int get_scroll_bg() const {return scroll_bg;} get_scroll_fg()74 int get_scroll_fg() const {return scroll_fg;} get_status_bg()75 int get_status_bg() const {return status_bg;} get_status_fg()76 int get_status_fg() const {return status_fg;} 77 78 // Mouse get_enable_mouse()79 bool get_enable_mouse() const {return enable_mouse;} 80 81 // Keyboard get_escape_key()82 char get_escape_key() const {return escape_key[0];} get_scrollback_key()83 char get_scrollback_key() const {return scrollback_key[0];} get_dial_key()84 char get_dial_key() const {return dial_key[0];} get_alt_erase()85 bool get_alt_erase() const {return alt_erase;} get_keyboard_paste()86 bool get_keyboard_paste() const {return keyboard_paste;} 87 88 // Scrollback get_scroll_mode()89 const char *get_scroll_mode() const {return scroll_mode;} get_scroll_enable()90 bool get_scroll_enable() const {return scroll_enable;} get_scroll_size()91 int get_scroll_size() const {return scroll_size;} 92 93 // Scripting get_scriptname()94 const char *get_scriptname() const {return scriptname;} get_script_enable()95 bool get_script_enable() const {return script_enable;} 96 97 // Pipes get_netpipe()98 const char *get_netpipe() const {return netpipe;} get_iopipe()99 const char *get_iopipe() const {return iopipe;} 100 101 // Host configuration get_host()102 const char *get_host() const {return host;} get_port()103 const char *get_port() const {return port;} 104 105 // Initialization 106 void init(char *dirname, char *exename); 107 bool Process_Params(int argc, char *argv[]); 108 109 // Ini variables 110 void print_vars(); 111 void print_vars(char *s); 112 void print_groups(); 113 bool set_value(const char *var, const char *value); 114 int print_value(const char *var); 115 116 // Aliases 117 void print_aliases(); 118 bool find_alias(const char *alias_name); 119 120 private: 121 122 void inifile_init(); 123 void keyfile_init(); 124 void redir_init(); 125 void init_varlist(); 126 void init_vars(); 127 void init_aliases(); 128 void set_string(char *dest, const char *src, const int length); 129 void set_bool(bool *boolval, const char *str); 130 131 // Miscellaneous strings 132 char startdir[MAX_PATH]; 133 char exename[MAX_PATH]; 134 char keyfile[MAX_PATH*2]; 135 char inifile[MAX_PATH*2]; 136 char dumpfile[MAX_PATH*2]; 137 char printer_name[MAX_PATH*2]; 138 char term[128]; 139 char default_config[128]; 140 141 // Terminal 142 int input_redir, output_redir; 143 bool strip_redir; 144 bool dstrbksp; 145 bool eightbit_ansi; 146 bool vt100_mode; 147 bool disable_break; 148 bool speaker_beep; 149 bool do_beep; 150 bool preserve_colors; 151 bool wrapline; 152 bool lock_linewrap; 153 bool fast_write; 154 bool set_title; 155 int term_width, term_height; 156 int window_width, window_height; 157 bool wide_enable; 158 bool ctrlbreak_as_ctrlc; 159 int buffer_size; 160 161 // Colors 162 int blink_bg; 163 int blink_fg; 164 int underline_bg; 165 int underline_fg; 166 int ulblink_bg; 167 int ulblink_fg; 168 int normal_bg; 169 int normal_fg; 170 int scroll_bg; 171 int scroll_fg; 172 int status_bg; 173 int status_fg; 174 175 // Mouse 176 bool enable_mouse; 177 178 // Keyboard 179 char escape_key[2]; 180 char scrollback_key[2]; 181 char dial_key[2]; 182 bool alt_erase; 183 bool keyboard_paste; 184 185 // Scrollback 186 char scroll_mode[8]; 187 bool scroll_enable; 188 int scroll_size; 189 190 // Scripting 191 char scriptname[MAX_PATH*2]; 192 bool script_enable; 193 194 // Pipes 195 char netpipe[MAX_PATH*2]; 196 char iopipe[MAX_PATH*2]; 197 198 // Host configration 199 char host[128]; 200 const char *port; 201 202 // Aliases 203 char **aliases; 204 int alias_total; 205 206 }; 207 208 extern TConfig ini; 209