+++ /dev/null
-#ifndef PUTTY_PUTTY_H\r
-#define PUTTY_PUTTY_H\r
-\r
-#include <stddef.h> /* for wchar_t */\r
-\r
-/*\r
- * Global variables. Most modules declare these `extern', but\r
- * window.c will do `#define PUTTY_DO_GLOBALS' before including this\r
- * module, and so will get them properly defined.\r
- */\r
-#ifndef GLOBAL\r
-#ifdef PUTTY_DO_GLOBALS\r
-#define GLOBAL\r
-#else\r
-#define GLOBAL extern\r
-#endif\r
-#endif\r
-\r
-#ifndef DONE_TYPEDEFS\r
-#define DONE_TYPEDEFS\r
-typedef struct config_tag Config;\r
-typedef struct backend_tag Backend;\r
-typedef struct terminal_tag Terminal;\r
-#endif\r
-\r
-#include "puttyps.h"\r
-#include "network.h"\r
-#include "misc.h"\r
-\r
-/*\r
- * Fingerprints of the PGP master keys that can be used to establish a trust\r
- * path between an executable and other files.\r
- */\r
-#define PGP_RSA_MASTER_KEY_FP \\r
- "8F 15 97 DA 25 30 AB 0D 88 D1 92 54 11 CF 0C 4C"\r
-#define PGP_DSA_MASTER_KEY_FP \\r
- "313C 3E76 4B74 C2C5 F2AE 83A8 4F5E 6DF5 6A93 B34E"\r
-\r
-/* Three attribute types: \r
- * The ATTRs (normal attributes) are stored with the characters in\r
- * the main display arrays\r
- *\r
- * The TATTRs (temporary attributes) are generated on the fly, they\r
- * can overlap with characters but not with normal attributes.\r
- *\r
- * The LATTRs (line attributes) are an entirely disjoint space of\r
- * flags.\r
- * \r
- * The DATTRs (display attributes) are internal to terminal.c (but\r
- * defined here because their values have to match the others\r
- * here); they reuse the TATTR_* space but are always masked off\r
- * before sending to the front end.\r
- *\r
- * ATTR_INVALID is an illegal colour combination.\r
- */\r
-\r
-#define TATTR_ACTCURS 0x40000000UL /* active cursor (block) */\r
-#define TATTR_PASCURS 0x20000000UL /* passive cursor (box) */\r
-#define TATTR_RIGHTCURS 0x10000000UL /* cursor-on-RHS */\r
-#define TATTR_COMBINING 0x80000000UL /* combining characters */\r
-\r
-#define DATTR_STARTRUN 0x80000000UL /* start of redraw run */\r
-\r
-#define TDATTR_MASK 0xF0000000UL\r
-#define TATTR_MASK (TDATTR_MASK)\r
-#define DATTR_MASK (TDATTR_MASK)\r
-\r
-#define LATTR_NORM 0x00000000UL\r
-#define LATTR_WIDE 0x00000001UL\r
-#define LATTR_TOP 0x00000002UL\r
-#define LATTR_BOT 0x00000003UL\r
-#define LATTR_MODE 0x00000003UL\r
-#define LATTR_WRAPPED 0x00000010UL /* this line wraps to next */\r
-#define LATTR_WRAPPED2 0x00000020UL /* with WRAPPED: CJK wide character\r
- wrapped to next line, so last\r
- single-width cell is empty */\r
-\r
-#define ATTR_INVALID 0x03FFFFU\r
-\r
-/* Like Linux use the F000 page for direct to font. */\r
-#define CSET_OEMCP 0x0000F000UL /* OEM Codepage DTF */\r
-#define CSET_ACP 0x0000F100UL /* Ansi Codepage DTF */\r
-\r
-/* These are internal use overlapping with the UTF-16 surrogates */\r
-#define CSET_ASCII 0x0000D800UL /* normal ASCII charset ESC ( B */\r
-#define CSET_LINEDRW 0x0000D900UL /* line drawing charset ESC ( 0 */\r
-#define CSET_SCOACS 0x0000DA00UL /* SCO Alternate charset */\r
-#define CSET_GBCHR 0x0000DB00UL /* UK variant charset ESC ( A */\r
-#define CSET_MASK 0xFFFFFF00UL /* Character set mask */\r
-\r
-#define DIRECT_CHAR(c) ((c&0xFFFFFC00)==0xD800)\r
-#define DIRECT_FONT(c) ((c&0xFFFFFE00)==0xF000)\r
-\r
-#define UCSERR (CSET_LINEDRW|'a') /* UCS Format error character. */\r
-/*\r
- * UCSWIDE is a special value used in the terminal data to signify\r
- * the character cell containing the right-hand half of a CJK wide\r
- * character. We use 0xDFFF because it's part of the surrogate\r
- * range and hence won't be used for anything else (it's impossible\r
- * to input it via UTF-8 because our UTF-8 decoder correctly\r
- * rejects surrogates).\r
- */\r
-#define UCSWIDE 0xDFFF\r
-\r
-#define ATTR_NARROW 0x800000U\r
-#define ATTR_WIDE 0x400000U\r
-#define ATTR_BOLD 0x040000U\r
-#define ATTR_UNDER 0x080000U\r
-#define ATTR_REVERSE 0x100000U\r
-#define ATTR_BLINK 0x200000U\r
-#define ATTR_FGMASK 0x0001FFU\r
-#define ATTR_BGMASK 0x03FE00U\r
-#define ATTR_COLOURS 0x03FFFFU\r
-#define ATTR_FGSHIFT 0\r
-#define ATTR_BGSHIFT 9\r
-\r
-/*\r
- * The definitive list of colour numbers stored in terminal\r
- * attribute words is kept here. It is:\r
- * \r
- * - 0-7 are ANSI colours (KRGYBMCW).\r
- * - 8-15 are the bold versions of those colours.\r
- * - 16-255 are the remains of the xterm 256-colour mode (a\r
- * 216-colour cube with R at most significant and B at least,\r
- * followed by a uniform series of grey shades running between\r
- * black and white but not including either on grounds of\r
- * redundancy).\r
- * - 256 is default foreground\r
- * - 257 is default bold foreground\r
- * - 258 is default background\r
- * - 259 is default bold background\r
- * - 260 is cursor foreground\r
- * - 261 is cursor background\r
- */\r
-\r
-#define ATTR_DEFFG (256 << ATTR_FGSHIFT)\r
-#define ATTR_DEFBG (258 << ATTR_BGSHIFT)\r
-#define ATTR_DEFAULT (ATTR_DEFFG | ATTR_DEFBG)\r
-\r
-struct sesslist {\r
- int nsessions;\r
- char **sessions;\r
- char *buffer; /* so memory can be freed later */\r
-};\r
-\r
-struct unicode_data {\r
- char **uni_tbl;\r
- int dbcs_screenfont;\r
- int font_codepage;\r
- int line_codepage;\r
- wchar_t unitab_scoacs[256];\r
- wchar_t unitab_line[256];\r
- wchar_t unitab_font[256];\r
- wchar_t unitab_xterm[256];\r
- wchar_t unitab_oemcp[256];\r
- unsigned char unitab_ctrl[256];\r
-};\r
-\r
-#define LGXF_OVR 1 /* existing logfile overwrite */\r
-#define LGXF_APN 0 /* existing logfile append */\r
-#define LGXF_ASK -1 /* existing logfile ask */\r
-#define LGTYP_NONE 0 /* logmode: no logging */\r
-#define LGTYP_ASCII 1 /* logmode: pure ascii */\r
-#define LGTYP_DEBUG 2 /* logmode: all chars of traffic */\r
-#define LGTYP_PACKETS 3 /* logmode: SSH data packets */\r
-#define LGTYP_SSHRAW 4 /* logmode: SSH raw data */\r
-\r
-typedef enum {\r
- /* Actual special commands. Originally Telnet, but some codes have\r
- * been re-used for similar specials in other protocols. */\r
- TS_AYT, TS_BRK, TS_SYNCH, TS_EC, TS_EL, TS_GA, TS_NOP, TS_ABORT,\r
- TS_AO, TS_IP, TS_SUSP, TS_EOR, TS_EOF, TS_LECHO, TS_RECHO, TS_PING,\r
- TS_EOL,\r
- /* Special command for SSH. */\r
- TS_REKEY,\r
- /* POSIX-style signals. (not Telnet) */\r
- TS_SIGABRT, TS_SIGALRM, TS_SIGFPE, TS_SIGHUP, TS_SIGILL,\r
- TS_SIGINT, TS_SIGKILL, TS_SIGPIPE, TS_SIGQUIT, TS_SIGSEGV,\r
- TS_SIGTERM, TS_SIGUSR1, TS_SIGUSR2,\r
- /* Pseudo-specials used for constructing the specials menu. */\r
- TS_SEP, /* Separator */\r
- TS_SUBMENU, /* Start a new submenu with specified name */\r
- TS_EXITMENU /* Exit current submenu or end of specials */\r
-} Telnet_Special;\r
-\r
-struct telnet_special {\r
- const char *name;\r
- int code;\r
-};\r
-\r
-typedef enum {\r
- MBT_NOTHING,\r
- MBT_LEFT, MBT_MIDDLE, MBT_RIGHT, /* `raw' button designations */\r
- MBT_SELECT, MBT_EXTEND, MBT_PASTE, /* `cooked' button designations */\r
- MBT_WHEEL_UP, MBT_WHEEL_DOWN /* mouse wheel */\r
-} Mouse_Button;\r
-\r
-typedef enum {\r
- MA_NOTHING, MA_CLICK, MA_2CLK, MA_3CLK, MA_DRAG, MA_RELEASE\r
-} Mouse_Action;\r
-\r
-/* Keyboard modifiers -- keys the user is actually holding down */\r
-\r
-#define PKM_SHIFT 0x01\r
-#define PKM_CONTROL 0x02\r
-#define PKM_META 0x04\r
-#define PKM_ALT 0x08\r
-\r
-/* Keyboard flags that aren't really modifiers */\r
-#define PKF_CAPSLOCK 0x10\r
-#define PKF_NUMLOCK 0x20\r
-#define PKF_REPEAT 0x40\r
-\r
-/* Stand-alone keysyms for function keys */\r
-\r
-typedef enum {\r
- PK_NULL, /* No symbol for this key */\r
- /* Main keypad keys */\r
- PK_ESCAPE, PK_TAB, PK_BACKSPACE, PK_RETURN, PK_COMPOSE,\r
- /* Editing keys */\r
- PK_HOME, PK_INSERT, PK_DELETE, PK_END, PK_PAGEUP, PK_PAGEDOWN,\r
- /* Cursor keys */\r
- PK_UP, PK_DOWN, PK_RIGHT, PK_LEFT, PK_REST,\r
- /* Numeric keypad */ /* Real one looks like: */\r
- PK_PF1, PK_PF2, PK_PF3, PK_PF4, /* PF1 PF2 PF3 PF4 */\r
- PK_KPCOMMA, PK_KPMINUS, PK_KPDECIMAL, /* 7 8 9 - */\r
- PK_KP0, PK_KP1, PK_KP2, PK_KP3, PK_KP4, /* 4 5 6 , */\r
- PK_KP5, PK_KP6, PK_KP7, PK_KP8, PK_KP9, /* 1 2 3 en- */\r
- PK_KPBIGPLUS, PK_KPENTER, /* 0 . ter */\r
- /* Top row */\r
- PK_F1, PK_F2, PK_F3, PK_F4, PK_F5,\r
- PK_F6, PK_F7, PK_F8, PK_F9, PK_F10,\r
- PK_F11, PK_F12, PK_F13, PK_F14, PK_F15,\r
- PK_F16, PK_F17, PK_F18, PK_F19, PK_F20,\r
- PK_PAUSE\r
-} Key_Sym;\r
-\r
-#define PK_ISEDITING(k) ((k) >= PK_HOME && (k) <= PK_PAGEDOWN)\r
-#define PK_ISCURSOR(k) ((k) >= PK_UP && (k) <= PK_REST)\r
-#define PK_ISKEYPAD(k) ((k) >= PK_PF1 && (k) <= PK_KPENTER)\r
-#define PK_ISFKEY(k) ((k) >= PK_F1 && (k) <= PK_F20)\r
-\r
-enum {\r
- VT_XWINDOWS, VT_OEMANSI, VT_OEMONLY, VT_POORMAN, VT_UNICODE\r
-};\r
-\r
-enum {\r
- /*\r
- * SSH-2 key exchange algorithms\r
- */\r
- KEX_WARN,\r
- KEX_DHGROUP1,\r
- KEX_DHGROUP14,\r
- KEX_DHGEX,\r
- KEX_RSA,\r
- KEX_MAX\r
-};\r
-\r
-enum {\r
- /*\r
- * SSH ciphers (both SSH-1 and SSH-2)\r
- */\r
- CIPHER_WARN, /* pseudo 'cipher' */\r
- CIPHER_3DES,\r
- CIPHER_BLOWFISH,\r
- CIPHER_AES, /* (SSH-2 only) */\r
- CIPHER_DES,\r
- CIPHER_ARCFOUR,\r
- CIPHER_MAX /* no. ciphers (inc warn) */\r
-};\r
-\r
-enum {\r
- /*\r
- * Several different bits of the PuTTY configuration seem to be\r
- * three-way settings whose values are `always yes', `always\r
- * no', and `decide by some more complex automated means'. This\r
- * is true of line discipline options (local echo and line\r
- * editing), proxy DNS, Close On Exit, and SSH server bug\r
- * workarounds. Accordingly I supply a single enum here to deal\r
- * with them all.\r
- */\r
- FORCE_ON, FORCE_OFF, AUTO\r
-};\r
-\r
-enum {\r
- /*\r
- * Proxy types.\r
- */\r
- PROXY_NONE, PROXY_SOCKS4, PROXY_SOCKS5,\r
- PROXY_HTTP, PROXY_TELNET, PROXY_CMD\r
-};\r
-\r
-enum {\r
- /*\r
- * Line discipline options which the backend might try to control.\r
- */\r
- LD_EDIT, /* local line editing */\r
- LD_ECHO /* local echo */\r
-};\r
-\r
-enum {\r
- /* Actions on remote window title query */\r
- TITLE_NONE, TITLE_EMPTY, TITLE_REAL\r
-};\r
-\r
-enum {\r
- /* Protocol back ends. (cfg.protocol) */\r
- PROT_RAW, PROT_TELNET, PROT_RLOGIN, PROT_SSH,\r
- /* PROT_SERIAL is supported on a subset of platforms, but it doesn't\r
- * hurt to define it globally. */\r
- PROT_SERIAL\r
-};\r
-\r
-enum {\r
- /* Bell settings (cfg.beep) */\r
- BELL_DISABLED, BELL_DEFAULT, BELL_VISUAL, BELL_WAVEFILE, BELL_PCSPEAKER\r
-};\r
-\r
-enum {\r
- /* Taskbar flashing indication on bell (cfg.beep_ind) */\r
- B_IND_DISABLED, B_IND_FLASH, B_IND_STEADY\r
-};\r
-\r
-enum {\r
- /* Resize actions (cfg.resize_action) */\r
- RESIZE_TERM, RESIZE_DISABLED, RESIZE_FONT, RESIZE_EITHER\r
-};\r
-\r
-enum {\r
- /* Function key types (cfg.funky_type) */\r
- FUNKY_TILDE,\r
- FUNKY_LINUX,\r
- FUNKY_XTERM,\r
- FUNKY_VT400,\r
- FUNKY_VT100P,\r
- FUNKY_SCO\r
-};\r
-\r
-enum {\r
- FQ_DEFAULT, FQ_ANTIALIASED, FQ_NONANTIALIASED, FQ_CLEARTYPE\r
-};\r
-\r
-enum {\r
- SER_PAR_NONE, SER_PAR_ODD, SER_PAR_EVEN, SER_PAR_MARK, SER_PAR_SPACE\r
-};\r
-\r
-enum {\r
- SER_FLOW_NONE, SER_FLOW_XONXOFF, SER_FLOW_RTSCTS, SER_FLOW_DSRDTR\r
-};\r
-\r
-/*\r
- * Tables of string <-> enum value mappings used in settings.c.\r
- * Defined here so that backends can export their GSS library tables\r
- * to the cross-platform settings code.\r
- */\r
-struct keyvalwhere {\r
- /*\r
- * Two fields which define a string and enum value to be\r
- * equivalent to each other.\r
- */\r
- char *s;\r
- int v;\r
-\r
- /*\r
- * The next pair of fields are used by gprefs() in settings.c to\r
- * arrange that when it reads a list of strings representing a\r
- * preference list and translates it into the corresponding list\r
- * of integers, strings not appearing in the list are entered in a\r
- * configurable position rather than uniformly at the end.\r
- */\r
-\r
- /*\r
- * 'vrel' indicates which other value in the list to place this\r
- * element relative to. It should be a value that has occurred in\r
- * a 'v' field of some other element of the array, or -1 to\r
- * indicate that we simply place relative to one or other end of\r
- * the list.\r
- *\r
- * gprefs will try to process the elements in an order which makes\r
- * this field work (i.e. so that the element referenced has been\r
- * added before processing this one).\r
- */\r
- int vrel;\r
-\r
- /*\r
- * 'where' indicates whether to place the new value before or\r
- * after the one referred to by vrel. -1 means before; +1 means\r
- * after.\r
- *\r
- * When vrel is -1, this also implicitly indicates which end of\r
- * the array to use. So vrel=-1, where=-1 means to place _before_\r
- * some end of the list (hence, at the last element); vrel=-1,\r
- * where=+1 means to place _after_ an end (hence, at the first).\r
- */\r
- int where;\r
-};\r
-\r
-#ifndef NO_GSSAPI\r
-extern const int ngsslibs;\r
-extern const char *const gsslibnames[]; /* for displaying in configuration */\r
-extern const struct keyvalwhere gsslibkeywords[]; /* for settings.c */\r
-#endif\r
-\r
-extern const char *const ttymodes[];\r
-\r
-enum {\r
- /*\r
- * Network address types. Used for specifying choice of IPv4/v6\r
- * in config; also used in proxy.c to indicate whether a given\r
- * host name has already been resolved or will be resolved at\r
- * the proxy end.\r
- */\r
- ADDRTYPE_UNSPEC, ADDRTYPE_IPV4, ADDRTYPE_IPV6, ADDRTYPE_NAME\r
-};\r
-\r
-struct backend_tag {\r
- const char *(*init) (void *frontend_handle, void **backend_handle,\r
- Config *cfg,\r
- char *host, int port, char **realhost, int nodelay,\r
- int keepalive);\r
- void (*free) (void *handle);\r
- /* back->reconfig() passes in a replacement configuration. */\r
- void (*reconfig) (void *handle, Config *cfg);\r
- /* back->send() returns the current amount of buffered data. */\r
- int (*send) (void *handle, char *buf, int len);\r
- /* back->sendbuffer() does the same thing but without attempting a send */\r
- int (*sendbuffer) (void *handle);\r
- void (*size) (void *handle, int width, int height);\r
- void (*special) (void *handle, Telnet_Special code);\r
- const struct telnet_special *(*get_specials) (void *handle);\r
- int (*connected) (void *handle);\r
- int (*exitcode) (void *handle);\r
- /* If back->sendok() returns FALSE, data sent to it from the frontend\r
- * may be lost. */\r
- int (*sendok) (void *handle);\r
- int (*ldisc) (void *handle, int);\r
- void (*provide_ldisc) (void *handle, void *ldisc);\r
- void (*provide_logctx) (void *handle, void *logctx);\r
- /*\r
- * back->unthrottle() tells the back end that the front end\r
- * buffer is clearing.\r
- */\r
- void (*unthrottle) (void *handle, int);\r
- int (*cfg_info) (void *handle);\r
- char *name;\r
- int protocol;\r
- int default_port;\r
-};\r
-\r
-extern Backend *backends[];\r
-\r
-/*\r
- * Suggested default protocol provided by the backend link module.\r
- * The application is free to ignore this.\r
- */\r
-extern const int be_default_protocol;\r
-\r
-/*\r
- * Name of this particular application, for use in the config box\r
- * and other pieces of text.\r
- */\r
-extern const char *const appname;\r
-\r
-/*\r
- * IMPORTANT POLICY POINT: everything in this structure which wants\r
- * to be treated like an integer must be an actual, honest-to-\r
- * goodness `int'. No enum-typed variables. This is because parts\r
- * of the code will want to pass around `int *' pointers to them\r
- * and we can't run the risk of porting to some system on which the\r
- * enum comes out as a different size from int.\r
- */\r
-struct config_tag {\r
- /* Basic options */\r
- char host[512];\r
- int port;\r
- int protocol;\r
- int addressfamily;\r
- int close_on_exit;\r
- int warn_on_close;\r
- int ping_interval; /* in seconds */\r
- int tcp_nodelay;\r
- int tcp_keepalives;\r
- char loghost[512]; /* logical host being contacted, for host key check */\r
- /* Proxy options */\r
- char proxy_exclude_list[512];\r
- int proxy_dns;\r
- int even_proxy_localhost;\r
- int proxy_type;\r
- char proxy_host[512];\r
- int proxy_port;\r
- char proxy_username[128];\r
- char proxy_password[128];\r
- char proxy_telnet_command[512];\r
- /* SSH options */\r
- char remote_cmd[512];\r
- char *remote_cmd_ptr; /* might point to a larger command\r
- * but never for loading/saving */\r
- char *remote_cmd_ptr2; /* might point to a larger command\r
- * but never for loading/saving */\r
- int nopty;\r
- int compression;\r
- int ssh_kexlist[KEX_MAX];\r
- int ssh_rekey_time; /* in minutes */\r
- char ssh_rekey_data[16];\r
- int tryagent;\r
- int agentfwd;\r
- int change_username; /* allow username switching in SSH-2 */\r
- int ssh_cipherlist[CIPHER_MAX];\r
- Filename keyfile;\r
- int sshprot; /* use v1 or v2 when both available */\r
- int ssh2_des_cbc; /* "des-cbc" unrecommended SSH-2 cipher */\r
- int ssh_no_userauth; /* bypass "ssh-userauth" (SSH-2 only) */\r
- int ssh_show_banner; /* show USERAUTH_BANNERs (SSH-2 only) */\r
- int try_tis_auth;\r
- int try_ki_auth;\r
- int try_gssapi_auth; /* attempt gssapi auth */\r
- int gssapifwd; /* forward tgt via gss */\r
- int ssh_gsslist[4]; /* preference order for local GSS libs */\r
- Filename ssh_gss_custom;\r
- int ssh_subsys; /* run a subsystem rather than a command */\r
- int ssh_subsys2; /* fallback to go with remote_cmd_ptr2 */\r
- int ssh_no_shell; /* avoid running a shell */\r
- char ssh_nc_host[512]; /* host to connect to in `nc' mode */\r
- int ssh_nc_port; /* port to connect to in `nc' mode */\r
- /* Telnet options */\r
- char termtype[32];\r
- char termspeed[32];\r
- char ttymodes[768]; /* MODE\tVvalue\0MODE\tA\0\0 */\r
- char environmt[1024]; /* VAR\tvalue\0VAR\tvalue\0\0 */\r
- char username[100];\r
- int username_from_env;\r
- char localusername[100];\r
- int rfc_environ;\r
- int passive_telnet;\r
- /* Serial port options */\r
- char serline[256];\r
- int serspeed;\r
- int serdatabits, serstopbits;\r
- int serparity;\r
- int serflow;\r
- /* Keyboard options */\r
- int bksp_is_delete;\r
- int rxvt_homeend;\r
- int funky_type;\r
- int no_applic_c; /* totally disable app cursor keys */\r
- int no_applic_k; /* totally disable app keypad */\r
- int no_mouse_rep; /* totally disable mouse reporting */\r
- int no_remote_resize; /* disable remote resizing */\r
- int no_alt_screen; /* disable alternate screen */\r
- int no_remote_wintitle; /* disable remote retitling */\r
- int no_dbackspace; /* disable destructive backspace */\r
- int no_remote_charset; /* disable remote charset config */\r
- int remote_qtitle_action; /* remote win title query action */\r
- int app_cursor;\r
- int app_keypad;\r
- int nethack_keypad;\r
- int telnet_keyboard;\r
- int telnet_newline;\r
- int alt_f4; /* is it special? */\r
- int alt_space; /* is it special? */\r
- int alt_only; /* is it special? */\r
- int localecho;\r
- int localedit;\r
- int alwaysontop;\r
- int fullscreenonaltenter;\r
- int scroll_on_key;\r
- int scroll_on_disp;\r
- int erase_to_scrollback;\r
- int compose_key;\r
- int ctrlaltkeys;\r
- char wintitle[256]; /* initial window title */\r
- /* Terminal options */\r
- int savelines;\r
- int dec_om;\r
- int wrap_mode;\r
- int lfhascr;\r
- int cursor_type; /* 0=block 1=underline 2=vertical */\r
- int blink_cur;\r
- int beep;\r
- int beep_ind;\r
- int bellovl; /* bell overload protection active? */\r
- int bellovl_n; /* number of bells to cause overload */\r
- int bellovl_t; /* time interval for overload (seconds) */\r
- int bellovl_s; /* period of silence to re-enable bell (s) */\r
- Filename bell_wavefile;\r
- int scrollbar;\r
- int scrollbar_in_fullscreen;\r
- int resize_action;\r
- int bce;\r
- int blinktext;\r
- int win_name_always;\r
- int width, height;\r
- FontSpec font;\r
- int font_quality;\r
- Filename logfilename;\r
- int logtype;\r
- int logxfovr;\r
- int logflush;\r
- int logomitpass;\r
- int logomitdata;\r
- int hide_mouseptr;\r
- int sunken_edge;\r
- int window_border;\r
- char answerback[256];\r
- char printer[128];\r
- int arabicshaping;\r
- int bidi;\r
- /* Colour options */\r
- int ansi_colour;\r
- int xterm_256_colour;\r
- int system_colour;\r
- int try_palette;\r
- int bold_colour;\r
- unsigned char colours[22][3];\r
- /* Selection options */\r
- int mouse_is_xterm;\r
- int rect_select;\r
- int rawcnp;\r
- int rtf_paste;\r
- int mouse_override;\r
- short wordness[256];\r
- /* translations */\r
- int vtmode;\r
- char line_codepage[128];\r
- int cjk_ambig_wide;\r
- int utf8_override;\r
- int xlat_capslockcyr;\r
- /* X11 forwarding */\r
- int x11_forward;\r
- char x11_display[128];\r
- int x11_auth;\r
- Filename xauthfile;\r
- /* port forwarding */\r
- int lport_acceptall; /* accept conns from hosts other than localhost */\r
- int rport_acceptall; /* same for remote forwarded ports (SSH-2 only) */\r
- /*\r
- * The port forwarding string contains a number of\r
- * NUL-terminated substrings, terminated in turn by an empty\r
- * string (i.e. a second NUL immediately after the previous\r
- * one). Each string can be of one of the following forms:\r
- * \r
- * [LR]localport\thost:port\r
- * [LR]localaddr:localport\thost:port\r
- * Dlocalport\r
- * Dlocaladdr:localport\r
- */\r
- char portfwd[1024];\r
- /* SSH bug compatibility modes */\r
- int sshbug_ignore1, sshbug_plainpw1, sshbug_rsa1,\r
- sshbug_hmac2, sshbug_derivekey2, sshbug_rsapad2,\r
- sshbug_pksessid2, sshbug_rekey2, sshbug_maxpkt2,\r
- sshbug_ignore2;\r
- /*\r
- * ssh_simple means that we promise never to open any channel other\r
- * than the main one, which means it can safely use a very large\r
- * window in SSH-2.\r
- */\r
- int ssh_simple;\r
- /* Options for pterm. Should split out into platform-dependent part. */\r
- int stamp_utmp;\r
- int login_shell;\r
- int scrollbar_on_left;\r
- int shadowbold;\r
- FontSpec boldfont;\r
- FontSpec widefont;\r
- FontSpec wideboldfont;\r
- int shadowboldoffset;\r
- int crhaslf;\r
- char winclass[256];\r
-};\r
-\r
-/*\r
- * Some global flags denoting the type of application.\r
- * \r
- * FLAG_VERBOSE is set when the user requests verbose details.\r
- * \r
- * FLAG_STDERR is set in command-line applications (which have a\r
- * functioning stderr that it makes sense to write to) and not in\r
- * GUI applications (which don't).\r
- * \r
- * FLAG_INTERACTIVE is set when a full interactive shell session is\r
- * being run, _either_ because no remote command has been provided\r
- * _or_ because the application is GUI and can't run non-\r
- * interactively.\r
- * \r
- * These flags describe the type of _application_ - they wouldn't\r
- * vary between individual sessions - and so it's OK to have this\r
- * variable be GLOBAL.\r
- * \r
- * Note that additional flags may be defined in platform-specific\r
- * headers. It's probably best if those ones start from 0x1000, to\r
- * avoid collision.\r
- */\r
-#define FLAG_VERBOSE 0x0001\r
-#define FLAG_STDERR 0x0002\r
-#define FLAG_INTERACTIVE 0x0004\r
-GLOBAL int flags;\r
-\r
-/*\r
- * Likewise, these two variables are set up when the application\r
- * initialises, and inform all default-settings accesses after\r
- * that.\r
- */\r
-GLOBAL int default_protocol;\r
-GLOBAL int default_port;\r
-\r
-/*\r
- * This is set TRUE by cmdline.c iff a session is loaded with "-load".\r
- */\r
-GLOBAL int loaded_session;\r
-/*\r
- * This is set to the name of the loaded session.\r
- */\r
-GLOBAL char *cmdline_session_name;\r
-\r
-struct RSAKey; /* be a little careful of scope */\r
-\r
-/*\r
- * Mechanism for getting text strings such as usernames and passwords\r
- * from the front-end.\r
- * The fields are mostly modelled after SSH's keyboard-interactive auth.\r
- * FIXME We should probably mandate a character set/encoding (probably UTF-8).\r
- *\r
- * Since many of the pieces of text involved may be chosen by the server,\r
- * the caller must take care to ensure that the server can't spoof locally-\r
- * generated prompts such as key passphrase prompts. Some ground rules:\r
- * - If the front-end needs to truncate a string, it should lop off the\r
- * end.\r
- * - The front-end should filter out any dangerous characters and\r
- * generally not trust the strings. (But \n is required to behave\r
- * vaguely sensibly, at least in `instruction', and ideally in\r
- * `prompt[]' too.)\r
- */\r
-typedef struct {\r
- char *prompt;\r
- int echo;\r
- char *result; /* allocated/freed by caller */\r
- size_t result_len;\r
-} prompt_t;\r
-typedef struct {\r
- /*\r
- * Indicates whether the information entered is to be used locally\r
- * (for instance a key passphrase prompt), or is destined for the wire.\r
- * This is a hint only; the front-end is at liberty not to use this\r
- * information (so the caller should ensure that the supplied text is\r
- * sufficient).\r
- */\r
- int to_server;\r
- char *name; /* Short description, perhaps for dialog box title */\r
- int name_reqd; /* Display of `name' required or optional? */\r
- char *instruction; /* Long description, maybe with embedded newlines */\r
- int instr_reqd; /* Display of `instruction' required or optional? */\r
- size_t n_prompts; /* May be zero (in which case display the foregoing,\r
- * if any, and return success) */\r
- prompt_t **prompts;\r
- void *frontend;\r
- void *data; /* slot for housekeeping data, managed by\r
- * get_userpass_input(); initially NULL */\r
-} prompts_t;\r
-prompts_t *new_prompts(void *frontend);\r
-void add_prompt(prompts_t *p, char *promptstr, int echo, size_t len);\r
-/* Burn the evidence. (Assumes _all_ strings want free()ing.) */\r
-void free_prompts(prompts_t *p);\r
-\r
-/*\r
- * Exports from the front end.\r
- */\r
-void request_resize(void *frontend, int, int);\r
-void do_text(Context, int, int, wchar_t *, int, unsigned long, int);\r
-void do_cursor(Context, int, int, wchar_t *, int, unsigned long, int);\r
-int char_width(Context ctx, int uc);\r
-#ifdef OPTIMISE_SCROLL\r
-void do_scroll(Context, int, int, int);\r
-#endif\r
-void set_title(void *frontend, char *);\r
-void set_icon(void *frontend, char *);\r
-void set_sbar(void *frontend, int, int, int);\r
-Context get_ctx(void *frontend);\r
-void free_ctx(Context);\r
-void palette_set(void *frontend, int, int, int, int);\r
-void palette_reset(void *frontend);\r
-void write_aclip(void *frontend, char *, int, int);\r
-void write_clip(void *frontend, wchar_t *, int *, int, int);\r
-void get_clip(void *frontend, wchar_t **, int *);\r
-void optimised_move(void *frontend, int, int, int);\r
-void set_raw_mouse_mode(void *frontend, int);\r
-void connection_fatal(void *frontend, char *, ...);\r
-void fatalbox(char *, ...);\r
-void modalfatalbox(char *, ...);\r
-#ifdef macintosh\r
-#pragma noreturn(fatalbox)\r
-#pragma noreturn(modalfatalbox)\r
-#endif\r
-void do_beep(void *frontend, int);\r
-void begin_session(void *frontend);\r
-void sys_cursor(void *frontend, int x, int y);\r
-void request_paste(void *frontend);\r
-void frontend_keypress(void *frontend);\r
-void ldisc_update(void *frontend, int echo, int edit);\r
-/* It's the backend's responsibility to invoke this at the start of a\r
- * connection, if necessary; it can also invoke it later if the set of\r
- * special commands changes. It does not need to invoke it at session\r
- * shutdown. */\r
-void update_specials_menu(void *frontend);\r
-int from_backend(void *frontend, int is_stderr, const char *data, int len);\r
-int from_backend_untrusted(void *frontend, const char *data, int len);\r
-void notify_remote_exit(void *frontend);\r
-/* Get a sensible value for a tty mode. NULL return = don't set.\r
- * Otherwise, returned value should be freed by caller. */\r
-char *get_ttymode(void *frontend, const char *mode);\r
-/*\r
- * >0 = `got all results, carry on'\r
- * 0 = `user cancelled' (FIXME distinguish "give up entirely" and "next auth"?)\r
- * <0 = `please call back later with more in/inlen'\r
- */\r
-int get_userpass_input(prompts_t *p, unsigned char *in, int inlen);\r
-#define OPTIMISE_IS_SCROLL 1\r
-\r
-void set_iconic(void *frontend, int iconic);\r
-void move_window(void *frontend, int x, int y);\r
-void set_zorder(void *frontend, int top);\r
-void refresh_window(void *frontend);\r
-void set_zoomed(void *frontend, int zoomed);\r
-int is_iconic(void *frontend);\r
-void get_window_pos(void *frontend, int *x, int *y);\r
-void get_window_pixels(void *frontend, int *x, int *y);\r
-char *get_window_title(void *frontend, int icon);\r
-/* Hint from backend to frontend about time-consuming operations.\r
- * Initial state is assumed to be BUSY_NOT. */\r
-enum {\r
- BUSY_NOT, /* Not busy, all user interaction OK */\r
- BUSY_WAITING, /* Waiting for something; local event loops still running\r
- so some local interaction (e.g. menus) OK, but network\r
- stuff is suspended */\r
- BUSY_CPU /* Locally busy (e.g. crypto); user interaction suspended */\r
-};\r
-void set_busy_status(void *frontend, int status);\r
-\r
-void cleanup_exit(int);\r
-\r
-/*\r
- * Exports from noise.c.\r
- */\r
-void noise_get_heavy(void (*func) (void *, int));\r
-void noise_get_light(void (*func) (void *, int));\r
-void noise_regular(void);\r
-void noise_ultralight(unsigned long data);\r
-void random_save_seed(void);\r
-void random_destroy_seed(void);\r
-\r
-/*\r
- * Exports from settings.c.\r
- */\r
-Backend *backend_from_name(const char *name);\r
-Backend *backend_from_proto(int proto);\r
-int get_remote_username(Config *cfg, char *user, size_t len);\r
-char *save_settings(char *section, Config * cfg);\r
-void save_open_settings(void *sesskey, Config *cfg);\r
-void load_settings(char *section, Config * cfg);\r
-void load_open_settings(void *sesskey, Config *cfg);\r
-void get_sesslist(struct sesslist *, int allocate);\r
-void do_defaults(char *, Config *);\r
-void registry_cleanup(void);\r
-\r
-/*\r
- * Functions used by settings.c to provide platform-specific\r
- * default settings.\r
- * \r
- * (The integer one is expected to return `def' if it has no clear\r
- * opinion of its own. This is because there's no integer value\r
- * which I can reliably set aside to indicate `nil'. The string\r
- * function is perfectly all right returning NULL, of course. The\r
- * Filename and FontSpec functions are _not allowed_ to fail to\r
- * return, since these defaults _must_ be per-platform.)\r
- */\r
-char *platform_default_s(const char *name);\r
-int platform_default_i(const char *name, int def);\r
-Filename platform_default_filename(const char *name);\r
-FontSpec platform_default_fontspec(const char *name);\r
-\r
-/*\r
- * Exports from terminal.c.\r
- */\r
-\r
-Terminal *term_init(Config *, struct unicode_data *, void *);\r
-void term_free(Terminal *);\r
-void term_size(Terminal *, int, int, int);\r
-void term_paint(Terminal *, Context, int, int, int, int, int);\r
-void term_scroll(Terminal *, int, int);\r
-void term_scroll_to_selection(Terminal *, int);\r
-void term_pwron(Terminal *, int);\r
-void term_clrsb(Terminal *);\r
-void term_mouse(Terminal *, Mouse_Button, Mouse_Button, Mouse_Action,\r
- int,int,int,int,int);\r
-void term_key(Terminal *, Key_Sym, wchar_t *, size_t, unsigned int,\r
- unsigned int);\r
-void term_deselect(Terminal *);\r
-void term_update(Terminal *);\r
-void term_invalidate(Terminal *);\r
-void term_blink(Terminal *, int set_cursor);\r
-void term_do_paste(Terminal *);\r
-int term_paste_pending(Terminal *);\r
-void term_paste(Terminal *);\r
-void term_nopaste(Terminal *);\r
-int term_ldisc(Terminal *, int option);\r
-void term_copyall(Terminal *);\r
-void term_reconfig(Terminal *, Config *);\r
-void term_seen_key_event(Terminal *); \r
-int term_data(Terminal *, int is_stderr, const char *data, int len);\r
-int term_data_untrusted(Terminal *, const char *data, int len);\r
-void term_provide_resize_fn(Terminal *term,\r
- void (*resize_fn)(void *, int, int),\r
- void *resize_ctx);\r
-void term_provide_logctx(Terminal *term, void *logctx);\r
-void term_set_focus(Terminal *term, int has_focus);\r
-char *term_get_ttymode(Terminal *term, const char *mode);\r
-int term_get_userpass_input(Terminal *term, prompts_t *p,\r
- unsigned char *in, int inlen);\r
-\r
-int format_arrow_key(char *buf, Terminal *term, int xkey, int ctrl);\r
-\r
-/*\r
- * Exports from logging.c.\r
- */\r
-void *log_init(void *frontend, Config *cfg);\r
-void log_free(void *logctx);\r
-void log_reconfig(void *logctx, Config *cfg);\r
-void logfopen(void *logctx);\r
-void logfclose(void *logctx);\r
-void logtraffic(void *logctx, unsigned char c, int logmode);\r
-void logflush(void *logctx);\r
-void log_eventlog(void *logctx, const char *string);\r
-enum { PKT_INCOMING, PKT_OUTGOING };\r
-enum { PKTLOG_EMIT, PKTLOG_BLANK, PKTLOG_OMIT };\r
-struct logblank_t {\r
- int offset;\r
- int len;\r
- int type;\r
-};\r
-void log_packet(void *logctx, int direction, int type,\r
- char *texttype, const void *data, int len,\r
- int n_blanks, const struct logblank_t *blanks,\r
- const unsigned long *sequence);\r
-\r
-/*\r
- * Exports from testback.c\r
- */\r
-\r
-extern Backend null_backend;\r
-extern Backend loop_backend;\r
-\r
-/*\r
- * Exports from raw.c.\r
- */\r
-\r
-extern Backend raw_backend;\r
-\r
-/*\r
- * Exports from rlogin.c.\r
- */\r
-\r
-extern Backend rlogin_backend;\r
-\r
-/*\r
- * Exports from telnet.c.\r
- */\r
-\r
-extern Backend telnet_backend;\r
-\r
-/*\r
- * Exports from ssh.c.\r
- */\r
-extern Backend ssh_backend;\r
-\r
-/*\r
- * Exports from ldisc.c.\r
- */\r
-void *ldisc_create(Config *, Terminal *, Backend *, void *, void *);\r
-void ldisc_free(void *);\r
-void ldisc_send(void *handle, char *buf, int len, int interactive);\r
-\r
-/*\r
- * Exports from ldiscucs.c.\r
- */\r
-void lpage_send(void *, int codepage, char *buf, int len, int interactive);\r
-void luni_send(void *, wchar_t * widebuf, int len, int interactive);\r
-\r
-/*\r
- * Exports from sshrand.c.\r
- */\r
-\r
-void random_add_noise(void *noise, int length);\r
-int random_byte(void);\r
-void random_get_savedata(void **data, int *len);\r
-extern int random_active;\r
-/* The random number subsystem is activated if at least one other entity\r
- * within the program expresses an interest in it. So each SSH session\r
- * calls random_ref on startup and random_unref on shutdown. */\r
-void random_ref(void);\r
-void random_unref(void);\r
-\r
-/*\r
- * Exports from pinger.c.\r
- */\r
-typedef struct pinger_tag *Pinger;\r
-Pinger pinger_new(Config *cfg, Backend *back, void *backhandle);\r
-void pinger_reconfig(Pinger, Config *oldcfg, Config *newcfg);\r
-void pinger_free(Pinger);\r
-\r
-/*\r
- * Exports from misc.c.\r
- */\r
-\r
-#include "misc.h"\r
-int cfg_launchable(const Config *cfg);\r
-char const *cfg_dest(const Config *cfg);\r
-\r
-/*\r
- * Exports from sercfg.c.\r
- */\r
-void ser_setup_config_box(struct controlbox *b, int midsession,\r
- int parity_mask, int flow_mask);\r
-\r
-/*\r
- * Exports from version.c.\r
- */\r
-extern char ver[];\r
-\r
-/*\r
- * Exports from unicode.c.\r
- */\r
-#ifndef CP_UTF8\r
-#define CP_UTF8 65001\r
-#endif\r
-/* void init_ucs(void); -- this is now in platform-specific headers */\r
-int is_dbcs_leadbyte(int codepage, char byte);\r
-int mb_to_wc(int codepage, int flags, char *mbstr, int mblen,\r
- wchar_t *wcstr, int wclen);\r
-int wc_to_mb(int codepage, int flags, wchar_t *wcstr, int wclen,\r
- char *mbstr, int mblen, char *defchr, int *defused,\r
- struct unicode_data *ucsdata);\r
-wchar_t xlat_uskbd2cyrllic(int ch);\r
-int check_compose(int first, int second);\r
-int decode_codepage(char *cp_name);\r
-const char *cp_enumerate (int index);\r
-const char *cp_name(int codepage);\r
-void get_unitab(int codepage, wchar_t * unitab, int ftype);\r
-\r
-/*\r
- * Exports from wcwidth.c\r
- */\r
-int mk_wcwidth(wchar_t ucs);\r
-int mk_wcswidth(const wchar_t *pwcs, size_t n);\r
-int mk_wcwidth_cjk(wchar_t ucs);\r
-int mk_wcswidth_cjk(const wchar_t *pwcs, size_t n);\r
-\r
-/*\r
- * Exports from mscrypto.c\r
- */\r
-#ifdef MSCRYPTOAPI\r
-int crypto_startup();\r
-void crypto_wrapup();\r
-#endif\r
-\r
-/*\r
- * Exports from pageantc.c.\r
- * \r
- * agent_query returns 1 for here's-a-response, and 0 for query-in-\r
- * progress. In the latter case there will be a call to `callback'\r
- * at some future point, passing callback_ctx as the first\r
- * parameter and the actual reply data as the second and third.\r
- * \r
- * The response may be a NULL pointer (in either of the synchronous\r
- * or asynchronous cases), which indicates failure to receive a\r
- * response.\r
- */\r
-int agent_query(void *in, int inlen, void **out, int *outlen,\r
- void (*callback)(void *, void *, int), void *callback_ctx);\r
-int agent_exists(void);\r
-\r
-/*\r
- * Exports from wildcard.c\r
- */\r
-const char *wc_error(int value);\r
-int wc_match(const char *wildcard, const char *target);\r
-int wc_unescape(char *output, const char *wildcard);\r
-\r
-/*\r
- * Exports from frontend (windlg.c etc)\r
- */\r
-void logevent(void *frontend, const char *);\r
-void pgp_fingerprints(void);\r
-/*\r
- * verify_ssh_host_key() can return one of three values:\r
- * \r
- * - +1 means `key was OK' (either already known or the user just\r
- * approved it) `so continue with the connection'\r
- * \r
- * - 0 means `key was not OK, abandon the connection'\r
- * \r
- * - -1 means `I've initiated enquiries, please wait to be called\r
- * back via the provided function with a result that's either 0\r
- * or +1'.\r
- */\r
-int verify_ssh_host_key(void *frontend, char *host, int port, char *keytype,\r
- char *keystr, char *fingerprint,\r
- void (*callback)(void *ctx, int result), void *ctx);\r
-/*\r
- * askalg has the same set of return values as verify_ssh_host_key.\r
- */\r
-int askalg(void *frontend, const char *algtype, const char *algname,\r
- void (*callback)(void *ctx, int result), void *ctx);\r
-/*\r
- * askappend can return four values:\r
- * \r
- * - 2 means overwrite the log file\r
- * - 1 means append to the log file\r
- * - 0 means cancel logging for this session\r
- * - -1 means please wait.\r
- */\r
-int askappend(void *frontend, Filename filename,\r
- void (*callback)(void *ctx, int result), void *ctx);\r
-\r
-/*\r
- * Exports from console frontends (wincons.c, uxcons.c)\r
- * that aren't equivalents to things in windlg.c et al.\r
- */\r
-extern int console_batch_mode;\r
-int console_get_userpass_input(prompts_t *p, unsigned char *in, int inlen);\r
-void console_provide_logctx(void *logctx);\r
-int is_interactive(void);\r
-\r
-/*\r
- * Exports from printing.c.\r
- */\r
-typedef struct printer_enum_tag printer_enum;\r
-typedef struct printer_job_tag printer_job;\r
-printer_enum *printer_start_enum(int *nprinters);\r
-char *printer_get_name(printer_enum *, int);\r
-void printer_finish_enum(printer_enum *);\r
-printer_job *printer_start_job(char *printer);\r
-void printer_job_data(printer_job *, void *, int);\r
-void printer_finish_job(printer_job *);\r
-\r
-/*\r
- * Exports from cmdline.c (and also cmdline_error(), which is\r
- * defined differently in various places and required _by_\r
- * cmdline.c).\r
- */\r
-int cmdline_process_param(char *, char *, int, Config *);\r
-void cmdline_run_saved(Config *);\r
-void cmdline_cleanup(void);\r
-int cmdline_get_passwd_input(prompts_t *p, unsigned char *in, int inlen);\r
-#define TOOLTYPE_FILETRANSFER 1\r
-#define TOOLTYPE_NONNETWORK 2\r
-extern int cmdline_tooltype;\r
-\r
-void cmdline_error(char *, ...);\r
-\r
-/*\r
- * Exports from config.c.\r
- */\r
-struct controlbox;\r
-void setup_config_box(struct controlbox *b, int midsession,\r
- int protocol, int protcfginfo);\r
-\r
-/*\r
- * Exports from minibidi.c.\r
- */\r
-typedef struct bidi_char {\r
- wchar_t origwc, wc;\r
- unsigned short index;\r
-} bidi_char;\r
-int do_bidi(bidi_char *line, int count);\r
-int do_shape(bidi_char *line, bidi_char *to, int count);\r
-int is_rtl(int c);\r
-\r
-/*\r
- * X11 auth mechanisms we know about.\r
- */\r
-enum {\r
- X11_NO_AUTH,\r
- X11_MIT, /* MIT-MAGIC-COOKIE-1 */\r
- X11_XDM, /* XDM-AUTHORIZATION-1 */\r
- X11_NAUTHS\r
-};\r
-extern const char *const x11_authnames[]; /* declared in x11fwd.c */\r
-\r
-/*\r
- * Miscellaneous exports from the platform-specific code.\r
- */\r
-Filename filename_from_str(const char *string);\r
-const char *filename_to_str(const Filename *fn);\r
-int filename_equal(Filename f1, Filename f2);\r
-int filename_is_null(Filename fn);\r
-char *get_username(void); /* return value needs freeing */\r
-char *get_random_data(int bytes); /* used in cmdgen.c */\r
-\r
-/*\r
- * Exports and imports from timing.c.\r
- *\r
- * schedule_timer() asks the front end to schedule a callback to a\r
- * timer function in a given number of ticks. The returned value is\r
- * the time (in ticks since an arbitrary offset) at which the\r
- * callback can be expected. This value will also be passed as the\r
- * `now' parameter to the callback function. Hence, you can (for\r
- * example) schedule an event at a particular time by calling\r
- * schedule_timer() and storing the return value in your context\r
- * structure as the time when that event is due. The first time a\r
- * callback function gives you that value or more as `now', you do\r
- * the thing.\r
- * \r
- * expire_timer_context() drops all current timers associated with\r
- * a given value of ctx (for when you're about to free ctx).\r
- * \r
- * run_timers() is called from the front end when it has reason to\r
- * think some timers have reached their moment, or when it simply\r
- * needs to know how long to wait next. We pass it the time we\r
- * think it is. It returns TRUE and places the time when the next\r
- * timer needs to go off in `next', or alternatively it returns\r
- * FALSE if there are no timers at all pending.\r
- * \r
- * timer_change_notify() must be supplied by the front end; it\r
- * notifies the front end that a new timer has been added to the\r
- * list which is sooner than any existing ones. It provides the\r
- * time when that timer needs to go off.\r
- * \r
- * *** FRONT END IMPLEMENTORS NOTE:\r
- * \r
- * There's an important subtlety in the front-end implementation of\r
- * the timer interface. When a front end is given a `next' value,\r
- * either returned from run_timers() or via timer_change_notify(),\r
- * it should ensure that it really passes _that value_ as the `now'\r
- * parameter to its next run_timers call. It should _not_ simply\r
- * call GETTICKCOUNT() to get the `now' parameter when invoking\r
- * run_timers().\r
- * \r
- * The reason for this is that an OS's system clock might not agree\r
- * exactly with the timing mechanisms it supplies to wait for a\r
- * given interval. I'll illustrate this by the simple example of\r
- * Unix Plink, which uses timeouts to select() in a way which for\r
- * these purposes can simply be considered to be a wait() function.\r
- * Suppose, for the sake of argument, that this wait() function\r
- * tends to return early by 1%. Then a possible sequence of actions\r
- * is:\r
- * \r
- * - run_timers() tells the front end that the next timer firing\r
- * is 10000ms from now.\r
- * - Front end calls wait(10000ms), but according to\r
- * GETTICKCOUNT() it has only waited for 9900ms.\r
- * - Front end calls run_timers() again, passing time T-100ms as\r
- * `now'.\r
- * - run_timers() does nothing, and says the next timer firing is\r
- * still 100ms from now.\r
- * - Front end calls wait(100ms), which only waits for 99ms.\r
- * - Front end calls run_timers() yet again, passing time T-1ms.\r
- * - run_timers() says there's still 1ms to wait.\r
- * - Front end calls wait(1ms).\r
- * \r
- * If you're _lucky_ at this point, wait(1ms) will actually wait\r
- * for 1ms and you'll only have woken the program up three times.\r
- * If you're unlucky, wait(1ms) might do nothing at all due to\r
- * being below some minimum threshold, and you might find your\r
- * program spends the whole of the last millisecond tight-looping\r
- * between wait() and run_timers().\r
- * \r
- * Instead, what you should do is to _save_ the precise `next'\r
- * value provided by run_timers() or via timer_change_notify(), and\r
- * use that precise value as the input to the next run_timers()\r
- * call. So:\r
- * \r
- * - run_timers() tells the front end that the next timer firing\r
- * is at time T, 10000ms from now.\r
- * - Front end calls wait(10000ms).\r
- * - Front end then immediately calls run_timers() and passes it\r
- * time T, without stopping to check GETTICKCOUNT() at all.\r
- * \r
- * This guarantees that the program wakes up only as many times as\r
- * there are actual timer actions to be taken, and that the timing\r
- * mechanism will never send it into a tight loop.\r
- * \r
- * (It does also mean that the timer action in the above example\r
- * will occur 100ms early, but this is not generally critical. And\r
- * the hypothetical 1% error in wait() will be partially corrected\r
- * for anyway when, _after_ run_timers() returns, you call\r
- * GETTICKCOUNT() and compare the result with the returned `next'\r
- * value to find out how long you have to make your next wait().)\r
- */\r
-typedef void (*timer_fn_t)(void *ctx, long now);\r
-long schedule_timer(int ticks, timer_fn_t fn, void *ctx);\r
-void expire_timer_context(void *ctx);\r
-int run_timers(long now, long *next);\r
-void timer_change_notify(long next);\r
-\r
-/*\r
- * Define no-op macros for the jump list functions, on platforms that\r
- * don't support them. (This is a bit of a hack, and it'd be nicer to\r
- * localise even the calls to those functions into the Windows front\r
- * end, but it'll do for the moment.)\r
- */\r
-#ifndef JUMPLIST_SUPPORTED\r
-#define add_session_to_jumplist(x) ((void)0)\r
-#define remove_session_from_jumplist(x) ((void)0)\r
-#endif\r
-\r
-#endif\r