Oops - fix total idiocies in applying that patch
[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
68typedef enum {
69 US_NONE = 0, US_KEY = 1, US_DISP = 2, US_BOTH = 3
70} Unscroll_Trigger;
71
ceba7599 72GLOBAL Unscroll_Trigger unscroll_event;
cabfd08c 73
374330e2 74#define WM_NETEVENT (WM_USER + 1)
75
76typedef enum {
77 TS_AYT, TS_BRK, TS_SYNCH, TS_EC, TS_EL, TS_GA, TS_NOP, TS_ABORT,
78 TS_AO, TS_IP, TS_SUSP, TS_EOR, TS_EOF
79} Telnet_Special;
80
81typedef enum {
82 MB_NOTHING, MB_SELECT, MB_EXTEND, MB_PASTE
83} Mouse_Button;
84
85typedef enum {
86 MA_NOTHING, MA_CLICK, MA_2CLK, MA_3CLK, MA_DRAG, MA_RELEASE
87} Mouse_Action;
88
89typedef enum {
90 VT_XWINDOWS, VT_OEMANSI, VT_OEMONLY, VT_POORMAN
91} VT_Mode;
92
93typedef struct {
94 char *(*init) (HWND hwnd, char *host, int port, char **realhost);
95 int (*msg) (WPARAM wParam, LPARAM lParam);
96 void (*send) (char *buf, int len);
97 void (*size) (void);
98 void (*special) (Telnet_Special code);
99} Backend;
100
101GLOBAL Backend *back;
102
103typedef struct {
5bc238bb 104 void (*send) (char *buf, int len);
105} Ldisc;
106
107GLOBAL Ldisc *ldisc;
108
109typedef struct {
374330e2 110 /* Basic options */
111 char host[512];
112 int port;
5e1a8e27 113 enum { PROT_RAW, PROT_TELNET, PROT_SSH } protocol;
374330e2 114 int close_on_exit;
9ef49106 115 int warn_on_close;
fef97f43 116 /* SSH options */
117 int nopty;
9697bfd2 118 enum { CIPHER_3DES, CIPHER_BLOWFISH, CIPHER_DES } cipher;
ccbfb941 119 int try_tis_auth;
374330e2 120 /* Telnet options */
121 char termtype[32];
122 char termspeed[32];
37508af4 123 char environmt[1024]; /* VAR\tvalue\0VAR\tvalue\0\0 */
374330e2 124 char username[32];
125 int rfc_environ;
126 /* Keyboard options */
127 int bksp_is_delete;
128 int rxvt_homeend;
129 int linux_funkeys;
130 int app_cursor;
131 int app_keypad;
c5e9c988 132 int nethack_keypad;
133 int alt_f4; /* is it special? */
134 int alt_space; /* is it special? */
5bc238bb 135 int ldisc_term;
374330e2 136 /* Terminal options */
137 int savelines;
138 int dec_om;
139 int wrap_mode;
fef97f43 140 int lfhascr;
374330e2 141 int win_name_always;
142 int width, height;
143 char font[64];
144 int fontisbold;
145 int fontheight;
14963b8f 146 int fontcharset;
374330e2 147 VT_Mode vtmode;
148 /* Colour options */
149 int try_palette;
150 int bold_colour;
151 unsigned char colours[22][3];
152 /* Selection options */
153 int mouse_is_xterm;
154 short wordness[256];
14963b8f 155 /* russian language translation */
156 int xlat_enablekoiwin;
d3d16feb 157 int xlat_88592w1250;
14963b8f 158 int xlat_capslockcyr;
374330e2 159} Config;
160
e277c42d 161/*
162 * You can compile with -DSSH_DEFAULT to have ssh by default.
163 */
164#ifndef SSH_DEFAULT
165#define DEFAULT_PROTOCOL PROT_TELNET
166#define DEFAULT_PORT 23
167#else
168#define DEFAULT_PROTOCOL PROT_SSH
169#define DEFAULT_PORT 22
170#endif
171
374330e2 172GLOBAL Config cfg;
e277c42d 173GLOBAL int default_protocol;
174GLOBAL int default_port;
374330e2 175
4e23b276 176struct RSAKey; /* be a little careful of scope */
177
374330e2 178/*
179 * Exports from window.c.
180 */
181void request_resize (int, int);
182void do_text (Context, int, int, char *, int, unsigned long);
183void set_title (char *);
184void set_icon (char *);
185void set_sbar (int, int, int);
f67b4e85 186Context get_ctx(void);
374330e2 187void free_ctx (Context);
188void palette_set (int, int, int, int);
189void palette_reset (void);
190void write_clip (void *, int);
191void get_clip (void **, int *);
192void optimised_move (int, int, int);
193void fatalbox (char *, ...);
194void beep (void);
195#define OPTIMISE_IS_SCROLL 1
196
197/*
198 * Exports from noise.c.
199 */
200void noise_get_heavy(void (*func) (void *, int));
201void noise_get_light(void (*func) (void *, int));
202void noise_ultralight(DWORD data);
203void random_save_seed(void);
204
205/*
206 * Exports from windlg.c.
207 */
208int do_config (void);
209int do_reconfig (HWND);
210void do_defaults (char *);
c5e9c988 211void logevent (char *);
212void showeventlog (HWND);
374330e2 213void showabout (HWND);
214void verify_ssh_host_key(char *host, struct RSAKey *key);
0a4aa984 215void get_sesslist(int allocate);
216
7393a137 217GLOBAL int nsessions;
218GLOBAL char **sessions;
374330e2 219
220/*
221 * Exports from terminal.c.
222 */
223
224void term_init (void);
225void term_size (int, int, int);
226void term_out (void);
227void term_paint (Context, int, int, int, int);
228void term_scroll (int, int);
229void term_pwron (void);
230void term_clrsb (void);
231void term_mouse (Mouse_Button, Mouse_Action, int, int);
232void term_deselect (void);
233void term_update (void);
234void term_invalidate(void);
235
236/*
5e1a8e27 237 * Exports from raw.c.
238 */
239
3d9a14c9 240extern Backend raw_backend;
5e1a8e27 241
242/*
374330e2 243 * Exports from telnet.c.
244 */
245
c14776e8 246extern Backend telnet_backend;
374330e2 247
248/*
249 * Exports from ssh.c.
250 */
251
c14776e8 252extern Backend ssh_backend;
374330e2 253
254/*
5bc238bb 255 * Exports from ldisc.c.
256 */
257
258extern Ldisc ldisc_term, ldisc_simple;
259
260/*
374330e2 261 * Exports from sshrand.c.
262 */
263
264void random_add_noise(void *noise, int length);
265void random_init(void);
266int random_byte(void);
267void random_get_savedata(void **data, int *len);
268
269/*
270 * Exports from misc.c.
271 */
272
273/* #define MALLOC_LOG do this if you suspect putty of leaking memory */
274#ifdef MALLOC_LOG
275#define smalloc(z) (mlog(__FILE__,__LINE__), safemalloc(z))
276#define srealloc(y,z) (mlog(__FILE__,__LINE__), saferealloc(y,z))
277#define sfree(z) (mlog(__FILE__,__LINE__), safefree(z))
278void mlog(char *, int);
279#else
280#define smalloc safemalloc
281#define srealloc saferealloc
282#define sfree safefree
283#endif
284
285void *safemalloc(size_t);
286void *saferealloc(void *, size_t);
287void safefree(void *);
288
289/*
067a15ea 290 * Exports from version.c.
291 */
292extern char ver[];
293
294/*
b73fd1b1 295 * Exports from sizetip.c.
296 */
297void UpdateSizeTip(HWND src, int cx, int cy);
298void EnableSizeTip(int bEnable);
299
300/*
14963b8f 301 * Exports from xlat.c.
302 */
303unsigned char xlat_kbd2tty(unsigned char c);
304unsigned char xlat_tty2scr(unsigned char c);
305unsigned char xlat_latkbd2win(unsigned char c);
306
307/*
374330e2 308 * A debug system.
309 */
310#ifdef DEBUG
311#include <stdarg.h>
312#define debug(x) (dprintf x)
313static void dprintf(char *fmt, ...) {
314 char buf[2048];
315 DWORD dw;
316 va_list ap;
317 static int gotconsole = 0;
318
319 if (!gotconsole) {
320 AllocConsole();
321 gotconsole = 1;
322 }
323
324 va_start(ap, fmt);
325 vsprintf(buf, fmt, ap);
326 WriteFile (GetStdHandle(STD_OUTPUT_HANDLE), buf, strlen(buf), &dw, NULL);
327 va_end(ap);
328}
329#else
330#define debug(x)
331#endif
332
333#endif