Almost _all_ of the final connection-layer loop, in both SSH1 and
[u/mdw/putty] / putty.h
CommitLineData
374330e2 1#ifndef PUTTY_PUTTY_H
2#define PUTTY_PUTTY_H
3
54a2bffb 4#include <stddef.h> /* for wchar_t */
ca20bfcf 5
f7f27309 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#ifndef GLOBAL
12#ifdef PUTTY_DO_GLOBALS
13#define GLOBAL
14#else
15#define GLOBAL extern
16#endif
17#endif
18
a8327734 19#ifndef DONE_TYPEDEFS
20#define DONE_TYPEDEFS
f7f27309 21typedef struct config_tag Config;
1709795f 22typedef struct backend_tag Backend;
887035a5 23typedef struct terminal_tag Terminal;
a8327734 24#endif
8df7a775 25
f7f27309 26#include "puttyps.h"
27#include "network.h"
9a30e26b 28#include "misc.h"
374330e2 29
4eeb7d09 30/* Three attribute types:
50c1be3f 31 * The ATTRs (normal attributes) are stored with the characters in
32 * the main display arrays
4eeb7d09 33 *
50c1be3f 34 * The TATTRs (temporary attributes) are generated on the fly, they
35 * can overlap with characters but not with normal attributes.
4eeb7d09 36 *
50c1be3f 37 * The LATTRs (line attributes) are an entirely disjoint space of
38 * flags.
4eeb7d09 39 *
40 * ATTR_INVALID is an illegal colour combination.
41 */
42
36566009 43#define TATTR_ACTCURS 0x40000000UL /* active cursor (block) */
44#define TATTR_PASCURS 0x20000000UL /* passive cursor (box) */
45#define TATTR_RIGHTCURS 0x10000000UL /* cursor-on-RHS */
c6958dfe 46#define TATTR_COMBINING 0x80000000UL /* combining characters */
374330e2 47
c9def1b8 48#define LATTR_NORM 0x00000000UL
36566009 49#define LATTR_WIDE 0x00000001UL
50#define LATTR_TOP 0x00000002UL
51#define LATTR_BOT 0x00000003UL
52#define LATTR_MODE 0x00000003UL
53#define LATTR_WRAPPED 0x00000010UL
54#define LATTR_WRAPPED2 0x00000020UL
4eeb7d09 55
36566009 56#define ATTR_INVALID 0x03FFU
4eeb7d09 57
58/* Like Linux use the F000 page for direct to font. */
36566009 59#define CSET_OEMCP 0x0000F000UL /* OEM Codepage DTF */
60#define CSET_ACP 0x0000F100UL /* Ansi Codepage DTF */
4eeb7d09 61
62/* These are internal use overlapping with the UTF-16 surrogates */
36566009 63#define CSET_ASCII 0x0000D800UL /* normal ASCII charset ESC ( B */
64#define CSET_LINEDRW 0x0000D900UL /* line drawing charset ESC ( 0 */
65#define CSET_SCOACS 0x0000DA00UL /* SCO Alternate charset */
66#define CSET_GBCHR 0x0000DB00UL /* UK variant charset ESC ( A */
67#define CSET_MASK 0xFFFFFF00UL /* Character set mask */
4eeb7d09 68
36566009 69#define DIRECT_CHAR(c) ((c&0xFFFFFC00)==0xD800)
70#define DIRECT_FONT(c) ((c&0xFFFFFE00)==0xF000)
4eeb7d09 71
36566009 72#define UCSERR (CSET_LINEDRW|'a') /* UCS Format error character. */
3c7366f8 73/*
74 * UCSWIDE is a special value used in the terminal data to signify
75 * the character cell containing the right-hand half of a CJK wide
76 * character. We use 0xDFFF because it's part of the surrogate
77 * range and hence won't be used for anything else (it's impossible
78 * to input it via UTF-8 because our UTF-8 decoder correctly
79 * rejects surrogates).
80 */
81#define UCSWIDE 0xDFFF
4eeb7d09 82
36566009 83#define ATTR_NARROW 0x8000U
84#define ATTR_WIDE 0x4000U
85#define ATTR_BOLD 0x0400U
86#define ATTR_UNDER 0x0800U
87#define ATTR_REVERSE 0x1000U
88#define ATTR_BLINK 0x2000U
89#define ATTR_FGMASK 0x001FU
90#define ATTR_BGMASK 0x03E0U
91#define ATTR_COLOURS 0x03FFU
92#define ATTR_FGSHIFT 0
93#define ATTR_BGSHIFT 5
94
95#define ATTR_DEFAULT 0x0128U /* bg 9, fg 8 */
96#define ATTR_DEFFG 0x0008U
97#define ATTR_DEFBG 0x0120U
4eeb7d09 98
99#define ATTR_CUR_AND (~(ATTR_BOLD|ATTR_REVERSE|ATTR_BLINK|ATTR_COLOURS))
36566009 100#define ATTR_CUR_XOR 0x016AU
374330e2 101
0b4f0bc0 102struct sesslist {
103 int nsessions;
104 char **sessions;
105 char *buffer; /* so memory can be freed later */
106};
1709795f 107
21d2b241 108struct unicode_data {
109 char **uni_tbl;
110 int dbcs_screenfont;
111 int font_codepage;
112 int line_codepage;
113 wchar_t unitab_scoacs[256];
114 wchar_t unitab_line[256];
115 wchar_t unitab_font[256];
116 wchar_t unitab_xterm[256];
117 wchar_t unitab_oemcp[256];
118 unsigned char unitab_ctrl[256];
119};
4eeb7d09 120
32874aea 121#define LGXF_OVR 1 /* existing logfile overwrite */
122#define LGXF_APN 0 /* existing logfile append */
123#define LGXF_ASK -1 /* existing logfile ask */
124#define LGTYP_NONE 0 /* logmode: no logging */
125#define LGTYP_ASCII 1 /* logmode: pure ascii */
00db133f 126#define LGTYP_DEBUG 2 /* logmode: all chars of traffic */
127#define LGTYP_PACKETS 3 /* logmode: SSH data packets */
5fd04f07 128
374330e2 129typedef enum {
6f2d0cde 130 /* Actual special commands. Originally Telnet, but some codes have
131 * been re-used for similar specials in other protocols. */
374330e2 132 TS_AYT, TS_BRK, TS_SYNCH, TS_EC, TS_EL, TS_GA, TS_NOP, TS_ABORT,
a5f3e637 133 TS_AO, TS_IP, TS_SUSP, TS_EOR, TS_EOF, TS_LECHO, TS_RECHO, TS_PING,
6f2d0cde 134 TS_EOL,
4423d5c7 135 /* Special command for SSH. */
136 TS_REKEY,
6f2d0cde 137 /* POSIX-style signals. (not Telnet) */
138 TS_SIGABRT, TS_SIGALRM, TS_SIGFPE, TS_SIGHUP, TS_SIGILL,
139 TS_SIGINT, TS_SIGKILL, TS_SIGPIPE, TS_SIGQUIT, TS_SIGSEGV,
140 TS_SIGTERM, TS_SIGUSR1, TS_SIGUSR2,
141 /* Pseudo-specials used for constructing the specials menu. */
142 TS_SEP, /* Separator */
143 TS_SUBMENU, /* Start a new submenu with specified name */
144 TS_EXITMENU /* Exit current submenu or end of specials */
374330e2 145} Telnet_Special;
146
125105d1 147struct telnet_special {
6f2d0cde 148 const char *name;
125105d1 149 int code;
150};
151
374330e2 152typedef enum {
01c034ad 153 MBT_NOTHING,
154 MBT_LEFT, MBT_MIDDLE, MBT_RIGHT, /* `raw' button designations */
155 MBT_SELECT, MBT_EXTEND, MBT_PASTE, /* `cooked' button designations */
156 MBT_WHEEL_UP, MBT_WHEEL_DOWN /* mouse wheel */
374330e2 157} Mouse_Button;
158
159typedef enum {
160 MA_NOTHING, MA_CLICK, MA_2CLK, MA_3CLK, MA_DRAG, MA_RELEASE
161} Mouse_Action;
162
6c50d421 163/* Keyboard modifiers -- keys the user is actually holding down */
164
165#define PKM_SHIFT 0x01
166#define PKM_CONTROL 0x02
167#define PKM_META 0x04
168#define PKM_ALT 0x08
169
170/* Keyboard flags that aren't really modifiers */
171#define PKF_CAPSLOCK 0x10
172#define PKF_NUMLOCK 0x20
173#define PKF_REPEAT 0x40
174
175/* Stand-alone keysyms for function keys */
176
177typedef enum {
178 PK_NULL, /* No symbol for this key */
179 /* Main keypad keys */
180 PK_ESCAPE, PK_TAB, PK_BACKSPACE, PK_RETURN, PK_COMPOSE,
181 /* Editing keys */
182 PK_HOME, PK_INSERT, PK_DELETE, PK_END, PK_PAGEUP, PK_PAGEDOWN,
183 /* Cursor keys */
184 PK_UP, PK_DOWN, PK_RIGHT, PK_LEFT, PK_REST,
185 /* Numeric keypad */ /* Real one looks like: */
186 PK_PF1, PK_PF2, PK_PF3, PK_PF4, /* PF1 PF2 PF3 PF4 */
187 PK_KPCOMMA, PK_KPMINUS, PK_KPDECIMAL, /* 7 8 9 - */
188 PK_KP0, PK_KP1, PK_KP2, PK_KP3, PK_KP4, /* 4 5 6 , */
189 PK_KP5, PK_KP6, PK_KP7, PK_KP8, PK_KP9, /* 1 2 3 en- */
190 PK_KPBIGPLUS, PK_KPENTER, /* 0 . ter */
191 /* Top row */
192 PK_F1, PK_F2, PK_F3, PK_F4, PK_F5,
193 PK_F6, PK_F7, PK_F8, PK_F9, PK_F10,
194 PK_F11, PK_F12, PK_F13, PK_F14, PK_F15,
195 PK_F16, PK_F17, PK_F18, PK_F19, PK_F20,
196 PK_PAUSE
197} Key_Sym;
198
199#define PK_ISEDITING(k) ((k) >= PK_HOME && (k) <= PK_PAGEDOWN)
200#define PK_ISCURSOR(k) ((k) >= PK_UP && (k) <= PK_REST)
201#define PK_ISKEYPAD(k) ((k) >= PK_PF1 && (k) <= PK_KPENTER)
202#define PK_ISFKEY(k) ((k) >= PK_F1 && (k) <= PK_F20)
203
5ecd7ad0 204enum {
4eeb7d09 205 VT_XWINDOWS, VT_OEMANSI, VT_OEMONLY, VT_POORMAN, VT_UNICODE
5ecd7ad0 206};
374330e2 207
0965bee0 208enum {
209 /*
ca20bfcf 210 * SSH ciphers (both SSH1 and SSH2)
211 */
212 CIPHER_WARN, /* pseudo 'cipher' */
213 CIPHER_3DES,
214 CIPHER_BLOWFISH,
215 CIPHER_AES, /* (SSH 2 only) */
7f1ae1d2 216 CIPHER_DES,
ca20bfcf 217 CIPHER_MAX /* no. ciphers (inc warn) */
218};
219
220enum {
221 /*
5ecd7ad0 222 * Several different bits of the PuTTY configuration seem to be
223 * three-way settings whose values are `always yes', `always
224 * no', and `decide by some more complex automated means'. This
225 * is true of line discipline options (local echo and line
226 * editing), proxy DNS, Close On Exit, and SSH server bug
227 * workarounds. Accordingly I supply a single enum here to deal
228 * with them all.
0965bee0 229 */
5ecd7ad0 230 FORCE_ON, FORCE_OFF, AUTO
231};
232
233enum {
234 /*
235 * Proxy types.
236 */
10068a0b 237 PROXY_NONE, PROXY_SOCKS4, PROXY_SOCKS5,
238 PROXY_HTTP, PROXY_TELNET, PROXY_CMD
0965bee0 239};
240
241enum {
242 /*
243 * Line discipline options which the backend might try to control.
244 */
32874aea 245 LD_EDIT, /* local line editing */
246 LD_ECHO /* local echo */
0965bee0 247};
248
b41069ff 249enum {
5ecd7ad0 250 /* Protocol back ends. (cfg.protocol) */
251 PROT_RAW, PROT_TELNET, PROT_RLOGIN, PROT_SSH
252};
253
254enum {
255 /* Bell settings (cfg.beep) */
85f6b361 256 BELL_DISABLED, BELL_DEFAULT, BELL_VISUAL, BELL_WAVEFILE, BELL_PCSPEAKER
5ecd7ad0 257};
258
259enum {
260 /* Taskbar flashing indication on bell (cfg.beep_ind) */
261 B_IND_DISABLED, B_IND_FLASH, B_IND_STEADY
262};
263
264enum {
265 /* Resize actions (cfg.resize_action) */
266 RESIZE_TERM, RESIZE_DISABLED, RESIZE_FONT, RESIZE_EITHER
b41069ff 267};
268
6c50d421 269enum {
270 /* Function key types (cfg.funky_type) */
271 FUNKY_TILDE,
272 FUNKY_LINUX,
273 FUNKY_XTERM,
274 FUNKY_VT400,
275 FUNKY_VT100P,
276 FUNKY_SCO
277};
278
1709795f 279struct backend_tag {
cbe2d68f 280 const char *(*init) (void *frontend_handle, void **backend_handle,
281 Config *cfg,
79bf227b 282 char *host, int port, char **realhost, int nodelay,
283 int keepalive);
fabd1805 284 void (*free) (void *handle);
86916870 285 /* back->reconfig() passes in a replacement configuration. */
286 void (*reconfig) (void *handle, Config *cfg);
5471d09a 287 /* back->send() returns the current amount of buffered data. */
51470298 288 int (*send) (void *handle, char *buf, int len);
5471d09a 289 /* back->sendbuffer() does the same thing but without attempting a send */
51470298 290 int (*sendbuffer) (void *handle);
291 void (*size) (void *handle, int width, int height);
292 void (*special) (void *handle, Telnet_Special code);
125105d1 293 const struct telnet_special *(*get_specials) (void *handle);
51470298 294 Socket(*socket) (void *handle);
295 int (*exitcode) (void *handle);
296 int (*sendok) (void *handle);
297 int (*ldisc) (void *handle, int);
b9d7bcad 298 void (*provide_ldisc) (void *handle, void *ldisc);
a8327734 299 void (*provide_logctx) (void *handle, void *logctx);
5471d09a 300 /*
301 * back->unthrottle() tells the back end that the front end
302 * buffer is clearing.
303 */
51470298 304 void (*unthrottle) (void *handle, int);
97db3be4 305 int default_port;
1709795f 306};
374330e2 307
297d398b 308extern struct backend_list {
89ee5268 309 int protocol;
310 char *name;
311 Backend *backend;
312} backends[];
313
ffa79828 314/*
315 * Suggested default protocol provided by the backend link module.
316 * The application is free to ignore this.
317 */
318extern const int be_default_protocol;
319
5ecd7ad0 320/*
47e4e735 321 * Name of this particular application, for use in the config box
322 * and other pieces of text.
323 */
324extern const char *const appname;
325
326/*
5ecd7ad0 327 * IMPORTANT POLICY POINT: everything in this structure which wants
328 * to be treated like an integer must be an actual, honest-to-
329 * goodness `int'. No enum-typed variables. This is because parts
330 * of the code will want to pass around `int *' pointers to them
331 * and we can't run the risk of porting to some system on which the
332 * enum comes out as a different size from int.
333 */
f7f27309 334struct config_tag {
374330e2 335 /* Basic options */
336 char host[512];
337 int port;
5ecd7ad0 338 int protocol;
374330e2 339 int close_on_exit;
9ef49106 340 int warn_on_close;
32874aea 341 int ping_interval; /* in seconds */
2184a5d9 342 int tcp_nodelay;
79bf227b 343 int tcp_keepalives;
8eebd221 344 /* Proxy options */
345 char proxy_exclude_list[512];
5ecd7ad0 346 int proxy_dns;
b804e1e5 347 int even_proxy_localhost;
5ecd7ad0 348 int proxy_type;
8eebd221 349 char proxy_host[512];
350 int proxy_port;
f33ba69e 351 char proxy_username[128];
352 char proxy_password[128];
8eebd221 353 char proxy_telnet_command[512];
fef97f43 354 /* SSH options */
6abbf9e3 355 char remote_cmd[512];
fd5e5847 356 char remote_cmd2[512]; /* fallback if the first fails
357 * (used internally for scp) */
32874aea 358 char *remote_cmd_ptr; /* might point to a larger command
359 * but never for loading/saving */
fd5e5847 360 char *remote_cmd_ptr2; /* might point to a larger command
361 * but never for loading/saving */
fef97f43 362 int nopty;
4ba9b64b 363 int compression;
979310f1 364 int agentfwd;
5bb641e1 365 int change_username; /* allow username switching in SSH2 */
ca20bfcf 366 int ssh_cipherlist[CIPHER_MAX];
9a30e26b 367 Filename keyfile;
32874aea 368 int sshprot; /* use v1 or v2 when both available */
cb4d4768 369 int ssh2_des_cbc; /* "des-cbc" nonstandard SSH2 cipher */
ccbfb941 370 int try_tis_auth;
f091e308 371 int try_ki_auth;
4a8fc3c4 372 int ssh_subsys; /* run a subsystem rather than a command */
fd5e5847 373 int ssh_subsys2; /* fallback to go with remote_cmd2 */
0ed48730 374 int ssh_no_shell; /* avoid running a shell */
374330e2 375 /* Telnet options */
376 char termtype[32];
377 char termspeed[32];
32874aea 378 char environmt[1024]; /* VAR\tvalue\0VAR\tvalue\0\0 */
277fc55e 379 char username[100];
380 char localusername[100];
374330e2 381 int rfc_environ;
8faa456c 382 int passive_telnet;
374330e2 383 /* Keyboard options */
384 int bksp_is_delete;
385 int rxvt_homeend;
c9def1b8 386 int funky_type;
32874aea 387 int no_applic_c; /* totally disable app cursor keys */
388 int no_applic_k; /* totally disable app keypad */
c0d36a72 389 int no_mouse_rep; /* totally disable mouse reporting */
0d2086c5 390 int no_remote_resize; /* disable remote resizing */
391 int no_alt_screen; /* disable alternate screen */
392 int no_remote_wintitle; /* disable remote retitling */
393 int no_dbackspace; /* disable destructive backspace */
394 int no_remote_charset; /* disable remote charset config */
7fcdebd3 395 int no_remote_qtitle; /* disable remote win title query */
374330e2 396 int app_cursor;
397 int app_keypad;
c5e9c988 398 int nethack_keypad;
a5f3e637 399 int telnet_keyboard;
eee63b77 400 int telnet_newline;
c5e9c988 401 int alt_f4; /* is it special? */
402 int alt_space; /* is it special? */
a094ae43 403 int alt_only; /* is it special? */
0965bee0 404 int localecho;
405 int localedit;
e95edc00 406 int alwaysontop;
8f57d753 407 int fullscreenonaltenter;
c9def1b8 408 int scroll_on_key;
a094ae43 409 int scroll_on_disp;
876e5d5e 410 int erase_to_scrollback;
a094ae43 411 int compose_key;
95bbe1ae 412 int ctrlaltkeys;
32874aea 413 char wintitle[256]; /* initial window title */
374330e2 414 /* Terminal options */
415 int savelines;
416 int dec_om;
417 int wrap_mode;
fef97f43 418 int lfhascr;
4e30ff69 419 int cursor_type; /* 0=block 1=underline 2=vertical */
c9def1b8 420 int blink_cur;
5ecd7ad0 421 int beep;
422 int beep_ind;
156686ef 423 int bellovl; /* bell overload protection active? */
424 int bellovl_n; /* number of bells to cause overload */
425 int bellovl_t; /* time interval for overload (seconds) */
426 int bellovl_s; /* period of silence to re-enable bell (s) */
9a30e26b 427 Filename bell_wavefile;
c9def1b8 428 int scrollbar;
a401e5f3 429 int scrollbar_in_fullscreen;
5ecd7ad0 430 int resize_action;
c9def1b8 431 int bce;
432 int blinktext;
374330e2 433 int win_name_always;
434 int width, height;
9a30e26b 435 FontSpec font;
436 Filename logfilename;
e1c8e0ed 437 int logtype;
9f89f96e 438 int logxfovr;
9a10ecf4 439 int logomitpass;
440 int logomitdata;
554c540d 441 int hide_mouseptr;
57d08f2f 442 int sunken_edge;
5a73255e 443 int window_border;
e7fbcdd8 444 char answerback[256];
b44b307a 445 char printer[128];
f0fccd51 446 int arabicshaping;
447 int bidi;
374330e2 448 /* Colour options */
c6f1b8ed 449 int ansi_colour;
26d1da7b 450 int system_colour;
374330e2 451 int try_palette;
452 int bold_colour;
453 unsigned char colours[22][3];
454 /* Selection options */
455 int mouse_is_xterm;
6908fed7 456 int rect_select;
d3a22f79 457 int rawcnp;
a7419ea4 458 int rtf_paste;
b90840c3 459 int mouse_override;
374330e2 460 short wordness[256];
c9def1b8 461 /* translations */
5ecd7ad0 462 int vtmode;
8bb92a1c 463 char line_codepage[128];
6ac7f054 464 int utf8_override;
a9c02454 465 int xlat_capslockcyr;
9c964e85 466 /* X11 forwarding */
467 int x11_forward;
468 char x11_display[128];
b3ebaa28 469 int x11_auth;
d74d141c 470 /* port forwarding */
beefa433 471 int lport_acceptall; /* accept conns from hosts other than localhost */
472 int rport_acceptall; /* same for remote forwarded ports (SSH2 only) */
820ebe3b 473 /*
474 * The port forwarding string contains a number of
475 * NUL-terminated substrings, terminated in turn by an empty
476 * string (i.e. a second NUL immediately after the previous
477 * one). Each string can be of one of the following forms:
478 *
479 * [LR]localport\thost:port
480 * [LR]localaddr:localport\thost:port
481 * Dlocalport
482 * Dlocaladdr:localport
483 */
484 char portfwd[1024];
2c9c6388 485 /* SSH bug compatibility modes */
5ecd7ad0 486 int sshbug_ignore1, sshbug_plainpw1, sshbug_rsa1,
8e975795 487 sshbug_hmac2, sshbug_derivekey2, sshbug_rsapad2,
dda87a28 488 sshbug_dhgex2, sshbug_pksessid2;
c8ee61b9 489 /* Options for pterm. Should split out into platform-dependent part. */
490 int stamp_utmp;
491 int login_shell;
239b3b36 492 int scrollbar_on_left;
bf133a73 493 int shadowbold;
9a30e26b 494 FontSpec boldfont;
495 FontSpec widefont;
496 FontSpec wideboldfont;
12994a99 497 int shadowboldoffset;
f7f27309 498};
374330e2 499
e277c42d 500/*
4017be6d 501 * Some global flags denoting the type of application.
67779be7 502 *
503 * FLAG_VERBOSE is set when the user requests verbose details.
504 *
505 * FLAG_STDERR is set in command-line applications (which have a
506 * functioning stderr that it makes sense to write to) and not in
507 * GUI applications (which don't).
508 *
509 * FLAG_INTERACTIVE is set when a full interactive shell session is
510 * being run, _either_ because no remote command has been provided
511 * _or_ because the application is GUI and can't run non-
512 * interactively.
0b4f0bc0 513 *
514 * These flags describe the type of _application_ - they wouldn't
515 * vary between individual sessions - and so it's OK to have this
516 * variable be GLOBAL.
c44bf5bd 517 *
518 * Note that additional flags may be defined in platform-specific
519 * headers. It's probably best if those ones start from 0x1000, to
520 * avoid collision.
4017be6d 521 */
67779be7 522#define FLAG_VERBOSE 0x0001
523#define FLAG_STDERR 0x0002
524#define FLAG_INTERACTIVE 0x0004
4017be6d 525GLOBAL int flags;
526
0b4f0bc0 527/*
528 * Likewise, these two variables are set up when the application
529 * initialises, and inform all default-settings accesses after
530 * that.
531 */
e277c42d 532GLOBAL int default_protocol;
533GLOBAL int default_port;
374330e2 534
18e62ad8 535/*
536 * This is set TRUE by cmdline.c iff a session is loaded with "-load".
537 */
538GLOBAL int loaded_session;
539
4e23b276 540struct RSAKey; /* be a little careful of scope */
541
374330e2 542/*
543 * Exports from window.c.
544 */
a8327734 545void request_resize(void *frontend, int, int);
36566009 546void do_text(Context, int, int, wchar_t *, int, unsigned long, int);
547void do_cursor(Context, int, int, wchar_t *, int, unsigned long, int);
2102eb8a 548int char_width(Context ctx, int uc);
37d2a505 549#ifdef OPTIMISE_SCROLL
341eb978 550void do_scroll(Context, int, int, int);
37d2a505 551#endif
a8327734 552void set_title(void *frontend, char *);
553void set_icon(void *frontend, char *);
554void set_sbar(void *frontend, int, int, int);
555Context get_ctx(void *frontend);
32874aea 556void free_ctx(Context);
a8327734 557void palette_set(void *frontend, int, int, int, int);
558void palette_reset(void *frontend);
559void write_aclip(void *frontend, char *, int, int);
560void write_clip(void *frontend, wchar_t *, int, int);
561void get_clip(void *frontend, wchar_t **, int *);
562void optimised_move(void *frontend, int, int, int);
563void set_raw_mouse_mode(void *frontend, int);
a8327734 564void connection_fatal(void *frontend, char *, ...);
32874aea 565void fatalbox(char *, ...);
1709795f 566void modalfatalbox(char *, ...);
4b599b6d 567#ifdef macintosh
568#pragma noreturn(fatalbox)
569#pragma noreturn(modalfatalbox)
570#endif
a8327734 571void beep(void *frontend, int);
572void begin_session(void *frontend);
573void sys_cursor(void *frontend, int x, int y);
574void request_paste(void *frontend);
b9d7bcad 575void frontend_keypress(void *frontend);
576void ldisc_update(void *frontend, int echo, int edit);
533b1743 577/* It's the backend's responsibility to invoke this at the start of a
578 * connection, if necessary; it can also invoke it later if the set of
579 * special commands changes. It does not need to invoke it at session
580 * shutdown. */
125105d1 581void update_specials_menu(void *frontend);
fbf6cb3b 582int from_backend(void *frontend, int is_stderr, const char *data, int len);
39934deb 583void notify_remote_exit(void *frontend);
374330e2 584#define OPTIMISE_IS_SCROLL 1
585
a8327734 586void set_iconic(void *frontend, int iconic);
587void move_window(void *frontend, int x, int y);
588void set_zorder(void *frontend, int top);
589void refresh_window(void *frontend);
590void set_zoomed(void *frontend, int zoomed);
591int is_iconic(void *frontend);
592void get_window_pos(void *frontend, int *x, int *y);
593void get_window_pixels(void *frontend, int *x, int *y);
594char *get_window_title(void *frontend, int icon);
68f9b3d9 595
93b581bd 596void cleanup_exit(int);
597
374330e2 598/*
599 * Exports from noise.c.
600 */
32874aea 601void noise_get_heavy(void (*func) (void *, int));
602void noise_get_light(void (*func) (void *, int));
7d6ee6ff 603void noise_regular(void);
f7f27309 604void noise_ultralight(unsigned long data);
374330e2 605void random_save_seed(void);
de3df031 606void random_destroy_seed(void);
374330e2 607
608/*
a9422f39 609 * Exports from settings.c.
610 */
3f935d5b 611char *save_settings(char *section, int do_host, Config * cfg);
b537dd42 612void save_open_settings(void *sesskey, int do_host, Config *cfg);
32874aea 613void load_settings(char *section, int do_host, Config * cfg);
ce283213 614void load_open_settings(void *sesskey, int do_host, Config *cfg);
0b4f0bc0 615void get_sesslist(struct sesslist *, int allocate);
1709795f 616void do_defaults(char *, Config *);
617void registry_cleanup(void);
a9422f39 618
619/*
5a9eb105 620 * Functions used by settings.c to provide platform-specific
621 * default settings.
622 *
623 * (The integer one is expected to return `def' if it has no clear
624 * opinion of its own. This is because there's no integer value
625 * which I can reliably set aside to indicate `nil'. The string
9a30e26b 626 * function is perfectly all right returning NULL, of course. The
627 * Filename and FontSpec functions are _not allowed_ to fail to
628 * return, since these defaults _must_ be per-platform.)
5a9eb105 629 */
c85623f9 630char *platform_default_s(const char *name);
631int platform_default_i(const char *name, int def);
9a30e26b 632Filename platform_default_filename(const char *name);
633FontSpec platform_default_fontspec(const char *name);
5a9eb105 634
635/*
374330e2 636 * Exports from terminal.c.
637 */
638
21d2b241 639Terminal *term_init(Config *, struct unicode_data *, void *);
fabd1805 640void term_free(Terminal *);
887035a5 641void term_size(Terminal *, int, int, int);
c1b55581 642void term_paint(Terminal *, Context, int, int, int, int, int);
887035a5 643void term_scroll(Terminal *, int, int);
644void term_pwron(Terminal *);
645void term_clrsb(Terminal *);
fc5b0934 646void term_mouse(Terminal *, Mouse_Button, Mouse_Button, Mouse_Action,
647 int,int,int,int,int);
6c50d421 648void term_key(Terminal *, Key_Sym, wchar_t *, size_t, unsigned int,
649 unsigned int);
887035a5 650void term_deselect(Terminal *);
651void term_update(Terminal *);
652void term_invalidate(Terminal *);
653void term_blink(Terminal *, int set_cursor);
654void term_do_paste(Terminal *);
655int term_paste_pending(Terminal *);
656void term_paste(Terminal *);
657void term_nopaste(Terminal *);
658int term_ldisc(Terminal *, int option);
659void term_copyall(Terminal *);
64734920 660void term_reconfig(Terminal *, Config *);
887035a5 661void term_seen_key_event(Terminal *);
fbf6cb3b 662int term_data(Terminal *, int is_stderr, const char *data, int len);
51470298 663void term_provide_resize_fn(Terminal *term,
664 void (*resize_fn)(void *, int, int),
665 void *resize_ctx);
a8327734 666void term_provide_logctx(Terminal *term, void *logctx);
374330e2 667
668/*
00db133f 669 * Exports from logging.c.
670 */
c229ef97 671void *log_init(void *frontend, Config *cfg);
fabd1805 672void log_free(void *logctx);
c229ef97 673void log_reconfig(void *logctx, Config *cfg);
a8327734 674void logfopen(void *logctx);
675void logfclose(void *logctx);
676void logtraffic(void *logctx, unsigned char c, int logmode);
11cc5e30 677void logflush(void *logctx);
cbe2d68f 678void log_eventlog(void *logctx, const char *string);
00db133f 679enum { PKT_INCOMING, PKT_OUTGOING };
9a10ecf4 680enum { PKTLOG_EMIT, PKTLOG_BLANK, PKTLOG_OMIT };
681struct logblank_t {
682 int offset;
683 int len;
684 int type;
685};
a8327734 686void log_packet(void *logctx, int direction, int type,
9a10ecf4 687 char *texttype, void *data, int len,
688 int n_blanks, const struct logblank_t *blanks);
00db133f 689
690/*
d082ac49 691 * Exports from testback.c
692 */
693
694extern Backend null_backend;
695extern Backend loop_backend;
696
697/*
5e1a8e27 698 * Exports from raw.c.
699 */
700
3d9a14c9 701extern Backend raw_backend;
5e1a8e27 702
703/*
c91409da 704 * Exports from rlogin.c.
705 */
706
707extern Backend rlogin_backend;
708
709/*
374330e2 710 * Exports from telnet.c.
711 */
712
c14776e8 713extern Backend telnet_backend;
374330e2 714
715/*
c0a81592 716 * Exports from ssh.c. (NB the getline variables have to be GLOBAL
717 * so that PuTTYtel will still compile - otherwise it would depend
718 * on ssh.c.)
374330e2 719 */
720
c0a81592 721GLOBAL int (*ssh_get_line) (const char *prompt, char *str, int maxlen,
32874aea 722 int is_pw);
c0a81592 723GLOBAL int ssh_getline_pw_only;
c14776e8 724extern Backend ssh_backend;
374330e2 725
726/*
5bc238bb 727 * Exports from ldisc.c.
728 */
fe5634f6 729void *ldisc_create(Config *, Terminal *, Backend *, void *, void *);
fabd1805 730void ldisc_free(void *);
b9d7bcad 731void ldisc_send(void *handle, char *buf, int len, int interactive);
5bc238bb 732
733/*
5def7522 734 * Exports from ldiscucs.c.
735 */
736void lpage_send(void *, int codepage, char *buf, int len, int interactive);
737void luni_send(void *, wchar_t * widebuf, int len, int interactive);
738
739/*
374330e2 740 * Exports from sshrand.c.
741 */
742
743void random_add_noise(void *noise, int length);
744void random_init(void);
745int random_byte(void);
746void random_get_savedata(void **data, int *len);
93b581bd 747extern int random_active;
374330e2 748
749/*
39934deb 750 * Exports from pinger.c.
751 */
752typedef struct pinger_tag *Pinger;
753Pinger pinger_new(Config *cfg, Backend *back, void *backhandle);
754void pinger_reconfig(Pinger, Config *oldcfg, Config *newcfg);
755void pinger_free(Pinger);
756
757/*
374330e2 758 * Exports from misc.c.
759 */
760
db9c0f86 761#include "misc.h"
374330e2 762
763/*
067a15ea 764 * Exports from version.c.
765 */
766extern char ver[];
767
768/*
4eeb7d09 769 * Exports from unicode.c.
14963b8f 770 */
4eeb7d09 771#ifndef CP_UTF8
772#define CP_UTF8 65001
773#endif
facd762c 774/* void init_ucs(void); -- this is now in platform-specific headers */
5def7522 775int is_dbcs_leadbyte(int codepage, char byte);
776int mb_to_wc(int codepage, int flags, char *mbstr, int mblen,
777 wchar_t *wcstr, int wclen);
778int wc_to_mb(int codepage, int flags, wchar_t *wcstr, int wclen,
21d2b241 779 char *mbstr, int mblen, char *defchr, int *defused,
780 struct unicode_data *ucsdata);
a9c02454 781wchar_t xlat_uskbd2cyrllic(int ch);
4eeb7d09 782int check_compose(int first, int second);
783int decode_codepage(char *cp_name);
d4413bd2 784const char *cp_enumerate (int index);
785const char *cp_name(int codepage);
a7419ea4 786void get_unitab(int codepage, wchar_t * unitab, int ftype);
14963b8f 787
788/*
5f6fe27e 789 * Exports from wcwidth.c
790 */
791int wcwidth(wchar_t ucs);
792int wcswidth(const wchar_t *pwcs, size_t n);
793
794/*
8f203108 795 * Exports from mscrypto.c
796 */
797#ifdef MSCRYPTOAPI
798int crypto_startup();
799void crypto_wrapup();
800#endif
801
802/*
839f10db 803 * Exports from pageantc.c.
804 *
805 * agent_query returns 1 for here's-a-response, and 0 for query-in-
806 * progress. In the latter case there will be a call to `callback'
807 * at some future point, passing callback_ctx as the first
808 * parameter and the actual reply data as the second and third.
809 *
810 * The response may be a NULL pointer (in either of the synchronous
811 * or asynchronous cases), which indicates failure to receive a
812 * response.
5c58ad2d 813 */
839f10db 814int agent_query(void *in, int inlen, void **out, int *outlen,
815 void (*callback)(void *, void *, int), void *callback_ctx);
5c58ad2d 816int agent_exists(void);
817
4eb24e3a 818/*
819 * Exports from wildcard.c
820 */
821const char *wc_error(int value);
822int wc_match(const char *wildcard, const char *target);
823int wc_unescape(char *output, const char *wildcard);
374330e2 824
ff2ae367 825/*
1709795f 826 * Exports from windlg.c
827 */
cbe2d68f 828void logevent(void *frontend, const char *);
a8327734 829void verify_ssh_host_key(void *frontend, char *host, int port, char *keytype,
1709795f 830 char *keystr, char *fingerprint);
a8327734 831void askcipher(void *frontend, char *ciphername, int cs);
9a30e26b 832int askappend(void *frontend, Filename filename);
1709795f 833
834/*
ff2ae367 835 * Exports from console.c (that aren't equivalents to things in
836 * windlg.c).
837 */
838extern int console_batch_mode;
ff2ae367 839int console_get_line(const char *prompt, char *str, int maxlen, int is_pw);
d3fef4a5 840void console_provide_logctx(void *logctx);
47a6b94c 841int is_interactive(void);
ff2ae367 842
b44b307a 843/*
844 * Exports from printing.c.
845 */
846typedef struct printer_enum_tag printer_enum;
847typedef struct printer_job_tag printer_job;
848printer_enum *printer_start_enum(int *nprinters);
849char *printer_get_name(printer_enum *, int);
850void printer_finish_enum(printer_enum *);
851printer_job *printer_start_job(char *printer);
852void printer_job_data(printer_job *, void *, int);
853void printer_finish_job(printer_job *);
854
c0a81592 855/*
856 * Exports from cmdline.c (and also cmdline_error(), which is
857 * defined differently in various places and required _by_
858 * cmdline.c).
859 */
5555d393 860int cmdline_process_param(char *, char *, int, Config *);
861void cmdline_run_saved(Config *);
679539d7 862void cmdline_cleanup(void);
c0a81592 863extern char *cmdline_password;
864#define TOOLTYPE_FILETRANSFER 1
46a3419b 865#define TOOLTYPE_NONNETWORK 2
c0a81592 866extern int cmdline_tooltype;
867
868void cmdline_error(char *, ...);
869
e0e7dff8 870/*
d1582b2e 871 * Exports from config.c.
872 */
1a602f03 873struct controlbox;
d1582b2e 874void setup_config_box(struct controlbox *b, struct sesslist *sesslist,
875 int midsession, int protocol);
876
877/*
f0fccd51 878 * Exports from minibidi.c.
879 */
880typedef struct bidi_char {
881 wchar_t origwc, wc;
882 unsigned short index;
883} bidi_char;
884int do_bidi(bidi_char *line, int count);
885int do_shape(bidi_char *line, bidi_char *to, int count);
886
887/*
e0e7dff8 888 * X11 auth mechanisms we know about.
889 */
890enum {
891 X11_NO_AUTH,
892 X11_MIT, /* MIT-MAGIC-COOKIE-1 */
2f92b717 893 X11_XDM, /* XDM-AUTHORIZATION-1 */
e0e7dff8 894 X11_NAUTHS
895};
896extern const char *const x11_authnames[]; /* declared in x11fwd.c */
897
9a30e26b 898/*
899 * Miscellaneous exports from the platform-specific code.
900 */
9fab77dc 901Filename filename_from_str(const char *string);
902const char *filename_to_str(const Filename *fn);
9a30e26b 903int filename_equal(Filename f1, Filename f2);
904int filename_is_null(Filename fn);
799dfcfa 905char *get_username(void); /* return value needs freeing */
47a6b94c 906char *get_random_data(int bytes); /* used in cmdgen.c */
9a30e26b 907
39934deb 908/*
909 * Exports and imports from timing.c.
910 *
911 * schedule_timer() asks the front end to schedule a callback to a
912 * timer function in a given number of ticks. The returned value is
913 * the time (in ticks since an arbitrary offset) at which the
914 * callback can be expected. This value will also be passed as the
915 * `now' parameter to the callback function. Hence, you can (for
916 * example) schedule an event at a particular time by calling
917 * schedule_timer() and storing the return value in your context
918 * structure as the time when that event is due. The first time a
919 * callback function gives you that value or more as `now', you do
920 * the thing.
921 *
922 * expire_timer_context() drops all current timers associated with
923 * a given value of ctx (for when you're about to free ctx).
924 *
925 * run_timers() is called from the front end when it has reason to
926 * think some timers have reached their moment, or when it simply
927 * needs to know how long to wait next. We pass it the time we
928 * think it is. It returns TRUE and places the time when the next
929 * timer needs to go off in `next', or alternatively it returns
930 * FALSE if there are no timers at all pending.
931 *
932 * timer_change_notify() must be supplied by the front end; it
933 * notifies the front end that a new timer has been added to the
934 * list which is sooner than any existing ones. It provides the
935 * time when that timer needs to go off.
936 */
937typedef void (*timer_fn_t)(void *ctx, long now);
938long schedule_timer(int ticks, timer_fn_t fn, void *ctx);
939void expire_timer_context(void *ctx);
940int run_timers(long now, long *next);
941void timer_change_notify(long next);
942
374330e2 943#endif