X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=putty.h;h=99961fdafc4ddd428173991efbc490423875eafe;hb=refs%2Fheads%2Fben-mac-port;hp=c570392ad1ca31e3c33f04f35b124a3901fce4a1;hpb=c74130d423fd83a65c51b7634e3c34aaf557ae68;p=PuTTY.git diff --git a/putty.h b/putty.h index c570392a..99961fda 100644 --- a/putty.h +++ b/putty.h @@ -3,15 +3,23 @@ #define PUTTY_REG_POS "Software\\SimonTatham\\PuTTY" -/* - * Global variables. Most modules declare these `extern', but - * window.c will do `#define PUTTY_DO_GLOBALS' before including this - * module, and so will get them properly defined. - */ -#ifdef PUTTY_DO_GLOBALS -#define GLOBAL -#else -#define GLOBAL extern +#ifdef macintosh +#define OPTIMISE_SCROLL +#endif + +#ifdef macintosh +#include +#include +#include +#include +typedef UInt32 DWORD; +#endif /* macintosh */ + +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef FALSE +#define FALSE 0 #endif #define ATTR_ACTCURS 0x80000000UL /* active cursor (block) */ @@ -39,26 +47,28 @@ #define ATTR_MASK 0xFFFFFF00UL #define CHAR_MASK 0x000000FFUL -typedef HDC Context; +#ifdef macintosh +#define SEL_NL { 13 } +#else #define SEL_NL { 13, 10 } +#endif -GLOBAL int rows, cols, savelines; - -GLOBAL int font_width, font_height; +/* + * Global variables. Most modules declare these `extern', but + * window.c will do `#define PUTTY_DO_GLOBALS' before including this + * module, and so will get them properly defined. + */ +#ifdef PUTTY_DO_GLOBALS +#define GLOBAL +#else +#define GLOBAL extern +#endif #define INBUF_SIZE 2048 #define INBUF_MASK (INBUF_SIZE-1) -GLOBAL unsigned char inbuf[INBUF_SIZE]; -GLOBAL int inbuf_head, inbuf_reap; #define OUTBUF_SIZE 2048 #define OUTBUF_MASK (OUTBUF_SIZE-1) -GLOBAL unsigned char outbuf[OUTBUF_SIZE]; -GLOBAL int outbuf_head, outbuf_reap; - -GLOBAL int has_focus; - -GLOBAL int app_cursor_keys, app_keypad_keys; #define WM_NETEVENT (WM_USER + 1) @@ -79,15 +89,63 @@ typedef enum { VT_XWINDOWS, VT_OEMANSI, VT_OEMONLY, VT_POORMAN } VT_Mode; +typedef struct Session Session; +typedef struct Socket Socket; + +/* Types of network event */ + +typedef enum { + NE_NULL, /* Nothing happened */ + NE_OPEN, /* Connection successfully opened */ + NE_NOHOST, /* DNS lookup failed for some reason */ + NE_REFUSED, /* Port unreachable */ + NE_NOOPEN, /* Connection failed to open for some other reason */ + NE_DATA, /* Incoming normal data */ + NE_URGENT, /* Incoming urgent data */ + NE_SENT, /* Used internally by Mac network stack */ + NE_CLOSING, /* Connection closed by remote host */ + NE_CLOSED, /* Connection close completed */ + NE_TIMEOUT, /* Remote host vanished */ + NE_ABORT, /* Remote host reset connection */ + NE_DIED, /* Connection has failed for some other reason */ +} Net_Event_Type; + +#ifdef macintosh +typedef void *SOCKET; +#define INVALID_SOCKET NULL +#endif + typedef struct { - char *(*init) (HWND hwnd, char *host, int port, char **realhost); - int (*msg) (WPARAM wParam, LPARAM lParam); - void (*send) (char *buf, int len); - void (*size) (void); - void (*special) (Telnet_Special code); + char *(*init) (Session *); + int (*msg)(Session *, SOCKET, Net_Event_Type); + void (*send) (Session *, char *buf, int len); + void (*size) (Session *); + void (*special) (Session *, Telnet_Special code); + void (*shutdown) (Session *); } Backend; -GLOBAL Backend *back; +#ifdef macintosh +typedef struct { + int (*init)(void); + SOCKET (*open)(Session *, char const *, int); + int (*recv)(SOCKET, void *, int, int); + int (*send)(SOCKET, void *, int, int); + void (*poll)(void); + void (*close)(SOCKET); + void (*destroy)(SOCKET); + void (*shutdown)(void); +} Network_Stack; + +GLOBAL Network_Stack *net_stack; + +#define net_open(s, h, p) ((*net_stack->open)((s), (h), (p))) +#define net_recv(s, b, l, f) ((*net_stack->recv)((s), (b), (l), (f))) +#define net_send(s, b, l, f) ((*net_stack->send)((s), (b), (l), (f))) +#define net_poll() ((*net_stack->poll)()) +#define net_close(s) ((*net_stack->close)(s)) +#define net_destroy(s) ((*net_stack->destroy)(s)) +#define net_shutdown() ((*net_stack->shutdown)()) +#endif typedef struct { /* Basic options */ @@ -95,10 +153,13 @@ typedef struct { int port; enum { PROT_TELNET, PROT_SSH } protocol; int close_on_exit; + /* SSH options */ + int nopty; + enum { CIPHER_3DES, CIPHER_BLOWFISH } cipher; /* Telnet options */ char termtype[32]; char termspeed[32]; - char environ[1024]; /* VAR\tvalue\0VAR\tvalue\0\0 */ + char environmt[1024]; /* VAR\tvalue\0VAR\tvalue\0\0 */ char username[32]; int rfc_environ; /* Keyboard options */ @@ -107,10 +168,12 @@ typedef struct { int linux_funkeys; int app_cursor; int app_keypad; + int meta_modifiers; /* Terminal options */ int savelines; int dec_om; int wrap_mode; + int lfhascr; int win_name_always; int width, height; char font[64]; @@ -120,32 +183,158 @@ typedef struct { /* Colour options */ int try_palette; int bold_colour; +#ifdef macintosh + PaletteHandle colours; +#else /* not macintosh */ unsigned char colours[22][3]; +#endif /* not macintosh */ /* Selection options */ + int implicit_copy; +#ifdef macintosh int mouse_is_xterm; +#endif short wordness[256]; } Config; -GLOBAL Config cfg; +typedef struct { + /* Display buffers and pointers within them */ + unsigned long *text; /* buffer of text on terminal screen */ + unsigned long *scrtop; /* top of working screen */ + unsigned long *disptop; /* top of displayed screen */ + unsigned long *sbtop; /* top of scrollback */ + unsigned long *cpos; /* cursor position (convenience) */ + unsigned long *disptext; /* buffer of text on real screen */ + unsigned long *wanttext; /* buffer of text we want on screen */ + unsigned long *alttext; /* buffer of text on alt. screen */ + unsigned char *selspace; /* buffer for building selections in */ + + /* Current state */ + unsigned long curr_attr; + int curs_x, curs_y; /* cursor */ + int cset; /* 0 or 1: which char set is in GL */ + unsigned long cset_attr[2]; /* G0 and G1 char sets */ + + /* Saved state */ + unsigned long save_attr; + int save_x, save_y; /* saved cursor position */ + int save_cset, save_csattr; /* saved with cursor position */ + + int marg_t, marg_b; /* scroll margins */ + + /* Flags */ + int dec_om; /* DEC origin mode flag */ + int wrap, wrapnext; /* wrap flags */ + int insert; /* insert-mode flag */ + int rvideo; /* global reverse video flag */ + + /* + * Saved settings on the alternate screen. + */ + int alt_x, alt_y, alt_om, alt_wrap, alt_wnext, alt_ins, alt_cset; + int alt_t, alt_b; + int alt_which; + + /* Escape sequence handler state */ +#define ARGS_MAX 32 /* max # of esc sequence arguments */ + int esc_args[ARGS_MAX]; + int esc_nargs; + int esc_query; +#define OSC_STR_MAX 2048 + int osc_strlen; + char osc_string[OSC_STR_MAX+1]; + int osc_w; + + unsigned char *tabs; + int nl_count; + + enum { + TOPLEVEL, IGNORE_NEXT, + SEEN_ESC, SEEN_CSI, SET_GL, SET_GR, + SEEN_OSC, SEEN_OSC_P, SEEN_OSC_W, OSC_STRING, OSC_MAYBE_ST, + SEEN_ESCHASH + } termstate; + + enum { + NO_SELECTION, ABOUT_TO, DRAGGING, SELECTED + } selstate; + enum { + SM_CHAR, SM_WORD, SM_LINE + } selmode; + unsigned long *selstart, *selend, *selanchor; + short wordness[256]; +} Term_State; + +typedef struct Session { + /* Config that created this session */ + Config cfg; + /* Terminal emulator internal state */ + Term_State ts; + /* Display state */ + int rows, cols, savelines; + int font_width, font_height; + int has_focus; + /* Buffers */ + unsigned char inbuf[INBUF_SIZE]; + int inbuf_head, inbuf_reap; + unsigned char outbuf[OUTBUF_SIZE]; + int outbuf_head, outbuf_reap; + /* Emulator state */ + int app_cursor_keys, app_keypad_keys; + /* Backend */ + Backend *back; + /* Conveniences */ + unsigned long attr_mask; /* Mask of attributes to display */ +#ifdef macintosh + short fontnum; + int font_ascent; + int font_leading; + int font_boldadjust; + WindowPtr window; + PaletteHandle palette; + ControlHandle scrollbar; + WCTabHandle wctab; +#endif +} Session; + +typedef struct Socket Socket; /* - * Exports from window.c. + * Exports from display system */ -void request_resize (int, int); -void do_text (Context, int, int, char *, int, unsigned long); -void set_title (char *); -void set_icon (char *); -void set_sbar (int, int, int); -Context get_ctx(); -void free_ctx (Context); -void palette_set (int, int, int, int); -void palette_reset (void); -void write_clip (void *, int); -void get_clip (void **, int *); -void optimised_move (int, int, int); -void fatalbox (char *, ...); -void beep (void); -#define OPTIMISE_IS_SCROLL 1 +extern void request_resize(Session *, int, int); +extern void do_text(Session *, int, int, char *, int, unsigned long); +extern void set_title(Session *, char *); +extern void set_icon(Session *, char *); +extern void set_sbar(Session *, int, int, int); +extern void pre_paint(Session *); +extern void post_paint(Session *); +extern void palette_set(Session *, int, int, int, int); +extern void palette_reset(Session *); +extern void write_clip (void *, int); +extern void get_clip (void **, int *); +extern void do_scroll(Session *, int, int, int); +extern void fatalbox(const char *, ...); +#ifdef macintosh +#pragma noreturn (fatalbox) +#endif +extern void beep(Session *s); +extern void lognegot(const char *); + +/* + * Exports from the network system + */ + +#ifndef macintosh +extern Socket *net_open(Session *, char *host, int port); +extern char *net_realname(Socket *); +extern int net_recv(Socket *, void *, int, int); +extern int net_send(Socket *, void *, int, int); +extern void net_close(Socket *); /* ask the remote end to close */ +extern void net_destroy(Socket *); /* Tidy up */ +#endif +#define SEND_PUSH 0x01 +#define SEND_URG 0x02 + /* * Exports from noise.c. @@ -155,6 +344,7 @@ void noise_get_light(void (*func) (void *, int)); void noise_ultralight(DWORD data); void random_save_seed(void); +#ifndef macintosh /* * Exports from windlg.c. */ @@ -165,34 +355,38 @@ void lognegot (char *); void shownegot (HWND); void showabout (HWND); void verify_ssh_host_key(char *host, struct RSAKey *key); +#endif /* * Exports from terminal.c. */ -void term_init (void); -void term_size (int, int, int); -void term_out (void); -void term_paint (Context, int, int, int, int); -void term_scroll (int, int); -void term_pwron (void); -void term_clrsb (void); -void term_mouse (Mouse_Button, Mouse_Action, int, int); -void term_deselect (void); -void term_update (void); -void term_invalidate(void); +extern void term_init(Session *); +extern void term_size(Session *, int, int, int); +extern void term_out(Session *); +extern void term_paint(Session *, int, int, int, int); +extern void term_scroll(Session *, int, int); +extern void term_pwron(Session *); +extern void term_clrsb(Session *); +extern void term_mouse(Session *, Mouse_Button, Mouse_Action, int, int); +extern void term_copy(Session *); +extern void term_paste(Session *); +extern int term_hasselection(Session *); +extern void term_deselect (Session *); +extern void term_update (Session *); +extern void term_invalidate(Session *); /* * Exports from telnet.c. */ -Backend telnet_backend; +extern Backend telnet_backend; /* * Exports from ssh.c. */ -Backend ssh_backend; +extern Backend ssh_backend; /* * Exports from sshrand.c. @@ -223,6 +417,19 @@ void *safemalloc(size_t); void *saferealloc(void *, size_t); void safefree(void *); +/* + * Exports from testback.c + */ + +extern Backend null_backend; +extern Backend loop_backend; +extern Backend hexdump_backend; + +/* + * Exports from version.c. + */ +extern char ver[]; + /* * A debug system. */