00001 #ifndef PUTTY_PUTTY_H
00002 #define PUTTY_PUTTY_H
00003
00004 #include <stdio.h>
00005
00006 #ifdef __SYMBIAN32__
00007 #include "epocmisc.h"
00008 #endif
00009
00010 #include "network.h"
00011
00012 #define PUTTY_REG_POS "Software\\SimonTatham\\PuTTY"
00013 #define PUTTY_REG_PARENT "Software\\SimonTatham"
00014 #define PUTTY_REG_PARENT_CHILD "PuTTY"
00015 #define PUTTY_REG_GPARENT "Software"
00016 #define PUTTY_REG_GPARENT_CHILD "SimonTatham"
00017
00018
00019
00020
00021
00022
00023 #ifdef PUTTY_DO_GLOBALS
00024 #define GLOBAL
00025 #else
00026 #define GLOBAL extern
00027 #endif
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #define TATTR_ACTCURS 0x4UL
00044 #define TATTR_PASCURS 0x2UL
00045 #define TATTR_RIGHTCURS 0x1UL
00046
00047 #define LATTR_NORM 0x00000000UL
00048 #define LATTR_WIDE 0x01000000UL
00049 #define LATTR_TOP 0x02000000UL
00050 #define LATTR_BOT 0x03000000UL
00051 #define LATTR_MODE 0x03000000UL
00052 #define LATTR_WRAPPED 0x10000000UL
00053
00054 #define ATTR_INVALID 0x00FF0000UL
00055
00056
00057 #define ATTR_OEMCP 0x0000F000UL
00058 #define ATTR_ACP 0x0000F100UL
00059
00060
00061 #define ATTR_ASCII 0x0000D800UL
00062 #define ATTR_LINEDRW 0x0000D900UL
00063 #define ATTR_SCOACS 0x0000DA00UL
00064 #define ATTR_GBCHR 0x0000DB00UL
00065 #define CSET_MASK 0x0000FF00UL
00066
00067 #define DIRECT_CHAR(c) ((c&0xFC00)==0xD800)
00068 #define DIRECT_FONT(c) ((c&0xFE00)==0xF000)
00069
00070 #define UCSERR (ATTR_LINEDRW|'a')
00071 #define UCSWIDE 0x303F
00072
00073 #define ATTR_NARROW 0x20000000UL
00074 #define ATTR_WIDE 0x10000000UL
00075 #define ATTR_BOLD 0x01000000UL
00076 #define ATTR_UNDER 0x02000000UL
00077 #define ATTR_REVERSE 0x04000000UL
00078 #define ATTR_BLINK 0x08000000UL
00079 #define ATTR_FGMASK 0x000F0000UL
00080 #define ATTR_BGMASK 0x00F00000UL
00081 #define ATTR_COLOURS 0x00FF0000UL
00082 #define ATTR_FGSHIFT 16
00083 #define ATTR_BGSHIFT 20
00084
00085 #define ATTR_DEFAULT 0x00980000UL
00086 #define ATTR_DEFFG 0x00080000UL
00087 #define ATTR_DEFBG 0x00900000UL
00088 #define ERASE_CHAR (ATTR_DEFAULT | ATTR_ASCII | ' ')
00089 #define ATTR_MASK 0xFFFFFF00UL
00090 #define CHAR_MASK 0x000000FFUL
00091
00092 #define ATTR_CUR_AND (~(ATTR_BOLD|ATTR_REVERSE|ATTR_BLINK|ATTR_COLOURS))
00093 #define ATTR_CUR_XOR 0x00BA0000UL
00094
00095 #ifdef __SYMBIAN32__
00096 typedef void* Context;
00097 #else
00098 typedef HDC Context;
00099 #endif
00100 #define SEL_NL { 13, 10 }
00101
00102 GLOBAL int rows, cols, savelines;
00103
00104 GLOBAL int has_focus;
00105
00106 GLOBAL int in_vbell;
00107 GLOBAL unsigned long vbell_startpoint;
00108
00109 GLOBAL int app_cursor_keys, app_keypad_keys, vt52_mode;
00110 GLOBAL int repeat_off, cr_lf_return;
00111
00112 GLOBAL int seen_key_event;
00113 GLOBAL int seen_disp_event;
00114 GLOBAL int alt_pressed;
00115
00116 GLOBAL int session_closed;
00117
00118 GLOBAL int big_cursor;
00119
00120 GLOBAL char *help_path;
00121 GLOBAL int help_has_contents;
00122
00123 GLOBAL int utf;
00124 GLOBAL int dbcs_screenfont;
00125 GLOBAL int font_codepage;
00126 GLOBAL int kbd_codepage;
00127 GLOBAL int line_codepage;
00128 GLOBAL WCHAR unitab_scoacs[256];
00129 GLOBAL WCHAR unitab_line[256];
00130 GLOBAL WCHAR unitab_xterm[256];
00131 GLOBAL WCHAR unitab_oemcp[256];
00132 GLOBAL WCHAR unitab_font[256];
00133 GLOBAL unsigned char unitab_ctrl[256];
00134 #define in_utf (utf || line_codepage==CP_UTF8)
00135
00136 #define LGXF_OVR 1
00137 #define LGXF_APN 0
00138 #define LGXF_ASK -1
00139 #define LGTYP_NONE 0
00140 #define LGTYP_ASCII 1
00141 #define LGTYP_DEBUG 2
00142 #define LGTYP_PACKETS 3
00143
00144
00145
00146
00147
00148 #ifndef __SYMBIAN32__
00149 GLOBAL HWND logbox;
00150 #endif
00151
00152
00153
00154
00155
00156
00157 #define WM_XUSER (WM_USER + 0x2000)
00158 #define WM_NETEVENT (WM_XUSER + 5)
00159
00160 typedef enum {
00161 TS_AYT, TS_BRK, TS_SYNCH, TS_EC, TS_EL, TS_GA, TS_NOP, TS_ABORT,
00162 TS_AO, TS_IP, TS_SUSP, TS_EOR, TS_EOF, TS_LECHO, TS_RECHO, TS_PING,
00163 TS_EOL
00164 } Telnet_Special;
00165
00166 typedef enum {
00167 MBT_NOTHING,
00168 MBT_LEFT, MBT_MIDDLE, MBT_RIGHT,
00169 MBT_SELECT, MBT_EXTEND, MBT_PASTE,
00170 MBT_WHEEL_UP, MBT_WHEEL_DOWN
00171 } Mouse_Button;
00172
00173 typedef enum {
00174 MA_NOTHING, MA_CLICK, MA_2CLK, MA_3CLK, MA_DRAG, MA_RELEASE
00175 } Mouse_Action;
00176
00177 typedef enum {
00178 VT_XWINDOWS, VT_OEMANSI, VT_OEMONLY, VT_POORMAN, VT_UNICODE
00179 } VT_Mode;
00180
00181 enum {
00182
00183
00184
00185 CIPHER_WARN,
00186 CIPHER_3DES,
00187 CIPHER_BLOWFISH,
00188 CIPHER_AES,
00189 CIPHER_DES,
00190 CIPHER_MAX
00191 };
00192
00193 enum {
00194
00195
00196
00197 LD_YES, LD_NO, LD_BACKEND
00198 };
00199
00200 enum {
00201
00202
00203
00204 LD_EDIT,
00205 LD_ECHO
00206 };
00207
00208 enum {
00209
00210
00211
00212 COE_NEVER,
00213 COE_NORMAL,
00214 COE_ALWAYS
00215 };
00216
00217 typedef struct {
00218 char *(*init) (char *host, int port, char **realhost, int nodelay);
00219
00220 int (*send) (char *buf, int len);
00221
00222 int (*sendbuffer) (void);
00223 void (*size) (void);
00224 void (*special) (Telnet_Special code);
00225 Socket(*socket) (void);
00226 int (*exitcode) (void);
00227 int (*sendok) (void);
00228 int (*ldisc) (int);
00229
00230
00231
00232
00233 void (*unthrottle) (int);
00234 int default_port;
00235 } Backend;
00236
00237 GLOBAL Backend *back;
00238
00239 extern struct backend_list {
00240 int protocol;
00241 char *name;
00242 Backend *backend;
00243 } backends[];
00244
00245 typedef struct {
00246
00247 char host[512];
00248 int port;
00249 enum { PROT_RAW, PROT_TELNET, PROT_RLOGIN, PROT_SSH } protocol;
00250 int close_on_exit;
00251 int warn_on_close;
00252 int ping_interval;
00253 int tcp_nodelay;
00254
00255 char proxy_exclude_list[512];
00256 enum { PROXY_NONE, PROXY_HTTP, PROXY_SOCKS, PROXY_TELNET } proxy_type;
00257 char proxy_host[512];
00258 int proxy_port;
00259 char proxy_username[32];
00260 char proxy_password[32];
00261 char proxy_telnet_command[512];
00262 int proxy_socks_version;
00263
00264 char remote_cmd[512];
00265 char remote_cmd2[512];
00266
00267 char *remote_cmd_ptr;
00268
00269 char *remote_cmd_ptr2;
00270
00271 int nopty;
00272 int compression;
00273 int agentfwd;
00274 int change_username;
00275 int ssh_cipherlist[CIPHER_MAX];
00276 char keyfile[FILENAME_MAX];
00277 int sshprot;
00278 int ssh2_des_cbc;
00279 int try_tis_auth;
00280 int try_ki_auth;
00281 int ssh_subsys;
00282 int ssh_subsys2;
00283
00284 char termtype[32];
00285 char termspeed[32];
00286 char environmt[1024];
00287 char username[100];
00288 char localusername[100];
00289 int rfc_environ;
00290 int passive_telnet;
00291
00292 int bksp_is_delete;
00293 int rxvt_homeend;
00294 int funky_type;
00295 int no_applic_c;
00296 int no_applic_k;
00297 int no_mouse_rep;
00298 int no_remote_resize;
00299 int no_alt_screen;
00300 int no_remote_wintitle;
00301 int no_dbackspace;
00302 int no_remote_charset;
00303 int app_cursor;
00304 int app_keypad;
00305 int nethack_keypad;
00306 int telnet_keyboard;
00307 int telnet_newline;
00308 int alt_f4;
00309 int alt_space;
00310 int alt_only;
00311 int localecho;
00312 int localedit;
00313 int alwaysontop;
00314 int fullscreenonaltenter;
00315 int scroll_on_key;
00316 int scroll_on_disp;
00317 int compose_key;
00318 int ctrlaltkeys;
00319 char wintitle[256];
00320
00321 int savelines;
00322 int dec_om;
00323 int wrap_mode;
00324 int lfhascr;
00325 int cursor_type;
00326 int blink_cur;
00327 enum {
00328 BELL_DISABLED, BELL_DEFAULT, BELL_VISUAL, BELL_WAVEFILE
00329 } beep;
00330 enum {
00331 B_IND_DISABLED, B_IND_FLASH, B_IND_STEADY
00332 } beep_ind;
00333 int bellovl;
00334 int bellovl_n;
00335 int bellovl_t;
00336 int bellovl_s;
00337 char bell_wavefile[FILENAME_MAX];
00338 int scrollbar;
00339 int scrollbar_in_fullscreen;
00340 enum { RESIZE_TERM, RESIZE_DISABLED, RESIZE_FONT, RESIZE_EITHER } resize_action;
00341 int bce;
00342 int blinktext;
00343 int win_name_always;
00344 int width, height;
00345 char font[64];
00346 int fontisbold;
00347 int fontheight;
00348 int fontcharset;
00349 char logfilename[FILENAME_MAX];
00350 int logtype;
00351 int logxfovr;
00352 int hide_mouseptr;
00353 int sunken_edge;
00354 int window_border;
00355 char answerback[256];
00356 char printer[128];
00357
00358 int try_palette;
00359 int bold_colour;
00360 unsigned char colours[22][3];
00361
00362 int mouse_is_xterm;
00363 int rect_select;
00364 int rawcnp;
00365 int rtf_paste;
00366 int mouse_override;
00367 short wordness[256];
00368
00369 VT_Mode vtmode;
00370 char line_codepage[128];
00371 int xlat_capslockcyr;
00372
00373 int x11_forward;
00374 char x11_display[128];
00375
00376 int lport_acceptall;
00377 int rport_acceptall;
00378 char portfwd[1024];
00379
00380 enum {
00381 BUG_AUTO, BUG_OFF, BUG_ON
00382 } sshbug_ignore1, sshbug_plainpw1, sshbug_rsa1,
00383 sshbug_hmac2, sshbug_derivekey2, sshbug_rsapad2,
00384 sshbug_dhgex2;
00385 } Config;
00386
00387
00388
00389
00390 #ifndef SSH_DEFAULT
00391 #define DEFAULT_PROTOCOL PROT_TELNET
00392 #define DEFAULT_PORT 23
00393 #else
00394 #define DEFAULT_PROTOCOL PROT_SSH
00395 #define DEFAULT_PORT 22
00396 #endif
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412 #define FLAG_VERBOSE 0x0001
00413 #define FLAG_STDERR 0x0002
00414 #define FLAG_INTERACTIVE 0x0004
00415 GLOBAL int flags;
00416
00417 GLOBAL Config cfg;
00418 GLOBAL int default_protocol;
00419 GLOBAL int default_port;
00420
00421 struct RSAKey;
00422
00423
00424
00425
00426 void request_resize(int, int);
00427 void do_text(Context, int, int, char *, int, unsigned long, int);
00428 void do_cursor(Context, int, int, char *, int, unsigned long, int);
00429 int CharWidth(Context ctx, int uc);
00430 void set_title(char *);
00431 void set_icon(char *);
00432 void set_sbar(int, int, int);
00433 Context get_ctx(void);
00434 void free_ctx(Context);
00435 void palette_set(int, int, int, int);
00436 void palette_reset(void);
00437 void write_aclip(char *, int, int);
00438 void write_clip(wchar_t *, int, int);
00439 void get_clip(wchar_t **, int *);
00440 void optimised_move(int, int, int);
00441 void set_raw_mouse_mode(int);
00442 Mouse_Button translate_button(Mouse_Button b);
00443 void connection_fatal(char *, ...);
00444 void fatalbox(char *, ...);
00445 void beep(int);
00446 void begin_session(void);
00447 void sys_cursor(int x, int y);
00448 #define OPTIMISE_IS_SCROLL 1
00449
00450 void set_iconic(int iconic);
00451 void move_window(int x, int y);
00452 void set_zorder(int top);
00453 void refresh_window(void);
00454 void set_zoomed(int zoomed);
00455 int is_iconic(void);
00456 void get_window_pos(int *x, int *y);
00457 void get_window_pixels(int *x, int *y);
00458 char *get_window_title(int icon);
00459
00460 void cleanup_exit(int);
00461
00462
00463
00464
00465 void noise_get_heavy(void (*func) (void *, int));
00466 void noise_get_light(void (*func) (void *, int));
00467 void noise_regular(void);
00468 void noise_ultralight(DWORD data);
00469 void random_save_seed(void);
00470 void random_destroy_seed(void);
00471
00472
00473
00474
00475 void logevent(char *);
00476 void do_defaults(char *, Config *);
00477 void verify_ssh_host_key(char *host, int port, char *keytype,
00478 char *keystr, char *fingerprint);
00479 void askcipher(char *ciphername, int cs);
00480 int askappend(char *filename);
00481 #ifndef __SYMBIAN32__
00482 void defuse_showwindow(void);
00483 int do_config(void);
00484 int do_reconfig(HWND);
00485 void showeventlog(HWND);
00486 void showabout(HWND);
00487 void registry_cleanup(void);
00488 void force_normal(HWND hwnd);
00489 #endif
00490
00491 GLOBAL int nsessions;
00492 GLOBAL char **sessions;
00493
00494
00495
00496
00497 void save_settings(char *section, int do_host, Config * cfg);
00498 void load_settings(char *section, int do_host, Config * cfg);
00499 void get_sesslist(int allocate);
00500
00501
00502
00503
00504
00505 void term_init(void);
00506 void term_size(int, int, int);
00507 void term_out(void);
00508 void term_paint(Context, int, int, int, int);
00509 void term_scroll(int, int);
00510 void term_pwron(void);
00511 void term_clrsb(void);
00512 void term_mouse(Mouse_Button, Mouse_Action, int, int, int, int, int);
00513 void term_deselect(void);
00514 void term_update(void);
00515 void term_invalidate(void);
00516 void term_blink(int set_cursor);
00517 void term_do_paste(void);
00518 void term_paste(void);
00519 void term_nopaste(void);
00520 int term_ldisc(int option);
00521 int from_backend(int is_stderr, char *data, int len);
00522 void logfopen(void);
00523 void logfclose(void);
00524 void term_copyall(void);
00525 void term_reconfig(void);
00526
00527
00528
00529
00530 void logtraffic(unsigned char c, int logmode);
00531 enum { PKT_INCOMING, PKT_OUTGOING };
00532 void log_eventlog(char *string);
00533 void log_packet(int direction, int type, char *texttype, void *data, int len);
00534
00535
00536
00537
00538
00539 extern Backend raw_backend;
00540
00541
00542
00543
00544
00545 extern Backend rlogin_backend;
00546
00547
00548
00549
00550
00551 extern Backend telnet_backend;
00552
00553
00554
00555
00556
00557
00558
00559 GLOBAL int (*ssh_get_line) (const char *prompt, char *str, int maxlen,
00560 int is_pw);
00561 GLOBAL int ssh_getline_pw_only;
00562 extern Backend ssh_backend;
00563
00564
00565
00566
00567
00568 extern void ldisc_send(char *buf, int len, int interactive);
00569
00570
00571
00572
00573
00574 void random_add_noise(void *noise, int length);
00575 void random_init(void);
00576 int random_byte(void);
00577 void random_get_savedata(void **data, int *len);
00578 extern int random_active;
00579
00580
00581
00582
00583
00584 #include "misc.h"
00585
00586
00587
00588
00589 extern char ver[];
00590
00591
00592
00593
00594 #ifndef __SYMBIAN32__
00595 void UpdateSizeTip(HWND src, int cx, int cy);
00596 void EnableSizeTip(int bEnable);
00597 #endif
00598
00599
00600
00601
00602 #ifndef CP_UTF8
00603 #define CP_UTF8 65001
00604 #endif
00605 void init_ucs_tables(void);
00606 void lpage_send(int codepage, char *buf, int len, int interactive);
00607 void luni_send(wchar_t * widebuf, int len, int interactive);
00608 wchar_t xlat_uskbd2cyrllic(int ch);
00609 int check_compose(int first, int second);
00610 int decode_codepage(char *cp_name);
00611 char *cp_enumerate (int index);
00612 char *cp_name(int codepage);
00613 void get_unitab(int codepage, wchar_t * unitab, int ftype);
00614
00615
00616
00617
00618 #ifdef MSCRYPTOAPI
00619 int crypto_startup();
00620 void crypto_wrapup();
00621 #endif
00622
00623
00624
00625
00626 void agent_query(void *in, int inlen, void **out, int *outlen);
00627 int agent_exists(void);
00628
00629
00630
00631
00632 const char *wc_error(int value);
00633 int wc_match(const char *wildcard, const char *target);
00634 int wc_unescape(char *output, const char *wildcard);
00635
00636
00637
00638
00639
00640 extern int console_batch_mode;
00641 int console_get_line(const char *prompt, char *str, int maxlen, int is_pw);
00642
00643
00644
00645
00646 typedef struct printer_enum_tag printer_enum;
00647 typedef struct printer_job_tag printer_job;
00648 printer_enum *printer_start_enum(int *nprinters);
00649 char *printer_get_name(printer_enum *, int);
00650 void printer_finish_enum(printer_enum *);
00651 printer_job *printer_start_job(char *printer);
00652 void printer_job_data(printer_job *, void *, int);
00653 void printer_finish_job(printer_job *);
00654
00655
00656
00657
00658
00659
00660 int cmdline_process_param(char *, char *, int);
00661 void cmdline_run_saved(void);
00662 extern char *cmdline_password;
00663 #define TOOLTYPE_FILETRANSFER 1
00664 extern int cmdline_tooltype;
00665
00666 void cmdline_error(char *, ...);
00667
00668 #endif