tnconfig.h
上传用户:tigerk9
上传日期:2020-03-10
资源大小:237k
文件大小:6k
源码类别:

Telnet客户端

开发平台:

Visual C++

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