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