]> asedeno.scripts.mit.edu Git - PuTTY.git/blob - putty.h
fcbb878f09f8e80269a64d4db5a97d473750bbb3
[PuTTY.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 #define WM_NETEVENT  (WM_USER + 1)
66
67 typedef enum {
68     TS_AYT, TS_BRK, TS_SYNCH, TS_EC, TS_EL, TS_GA, TS_NOP, TS_ABORT,
69     TS_AO, TS_IP, TS_SUSP, TS_EOR, TS_EOF
70 } Telnet_Special;
71
72 typedef enum {
73     MB_NOTHING, MB_SELECT, MB_EXTEND, MB_PASTE
74 } Mouse_Button;
75
76 typedef enum {
77     MA_NOTHING, MA_CLICK, MA_2CLK, MA_3CLK, MA_DRAG, MA_RELEASE
78 } Mouse_Action;
79
80 typedef enum {
81     VT_XWINDOWS, VT_OEMANSI, VT_OEMONLY, VT_POORMAN
82 } VT_Mode;
83
84 typedef struct {
85     char *(*init) (HWND hwnd, char *host, int port, char **realhost);
86     int (*msg) (WPARAM wParam, LPARAM lParam);
87     void (*send) (char *buf, int len);
88     void (*size) (void);
89     void (*special) (Telnet_Special code);
90 } Backend;
91
92 GLOBAL Backend *back;
93
94 typedef struct {
95     /* Basic options */
96     char host[512];
97     int port;
98     enum { PROT_RAW, PROT_TELNET, PROT_SSH } protocol;
99     int close_on_exit;
100     int warn_on_close;
101     /* SSH options */
102     int nopty;
103     enum { CIPHER_3DES, CIPHER_BLOWFISH, CIPHER_DES } cipher;
104     /* Telnet options */
105     char termtype[32];
106     char termspeed[32];
107     char environmt[1024];                    /* VAR\tvalue\0VAR\tvalue\0\0 */
108     char username[32];
109     int rfc_environ;
110     /* Keyboard options */
111     int bksp_is_delete;
112     int rxvt_homeend;
113     int linux_funkeys;
114     int app_cursor;
115     int app_keypad;
116     /* Terminal options */
117     int savelines;
118     int dec_om;
119     int wrap_mode;
120     int lfhascr;
121     int win_name_always;
122     int width, height;
123     char font[64];
124     int fontisbold;
125     int fontheight;
126     VT_Mode vtmode;
127     /* Colour options */
128     int try_palette;
129     int bold_colour;
130     unsigned char colours[22][3];
131     /* Selection options */
132     int mouse_is_xterm;
133     short wordness[256];
134 } Config;
135
136 /*
137  * You can compile with -DSSH_DEFAULT to have ssh by default.
138  */
139 #ifndef SSH_DEFAULT
140 #define DEFAULT_PROTOCOL PROT_TELNET
141 #define DEFAULT_PORT 23
142 #else
143 #define DEFAULT_PROTOCOL PROT_SSH
144 #define DEFAULT_PORT 22
145 #endif
146
147 GLOBAL Config cfg;
148 GLOBAL int default_protocol;
149 GLOBAL int default_port;
150
151 /*
152  * Exports from window.c.
153  */
154 void request_resize (int, int);
155 void do_text (Context, int, int, char *, int, unsigned long);
156 void set_title (char *);
157 void set_icon (char *);
158 void set_sbar (int, int, int);
159 Context get_ctx(void);
160 void free_ctx (Context);
161 void palette_set (int, int, int, int);
162 void palette_reset (void);
163 void write_clip (void *, int);
164 void get_clip (void **, int *);
165 void optimised_move (int, int, int);
166 void fatalbox (char *, ...);
167 void beep (void);
168 #define OPTIMISE_IS_SCROLL 1
169
170 /*
171  * Exports from noise.c.
172  */
173 void noise_get_heavy(void (*func) (void *, int));
174 void noise_get_light(void (*func) (void *, int));
175 void noise_ultralight(DWORD data);
176 void random_save_seed(void);
177
178 /*
179  * Exports from windlg.c.
180  */
181 int do_config (void);
182 int do_reconfig (HWND);
183 void do_defaults (char *);
184 void lognegot (char *);
185 void shownegot (HWND);
186 void showabout (HWND);
187 void verify_ssh_host_key(char *host, struct RSAKey *key);
188 void get_sesslist(int allocate);
189
190 GLOBAL int nsessions;
191 GLOBAL char **sessions;
192
193 /*
194  * Exports from terminal.c.
195  */
196
197 void term_init (void);
198 void term_size (int, int, int);
199 void term_out (void);
200 void term_paint (Context, int, int, int, int);
201 void term_scroll (int, int);
202 void term_pwron (void);
203 void term_clrsb (void);
204 void term_mouse (Mouse_Button, Mouse_Action, int, int);
205 void term_deselect (void);
206 void term_update (void);
207 void term_invalidate(void);
208
209 /*
210  * Exports from raw.c.
211  */
212
213 Backend raw_backend;
214
215 /*
216  * Exports from telnet.c.
217  */
218
219 extern Backend telnet_backend;
220
221 /*
222  * Exports from ssh.c.
223  */
224
225 extern Backend ssh_backend;
226
227 /*
228  * Exports from sshrand.c.
229  */
230
231 void random_add_noise(void *noise, int length);
232 void random_init(void);
233 int random_byte(void);
234 void random_get_savedata(void **data, int *len);
235
236 /*
237  * Exports from misc.c.
238  */
239
240 /* #define MALLOC_LOG  do this if you suspect putty of leaking memory */
241 #ifdef MALLOC_LOG
242 #define smalloc(z) (mlog(__FILE__,__LINE__), safemalloc(z))
243 #define srealloc(y,z) (mlog(__FILE__,__LINE__), saferealloc(y,z))
244 #define sfree(z) (mlog(__FILE__,__LINE__), safefree(z))
245 void mlog(char *, int);
246 #else
247 #define smalloc safemalloc
248 #define srealloc saferealloc
249 #define sfree safefree
250 #endif
251
252 void *safemalloc(size_t);
253 void *saferealloc(void *, size_t);
254 void safefree(void *);
255
256 /*
257  * Exports from version.c.
258  */
259 extern char ver[];
260
261 /*
262  * A debug system.
263  */
264 #ifdef DEBUG
265 #include <stdarg.h>
266 #define debug(x) (dprintf x)
267 static void dprintf(char *fmt, ...) {
268     char buf[2048];
269     DWORD dw;
270     va_list ap;
271     static int gotconsole = 0;
272
273     if (!gotconsole) {
274         AllocConsole();
275         gotconsole = 1;
276     }
277
278     va_start(ap, fmt);
279     vsprintf(buf, fmt, ap);
280     WriteFile (GetStdHandle(STD_OUTPUT_HANDLE), buf, strlen(buf), &dw, NULL);
281     va_end(ap);
282 }
283 #else
284 #define debug(x)
285 #endif
286
287 #endif