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