]> asedeno.scripts.mit.edu Git - PuTTY.git/blob - putty.h
Now uses the Palette Manager for everything. Unfortunately this seems to
[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     int mouse_is_xterm;
158     short wordness[256];
159 } Config;
160
161 GLOBAL Config cfg;
162
163 typedef struct {
164     /* Display state */
165     int rows, cols, savelines;
166     int font_width, font_height;
167     int has_focus;
168     /* Buffers */
169     unsigned char inbuf[INBUF_SIZE];
170     int inbuf_head, inbuf_reap;
171     unsigned char outbuf[OUTBUF_SIZE];
172     int outbuf_head, outbuf_reap;
173     /* Emulator state */
174     int app_cursor_keys, app_keypad_keys;
175     /* Backend */
176     Backend *back;
177     /* Config that created this session */
178     Config cfg;
179 } Session;
180
181
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);
190 Context get_ctx();
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 (const 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 #ifndef macintosh
210 /*
211  * Exports from windlg.c.
212  */
213 int do_config (void);
214 int do_reconfig (HWND);
215 void do_defaults (char *);
216 void lognegot (char *);
217 void shownegot (HWND);
218 void showabout (HWND);
219 void verify_ssh_host_key(char *host, struct RSAKey *key);
220 #endif
221
222 /*
223  * Exports from terminal.c.
224  */
225
226 void term_init (void);
227 void term_size (int, int, int);
228 void term_out (void);
229 void term_paint (Context, int, int, int, int);
230 void term_scroll (int, int);
231 void term_pwron (void);
232 void term_clrsb (void);
233 void term_mouse (Mouse_Button, Mouse_Action, int, int);
234 void term_deselect (void);
235 void term_update (void);
236 void term_invalidate(void);
237
238 /*
239  * Exports from telnet.c.
240  */
241
242 Backend telnet_backend;
243
244 /*
245  * Exports from ssh.c.
246  */
247
248 Backend ssh_backend;
249
250 /*
251  * Exports from sshrand.c.
252  */
253
254 void random_add_noise(void *noise, int length);
255 void random_init(void);
256 int random_byte(void);
257 void random_get_savedata(void **data, int *len);
258
259 /*
260  * Exports from misc.c.
261  */
262
263 /* #define MALLOC_LOG  do this if you suspect putty of leaking memory */
264 #ifdef MALLOC_LOG
265 #define smalloc(z) (mlog(__FILE__,__LINE__), safemalloc(z))
266 #define srealloc(y,z) (mlog(__FILE__,__LINE__), saferealloc(y,z))
267 #define sfree(z) (mlog(__FILE__,__LINE__), safefree(z))
268 void mlog(char *, int);
269 #else
270 #define smalloc safemalloc
271 #define srealloc saferealloc
272 #define sfree safefree
273 #endif
274
275 void *safemalloc(size_t);
276 void *saferealloc(void *, size_t);
277 void safefree(void *);
278
279 /*
280  * Exports from version.c.
281  */
282 extern char ver[];
283
284 /*
285  * A debug system.
286  */
287 #ifdef DEBUG
288 #include <stdarg.h>
289 #define debug(x) (dprintf x)
290 static void dprintf(char *fmt, ...) {
291     char buf[2048];
292     DWORD dw;
293     va_list ap;
294     static int gotconsole = 0;
295
296     if (!gotconsole) {
297         AllocConsole();
298         gotconsole = 1;
299     }
300
301     va_start(ap, fmt);
302     vsprintf(buf, fmt, ap);
303     WriteFile (GetStdHandle(STD_OUTPUT_HANDLE), buf, strlen(buf), &dw, NULL);
304     va_end(ap);
305 }
306 #else
307 #define debug(x)
308 #endif
309
310 #endif