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