Couple of bug fixes to cygwin makefile
[u/mdw/putty] / putty.h
CommitLineData
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 17GLOBAL 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
44typedef HDC Context;
45#define SEL_NL { 13, 10 }
46
47GLOBAL int rows, cols, savelines;
48
49GLOBAL int font_width, font_height;
50
51#define INBUF_SIZE 2048
52#define INBUF_MASK (INBUF_SIZE-1)
53GLOBAL unsigned char inbuf[INBUF_SIZE];
54GLOBAL int inbuf_head, inbuf_reap;
55
56#define OUTBUF_SIZE 2048
57#define OUTBUF_MASK (OUTBUF_SIZE-1)
58GLOBAL unsigned char outbuf[OUTBUF_SIZE];
59GLOBAL int outbuf_head, outbuf_reap;
60
61GLOBAL int has_focus;
62
63GLOBAL int app_cursor_keys, app_keypad_keys;
64
cabfd08c 65GLOBAL int seen_key_event;
66GLOBAL int seen_disp_event;
67
68typedef enum {
69 US_NONE = 0, US_KEY = 1, US_DISP = 2, US_BOTH = 3
70} Unscroll_Trigger;
71
ceba7599 72GLOBAL Unscroll_Trigger unscroll_event;
cabfd08c 73
5fd04f07 74GLOBAL char *logfile;
75
374330e2 76#define WM_NETEVENT (WM_USER + 1)
77
78typedef enum {
79 TS_AYT, TS_BRK, TS_SYNCH, TS_EC, TS_EL, TS_GA, TS_NOP, TS_ABORT,
80 TS_AO, TS_IP, TS_SUSP, TS_EOR, TS_EOF
81} Telnet_Special;
82
83typedef enum {
84 MB_NOTHING, MB_SELECT, MB_EXTEND, MB_PASTE
85} Mouse_Button;
86
87typedef enum {
88 MA_NOTHING, MA_CLICK, MA_2CLK, MA_3CLK, MA_DRAG, MA_RELEASE
89} Mouse_Action;
90
91typedef enum {
92 VT_XWINDOWS, VT_OEMANSI, VT_OEMONLY, VT_POORMAN
93} VT_Mode;
94
95typedef struct {
96 char *(*init) (HWND hwnd, char *host, int port, char **realhost);
97 int (*msg) (WPARAM wParam, LPARAM lParam);
98 void (*send) (char *buf, int len);
99 void (*size) (void);
100 void (*special) (Telnet_Special code);
101} Backend;
102
103GLOBAL Backend *back;
104
105typedef struct {
5bc238bb 106 void (*send) (char *buf, int len);
107} Ldisc;
108
109GLOBAL Ldisc *ldisc;
110
111typedef struct {
374330e2 112 /* Basic options */
113 char host[512];
114 int port;
5e1a8e27 115 enum { PROT_RAW, PROT_TELNET, PROT_SSH } protocol;
374330e2 116 int close_on_exit;
9ef49106 117 int warn_on_close;
fef97f43 118 /* SSH options */
119 int nopty;
9697bfd2 120 enum { CIPHER_3DES, CIPHER_BLOWFISH, CIPHER_DES } cipher;
ccbfb941 121 int try_tis_auth;
374330e2 122 /* Telnet options */
123 char termtype[32];
124 char termspeed[32];
37508af4 125 char environmt[1024]; /* VAR\tvalue\0VAR\tvalue\0\0 */
374330e2 126 char username[32];
127 int rfc_environ;
128 /* Keyboard options */
129 int bksp_is_delete;
130 int rxvt_homeend;
131 int linux_funkeys;
132 int app_cursor;
133 int app_keypad;
c5e9c988 134 int nethack_keypad;
135 int alt_f4; /* is it special? */
136 int alt_space; /* is it special? */
5bc238bb 137 int ldisc_term;
374330e2 138 /* Terminal options */
139 int savelines;
140 int dec_om;
141 int wrap_mode;
fef97f43 142 int lfhascr;
374330e2 143 int win_name_always;
144 int width, height;
145 char font[64];
146 int fontisbold;
147 int fontheight;
14963b8f 148 int fontcharset;
374330e2 149 VT_Mode vtmode;
150 /* Colour options */
151 int try_palette;
152 int bold_colour;
153 unsigned char colours[22][3];
154 /* Selection options */
155 int mouse_is_xterm;
156 short wordness[256];
14963b8f 157 /* russian language translation */
158 int xlat_enablekoiwin;
d3d16feb 159 int xlat_88592w1250;
14963b8f 160 int xlat_capslockcyr;
374330e2 161} Config;
162
e277c42d 163/*
164 * You can compile with -DSSH_DEFAULT to have ssh by default.
165 */
166#ifndef SSH_DEFAULT
167#define DEFAULT_PROTOCOL PROT_TELNET
168#define DEFAULT_PORT 23
169#else
170#define DEFAULT_PROTOCOL PROT_SSH
171#define DEFAULT_PORT 22
172#endif
173
374330e2 174GLOBAL Config cfg;
e277c42d 175GLOBAL int default_protocol;
176GLOBAL int default_port;
374330e2 177
4e23b276 178struct RSAKey; /* be a little careful of scope */
179
374330e2 180/*
181 * Exports from window.c.
182 */
183void request_resize (int, int);
184void do_text (Context, int, int, char *, int, unsigned long);
185void set_title (char *);
186void set_icon (char *);
187void set_sbar (int, int, int);
f67b4e85 188Context get_ctx(void);
374330e2 189void free_ctx (Context);
190void palette_set (int, int, int, int);
191void palette_reset (void);
192void write_clip (void *, int);
193void get_clip (void **, int *);
194void optimised_move (int, int, int);
195void fatalbox (char *, ...);
196void beep (void);
197#define OPTIMISE_IS_SCROLL 1
198
199/*
200 * Exports from noise.c.
201 */
202void noise_get_heavy(void (*func) (void *, int));
203void noise_get_light(void (*func) (void *, int));
204void noise_ultralight(DWORD data);
205void random_save_seed(void);
206
207/*
208 * Exports from windlg.c.
209 */
210int do_config (void);
211int do_reconfig (HWND);
212void do_defaults (char *);
c5e9c988 213void logevent (char *);
214void showeventlog (HWND);
374330e2 215void showabout (HWND);
216void verify_ssh_host_key(char *host, struct RSAKey *key);
0a4aa984 217void get_sesslist(int allocate);
218
7393a137 219GLOBAL int nsessions;
220GLOBAL char **sessions;
374330e2 221
222/*
223 * Exports from terminal.c.
224 */
225
226void term_init (void);
227void term_size (int, int, int);
228void term_out (void);
229void term_paint (Context, int, int, int, int);
230void term_scroll (int, int);
231void term_pwron (void);
232void term_clrsb (void);
233void term_mouse (Mouse_Button, Mouse_Action, int, int);
234void term_deselect (void);
235void term_update (void);
236void term_invalidate(void);
237
238/*
5e1a8e27 239 * Exports from raw.c.
240 */
241
3d9a14c9 242extern Backend raw_backend;
5e1a8e27 243
244/*
374330e2 245 * Exports from telnet.c.
246 */
247
c14776e8 248extern Backend telnet_backend;
374330e2 249
250/*
251 * Exports from ssh.c.
252 */
253
c14776e8 254extern Backend ssh_backend;
374330e2 255
256/*
5bc238bb 257 * Exports from ldisc.c.
258 */
259
260extern Ldisc ldisc_term, ldisc_simple;
261
262/*
374330e2 263 * Exports from sshrand.c.
264 */
265
266void random_add_noise(void *noise, int length);
267void random_init(void);
268int random_byte(void);
269void random_get_savedata(void **data, int *len);
270
271/*
272 * Exports from misc.c.
273 */
274
275/* #define MALLOC_LOG do this if you suspect putty of leaking memory */
276#ifdef MALLOC_LOG
277#define smalloc(z) (mlog(__FILE__,__LINE__), safemalloc(z))
278#define srealloc(y,z) (mlog(__FILE__,__LINE__), saferealloc(y,z))
279#define sfree(z) (mlog(__FILE__,__LINE__), safefree(z))
280void mlog(char *, int);
281#else
282#define smalloc safemalloc
283#define srealloc saferealloc
284#define sfree safefree
285#endif
286
287void *safemalloc(size_t);
288void *saferealloc(void *, size_t);
289void safefree(void *);
290
291/*
067a15ea 292 * Exports from version.c.
293 */
294extern char ver[];
295
296/*
b73fd1b1 297 * Exports from sizetip.c.
298 */
299void UpdateSizeTip(HWND src, int cx, int cy);
300void EnableSizeTip(int bEnable);
301
302/*
14963b8f 303 * Exports from xlat.c.
304 */
305unsigned char xlat_kbd2tty(unsigned char c);
306unsigned char xlat_tty2scr(unsigned char c);
307unsigned char xlat_latkbd2win(unsigned char c);
308
309/*
374330e2 310 * A debug system.
311 */
312#ifdef DEBUG
313#include <stdarg.h>
314#define debug(x) (dprintf x)
315static void dprintf(char *fmt, ...) {
316 char buf[2048];
317 DWORD dw;
318 va_list ap;
319 static int gotconsole = 0;
320
321 if (!gotconsole) {
322 AllocConsole();
323 gotconsole = 1;
324 }
325
326 va_start(ap, fmt);
327 vsprintf(buf, fmt, ap);
328 WriteFile (GetStdHandle(STD_OUTPUT_HANDLE), buf, strlen(buf), &dw, NULL);
329 va_end(ap);
330}
331#else
332#define debug(x)
333#endif
334
335#endif