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