From RDB: a patch to allow special keys (^C, ^Z, Delete, Return) to
[u/mdw/putty] / putty.h
... / ...
CommitLineData
1#ifndef PUTTY_PUTTY_H
2#define PUTTY_PUTTY_H
3
4#include "network.h"
5
6#define PUTTY_REG_POS "Software\\SimonTatham\\PuTTY"
7#define PUTTY_REG_PARENT "Software\\SimonTatham"
8#define PUTTY_REG_PARENT_CHILD "PuTTY"
9#define PUTTY_REG_GPARENT "Software"
10#define PUTTY_REG_GPARENT_CHILD "SimonTatham"
11
12/*
13 * Global variables. Most modules declare these `extern', but
14 * window.c will do `#define PUTTY_DO_GLOBALS' before including this
15 * module, and so will get them properly defined.
16 */
17#ifdef PUTTY_DO_GLOBALS
18#define GLOBAL
19#else
20#define GLOBAL extern
21#endif
22
23#define ATTR_ACTCURS 0x80000000UL /* active cursor (block) */
24#define ATTR_PASCURS 0x40000000UL /* passive cursor (box) */
25#define ATTR_INVALID 0x20000000UL
26#define ATTR_WRAPPED 0x10000000UL
27#define ATTR_RIGHTCURS 0x10000000UL /* doubles as cursor-on-RHS indicator */
28
29#define LATTR_NORM 0x00000000UL
30#define LATTR_WIDE 0x01000000UL
31#define LATTR_TOP 0x02000000UL
32#define LATTR_BOT 0x03000000UL
33#define LATTR_MODE 0x03000000UL
34
35#define ATTR_ASCII 0x00000000UL /* normal ASCII charset ESC ( B */
36#define ATTR_GBCHR 0x00100000UL /* UK variant charset ESC ( A */
37#define ATTR_LINEDRW 0x00200000UL /* line drawing charset ESC ( 0 */
38
39#define ATTR_BOLD 0x00000100UL
40#define ATTR_UNDER 0x00000200UL
41#define ATTR_REVERSE 0x00000400UL
42#define ATTR_BLINK 0x00000800UL
43#define ATTR_FGMASK 0x0000F000UL
44#define ATTR_BGMASK 0x000F0000UL
45#define ATTR_FGSHIFT 12
46#define ATTR_BGSHIFT 16
47
48#define ATTR_DEFAULT 0x00098000UL
49#define ATTR_DEFFG 0x00008000UL
50#define ATTR_DEFBG 0x00090000UL
51#define ATTR_CUR_XOR 0x000BA000UL
52#define ERASE_CHAR (ATTR_DEFAULT | ' ')
53#define ATTR_MASK 0xFFFFFF00UL
54#define CHAR_MASK 0x000000FFUL
55#define CSET_MASK 0x00F00000UL /* mask for character set */
56
57typedef HDC Context;
58#define SEL_NL { 13, 10 }
59
60GLOBAL int rows, cols, savelines;
61
62GLOBAL int font_width, font_height;
63
64#define INBUF_SIZE 2048
65GLOBAL unsigned char inbuf[INBUF_SIZE];
66GLOBAL int inbuf_head;
67
68#define OUTBUF_SIZE 2048
69#define OUTBUF_MASK (OUTBUF_SIZE-1)
70GLOBAL unsigned char outbuf[OUTBUF_SIZE];
71GLOBAL int outbuf_head, outbuf_reap;
72
73GLOBAL int has_focus;
74
75GLOBAL int in_vbell;
76GLOBAL long vbell_timeout;
77
78GLOBAL int app_cursor_keys, app_keypad_keys, vt52_mode;
79GLOBAL int repeat_off, cr_lf_return;
80
81GLOBAL int seen_key_event;
82GLOBAL int seen_disp_event;
83
84GLOBAL int session_closed;
85
86#define LGXF_OVR 1 /* existing logfile overwrite */
87#define LGXF_APN 0 /* existing logfile append */
88#define LGXF_ASK -1 /* existing logfile ask */
89#define LGTYP_NONE 0 /* logmode: no logging */
90#define LGTYP_ASCII 1 /* logmode: pure ascii */
91#define LGTYP_DEBUG 2 /* logmode: all chars of taffic */
92GLOBAL char *logfile;
93
94/*
95 * Window handles for the dialog boxes that can be running during a
96 * PuTTY session.
97 */
98GLOBAL HWND logbox;
99
100/*
101 * I've just looked in the windows standard headr files for WM_USER, there
102 * are hundreds of flags defined using the form WM_USER+123 so I've
103 * renumbered this NETEVENT value and the two in window.c
104 */
105#define WM_XUSER (WM_USER + 0x2000)
106#define WM_NETEVENT (WM_XUSER + 5)
107
108typedef enum {
109 TS_AYT, TS_BRK, TS_SYNCH, TS_EC, TS_EL, TS_GA, TS_NOP, TS_ABORT,
110 TS_AO, TS_IP, TS_SUSP, TS_EOR, TS_EOF, TS_LECHO, TS_RECHO, TS_PING,
111 TS_EOL
112} Telnet_Special;
113
114typedef enum {
115 MBT_NOTHING,
116 MBT_LEFT, MBT_MIDDLE, MBT_RIGHT, /* `raw' button designations */
117 MBT_SELECT, MBT_EXTEND, MBT_PASTE, /* `cooked' button designations */
118 MBT_WHEEL_UP, MBT_WHEEL_DOWN /* mouse wheel */
119} Mouse_Button;
120
121typedef enum {
122 MA_NOTHING, MA_CLICK, MA_2CLK, MA_3CLK, MA_DRAG, MA_RELEASE
123} Mouse_Action;
124
125typedef enum {
126 VT_XWINDOWS, VT_OEMANSI, VT_OEMONLY, VT_POORMAN
127} VT_Mode;
128
129enum {
130 /*
131 * Line discipline option states: off, on, up to the backend.
132 */
133 LD_YES, LD_NO, LD_BACKEND
134};
135
136enum {
137 /*
138 * Line discipline options which the backend might try to control.
139 */
140 LD_EDIT, /* local line editing */
141 LD_ECHO /* local echo */
142};
143
144enum {
145 /*
146 * Close On Exit behaviours. (cfg.close_on_exit)
147 */
148 COE_NEVER, /* Never close the window */
149 COE_NORMAL, /* Close window on "normal" (non-error) exits only */
150 COE_ALWAYS /* Always close the window */
151};
152
153typedef struct {
154 char *(*init) (char *host, int port, char **realhost);
155 void (*send) (char *buf, int len);
156 void (*size) (void);
157 void (*special) (Telnet_Special code);
158 Socket(*socket) (void);
159 int (*sendok) (void);
160 int (*ldisc) (int);
161 int default_port;
162} Backend;
163
164GLOBAL Backend *back;
165
166extern struct backend_list {
167 int protocol;
168 char *name;
169 Backend *backend;
170} backends[];
171
172typedef struct {
173 /* Basic options */
174 char host[512];
175 int port;
176 enum { PROT_RAW, PROT_TELNET, PROT_RLOGIN, PROT_SSH } protocol;
177 int close_on_exit;
178 int warn_on_close;
179 int ping_interval; /* in seconds */
180 /* SSH options */
181 char remote_cmd[512];
182 char *remote_cmd_ptr; /* might point to a larger command
183 * but never for loading/saving */
184 int nopty;
185 int compression;
186 int agentfwd;
187 enum { CIPHER_3DES, CIPHER_BLOWFISH, CIPHER_DES, CIPHER_AES } cipher;
188 char keyfile[FILENAME_MAX];
189 int sshprot; /* use v1 or v2 when both available */
190 int buggymac; /* MAC bug commmercial <=v2.3.x SSH2 */
191 int try_tis_auth;
192 int ssh_subsys; /* run a subsystem rather than a command */
193 /* Telnet options */
194 char termtype[32];
195 char termspeed[32];
196 char environmt[1024]; /* VAR\tvalue\0VAR\tvalue\0\0 */
197 char username[32];
198 char localusername[32];
199 int rfc_environ;
200 int passive_telnet;
201 /* Keyboard options */
202 int bksp_is_delete;
203 int rxvt_homeend;
204 int funky_type;
205 int no_applic_c; /* totally disable app cursor keys */
206 int no_applic_k; /* totally disable app keypad */
207 int app_cursor;
208 int app_keypad;
209 int nethack_keypad;
210 int telnet_keyboard;
211 int alt_f4; /* is it special? */
212 int alt_space; /* is it special? */
213 int alt_only; /* is it special? */
214 int localecho;
215 int localedit;
216 int alwaysontop;
217 int scroll_on_key;
218 int scroll_on_disp;
219 int compose_key;
220 int ctrlaltkeys;
221 char wintitle[256]; /* initial window title */
222 /* Terminal options */
223 int savelines;
224 int dec_om;
225 int wrap_mode;
226 int lfhascr;
227 int cursor_type; /* 0=block 1=underline 2=vertical */
228 int blink_cur;
229 enum {
230 BELL_DISABLED, BELL_DEFAULT, BELL_VISUAL, BELL_WAVEFILE
231 } beep;
232 int bellovl; /* bell overload protection active? */
233 int bellovl_n; /* number of bells to cause overload */
234 int bellovl_t; /* time interval for overload (seconds) */
235 int bellovl_s; /* period of silence to re-enable bell (s) */
236 char bell_wavefile[FILENAME_MAX];
237 int scrollbar;
238 int locksize;
239 int bce;
240 int blinktext;
241 int win_name_always;
242 int width, height;
243 char font[64];
244 int fontisbold;
245 int fontheight;
246 int fontcharset;
247 char logfilename[FILENAME_MAX];
248 int logtype;
249 int logxfovr;
250 int hide_mouseptr;
251 int sunken_edge;
252 char answerback[256];
253 /* Colour options */
254 int try_palette;
255 int bold_colour;
256 unsigned char colours[22][3];
257 /* Selection options */
258 int mouse_is_xterm;
259 int rawcnp;
260 short wordness[256];
261 /* translations */
262 VT_Mode vtmode;
263 int xlat_enablekoiwin;
264 int xlat_88592w1250;
265 int xlat_88592cp852;
266 int xlat_capslockcyr;
267 /* X11 forwarding */
268 int x11_forward;
269 char x11_display[128];
270} Config;
271
272/*
273 * You can compile with -DSSH_DEFAULT to have ssh by default.
274 */
275#ifndef SSH_DEFAULT
276#define DEFAULT_PROTOCOL PROT_TELNET
277#define DEFAULT_PORT 23
278#else
279#define DEFAULT_PROTOCOL PROT_SSH
280#define DEFAULT_PORT 22
281#endif
282
283/*
284 * Some global flags denoting the type of application.
285 *
286 * FLAG_VERBOSE is set when the user requests verbose details.
287 *
288 * FLAG_STDERR is set in command-line applications (which have a
289 * functioning stderr that it makes sense to write to) and not in
290 * GUI applications (which don't).
291 *
292 * FLAG_INTERACTIVE is set when a full interactive shell session is
293 * being run, _either_ because no remote command has been provided
294 * _or_ because the application is GUI and can't run non-
295 * interactively.
296 */
297#define FLAG_VERBOSE 0x0001
298#define FLAG_STDERR 0x0002
299#define FLAG_INTERACTIVE 0x0004
300GLOBAL int flags;
301
302GLOBAL Config cfg;
303GLOBAL int default_protocol;
304GLOBAL int default_port;
305
306struct RSAKey; /* be a little careful of scope */
307
308/*
309 * Exports from window.c.
310 */
311void request_resize(int, int, int);
312void do_text(Context, int, int, char *, int, unsigned long, int);
313void set_title(char *);
314void set_icon(char *);
315void set_sbar(int, int, int);
316Context get_ctx(void);
317void free_ctx(Context);
318void palette_set(int, int, int, int);
319void palette_reset(void);
320void write_clip(void *, int, int);
321void get_clip(void **, int *);
322void optimised_move(int, int, int);
323void set_raw_mouse_mode(int);
324Mouse_Button translate_button(Mouse_Button b);
325void connection_fatal(char *, ...);
326void fatalbox(char *, ...);
327void beep(int);
328void begin_session(void);
329void sys_cursor(int x, int y);
330#define OPTIMISE_IS_SCROLL 1
331
332/*
333 * Exports from noise.c.
334 */
335void noise_get_heavy(void (*func) (void *, int));
336void noise_get_light(void (*func) (void *, int));
337void noise_regular(void);
338void noise_ultralight(DWORD data);
339void random_save_seed(void);
340void random_destroy_seed(void);
341
342/*
343 * Exports from windlg.c.
344 */
345void defuse_showwindow(void);
346int do_config(void);
347int do_reconfig(HWND);
348void do_defaults(char *, Config *);
349void logevent(char *);
350void showeventlog(HWND);
351void showabout(HWND);
352void verify_ssh_host_key(char *host, int port, char *keytype,
353 char *keystr, char *fingerprint);
354int askappend(char *filename);
355void registry_cleanup(void);
356void force_normal(HWND hwnd);
357
358GLOBAL int nsessions;
359GLOBAL char **sessions;
360
361/*
362 * Exports from settings.c.
363 */
364void save_settings(char *section, int do_host, Config * cfg);
365void load_settings(char *section, int do_host, Config * cfg);
366void get_sesslist(int allocate);
367
368/*
369 * Exports from terminal.c.
370 */
371
372void term_init(void);
373void term_size(int, int, int);
374void term_out(void);
375void term_paint(Context, int, int, int, int);
376void term_scroll(int, int);
377void term_pwron(void);
378void term_clrsb(void);
379void term_mouse(Mouse_Button, Mouse_Action, int, int, int, int);
380void term_deselect(void);
381void term_update(void);
382void term_invalidate(void);
383void term_blink(int set_cursor);
384void term_paste(void);
385void term_nopaste(void);
386int term_ldisc(int option);
387void from_backend(int is_stderr, char *data, int len);
388void logfopen(void);
389void logfclose(void);
390void term_copyall(void);
391
392/*
393 * Exports from raw.c.
394 */
395
396extern Backend raw_backend;
397
398/*
399 * Exports from rlogin.c.
400 */
401
402extern Backend rlogin_backend;
403
404/*
405 * Exports from telnet.c.
406 */
407
408extern Backend telnet_backend;
409
410/*
411 * Exports from ssh.c.
412 */
413
414extern int (*ssh_get_line) (const char *prompt, char *str, int maxlen,
415 int is_pw);
416extern Backend ssh_backend;
417
418/*
419 * Exports from ldisc.c.
420 */
421
422extern void ldisc_send(char *buf, int len);
423
424/*
425 * Exports from sshrand.c.
426 */
427
428void random_add_noise(void *noise, int length);
429void random_init(void);
430int random_byte(void);
431void random_get_savedata(void **data, int *len);
432
433/*
434 * Exports from misc.c.
435 */
436
437#include "misc.h"
438
439/*
440 * Exports from version.c.
441 */
442extern char ver[];
443
444/*
445 * Exports from sizetip.c.
446 */
447void UpdateSizeTip(HWND src, int cx, int cy);
448void EnableSizeTip(int bEnable);
449
450/*
451 * Exports from xlat.c.
452 */
453unsigned char xlat_kbd2tty(unsigned char c);
454unsigned char xlat_tty2scr(unsigned char c);
455unsigned char xlat_latkbd2win(unsigned char c);
456
457/*
458 * Exports from mscrypto.c
459 */
460#ifdef MSCRYPTOAPI
461int crypto_startup();
462void crypto_wrapup();
463#endif
464
465/*
466 * Exports from pageantc.c
467 */
468void agent_query(void *in, int inlen, void **out, int *outlen);
469int agent_exists(void);
470
471
472#endif