4 #define PUTTY_REG_POS "Software\\SimonTatham\\PuTTY"
7 #define OPTIMISE_SCROLL
17 #endif /* macintosh */
26 #define ATTR_ACTCURS 0x80000000UL /* active cursor (block) */
27 #define ATTR_PASCURS 0x40000000UL /* passive cursor (box) */
28 #define ATTR_INVALID 0x20000000UL
29 #define ATTR_WRAPPED 0x10000000UL
31 #define ATTR_ASCII 0x00000000UL /* normal ASCII charset ESC ( B */
32 #define ATTR_GBCHR 0x00100000UL /* UK variant charset ESC ( A */
33 #define ATTR_LINEDRW 0x00200000UL /* line drawing charset ESC ( 0 */
35 #define ATTR_BOLD 0x00000100UL
36 #define ATTR_UNDER 0x00000200UL
37 #define ATTR_REVERSE 0x00000400UL
38 #define ATTR_FGMASK 0x0000F000UL
39 #define ATTR_BGMASK 0x000F0000UL
40 #define ATTR_FGSHIFT 12
41 #define ATTR_BGSHIFT 16
43 #define ATTR_DEFAULT 0x00098000UL
44 #define ATTR_DEFFG 0x00008000UL
45 #define ATTR_DEFBG 0x00090000UL
46 #define ATTR_CUR_XOR 0x000BA000UL
47 #define ERASE_CHAR (ATTR_DEFAULT | ' ')
48 #define ATTR_MASK 0xFFFFFF00UL
49 #define CHAR_MASK 0x000000FFUL
53 typedef struct mac_session *Context;
54 #else /* not macintosh */
56 #endif /* not macintosh */
61 #define SEL_NL { 13, 10 }
65 * Global variables. Most modules declare these `extern', but
66 * window.c will do `#define PUTTY_DO_GLOBALS' before including this
67 * module, and so will get them properly defined.
69 #ifdef PUTTY_DO_GLOBALS
75 #define INBUF_SIZE 2048
76 #define INBUF_MASK (INBUF_SIZE-1)
78 #define OUTBUF_SIZE 2048
79 #define OUTBUF_MASK (OUTBUF_SIZE-1)
81 #define WM_NETEVENT (WM_USER + 1)
84 TS_AYT, TS_BRK, TS_SYNCH, TS_EC, TS_EL, TS_GA, TS_NOP, TS_ABORT,
85 TS_AO, TS_IP, TS_SUSP, TS_EOR, TS_EOF
89 MB_NOTHING, MB_SELECT, MB_EXTEND, MB_PASTE
93 MA_NOTHING, MA_CLICK, MA_2CLK, MA_3CLK, MA_DRAG, MA_RELEASE
97 VT_XWINDOWS, VT_OEMANSI, VT_OEMONLY, VT_POORMAN
100 typedef struct Session Session;
104 char *(*init) (Session *, char *host, int port, char **realhost);
105 int (*msg)(Session *);
106 #else /* not macintosh */
107 char *(*init) (HWND hwnd, char *host, int port, char **realhost);
108 int (*msg) (WPARAM wParam, LPARAM lParam);
109 #endif /* not macintosh */
110 void (*send) (Session *, char *buf, int len);
111 void (*size) (Session *);
112 void (*special) (Session *, Telnet_Special code);
119 enum { PROT_TELNET, PROT_SSH } protocol;
126 char environmt[1024]; /* VAR\tvalue\0VAR\tvalue\0\0 */
129 /* Keyboard options */
136 /* Terminal options */
151 PaletteHandle colours;
152 #else /* not macintosh */
153 unsigned char colours[22][3];
154 #endif /* not macintosh */
155 /* Selection options */
164 /* Display buffers and pointers within them */
165 unsigned long *text; /* buffer of text on terminal screen */
166 unsigned long *scrtop; /* top of working screen */
167 unsigned long *disptop; /* top of displayed screen */
168 unsigned long *sbtop; /* top of scrollback */
169 unsigned long *cpos; /* cursor position (convenience) */
170 unsigned long *disptext; /* buffer of text on real screen */
171 unsigned long *wanttext; /* buffer of text we want on screen */
172 unsigned long *alttext; /* buffer of text on alt. screen */
173 unsigned char *selspace; /* buffer for building selections in */
176 unsigned long curr_attr;
177 int curs_x, curs_y; /* cursor */
178 int cset; /* 0 or 1: which char set is in GL */
179 unsigned long cset_attr[2]; /* G0 and G1 char sets */
182 unsigned long save_attr;
183 int save_x, save_y; /* saved cursor position */
184 int save_cset, save_csattr; /* saved with cursor position */
186 int marg_t, marg_b; /* scroll margins */
189 int dec_om; /* DEC origin mode flag */
190 int wrap, wrapnext; /* wrap flags */
191 int insert; /* insert-mode flag */
192 int rvideo; /* global reverse video flag */
195 * Saved settings on the alternate screen.
197 int alt_x, alt_y, alt_om, alt_wrap, alt_wnext, alt_ins, alt_cset;
201 /* Escape sequence handler state */
202 #define ARGS_MAX 32 /* max # of esc sequence arguments */
203 int esc_args[ARGS_MAX];
206 #define OSC_STR_MAX 2048
208 char osc_string[OSC_STR_MAX+1];
215 TOPLEVEL, IGNORE_NEXT,
216 SEEN_ESC, SEEN_CSI, SET_GL, SET_GR,
217 SEEN_OSC, SEEN_OSC_P, SEEN_OSC_W, OSC_STRING, OSC_MAYBE_ST,
222 NO_SELECTION, ABOUT_TO, DRAGGING, SELECTED
225 SM_CHAR, SM_WORD, SM_LINE
227 unsigned long *selstart, *selend, *selanchor;
231 typedef struct Session {
232 /* Config that created this session */
234 /* Terminal emulator internal state */
237 int rows, cols, savelines;
238 int font_width, font_height;
241 unsigned char inbuf[INBUF_SIZE];
242 int inbuf_head, inbuf_reap;
243 unsigned char outbuf[OUTBUF_SIZE];
244 int outbuf_head, outbuf_reap;
246 int app_cursor_keys, app_keypad_keys;
250 unsigned long attr_mask; /* Mask of attributes to display */
256 PaletteHandle palette;
257 ControlHandle scrollbar;
264 * Exports from display system
266 extern void request_resize(Session *, int, int);
267 extern void do_text(Session *, int, int, char *, int, unsigned long);
268 extern void set_title(Session *, char *);
269 extern void set_icon(Session *, char *);
270 extern void set_sbar(Session *, int, int, int);
271 extern void pre_paint(Session *);
272 extern void post_paint(Session *);
273 extern void palette_set(Session *, int, int, int, int);
274 extern void palette_reset(Session *);
275 void write_clip (void *, int);
276 void get_clip (void **, int *);
277 extern void do_scroll(Session *, int, int, int);
278 void fatalbox (const char *, ...);
280 #pragma noreturn (fatalbox)
282 extern void beep (Session *s);
283 #define OPTIMISE_IS_SCROLL 1
286 * Exports from noise.c.
288 void noise_get_heavy(void (*func) (void *, int));
289 void noise_get_light(void (*func) (void *, int));
290 void noise_ultralight(DWORD data);
291 void random_save_seed(void);
295 * Exports from windlg.c.
297 int do_config (void);
298 int do_reconfig (HWND);
299 void do_defaults (char *);
300 void lognegot (char *);
301 void shownegot (HWND);
302 void showabout (HWND);
303 void verify_ssh_host_key(char *host, struct RSAKey *key);
307 * Exports from terminal.c.
310 extern void term_init(Session *);
311 extern void term_size(Session *, int, int, int);
312 extern void term_out(Session *);
313 extern void term_paint(Session *, int, int, int, int);
314 extern void term_scroll(Session *, int, int);
315 extern void term_pwron(Session *);
316 extern void term_clrsb(Session *);
317 extern void term_mouse(Session *, Mouse_Button, Mouse_Action, int, int);
318 extern void term_copy(Session *);
319 extern void term_paste(Session *);
320 extern int term_hasselection(Session *);
321 extern void term_deselect (Session *);
322 extern void term_update (Session *);
323 extern void term_invalidate(Session *);
326 * Exports from telnet.c.
329 extern Backend telnet_backend;
332 * Exports from ssh.c.
335 extern Backend ssh_backend;
338 * Exports from sshrand.c.
341 void random_add_noise(void *noise, int length);
342 void random_init(void);
343 int random_byte(void);
344 void random_get_savedata(void **data, int *len);
347 * Exports from misc.c.
350 /* #define MALLOC_LOG do this if you suspect putty of leaking memory */
352 #define smalloc(z) (mlog(__FILE__,__LINE__), safemalloc(z))
353 #define srealloc(y,z) (mlog(__FILE__,__LINE__), saferealloc(y,z))
354 #define sfree(z) (mlog(__FILE__,__LINE__), safefree(z))
355 void mlog(char *, int);
357 #define smalloc safemalloc
358 #define srealloc saferealloc
359 #define sfree safefree
362 void *safemalloc(size_t);
363 void *saferealloc(void *, size_t);
364 void safefree(void *);
367 * Exports from testback.c
370 extern Backend null_backend;
371 extern Backend loop_backend;
372 extern Backend hexdump_backend;
375 * Exports from version.c.
384 #define debug(x) (dprintf x)
385 static void dprintf(char *fmt, ...) {
389 static int gotconsole = 0;
397 vsprintf(buf, fmt, ap);
398 WriteFile (GetStdHandle(STD_OUTPUT_HANDLE), buf, strlen(buf), &dw, NULL);