]> asedeno.scripts.mit.edu Git - PuTTY.git/blob - putty.h
Changes for updates elsewhere.
[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 #ifdef macintosh
7 #define OPTIMISE_SCROLL
8 #endif
9
10 #ifdef macintosh
11 #include <MacTypes.h>
12 #include <Palettes.h>
13 typedef UInt32 DWORD;
14 struct mac_session;
15 #endif /* macintosh */
16
17 #ifndef TRUE
18 #define TRUE 1
19 #endif
20 #ifndef FALSE
21 #define FALSE 0
22 #endif
23
24 #define ATTR_ACTCURS 0x80000000UL      /* active cursor (block) */
25 #define ATTR_PASCURS 0x40000000UL      /* passive cursor (box) */
26 #define ATTR_INVALID 0x20000000UL
27 #define ATTR_WRAPPED 0x10000000UL
28
29 #define ATTR_ASCII   0x00000000UL      /* normal ASCII charset ESC ( B */
30 #define ATTR_GBCHR   0x00100000UL      /* UK variant   charset ESC ( A */
31 #define ATTR_LINEDRW 0x00200000UL      /* line drawing charset ESC ( 0 */
32
33 #define ATTR_BOLD    0x00000100UL
34 #define ATTR_UNDER   0x00000200UL
35 #define ATTR_REVERSE 0x00000400UL
36 #define ATTR_FGMASK  0x0000F000UL
37 #define ATTR_BGMASK  0x000F0000UL
38 #define ATTR_FGSHIFT 12
39 #define ATTR_BGSHIFT 16
40
41 #define ATTR_DEFAULT 0x00098000UL
42 #define ATTR_DEFFG   0x00008000UL
43 #define ATTR_DEFBG   0x00090000UL
44 #define ATTR_CUR_XOR 0x000BA000UL
45 #define ERASE_CHAR   (ATTR_DEFAULT | ' ')
46 #define ATTR_MASK    0xFFFFFF00UL
47 #define CHAR_MASK    0x000000FFUL
48
49 #ifdef macintosh
50 struct mac_session;
51 typedef struct mac_session *Context;
52 #else /* not macintosh */
53 typedef HDC Context;
54 #endif /* not macintosh */
55
56 #define SEL_NL { 13, 10 }
57
58 /*
59  * Global variables. Most modules declare these `extern', but
60  * window.c will do `#define PUTTY_DO_GLOBALS' before including this
61  * module, and so will get them properly defined.
62  */
63 #ifdef PUTTY_DO_GLOBALS
64 #define GLOBAL
65 #else
66 #define GLOBAL extern
67 #endif
68
69 GLOBAL int rows, cols, savelines;
70
71 GLOBAL int font_width, font_height;
72
73 #define INBUF_SIZE 2048
74 #define INBUF_MASK (INBUF_SIZE-1)
75 GLOBAL unsigned char inbuf[INBUF_SIZE];
76 GLOBAL int inbuf_head, inbuf_reap;
77
78 #define OUTBUF_SIZE 2048
79 #define OUTBUF_MASK (OUTBUF_SIZE-1)
80 GLOBAL unsigned char outbuf[OUTBUF_SIZE];
81 GLOBAL int outbuf_head, outbuf_reap;
82
83 GLOBAL int has_focus;
84
85 GLOBAL int app_cursor_keys, app_keypad_keys;
86
87 #define WM_NETEVENT  (WM_USER + 1)
88
89 typedef enum {
90     TS_AYT, TS_BRK, TS_SYNCH, TS_EC, TS_EL, TS_GA, TS_NOP, TS_ABORT,
91     TS_AO, TS_IP, TS_SUSP, TS_EOR, TS_EOF
92 } Telnet_Special;
93
94 typedef enum {
95     MB_NOTHING, MB_SELECT, MB_EXTEND, MB_PASTE
96 } Mouse_Button;
97
98 typedef enum {
99     MA_NOTHING, MA_CLICK, MA_2CLK, MA_3CLK, MA_DRAG, MA_RELEASE
100 } Mouse_Action;
101
102 typedef enum {
103     VT_XWINDOWS, VT_OEMANSI, VT_OEMONLY, VT_POORMAN
104 } VT_Mode;
105
106 typedef struct {
107 #ifdef macintosh
108         char *(*init) (char *host, int port, char **realhost);
109         int (*msg)(void);
110 #else /* not macintosh */
111     char *(*init) (HWND hwnd, char *host, int port, char **realhost);
112     int (*msg) (WPARAM wParam, LPARAM lParam);
113 #endif /* not macintosh */
114     void (*send) (char *buf, int len);
115     void (*size) (void);
116     void (*special) (Telnet_Special code);
117 } Backend;
118
119 GLOBAL Backend *back;
120
121 typedef struct {
122     /* Basic options */
123     char host[512];
124     int port;
125     enum { PROT_TELNET, PROT_SSH } protocol;
126     int close_on_exit;
127     /* SSH options */
128     int nopty;
129     /* Telnet options */
130     char termtype[32];
131     char termspeed[32];
132     char environmt[1024];                    /* VAR\tvalue\0VAR\tvalue\0\0 */
133     char username[32];
134     int rfc_environ;
135     /* Keyboard options */
136     int bksp_is_delete;
137     int rxvt_homeend;
138     int linux_funkeys;
139     int app_cursor;
140     int app_keypad;
141     /* Terminal options */
142     int savelines;
143     int dec_om;
144     int wrap_mode;
145     int lfhascr;
146     int win_name_always;
147     int width, height;
148     char font[64];
149     int fontisbold;
150     int fontheight;
151     VT_Mode vtmode;
152     /* Colour options */
153     int try_palette;
154     int bold_colour;
155 #ifdef macintosh
156     PaletteHandle colours;
157 #else /* not macintosh */
158     unsigned char colours[22][3];
159 #endif /* not macintosh */
160     /* Selection options */
161 #ifndef macintosh
162     int mouse_is_xterm;
163 #endif
164     short wordness[256];
165 } Config;
166
167 GLOBAL Config cfg;
168
169 typedef struct {
170     /* Display state */
171     int rows, cols, savelines;
172     int font_width, font_height;
173     int has_focus;
174     /* Buffers */
175     unsigned char inbuf[INBUF_SIZE];
176     int inbuf_head, inbuf_reap;
177     unsigned char outbuf[OUTBUF_SIZE];
178     int outbuf_head, outbuf_reap;
179     /* Emulator state */
180     int app_cursor_keys, app_keypad_keys;
181     /* Backend */
182     Backend *back;
183     /* Config that created this session */
184     Config cfg;
185 } Session;
186
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();
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 do_scroll(int, int, int);
204 void fatalbox (const char *, ...);
205 void beep (void);
206 #define OPTIMISE_IS_SCROLL 1
207
208 /*
209  * Exports from noise.c.
210  */
211 void noise_get_heavy(void (*func) (void *, int));
212 void noise_get_light(void (*func) (void *, int));
213 void noise_ultralight(DWORD data);
214 void random_save_seed(void);
215
216 #ifndef macintosh
217 /*
218  * Exports from windlg.c.
219  */
220 int do_config (void);
221 int do_reconfig (HWND);
222 void do_defaults (char *);
223 void lognegot (char *);
224 void shownegot (HWND);
225 void showabout (HWND);
226 void verify_ssh_host_key(char *host, struct RSAKey *key);
227 #endif
228
229 /*
230  * Exports from terminal.c.
231  */
232
233 void term_init (void);
234 void term_size (int, int, int);
235 void term_out (void);
236 void term_paint (Context, int, int, int, int);
237 void term_scroll (int, int);
238 void term_pwron (void);
239 void term_clrsb (void);
240 void term_mouse (Mouse_Button, Mouse_Action, int, int);
241 void term_deselect (void);
242 void term_update (void);
243 void term_invalidate(void);
244
245 /*
246  * Exports from telnet.c.
247  */
248
249 Backend telnet_backend;
250
251 /*
252  * Exports from ssh.c.
253  */
254
255 Backend ssh_backend;
256
257 /*
258  * Exports from sshrand.c.
259  */
260
261 void random_add_noise(void *noise, int length);
262 void random_init(void);
263 int random_byte(void);
264 void random_get_savedata(void **data, int *len);
265
266 /*
267  * Exports from misc.c.
268  */
269
270 /* #define MALLOC_LOG  do this if you suspect putty of leaking memory */
271 #ifdef MALLOC_LOG
272 #define smalloc(z) (mlog(__FILE__,__LINE__), safemalloc(z))
273 #define srealloc(y,z) (mlog(__FILE__,__LINE__), saferealloc(y,z))
274 #define sfree(z) (mlog(__FILE__,__LINE__), safefree(z))
275 void mlog(char *, int);
276 #else
277 #define smalloc safemalloc
278 #define srealloc saferealloc
279 #define sfree safefree
280 #endif
281
282 void *safemalloc(size_t);
283 void *saferealloc(void *, size_t);
284 void safefree(void *);
285
286 /*
287  * Exports from testback.c
288  */
289
290 extern Backend null_backend;
291 extern Backend loop_backend;
292
293 /*
294  * Exports from version.c.
295  */
296 extern char ver[];
297
298 /*
299  * A debug system.
300  */
301 #ifdef DEBUG
302 #include <stdarg.h>
303 #define debug(x) (dprintf x)
304 static void dprintf(char *fmt, ...) {
305     char buf[2048];
306     DWORD dw;
307     va_list ap;
308     static int gotconsole = 0;
309
310     if (!gotconsole) {
311         AllocConsole();
312         gotconsole = 1;
313     }
314
315     va_start(ap, fmt);
316     vsprintf(buf, fmt, ap);
317     WriteFile (GetStdHandle(STD_OUTPUT_HANDLE), buf, strlen(buf), &dw, NULL);
318     va_end(ap);
319 }
320 #else
321 #define debug(x)
322 #endif
323
324 #endif