X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/5a9eb1056517b6ee6efa526a3a6b5a21aa802648..fabd1805a8f429ca83b4271aabd1206ac3537ebb:/mac/mac.c diff --git a/mac/mac.c b/mac/mac.c index a2c9b08f..52258c36 100644 --- a/mac/mac.c +++ b/mac/mac.c @@ -1,4 +1,4 @@ -/* $Id: mac.c,v 1.21 2003/01/09 18:06:29 simon Exp $ */ +/* $Id: mac.c,v 1.32 2003/01/15 23:30:21 ben Exp $ */ /* * Copyright (c) 1999 Ben Harris * All rights reserved. @@ -169,8 +169,21 @@ static void mac_startup(void) { mac_gestalts.uncvattr = (*ti)->tecUnicodeConverterFeatures; DisposeHandle((Handle)ti); } - - mactcp_init(); + /* OpenTransport? */ + if (Gestalt(gestaltOpenTpt, &mac_gestalts.otptattr) != noErr || + (mac_gestalts.otptattr & gestaltOpenTptTCPPresentMask) == 0 || + ot_init() != noErr) + mac_gestalts.otptattr = 0; + if (mac_gestalts.otptattr == 0) { + /* MacTCP? */ + if (Gestalt(FOUR_CHAR_CODE('mtcp'), &mac_gestalts.mtcpvers) != noErr) + mac_gestalts.mtcpvers = 0; + if (mac_gestalts.mtcpvers > 0) { + if (mactcp_init() != noErr) + mac_gestalts.mtcpvers = 0; + } + } else + mac_gestalts.mtcpvers = 0; /* We've been tested with the Appearance Manager */ if (mac_gestalts.apprvers != 0) @@ -187,18 +200,19 @@ static void mac_startup(void) { windows.about = NULL; windows.licence = NULL; - default_protocol = DEFAULT_PROTOCOL; - default_port = DEFAULT_PORT; + default_protocol = be_default_protocol; + /* Find the appropriate default port. */ + { + int i; + default_port = 0; /* illegal */ + for (i = 0; backends[i].backend != NULL; i++) + if (backends[i].protocol == default_protocol) { + default_port = backends[i].backend->default_port; + break; + } + } flags = FLAG_INTERACTIVE; - /* - * Really grotty hack to ensure that anything that looks at the - * global "cfg" variable gets something vaguely sensible. - * Obviously, nothing should actually be using it, but that will - * take a while to arrange. - */ - do_defaults(NULL, &cfg); - { short vol; long dirid; @@ -210,7 +224,6 @@ static void mac_startup(void) { LMSetCurDirStore(dirid); } } - init_ucs(); } static void mac_eventloop(void) { @@ -225,7 +238,10 @@ static void mac_eventloop(void) { mac_adjustcursor(cursrgn); if (gotevent) mac_event(&event); - mactcp_poll(); + if (mac_gestalts.mtcpvers != 0) + mactcp_poll(); + if (mac_gestalts.otptattr != 0) + ot_poll(); mac_pollterm(); } DisposeRgn(cursrgn); @@ -525,18 +541,15 @@ static void mac_closewindow(WindowPtr window) { CloseDeskAcc(((WindowPeek)window)->windowKind); break; case wTerminal: - /* FIXME: end session and stuff */ + mac_closeterm(window); break; case wAbout: windows.about = NULL; - CloseWindow(window); + DisposeDialog(window); break; case wLicence: windows.licence = NULL; - CloseWindow(window); - break; - default: - CloseWindow(window); + DisposeWindow(window); break; } } @@ -617,7 +630,7 @@ void cleanup_exit(int status) if (mac_gestalts.encvvers != 0) TerminateUnicodeConverter(); #endif - mactcp_shutdown(); + sk_cleanup(); exit(status); } @@ -631,7 +644,7 @@ void fatalbox(char *fmt, ...) { va_end(ap); ParamText(stuff, NULL, NULL, NULL); StopAlert(128, NULL); - exit(1); + cleanup_exit(1); } void modalfatalbox(char *fmt, ...) { @@ -644,7 +657,7 @@ void modalfatalbox(char *fmt, ...) { va_end(ap); ParamText(stuff, NULL, NULL, NULL); StopAlert(128, NULL); - exit(1); + cleanup_exit(1); } /* This should only kill the current session, not the whole application. */ @@ -658,7 +671,7 @@ void connection_fatal(void *fontend, char *fmt, ...) { va_end(ap); ParamText(stuff, NULL, NULL, NULL); StopAlert(128, NULL); - exit(1); + cleanup_exit(1); } /* Null SSH agent client -- never finds an agent. */ @@ -694,17 +707,42 @@ void old_keyfile_warning(void) } -char *platform_default_s(char *name) +char *platform_default_s(char const *name) { - if (!strcmp(name, "Font")) - return "Monaco"; + long smfs; + Str255 pname; + static char cname[256]; + + if (!strcmp(name, "Font")) { + smfs = GetScriptVariable(smSystemScript, smScriptMonoFondSize); + if (smfs == 0) + smfs = GetScriptVariable(smRoman, smScriptMonoFondSize); + if (smfs != 0) { + GetFontName(HiWord(smfs), pname); + if (pname[0] == 0) + return "Monaco"; + p2cstrcpy(cname, pname); + return cname; + } else + return "Monaco"; + } return NULL; } -int platform_default_i(char *name, int def) +int platform_default_i(char const *name, int def) { - if (!strcmp(name, "FontHeight")) - return 9; + long smfs; + + if (!strcmp(name, "FontHeight")) { + smfs = GetScriptVariable(smSystemScript, smScriptMonoFondSize); + if (smfs == 0) + smfs = GetScriptVariable(smRoman, smScriptMonoFondSize); + if (smfs != 0) + return LoWord(smfs); + else + return 9; + } + /* Non-raw cut and paste of line-drawing chars works badly on the * current Unix stub implementation of the Unicode functions. * So I'm going to temporarily set the default to raw mode so @@ -715,6 +753,12 @@ int platform_default_i(char *name, int def) return def; } +void platform_get_x11_auth(char *display, int *proto, + unsigned char *data, int *datalen) +{ + /* SGT: I have no idea whether Mac X servers need anything here. */ +} + /* * Local Variables: * c-file-style: "simon"