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 |
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 | |
cabfd08c |
65 | GLOBAL int seen_key_event; |
66 | GLOBAL int seen_disp_event; |
67 | |
d85548fe |
68 | GLOBAL int session_closed; |
69 | |
cabfd08c |
70 | typedef enum { |
71 | US_NONE = 0, US_KEY = 1, US_DISP = 2, US_BOTH = 3 |
72 | } Unscroll_Trigger; |
73 | |
ceba7599 |
74 | GLOBAL Unscroll_Trigger unscroll_event; |
cabfd08c |
75 | |
5fd04f07 |
76 | GLOBAL char *logfile; |
77 | |
374330e2 |
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 |
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 | typedef struct { |
5bc238bb |
108 | void (*send) (char *buf, int len); |
109 | } Ldisc; |
110 | |
111 | GLOBAL Ldisc *ldisc; |
112 | |
113 | typedef 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 |
176 | GLOBAL Config cfg; |
e277c42d |
177 | GLOBAL int default_protocol; |
178 | GLOBAL int default_port; |
374330e2 |
179 | |
4e23b276 |
180 | struct RSAKey; /* be a little careful of scope */ |
181 | |
374330e2 |
182 | /* |
183 | * Exports from window.c. |
184 | */ |
185 | void request_resize (int, int); |
186 | void do_text (Context, int, int, char *, int, unsigned long); |
187 | void set_title (char *); |
188 | void set_icon (char *); |
189 | void set_sbar (int, int, int); |
f67b4e85 |
190 | Context get_ctx(void); |
374330e2 |
191 | void free_ctx (Context); |
192 | void palette_set (int, int, int, int); |
193 | void palette_reset (void); |
194 | void write_clip (void *, int); |
195 | void get_clip (void **, int *); |
196 | void optimised_move (int, int, int); |
197 | void fatalbox (char *, ...); |
198 | void beep (void); |
199 | #define OPTIMISE_IS_SCROLL 1 |
200 | |
201 | /* |
202 | * Exports from noise.c. |
203 | */ |
204 | void noise_get_heavy(void (*func) (void *, int)); |
205 | void noise_get_light(void (*func) (void *, int)); |
206 | void noise_ultralight(DWORD data); |
207 | void random_save_seed(void); |
208 | |
209 | /* |
210 | * Exports from windlg.c. |
211 | */ |
212 | int do_config (void); |
213 | int do_reconfig (HWND); |
214 | void do_defaults (char *); |
c5e9c988 |
215 | void logevent (char *); |
216 | void showeventlog (HWND); |
374330e2 |
217 | void showabout (HWND); |
218 | void verify_ssh_host_key(char *host, struct RSAKey *key); |
0a4aa984 |
219 | void get_sesslist(int allocate); |
220 | |
7393a137 |
221 | GLOBAL int nsessions; |
222 | GLOBAL char **sessions; |
374330e2 |
223 | |
224 | /* |
225 | * Exports from terminal.c. |
226 | */ |
227 | |
228 | void term_init (void); |
229 | void term_size (int, int, int); |
230 | void term_out (void); |
231 | void term_paint (Context, int, int, int, int); |
232 | void term_scroll (int, int); |
233 | void term_pwron (void); |
234 | void term_clrsb (void); |
235 | void term_mouse (Mouse_Button, Mouse_Action, int, int); |
236 | void term_deselect (void); |
237 | void term_update (void); |
238 | void term_invalidate(void); |
239 | |
240 | /* |
5e1a8e27 |
241 | * Exports from raw.c. |
242 | */ |
243 | |
3d9a14c9 |
244 | extern Backend raw_backend; |
5e1a8e27 |
245 | |
246 | /* |
374330e2 |
247 | * Exports from telnet.c. |
248 | */ |
249 | |
c14776e8 |
250 | extern Backend telnet_backend; |
374330e2 |
251 | |
252 | /* |
253 | * Exports from ssh.c. |
254 | */ |
255 | |
c14776e8 |
256 | extern Backend ssh_backend; |
374330e2 |
257 | |
258 | /* |
5bc238bb |
259 | * Exports from ldisc.c. |
260 | */ |
261 | |
262 | extern Ldisc ldisc_term, ldisc_simple; |
263 | |
264 | /* |
374330e2 |
265 | * Exports from sshrand.c. |
266 | */ |
267 | |
268 | void random_add_noise(void *noise, int length); |
269 | void random_init(void); |
270 | int random_byte(void); |
271 | void 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)) |
282 | void mlog(char *, int); |
283 | #else |
284 | #define smalloc safemalloc |
285 | #define srealloc saferealloc |
286 | #define sfree safefree |
287 | #endif |
288 | |
289 | void *safemalloc(size_t); |
290 | void *saferealloc(void *, size_t); |
291 | void safefree(void *); |
292 | |
293 | /* |
067a15ea |
294 | * Exports from version.c. |
295 | */ |
296 | extern char ver[]; |
297 | |
298 | /* |
b73fd1b1 |
299 | * Exports from sizetip.c. |
300 | */ |
301 | void UpdateSizeTip(HWND src, int cx, int cy); |
302 | void EnableSizeTip(int bEnable); |
303 | |
304 | /* |
14963b8f |
305 | * Exports from xlat.c. |
306 | */ |
307 | unsigned char xlat_kbd2tty(unsigned char c); |
308 | unsigned char xlat_tty2scr(unsigned char c); |
309 | unsigned 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) |
317 | static 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 |