| 1 | /* |
| 2 | * mac.h -- macintosh-specific declarations |
| 3 | */ |
| 4 | |
| 5 | #ifndef PUTTY_MAC_H |
| 6 | #define PUTTY_MAC_H |
| 7 | |
| 8 | #include <MacTypes.h> |
| 9 | #include <Controls.h> |
| 10 | #include <Events.h> |
| 11 | #include <Gestalt.h> |
| 12 | #include <Lists.h> |
| 13 | #include <MacWindows.h> |
| 14 | #include <Palettes.h> |
| 15 | #include <UnicodeConverter.h> |
| 16 | |
| 17 | #include "charset.h" |
| 18 | #include "tree234.h" |
| 19 | |
| 20 | #define PUTTY_CREATOR FOUR_CHAR_CODE('pTTY') |
| 21 | #define INTERNAL_CREATOR FOUR_CHAR_CODE('pTTI') |
| 22 | #define SESS_TYPE FOUR_CHAR_CODE('Sess') |
| 23 | #define SEED_TYPE FOUR_CHAR_CODE('Seed') |
| 24 | #define HKYS_TYPE FOUR_CHAR_CODE('Hkys') |
| 25 | |
| 26 | struct mac_gestalts { |
| 27 | long sysvers; |
| 28 | long qdvers; |
| 29 | long apprvers; |
| 30 | long cntlattr; |
| 31 | long windattr; |
| 32 | long menuattr; |
| 33 | long encvvers; /* TEC version (from TECGetInfo()) */ |
| 34 | long uncvattr; /* Unicode Converter attributes (frem TECGetInfo()) */ |
| 35 | long navsvers; /* Navigation Services version */ |
| 36 | }; |
| 37 | |
| 38 | extern struct mac_gestalts mac_gestalts; |
| 39 | extern UInt32 sleeptime; |
| 40 | |
| 41 | #if TARGET_RT_MAC_CFM |
| 42 | /* All systems that can use CFM have Color QuickDraw */ |
| 43 | #define HAVE_COLOR_QD() 1 |
| 44 | #else |
| 45 | #define HAVE_COLOR_QD() (mac_gestalts.qdvers > gestaltOriginalQD) |
| 46 | #endif |
| 47 | |
| 48 | /* Every window used by PuTTY has a refCon field pointing to one of these. */ |
| 49 | typedef struct { |
| 50 | struct Session *s; /* Only used in PuTTY */ |
| 51 | struct KeyState *ks; /* Only used in PuTTYgen */ |
| 52 | struct macctrls *mcs; |
| 53 | |
| 54 | void (*activate) (WindowPtr, EventRecord *); |
| 55 | void (*adjustcursor)(WindowPtr, Point, RgnHandle); |
| 56 | void (*adjustmenus) (WindowPtr); |
| 57 | void (*update) (WindowPtr); |
| 58 | void (*click) (WindowPtr, EventRecord *); |
| 59 | void (*grow) (WindowPtr, EventRecord *); |
| 60 | void (*key) (WindowPtr, EventRecord *); |
| 61 | void (*menu) (WindowPtr, short, short); |
| 62 | void (*close) (WindowPtr); |
| 63 | |
| 64 | int wtype; |
| 65 | } WinInfo; |
| 66 | |
| 67 | #define mac_wininfo(w) ((WinInfo *)GetWRefCon(w)) |
| 68 | #define mac_windowsession(w) (((WinInfo *)GetWRefCon(w))->s) |
| 69 | #define mac_winctrls(w) (((WinInfo *)GetWRefCon(w))->mcs) |
| 70 | |
| 71 | union macctrl; |
| 72 | |
| 73 | struct macctrls { |
| 74 | WindowPtr window; |
| 75 | void (*end)(WindowPtr, int); |
| 76 | tree234 *byctrl; |
| 77 | void *data; /* private data for config box */ |
| 78 | unsigned int npanels; |
| 79 | unsigned int curpanel; |
| 80 | union macctrl **panels; /* lists of controls by panel */ |
| 81 | union macctrl *focus; /* Input focus for System 7 */ |
| 82 | union macctrl *defbutton; /* Default button */ |
| 83 | union macctrl *canbutton; /* Cancel button */ |
| 84 | Boolean gotcolour; |
| 85 | RGBColor thecolour; |
| 86 | }; |
| 87 | |
| 88 | typedef struct Session { |
| 89 | struct Session *next; |
| 90 | struct Session **prev; |
| 91 | /* Config that created this session */ |
| 92 | Config cfg; |
| 93 | /* Temporary config for passing to Change Settings */ |
| 94 | Config temp_cfg; |
| 95 | /* Terminal emulator internal state */ |
| 96 | Terminal *term; |
| 97 | /* Display state */ |
| 98 | int font_width, font_height; |
| 99 | /* Line discipline */ |
| 100 | void *ldisc; |
| 101 | /* Backend */ |
| 102 | Backend *back; |
| 103 | void *backhandle; |
| 104 | char *realhost; |
| 105 | /* Logging */ |
| 106 | void *logctx; |
| 107 | /* Unicode stuff */ |
| 108 | struct unicode_data ucsdata; |
| 109 | |
| 110 | /* Mac-specific elements */ |
| 111 | short fontnum; |
| 112 | int font_ascent; |
| 113 | int font_leading; |
| 114 | int font_boldadjust; |
| 115 | Point font_stdnumer; |
| 116 | Point font_stddenom; |
| 117 | Point font_widenumer; |
| 118 | Point font_widedenom; |
| 119 | Point font_bignumer; |
| 120 | Point font_bigdenom; |
| 121 | WindowPtr window; |
| 122 | WindowPtr eventlog_window; |
| 123 | ListHandle eventlog; |
| 124 | PaletteHandle palette; |
| 125 | ControlHandle scrollbar; |
| 126 | WCTabHandle wctab; |
| 127 | int raw_mouse; |
| 128 | UnicodeToTextInfo uni_to_font; /* Only one of uni_to_font and */ |
| 129 | charset_t font_charset; /* font_charset is used at a time. */ |
| 130 | int hasfile; |
| 131 | FSSpec savefile; |
| 132 | |
| 133 | /* Config dialogue bits */ |
| 134 | WindowPtr settings_window; |
| 135 | struct controlbox *ctrlbox; |
| 136 | struct macctrls settings_ctrls; |
| 137 | } Session; |
| 138 | |
| 139 | extern Session *sesslist; |
| 140 | |
| 141 | /* PuTTYgen per-window state */ |
| 142 | typedef struct KeyState { |
| 143 | DialogPtr box; |
| 144 | int collecting_entropy; |
| 145 | int entropy_got, entropy_required, entropy_size; |
| 146 | unsigned *entropy; |
| 147 | ControlHandle progress; |
| 148 | } KeyState; |
| 149 | |
| 150 | #define mac_windowkey(w) (((WinInfo *)GetWRefCon(w))->ks) |
| 151 | |
| 152 | /* from macmisc.c */ |
| 153 | extern WindowPtr mac_frontwindow(void); |
| 154 | /* from macdlg.c */ |
| 155 | extern void mac_newsession(void); |
| 156 | extern void mac_reconfig(void); |
| 157 | extern void mac_dupsession(void); |
| 158 | extern void mac_savesession(void); |
| 159 | extern void mac_savesessionas(void); |
| 160 | /* from maceventlog.c */ |
| 161 | extern void mac_freeeventlog(Session *); |
| 162 | extern void mac_showeventlog(Session *); |
| 163 | /* from macterm.c */ |
| 164 | extern void mac_opensession(void); |
| 165 | extern void mac_startsession(Session *); |
| 166 | /* from macstore.c */ |
| 167 | extern OSErr get_putty_dir(Boolean makeit, short *pVRefNum, long *pDirID); |
| 168 | extern OSErr get_session_dir(Boolean makeit, short *pVRefNum, long *pDirID); |
| 169 | extern void *open_settings_r_fsp(FSSpec *); |
| 170 | extern void *open_settings_w_fsp(FSSpec *); |
| 171 | extern int verify_host_key(const char *, int, const char *, const char*); |
| 172 | extern void store_host_key(const char *, int, const char *, const char*); |
| 173 | /* from macucs.c */ |
| 174 | extern void init_ucs(Session *); |
| 175 | /* from macnet.c */ |
| 176 | extern void sk_poll(void); |
| 177 | /* from mtcpnet.c */ |
| 178 | extern OSErr mactcp_init(void); |
| 179 | extern void mactcp_cleanup(void); |
| 180 | extern void mactcp_poll(void); |
| 181 | extern SockAddr mactcp_namelookup(char const *, char **); |
| 182 | extern SockAddr mactcp_nonamelookup(char const *); |
| 183 | extern void mactcp_getaddr(SockAddr, char *, int); |
| 184 | extern int mactcp_hostname_is_local(char *); |
| 185 | extern int mactcp_address_is_local(SockAddr); |
| 186 | extern int mactcp_addrtype(SockAddr); |
| 187 | extern void mactcp_addrcopy(SockAddr, char *); |
| 188 | extern void mactcp_addr_free(SockAddr); |
| 189 | extern Socket mactcp_register(void *, Plug); |
| 190 | extern Socket mactcp_new(SockAddr addr, int, int, int, int, int, Plug); |
| 191 | extern Socket mactcp_newlistener(char *, int, Plug, int); |
| 192 | extern char *mactcp_addr_error(SockAddr); |
| 193 | /* from otnet.c */ |
| 194 | extern OSErr ot_init(void); |
| 195 | extern void ot_cleanup(void); |
| 196 | extern void ot_poll(void); |
| 197 | extern SockAddr ot_namelookup(char const *, char **); |
| 198 | extern SockAddr ot_nonamelookup(char const *); |
| 199 | extern void ot_getaddr(SockAddr, char *, int); |
| 200 | extern int ot_hostname_is_local(char *); |
| 201 | extern int ot_address_is_local(SockAddr); |
| 202 | extern int ot_addrtype(SockAddr); |
| 203 | extern void ot_addrcopy(SockAddr, char *); |
| 204 | extern void ot_addr_free(SockAddr); |
| 205 | extern Socket ot_register(void *, Plug); |
| 206 | extern Socket ot_new(SockAddr addr, int, int, int, int, int, Plug); |
| 207 | extern Socket ot_newlistener(char *, int, Plug, int); |
| 208 | extern char *ot_addr_error(SockAddr); |
| 209 | /* from macabout.c */ |
| 210 | extern void mac_openabout(void); |
| 211 | /* from macctrls.c */ |
| 212 | extern void macctrl_layoutbox(struct controlbox *, WindowPtr, |
| 213 | struct macctrls *); |
| 214 | extern void macctrl_activate(WindowPtr, EventRecord *); |
| 215 | extern void macctrl_click(WindowPtr, EventRecord *); |
| 216 | extern void macctrl_key(WindowPtr, EventRecord *); |
| 217 | extern void macctrl_update(WindowPtr); |
| 218 | extern void macctrl_adjustmenus(WindowPtr); |
| 219 | extern void macctrl_close(WindowPtr); |
| 220 | |
| 221 | |
| 222 | /* from macpgkey.c */ |
| 223 | extern void mac_newkey(void); |
| 224 | /* Apple Event Handlers (in various files) */ |
| 225 | extern pascal OSErr mac_aevt_oapp(const AppleEvent *, AppleEvent *, long); |
| 226 | extern pascal OSErr mac_aevt_odoc(const AppleEvent *, AppleEvent *, long); |
| 227 | extern pascal OSErr mac_aevt_pdoc(const AppleEvent *, AppleEvent *, long); |
| 228 | extern pascal OSErr mac_aevt_quit(const AppleEvent *, AppleEvent *, long); |
| 229 | |
| 230 | #endif |
| 231 | |
| 232 | /* |
| 233 | * Local Variables: |
| 234 | * c-file-style: "simon" |
| 235 | * End: |
| 236 | */ |