Support for saving sessions on the Mac. This is slightly useful even in the
[u/mdw/putty] / mac / mac.c
CommitLineData
b537dd42 1/* $Id: mac.c,v 1.33 2003/01/18 20:09:21 ben Exp $ */
d082ac49 2/*
3 * Copyright (c) 1999 Ben Harris
4 * All rights reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person
7 * obtaining a copy of this software and associated documentation
8 * files (the "Software"), to deal in the Software without
9 * restriction, including without limitation the rights to use,
10 * copy, modify, merge, publish, distribute, sublicense, and/or
11 * sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following
13 * conditions:
14 *
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
23 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
26 */
27/*
28 * mac.c -- miscellaneous Mac-specific routines
29 */
30
31#include <MacTypes.h>
32#include <Quickdraw.h>
33#include <Fonts.h>
34#include <MacWindows.h>
35#include <Menus.h>
36#include <TextEdit.h>
37#include <Appearance.h>
38#include <CodeFragments.h>
39#include <Dialogs.h>
40#include <Devices.h>
41#include <DiskInit.h>
42#include <Gestalt.h>
bf873e8e 43#include <LowMem.h>
d082ac49 44#include <Resources.h>
36577dc9 45#include <Script.h>
8768ce31 46#include <TextCommon.h>
d082ac49 47#include <ToolUtils.h>
8768ce31 48#include <UnicodeConverter.h>
d082ac49 49
50#include <assert.h>
51#include <limits.h>
52#include <stdarg.h>
53#include <stdlib.h> /* putty.h needs size_t */
54#include <stdio.h> /* for vsprintf */
55
56#define PUTTY_DO_GLOBALS
57
58#include "macresid.h"
59#include "putty.h"
0c4b7799 60#include "ssh.h"
d082ac49 61#include "mac.h"
62
63QDGlobals qd;
64
0c4b7799 65Session *sesslist;
66
d082ac49 67static int cold = 1;
68struct mac_gestalts mac_gestalts;
69
70static void mac_startup(void);
71static void mac_eventloop(void);
72#pragma noreturn (mac_eventloop)
73static void mac_event(EventRecord *);
74static void mac_contentclick(WindowPtr, EventRecord *);
75static void mac_growwindow(WindowPtr, EventRecord *);
76static void mac_activatewindow(WindowPtr, EventRecord *);
77static void mac_activateabout(WindowPtr, EventRecord *);
78static void mac_updatewindow(WindowPtr);
ebd78b62 79static void mac_updatelicence(WindowPtr);
d082ac49 80static void mac_keypress(EventRecord *);
81static int mac_windowtype(WindowPtr);
82static void mac_menucommand(long);
83static void mac_openabout(void);
ebd78b62 84static void mac_openlicence(void);
d082ac49 85static void mac_adjustcursor(RgnHandle);
86static void mac_adjustmenus(void);
87static void mac_closewindow(WindowPtr);
88static void mac_zoomwindow(WindowPtr, short);
89static void mac_shutdown(void);
0c4b7799 90#pragma noreturn (cleanup_exit)
d082ac49 91
92struct mac_windows {
93 WindowPtr about;
94 WindowPtr licence;
95};
96
97struct mac_windows windows;
98
99int main (int argc, char **argv) {
100
101 mac_startup();
102 mac_eventloop();
103}
104
105#pragma noreturn (main)
106
107static void mac_startup(void) {
108 Handle menuBar;
8768ce31 109 TECInfoHandle ti;
d082ac49 110
111 /* Init Memory Manager */
112 MaxApplZone();
113 /* Init QuickDraw */
114 InitGraf(&qd.thePort);
115 /* Init Font Manager */
116 InitFonts();
117 /* Init Window Manager */
118 InitWindows();
119 /* Init Menu Manager */
120 InitMenus();
121 /* Init TextEdit */
122 TEInit();
123 /* Init Dialog Manager */
f3ab148c 124 InitDialogs(NULL);
d082ac49 125 cold = 0;
126
56ed4cf7 127 /* Get base system version (only used if there's no better selector) */
128 if (Gestalt(gestaltSystemVersion, &mac_gestalts.sysvers) != noErr ||
6e1063b1 129 (mac_gestalts.sysvers &= 0xffff) < 0x700)
56ed4cf7 130 fatalbox("PuTTY requires System 7 or newer");
d082ac49 131 /* Find out if we've got Color Quickdraw */
132 if (Gestalt(gestaltQuickdrawVersion, &mac_gestalts.qdvers) != noErr)
133 mac_gestalts.qdvers = gestaltOriginalQD;
134 /* ... and the Appearance Manager? */
135 if (Gestalt(gestaltAppearanceVersion, &mac_gestalts.apprvers) != noErr)
136 if (Gestalt(gestaltAppearanceAttr, NULL) == noErr)
137 mac_gestalts.apprvers = 0x0100;
138 else
139 mac_gestalts.apprvers = 0;
140#if TARGET_RT_MAC_CFM
141 /* Paranoia: Did we manage to pull in AppearanceLib? */
142 if (&RegisterAppearanceClient == kUnresolvedCFragSymbolAddress)
143 mac_gestalts.apprvers = 0;
144#endif
1fc898ea 145#if TARGET_CPU_68K
146 mac_gestalts.cntlattr = 0;
147 mac_gestalts.windattr = 0;
148#else
d082ac49 149 /* Mac OS 8.5 Control Manager (proportional scrollbars)? */
1fc898ea 150 if (Gestalt(gestaltControlMgrAttr, &mac_gestalts.cntlattr) != noErr ||
151 &SetControlViewSize == kUnresolvedCFragSymbolAddress)
d082ac49 152 mac_gestalts.cntlattr = 0;
153 /* Mac OS 8.5 Window Manager? */
1fc898ea 154 if (Gestalt(gestaltWindowMgrAttr, &mac_gestalts.windattr) != noErr ||
155 &SetWindowContentColor == kUnresolvedCFragSymbolAddress)
d082ac49 156 mac_gestalts.windattr = 0;
1fc898ea 157#endif
8768ce31 158 /* Text Encoding Conversion Manager? */
159 if (
160#if TARGET_RT_MAC_CFM
161 &TECGetInfo == kUnresolvedCFragSymbolAddress ||
162#else
163 InitializeUnicodeConverter(NULL) != noErr ||
164#endif
165 TECGetInfo(&ti) != noErr)
166 mac_gestalts.encvvers = 0;
167 else {
168 mac_gestalts.encvvers = (*ti)->tecVersion;
379836ca 169 mac_gestalts.uncvattr = (*ti)->tecUnicodeConverterFeatures;
8768ce31 170 DisposeHandle((Handle)ti);
171 }
27a3458f 172 /* OpenTransport? */
173 if (Gestalt(gestaltOpenTpt, &mac_gestalts.otptattr) != noErr ||
174 (mac_gestalts.otptattr & gestaltOpenTptTCPPresentMask) == 0 ||
175 ot_init() != noErr)
176 mac_gestalts.otptattr = 0;
177 if (mac_gestalts.otptattr == 0) {
178 /* MacTCP? */
179 if (Gestalt(FOUR_CHAR_CODE('mtcp'), &mac_gestalts.mtcpvers) != noErr)
deed9e25 180 mac_gestalts.mtcpvers = 0;
27a3458f 181 if (mac_gestalts.mtcpvers > 0) {
182 if (mactcp_init() != noErr)
183 mac_gestalts.mtcpvers = 0;
184 }
185 } else
186 mac_gestalts.mtcpvers = 0;
2beb0fb0 187
d082ac49 188 /* We've been tested with the Appearance Manager */
189 if (mac_gestalts.apprvers != 0)
190 RegisterAppearanceClient();
191
192 menuBar = GetNewMBar(128);
193 if (menuBar == NULL)
194 fatalbox("Unable to create menu bar.");
195 SetMenuBar(menuBar);
196 AppendResMenu(GetMenuHandle(mApple), 'DRVR');
197 mac_adjustmenus();
198 DrawMenuBar();
199 InitCursor();
200 windows.about = NULL;
201 windows.licence = NULL;
202
ffa79828 203 default_protocol = be_default_protocol;
204 /* Find the appropriate default port. */
205 {
ffa79828 206 int i;
1adaeb2e 207 default_port = 0; /* illegal */
ffa79828 208 for (i = 0; backends[i].backend != NULL; i++)
209 if (backends[i].protocol == default_protocol) {
210 default_port = backends[i].backend->default_port;
211 break;
212 }
213 }
0c4b7799 214 flags = FLAG_INTERACTIVE;
215
bf873e8e 216 {
217 short vol;
218 long dirid;
219
220 /* Set the default directory for loading and saving settings. */
221 /* XXX Should we create it? */
222 if (get_session_dir(FALSE, &vol, &dirid) == noErr) {
223 LMSetSFSaveDisk(-vol);
224 LMSetCurDirStore(dirid);
225 }
226 }
d082ac49 227}
228
229static void mac_eventloop(void) {
230 Boolean gotevent;
231 EventRecord event;
232 RgnHandle cursrgn;
233
234 cursrgn = NewRgn();
235 for (;;) {
236 mac_adjustcursor(cursrgn);
237 gotevent = WaitNextEvent(everyEvent, &event, LONG_MAX, cursrgn);
238 mac_adjustcursor(cursrgn);
239 if (gotevent)
240 mac_event(&event);
deed9e25 241 if (mac_gestalts.mtcpvers != 0)
242 mactcp_poll();
04b0fa02 243 if (mac_gestalts.otptattr != 0)
244 ot_poll();
0c4b7799 245 mac_pollterm();
d082ac49 246 }
247 DisposeRgn(cursrgn);
248}
249
250static void mac_event(EventRecord *event) {
251 short part;
252 WindowPtr window;
253 Point pt;
254
255 switch (event->what) {
256 case mouseDown:
257 part = FindWindow(event->where, &window);
258 switch (part) {
259 case inMenuBar:
260 mac_adjustmenus();
261 mac_menucommand(MenuSelect(event->where));
262 break;
263 case inSysWindow:
264 SystemClick(event, window);
265 break;
266 case inContent:
267 if (window != FrontWindow())
268 /* XXX: check for movable modal dboxes? */
269 SelectWindow(window);
270 else
271 mac_contentclick(window, event);
272 break;
273 case inGoAway:
274 if (TrackGoAway(window, event->where))
275 mac_closewindow(window);
276 break;
277 case inDrag:
278 /* XXX: moveable modal check? */
279 DragWindow(window, event->where, &qd.screenBits.bounds);
280 break;
281 case inGrow:
282 mac_growwindow(window, event);
283 break;
284 case inZoomIn:
285 case inZoomOut:
286 if (TrackBox(window, event->where, part))
287 mac_zoomwindow(window, part);
288 break;
289 }
290 break;
291 case keyDown:
292 case autoKey:
293 mac_keypress(event);
294 break;
295 case activateEvt:
296 mac_activatewindow((WindowPtr)event->message, event);
297 break;
298 case updateEvt:
299 mac_updatewindow((WindowPtr)event->message);
300 break;
301 case diskEvt:
302 if (HiWord(event->message) != noErr) {
303 SetPt(&pt, 120, 120);
304 DIBadMount(pt, event->message);
305 }
306 break;
307 }
308}
309
310static void mac_contentclick(WindowPtr window, EventRecord *event) {
311 short item;
312
313 switch (mac_windowtype(window)) {
314 case wTerminal:
315 mac_clickterm(window, event);
316 break;
317 case wAbout:
34e9a202 318 if (DialogSelect(event, &window, &item))
d082ac49 319 switch (item) {
320 case wiAboutLicence:
ebd78b62 321 mac_openlicence();
d082ac49 322 break;
323 }
324 break;
6cb61a05 325 case wSettings:
326 mac_clickdlg(window, event);
327 break;
d082ac49 328 }
329}
330
331static void mac_growwindow(WindowPtr window, EventRecord *event) {
332
333 switch (mac_windowtype(window)) {
334 case wTerminal:
335 mac_growterm(window, event);
336 }
337}
338
339static void mac_activatewindow(WindowPtr window, EventRecord *event) {
340 int active;
341
342 active = (event->modifiers & activeFlag) != 0;
343 mac_adjustmenus();
344 switch (mac_windowtype(window)) {
345 case wTerminal:
346 mac_activateterm(window, active);
347 break;
6cb61a05 348 case wSettings:
349 mac_activatedlg(window, event);
350 break;
d082ac49 351 case wAbout:
352 mac_activateabout(window, event);
353 break;
354 }
355}
356
357static void mac_activateabout(WindowPtr window, EventRecord *event) {
358 DialogItemType itemtype;
359 Handle itemhandle;
360 short item;
361 Rect itemrect;
362 int active;
363
364 active = (event->modifiers & activeFlag) != 0;
365 GetDialogItem(window, wiAboutLicence, &itemtype, &itemhandle, &itemrect);
366 HiliteControl((ControlHandle)itemhandle, active ? 0 : 255);
367 DialogSelect(event, &window, &item);
368}
369
370static void mac_updatewindow(WindowPtr window) {
371
372 switch (mac_windowtype(window)) {
373 case wTerminal:
374 mac_updateterm(window);
375 break;
376 case wAbout:
6cb61a05 377 case wSettings:
d082ac49 378 BeginUpdate(window);
379 UpdateDialog(window, window->visRgn);
380 EndUpdate(window);
381 break;
382 case wLicence:
ebd78b62 383 mac_updatelicence(window);
384 break;
385 }
386}
387
388static void mac_updatelicence(WindowPtr window)
389{
390 Handle h;
391 int len;
36577dc9 392 long fondsize;
ebd78b62 393
394 SetPort(window);
395 BeginUpdate(window);
36577dc9 396 fondsize = GetScriptVariable(smRoman, smScriptSmallFondSize);
397 TextFont(HiWord(fondsize));
398 TextSize(LoWord(fondsize));
ebd78b62 399 h = Get1Resource('TEXT', wLicence);
400 len = GetResourceSizeOnDisk(h);
401 if (h != NULL) {
402 HLock(h);
403 TETextBox(*h, len, &window->portRect, teFlushDefault);
404 HUnlock(h);
d082ac49 405 }
ebd78b62 406 EndUpdate(window);
d082ac49 407}
408
409/*
410 * Work out what kind of window we're dealing with.
411 * Concept shamelessly nicked from SurfWriter.
412 */
413static int mac_windowtype(WindowPtr window) {
414 int kind;
6cb61a05 415 long refcon;
d082ac49 416
417 if (window == NULL)
418 return wNone;
419 kind = ((WindowPeek)window)->windowKind;
420 if (kind < 0)
421 return wDA;
422 if (GetWVariant(window) == zoomDocProc)
423 return wTerminal;
6cb61a05 424 refcon = GetWRefCon(window);
425 if (refcon < 1024)
426 return refcon;
427 else
428 return wSettings;
d082ac49 429}
430
431/*
432 * Handle a key press
433 */
434static void mac_keypress(EventRecord *event) {
435 WindowPtr window;
436
437 window = FrontWindow();
438 /*
439 * Check for a command-key combination, but ignore it if it counts
440 * as a meta-key combination and we're in a terminal window.
441 */
442 if (event->what == keyDown && (event->modifiers & cmdKey) /*&&
443 !((event->modifiers & cfg.meta_modifiers) == cfg.meta_modifiers &&
444 mac_windowtype(window) == wTerminal)*/) {
445 mac_adjustmenus();
446 mac_menucommand(MenuKey(event->message & charCodeMask));
447 } else {
448 switch (mac_windowtype(window)) {
449 case wTerminal:
450 mac_keyterm(window, event);
451 break;
452 }
453 }
454}
455
456static void mac_menucommand(long result) {
457 short menu, item;
458 Str255 da;
459 WindowPtr window;
460
461 menu = HiWord(result);
462 item = LoWord(result);
463 window = FrontWindow();
464 /* Things which do the same whatever window we're in. */
465 switch (menu) {
466 case mApple:
467 switch (item) {
468 case iAbout:
469 mac_openabout();
470 goto done;
471 default:
472 GetMenuItemText(GetMenuHandle(mApple), item, da);
473 OpenDeskAcc(da);
474 goto done;
475 }
476 break;
477 case mFile:
478 switch (item) {
479 case iNew:
480 mac_newsession();
481 goto done;
ce283213 482 case iOpen:
483 mac_opensession();
484 goto done;
d082ac49 485 case iClose:
486 mac_closewindow(window);
487 goto done;
b537dd42 488 case iSave:
489 mac_savesession();
490 goto done;
491 case iSaveAs:
492 mac_savesessionas();
493 goto done;
d082ac49 494 case iQuit:
0c4b7799 495 cleanup_exit(0);
d082ac49 496 goto done;
497 }
498 break;
499 }
500 /* If we get here, handling is up to window-specific code. */
501 switch (mac_windowtype(window)) {
502 case wTerminal:
503 mac_menuterm(window, menu, item);
504 break;
505 }
506 done:
507 HiliteMenu(0);
508}
509
510static void mac_openabout(void) {
511 DialogItemType itemtype;
512 Handle item;
513 VersRecHndl vers;
514 Rect box;
515 StringPtr longvers;
516
517 if (windows.about)
518 SelectWindow(windows.about);
519 else {
520 windows.about = GetNewDialog(wAbout, NULL, (WindowPtr)-1);
5dbc118e 521 vers = (VersRecHndl)Get1Resource('vers', 1);
522 if (vers != NULL && *vers != NULL) {
523 longvers = (*vers)->shortVersion + (*vers)->shortVersion[0] + 1;
524 GetDialogItem(windows.about, wiAboutVersion,
525 &itemtype, &item, &box);
526 assert(itemtype & kStaticTextDialogItem);
527 SetDialogItemText(item, longvers);
528 }
d082ac49 529 ShowWindow(windows.about);
530 }
531}
532
ebd78b62 533static void mac_openlicence(void) {
ebd78b62 534
535 if (windows.licence)
536 SelectWindow(windows.licence);
537 else {
538 windows.licence = GetNewWindow(wLicence, NULL, (WindowPtr)-1);
539 ShowWindow(windows.licence);
540 }
541}
542
d082ac49 543static void mac_closewindow(WindowPtr window) {
544
545 switch (mac_windowtype(window)) {
546 case wDA:
547 CloseDeskAcc(((WindowPeek)window)->windowKind);
548 break;
549 case wTerminal:
fabd1805 550 mac_closeterm(window);
d082ac49 551 break;
552 case wAbout:
553 windows.about = NULL;
fabd1805 554 DisposeDialog(window);
d082ac49 555 break;
ebd78b62 556 case wLicence:
557 windows.licence = NULL;
fabd1805 558 DisposeWindow(window);
d082ac49 559 break;
560 }
561}
562
563static void mac_zoomwindow(WindowPtr window, short part) {
564
565 /* FIXME: do something */
566}
567
568/*
569 * Make the menus look right before the user gets to see them.
570 */
571static void mac_adjustmenus(void) {
572 WindowPtr window;
573 MenuHandle menu;
574
575 window = FrontWindow();
576 menu = GetMenuHandle(mApple);
577 EnableItem(menu, 0);
578 EnableItem(menu, iAbout);
579
580 menu = GetMenuHandle(mFile);
581 EnableItem(menu, 0);
582 EnableItem(menu, iNew);
583 if (window != NULL)
584 EnableItem(menu, iClose);
585 else
586 DisableItem(menu, iClose);
587 EnableItem(menu, iQuit);
588
589 switch (mac_windowtype(window)) {
b537dd42 590 case wSettings:
591 DisableItem(menu, iSave); /* XXX enable if modified */
592 EnableItem(menu, iSaveAs);
593 menu = GetMenuHandle(mEdit);
594 DisableItem(menu, 0);
595 break;
d082ac49 596 case wTerminal:
597 mac_adjusttermmenus(window);
598 break;
599 default:
b537dd42 600 DisableItem(menu, iSave);
601 DisableItem(menu, iSaveAs);
d082ac49 602 menu = GetMenuHandle(mEdit);
603 DisableItem(menu, 0);
604 break;
605 }
606 DrawMenuBar();
607}
608
609/*
610 * Make sure the right cursor's being displayed.
611 */
612static void mac_adjustcursor(RgnHandle cursrgn) {
613 Point mouse;
614 WindowPtr window, front;
615 short part;
616
617 GetMouse(&mouse);
618 LocalToGlobal(&mouse);
619 part = FindWindow(mouse, &window);
620 front = FrontWindow();
621 if (part != inContent || window == NULL || window != front) {
622 /* Cursor isn't in the front window, so switch to arrow */
623 SetCursor(&qd.arrow);
624 SetRectRgn(cursrgn, SHRT_MIN, SHRT_MIN, SHRT_MAX, SHRT_MAX);
625 if (front != NULL)
626 DiffRgn(cursrgn, front->visRgn, cursrgn);
627 } else {
628 switch (mac_windowtype(window)) {
629 case wTerminal:
630 mac_adjusttermcursor(window, mouse, cursrgn);
631 break;
632 default:
633 SetCursor(&qd.arrow);
634 CopyRgn(window->visRgn, cursrgn);
635 break;
636 }
637 }
638}
639
0c4b7799 640void cleanup_exit(int status)
641{
d082ac49 642
713b8b7a 643#if !TARGET_RT_MAC_CFM
8768ce31 644 if (mac_gestalts.encvvers != 0)
645 TerminateUnicodeConverter();
713b8b7a 646#endif
27a3458f 647 sk_cleanup();
0c4b7799 648 exit(status);
d082ac49 649}
650
651void fatalbox(char *fmt, ...) {
652 va_list ap;
653 Str255 stuff;
654
655 va_start(ap, fmt);
656 /* We'd like stuff to be a Pascal string */
657 stuff[0] = vsprintf((char *)(&stuff[1]), fmt, ap);
658 va_end(ap);
659 ParamText(stuff, NULL, NULL, NULL);
f3ab148c 660 StopAlert(128, NULL);
04b0fa02 661 cleanup_exit(1);
d082ac49 662}
663
664void modalfatalbox(char *fmt, ...) {
665 va_list ap;
666 Str255 stuff;
667
668 va_start(ap, fmt);
669 /* We'd like stuff to be a Pascal string */
670 stuff[0] = vsprintf((char *)(&stuff[1]), fmt, ap);
671 va_end(ap);
672 ParamText(stuff, NULL, NULL, NULL);
f3ab148c 673 StopAlert(128, NULL);
04b0fa02 674 cleanup_exit(1);
d082ac49 675}
676
2beb0fb0 677/* This should only kill the current session, not the whole application. */
678void connection_fatal(void *fontend, char *fmt, ...) {
679 va_list ap;
680 Str255 stuff;
681
682 va_start(ap, fmt);
683 /* We'd like stuff to be a Pascal string */
684 stuff[0] = vsprintf((char *)(&stuff[1]), fmt, ap);
685 va_end(ap);
686 ParamText(stuff, NULL, NULL, NULL);
687 StopAlert(128, NULL);
04b0fa02 688 cleanup_exit(1);
2beb0fb0 689}
690
0c4b7799 691/* Null SSH agent client -- never finds an agent. */
692
693int agent_exists(void)
694{
695
696 return FALSE;
697}
698
699void agent_query(void *in, int inlen, void **out, int *outlen)
700{
701
702 *out = NULL;
703 *outlen = 0;
704}
705
706/* Temporary null routines for testing. */
707
708void verify_ssh_host_key(void *frontend, char *host, int port, char *keytype,
709 char *keystr, char *fingerprint)
710{
711
712}
713
714void askcipher(void *frontend, char *ciphername, int cs)
715{
716
717}
718
719void old_keyfile_warning(void)
720{
721
722}
723
f5d2d791 724char *platform_default_s(char const *name)
5a9eb105 725{
a499fbf9 726 long smfs;
727 Str255 pname;
728 static char cname[256];
729
730 if (!strcmp(name, "Font")) {
731 smfs = GetScriptVariable(smSystemScript, smScriptMonoFondSize);
732 if (smfs == 0)
733 smfs = GetScriptVariable(smRoman, smScriptMonoFondSize);
734 if (smfs != 0) {
735 GetFontName(HiWord(smfs), pname);
736 if (pname[0] == 0)
737 return "Monaco";
738 p2cstrcpy(cname, pname);
739 return cname;
740 } else
741 return "Monaco";
742 }
5a9eb105 743 return NULL;
744}
745
f5d2d791 746int platform_default_i(char const *name, int def)
5a9eb105 747{
a499fbf9 748 long smfs;
749
750 if (!strcmp(name, "FontHeight")) {
751 smfs = GetScriptVariable(smSystemScript, smScriptMonoFondSize);
752 if (smfs == 0)
753 smfs = GetScriptVariable(smRoman, smScriptMonoFondSize);
754 if (smfs != 0)
755 return LoWord(smfs);
756 else
757 return 9;
758 }
759
5a9eb105 760 /* Non-raw cut and paste of line-drawing chars works badly on the
761 * current Unix stub implementation of the Unicode functions.
762 * So I'm going to temporarily set the default to raw mode so
763 * that the failure mode isn't quite so drastically horrid.
764 * When Unicode comes in, this can all be put right. */
765 if (!strcmp(name, "RawCNP"))
766 return 1;
767 return def;
768}
769
e0e7dff8 770void platform_get_x11_auth(char *display, int *proto,
771 unsigned char *data, int *datalen)
772{
773 /* SGT: I have no idea whether Mac X servers need anything here. */
774}
775
d082ac49 776/*
777 * Local Variables:
778 * c-file-style: "simon"
779 * End:
780 */