Let's spell '\t' as VK_TAB in that last patch, in fact, just in case
[u/mdw/putty] / putty.h
CommitLineData
374330e2 1#ifndef PUTTY_PUTTY_H
2#define PUTTY_PUTTY_H
3
4#define PUTTY_REG_POS "Software\\SimonTatham\\PuTTY"
5
6/*
7 * Global variables. Most modules declare these `extern', but
8 * window.c will do `#define PUTTY_DO_GLOBALS' before including this
9 * module, and so will get them properly defined.
10 */
11#ifdef PUTTY_DO_GLOBALS
12#define GLOBAL
13#else
14#define GLOBAL extern
15#endif
16
73251d5d 17GLOBAL HINSTANCE putty_inst;
18
374330e2 19#define ATTR_ACTCURS 0x80000000UL /* active cursor (block) */
20#define ATTR_PASCURS 0x40000000UL /* passive cursor (box) */
21#define ATTR_INVALID 0x20000000UL
22#define ATTR_WRAPPED 0x10000000UL
23
24#define ATTR_ASCII 0x00000000UL /* normal ASCII charset ESC ( B */
25#define ATTR_GBCHR 0x00100000UL /* UK variant charset ESC ( A */
26#define ATTR_LINEDRW 0x00200000UL /* line drawing charset ESC ( 0 */
27
28#define ATTR_BOLD 0x00000100UL
29#define ATTR_UNDER 0x00000200UL
30#define ATTR_REVERSE 0x00000400UL
31#define ATTR_FGMASK 0x0000F000UL
32#define ATTR_BGMASK 0x000F0000UL
33#define ATTR_FGSHIFT 12
34#define ATTR_BGSHIFT 16
35
36#define ATTR_DEFAULT 0x00098000UL
37#define ATTR_DEFFG 0x00008000UL
38#define ATTR_DEFBG 0x00090000UL
39#define ATTR_CUR_XOR 0x000BA000UL
40#define ERASE_CHAR (ATTR_DEFAULT | ' ')
41#define ATTR_MASK 0xFFFFFF00UL
42#define CHAR_MASK 0x000000FFUL
43
44typedef HDC Context;
45#define SEL_NL { 13, 10 }
46
47GLOBAL int rows, cols, savelines;
48
49GLOBAL int font_width, font_height;
50
51#define INBUF_SIZE 2048
52#define INBUF_MASK (INBUF_SIZE-1)
53GLOBAL unsigned char inbuf[INBUF_SIZE];
54GLOBAL int inbuf_head, inbuf_reap;
55
56#define OUTBUF_SIZE 2048
57#define OUTBUF_MASK (OUTBUF_SIZE-1)
58GLOBAL unsigned char outbuf[OUTBUF_SIZE];
59GLOBAL int outbuf_head, outbuf_reap;
60
61GLOBAL int has_focus;
62
63GLOBAL int app_cursor_keys, app_keypad_keys;
64
cabfd08c 65GLOBAL int seen_key_event;
66GLOBAL int seen_disp_event;
67
d85548fe 68GLOBAL int session_closed;
69
cabfd08c 70typedef enum {
71 US_NONE = 0, US_KEY = 1, US_DISP = 2, US_BOTH = 3
72} Unscroll_Trigger;
73
ceba7599 74GLOBAL Unscroll_Trigger unscroll_event;
cabfd08c 75
5fd04f07 76GLOBAL char *logfile;
77
374330e2 78#define WM_NETEVENT (WM_USER + 1)
79
80typedef enum {
81 TS_AYT, TS_BRK, TS_SYNCH, TS_EC, TS_EL, TS_GA, TS_NOP, TS_ABORT,
684d367c 82 TS_AO, TS_IP, TS_SUSP, TS_EOR, TS_EOF, TS_LECHO, TS_RECHO
374330e2 83} Telnet_Special;
84
85typedef enum {
86 MB_NOTHING, MB_SELECT, MB_EXTEND, MB_PASTE
87} Mouse_Button;
88
89typedef enum {
90 MA_NOTHING, MA_CLICK, MA_2CLK, MA_3CLK, MA_DRAG, MA_RELEASE
91} Mouse_Action;
92
93typedef enum {
94 VT_XWINDOWS, VT_OEMANSI, VT_OEMONLY, VT_POORMAN
95} VT_Mode;
96
97typedef struct {
98 char *(*init) (HWND hwnd, char *host, int port, char **realhost);
99 int (*msg) (WPARAM wParam, LPARAM lParam);
100 void (*send) (char *buf, int len);
101 void (*size) (void);
102 void (*special) (Telnet_Special code);
103} Backend;
104
105GLOBAL Backend *back;
106
107typedef struct {
5bc238bb 108 void (*send) (char *buf, int len);
109} Ldisc;
110
111GLOBAL Ldisc *ldisc;
112
113typedef struct {
374330e2 114 /* Basic options */
115 char host[512];
116 int port;
5e1a8e27 117 enum { PROT_RAW, PROT_TELNET, PROT_SSH } protocol;
374330e2 118 int close_on_exit;
9ef49106 119 int warn_on_close;
fef97f43 120 /* SSH options */
121 int nopty;
9697bfd2 122 enum { CIPHER_3DES, CIPHER_BLOWFISH, CIPHER_DES } cipher;
ccbfb941 123 int try_tis_auth;
374330e2 124 /* Telnet options */
125 char termtype[32];
126 char termspeed[32];
37508af4 127 char environmt[1024]; /* VAR\tvalue\0VAR\tvalue\0\0 */
374330e2 128 char username[32];
129 int rfc_environ;
130 /* Keyboard options */
131 int bksp_is_delete;
132 int rxvt_homeend;
133 int linux_funkeys;
134 int app_cursor;
135 int app_keypad;
c5e9c988 136 int nethack_keypad;
137 int alt_f4; /* is it special? */
138 int alt_space; /* is it special? */
5bc238bb 139 int ldisc_term;
374330e2 140 /* Terminal options */
141 int savelines;
142 int dec_om;
143 int wrap_mode;
fef97f43 144 int lfhascr;
374330e2 145 int win_name_always;
146 int width, height;
147 char font[64];
148 int fontisbold;
149 int fontheight;
14963b8f 150 int fontcharset;
374330e2 151 VT_Mode vtmode;
152 /* Colour options */
153 int try_palette;
154 int bold_colour;
155 unsigned char colours[22][3];
156 /* Selection options */
157 int mouse_is_xterm;
158 short wordness[256];
14963b8f 159 /* russian language translation */
160 int xlat_enablekoiwin;
d3d16feb 161 int xlat_88592w1250;
14963b8f 162 int xlat_capslockcyr;
374330e2 163} Config;
164
e277c42d 165/*
166 * You can compile with -DSSH_DEFAULT to have ssh by default.
167 */
168#ifndef SSH_DEFAULT
169#define DEFAULT_PROTOCOL PROT_TELNET
170#define DEFAULT_PORT 23
171#else
172#define DEFAULT_PROTOCOL PROT_SSH
173#define DEFAULT_PORT 22
174#endif
175
374330e2 176GLOBAL Config cfg;
e277c42d 177GLOBAL int default_protocol;
178GLOBAL int default_port;
374330e2 179
4e23b276 180struct RSAKey; /* be a little careful of scope */
181
374330e2 182/*
183 * Exports from window.c.
184 */
185void request_resize (int, int);
186void do_text (Context, int, int, char *, int, unsigned long);
187void set_title (char *);
188void set_icon (char *);
189void set_sbar (int, int, int);
f67b4e85 190Context get_ctx(void);
374330e2 191void free_ctx (Context);
192void palette_set (int, int, int, int);
193void palette_reset (void);
194void write_clip (void *, int);
195void get_clip (void **, int *);
196void optimised_move (int, int, int);
197void fatalbox (char *, ...);
198void beep (void);
199#define OPTIMISE_IS_SCROLL 1
200
201/*
202 * Exports from noise.c.
203 */
204void noise_get_heavy(void (*func) (void *, int));
205void noise_get_light(void (*func) (void *, int));
206void noise_ultralight(DWORD data);
207void random_save_seed(void);
208
209/*
210 * Exports from windlg.c.
211 */
212int do_config (void);
213int do_reconfig (HWND);
214void do_defaults (char *);
c5e9c988 215void logevent (char *);
216void showeventlog (HWND);
374330e2 217void showabout (HWND);
218void verify_ssh_host_key(char *host, struct RSAKey *key);
0a4aa984 219void get_sesslist(int allocate);
220
7393a137 221GLOBAL int nsessions;
222GLOBAL char **sessions;
374330e2 223
224/*
225 * Exports from terminal.c.
226 */
227
228void term_init (void);
229void term_size (int, int, int);
230void term_out (void);
231void term_paint (Context, int, int, int, int);
232void term_scroll (int, int);
233void term_pwron (void);
234void term_clrsb (void);
235void term_mouse (Mouse_Button, Mouse_Action, int, int);
236void term_deselect (void);
237void term_update (void);
238void term_invalidate(void);
239
240/*
5e1a8e27 241 * Exports from raw.c.
242 */
243
3d9a14c9 244extern Backend raw_backend;
5e1a8e27 245
246/*
374330e2 247 * Exports from telnet.c.
248 */
249
c14776e8 250extern Backend telnet_backend;
374330e2 251
252/*
253 * Exports from ssh.c.
254 */
255
c14776e8 256extern Backend ssh_backend;
374330e2 257
258/*
5bc238bb 259 * Exports from ldisc.c.
260 */
261
262extern Ldisc ldisc_term, ldisc_simple;
263
264/*
374330e2 265 * Exports from sshrand.c.
266 */
267
268void random_add_noise(void *noise, int length);
269void random_init(void);
270int random_byte(void);
271void random_get_savedata(void **data, int *len);
272
273/*
274 * Exports from misc.c.
275 */
276
277/* #define MALLOC_LOG do this if you suspect putty of leaking memory */
278#ifdef MALLOC_LOG
279#define smalloc(z) (mlog(__FILE__,__LINE__), safemalloc(z))
280#define srealloc(y,z) (mlog(__FILE__,__LINE__), saferealloc(y,z))
281#define sfree(z) (mlog(__FILE__,__LINE__), safefree(z))
282void mlog(char *, int);
283#else
284#define smalloc safemalloc
285#define srealloc saferealloc
286#define sfree safefree
287#endif
288
289void *safemalloc(size_t);
290void *saferealloc(void *, size_t);
291void safefree(void *);
292
293/*
067a15ea 294 * Exports from version.c.
295 */
296extern char ver[];
297
298/*
b73fd1b1 299 * Exports from sizetip.c.
300 */
301void UpdateSizeTip(HWND src, int cx, int cy);
302void EnableSizeTip(int bEnable);
303
304/*
14963b8f 305 * Exports from xlat.c.
306 */
307unsigned char xlat_kbd2tty(unsigned char c);
308unsigned char xlat_tty2scr(unsigned char c);
309unsigned char xlat_latkbd2win(unsigned char c);
310
311/*
374330e2 312 * A debug system.
313 */
314#ifdef DEBUG
315#include <stdarg.h>
316#define debug(x) (dprintf x)
317static void dprintf(char *fmt, ...) {
318 char buf[2048];
319 DWORD dw;
320 va_list ap;
321 static int gotconsole = 0;
322
323 if (!gotconsole) {
324 AllocConsole();
325 gotconsole = 1;
326 }
327
328 va_start(ap, fmt);
329 vsprintf(buf, fmt, ap);
330 WriteFile (GetStdHandle(STD_OUTPUT_HANDLE), buf, strlen(buf), &dw, NULL);
331 va_end(ap);
332}
333#else
334#define debug(x)
335#endif
336
337#endif