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