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