]> asedeno.scripts.mit.edu Git - PuTTY.git/blob - mac/mac.c
91fa2fc21f406ba207245088aa83b7532a2b9efa
[PuTTY.git] / mac / mac.c
1 /* $Id: mac.c,v 1.55 2003/03/17 19:00:36 ben Exp $ */
2 /*
3  * Copyright (c) 1999, 2003 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 <Navigation.h>
47 #include <Resources.h>
48 #include <Script.h>
49 #include <TextCommon.h>
50 #include <ToolUtils.h>
51 #include <UnicodeConverter.h>
52
53 #include <assert.h>
54 #include <limits.h>
55 #include <stdarg.h>
56 #include <stdlib.h>             /* putty.h needs size_t */
57 #include <stdio.h>              /* for vsprintf */
58
59 #define PUTTY_DO_GLOBALS
60
61 #include "macresid.h"
62 #include "putty.h"
63 #include "ssh.h"
64 #include "terminal.h"
65 #include "mac.h"
66
67 Session *sesslist;
68
69 static int cold = 1;
70 static int borednow = FALSE;
71 struct mac_gestalts mac_gestalts;
72 UInt32 sleeptime;
73
74 static void mac_startup(void);
75 static void mac_eventloop(void);
76 #pragma noreturn (mac_eventloop)
77 static void mac_event(EventRecord *);
78 static void mac_contentclick(WindowPtr, EventRecord *);
79 static void mac_growwindow(WindowPtr, EventRecord *);
80 static void mac_activatewindow(WindowPtr, EventRecord *);
81 static void mac_suspendresume(EventRecord *);
82 static void mac_activateabout(WindowPtr, EventRecord *);
83 static void mac_updatewindow(WindowPtr);
84 static void mac_updatelicence(WindowPtr);
85 static void mac_keypress(EventRecord *);
86 static int mac_windowtype(WindowPtr);
87 static void mac_menucommand(long);
88 static void mac_openlicence(void);
89 static void mac_adjustcursor(RgnHandle);
90 static void mac_adjustmenus(void);
91 static void mac_closewindow(WindowPtr);
92 static void mac_zoomwindow(WindowPtr, short);
93 #pragma noreturn (cleanup_exit)
94
95 struct mac_windows {
96     WindowPtr about;
97     WindowPtr licence;
98 };
99
100 struct mac_windows windows;
101
102 int main (int argc, char **argv) {
103
104     mac_startup();
105     mac_eventloop();
106 }
107
108 #pragma noreturn (main)
109
110 static void mac_startup(void) {
111     Handle menuBar;
112     TECInfoHandle ti;
113
114 #if !TARGET_API_MAC_CARBON
115     /* Init Memory Manager */
116     MaxApplZone();
117     /* Init QuickDraw */
118     InitGraf(&qd.thePort);
119     /* Init Font Manager */
120     InitFonts();
121     /* Init Window Manager */
122     InitWindows();
123     /* Init Menu Manager */
124     InitMenus();
125     /* Init TextEdit */
126     TEInit();
127     /* Init Dialog Manager */
128     InitDialogs(NULL);
129 #endif
130     cold = 0;
131     
132     /* Get base system version (only used if there's no better selector) */
133     if (Gestalt(gestaltSystemVersion, &mac_gestalts.sysvers) != noErr ||
134         (mac_gestalts.sysvers &= 0xffff) < 0x700)
135         fatalbox("PuTTY requires System 7 or newer");
136     /* Find out if we've got Color Quickdraw */
137     if (Gestalt(gestaltQuickdrawVersion, &mac_gestalts.qdvers) != noErr)
138         mac_gestalts.qdvers = gestaltOriginalQD;
139     /* ... and the Appearance Manager? */
140     if (Gestalt(gestaltAppearanceVersion, &mac_gestalts.apprvers) != noErr)
141         if (Gestalt(gestaltAppearanceAttr, NULL) == noErr)
142             mac_gestalts.apprvers = 0x0100;
143         else
144             mac_gestalts.apprvers = 0;
145 #if TARGET_RT_MAC_CFM
146     /* Paranoia: Did we manage to pull in AppearanceLib? */
147     if (&RegisterAppearanceClient == kUnresolvedCFragSymbolAddress)
148         mac_gestalts.apprvers = 0;
149 #endif
150 #if TARGET_CPU_68K
151     mac_gestalts.cntlattr = 0;
152     mac_gestalts.windattr = 0;
153 #else
154     /* Mac OS 8.5 Control Manager (proportional scrollbars)? */
155     if (Gestalt(gestaltControlMgrAttr, &mac_gestalts.cntlattr) != noErr ||
156         &SetControlViewSize == kUnresolvedCFragSymbolAddress)
157         mac_gestalts.cntlattr = 0;
158     /* Mac OS 8.5 Window Manager? */
159     if (Gestalt(gestaltWindowMgrAttr, &mac_gestalts.windattr) != noErr ||
160         &SetWindowContentColor == kUnresolvedCFragSymbolAddress)
161         mac_gestalts.windattr = 0;
162     /* Mac OS 8.5 Menu Manager? */
163     if (Gestalt(gestaltMenuMgrAttr, &mac_gestalts.menuattr) != noErr)
164         mac_gestalts.menuattr = 0;
165 #endif
166     /* Text Encoding Conversion Manager? */
167     if (
168 #if TARGET_RT_MAC_CFM
169         &TECGetInfo == kUnresolvedCFragSymbolAddress ||
170 #else
171         InitializeUnicodeConverter(NULL) != noErr ||
172 #endif
173         TECGetInfo(&ti) != noErr)
174         mac_gestalts.encvvers = 0;
175     else {
176         mac_gestalts.encvvers = (*ti)->tecVersion;
177         mac_gestalts.uncvattr = (*ti)->tecUnicodeConverterFeatures;
178         DisposeHandle((Handle)ti);
179     }
180     /* Navigation Services? */
181     if (NavServicesAvailable())
182         mac_gestalts.navsvers = NavLibraryVersion();
183     else
184         mac_gestalts.navsvers = 0;
185
186     sk_init();
187
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     if (mac_gestalts.menuattr & gestaltMenuMgrAquaLayoutMask) {
198         DeleteMenuItem(GetMenuHandle(mFile), iQuit);
199         /* Also delete the separator above the Quit item. */
200         DeleteMenuItem(GetMenuHandle(mFile), iQuit - 1);
201     }
202     mac_adjustmenus();
203     DrawMenuBar();
204     InitCursor();
205     windows.about = NULL;
206     windows.licence = NULL;
207
208     default_protocol = be_default_protocol;
209     /* Find the appropriate default port. */
210     {
211         int i;
212         default_port = 0; /* illegal */
213         for (i = 0; backends[i].backend != NULL; i++)
214             if (backends[i].protocol == default_protocol) {
215                 default_port = backends[i].backend->default_port;
216                 break;
217             }
218     }
219     flags = FLAG_INTERACTIVE;
220
221 #if !TARGET_API_MAC_CARBON
222     {
223         short vol;
224         long dirid;
225
226         /* Set the default directory for loading and saving settings. */
227         /* XXX Should we create it? */
228         if (get_session_dir(FALSE, &vol, &dirid) == noErr) {
229             LMSetSFSaveDisk(-vol);
230             LMSetCurDirStore(dirid);
231         }
232     }
233 #endif
234
235     /* Install Apple Event handlers. */
236     AEInstallEventHandler(kCoreEventClass, kAEOpenApplication,
237                           NewAEEventHandlerUPP(&mac_aevt_oapp), 0, FALSE);
238     AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments,
239                           NewAEEventHandlerUPP(&mac_aevt_odoc), 0, FALSE);
240     AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments,
241                           NewAEEventHandlerUPP(&mac_aevt_pdoc), 0, FALSE);
242     AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
243                           NewAEEventHandlerUPP(&mac_aevt_quit), 0, FALSE);
244 }
245
246 static void mac_eventloop(void) {
247     Boolean gotevent;
248     EventRecord event;
249     RgnHandle cursrgn;
250
251     cursrgn = NewRgn();
252     sleeptime = 0;
253     for (;;) {
254         mac_adjustcursor(cursrgn);
255         gotevent = WaitNextEvent(everyEvent, &event, sleeptime, cursrgn);
256         /*
257          * XXX For now, limit sleep time to 1/10 s to work around
258          * wake-before-sleep race in MacTCP code.
259          */
260         sleeptime = 6;
261         mac_adjustcursor(cursrgn);
262         if (gotevent) {
263             /* Ensure we get a null event when the real ones run out. */
264             sleeptime = 0;
265             mac_event(&event);
266             if (borednow)
267                 cleanup_exit(0);
268         }
269         sk_poll();
270         if (!gotevent)
271             mac_pollterm();
272     }
273     DisposeRgn(cursrgn);
274 }
275
276 static void mac_event(EventRecord *event) {
277     short part;
278     WindowPtr window;
279
280     switch (event->what) {
281       case mouseDown:
282         part = FindWindow(event->where, &window);
283         switch (part) {
284           case inMenuBar:
285             mac_adjustmenus();
286             mac_menucommand(MenuSelect(event->where));
287             break;
288 #if !TARGET_API_MAC_CARBON
289           case inSysWindow:
290             SystemClick(event, window);
291             break;
292 #endif
293           case inContent:
294             if (window != FrontWindow())
295                 /* XXX: check for movable modal dboxes? */
296                 SelectWindow(window);
297             else
298                 mac_contentclick(window, event);
299             break;
300           case inGoAway:
301             if (TrackGoAway(window, event->where))
302                 mac_closewindow(window);
303             break;
304           case inDrag:
305             /* XXX: moveable modal check? */
306 #if TARGET_API_MAC_CARBON
307             {
308                 BitMap screenBits;
309
310                 GetQDGlobalsScreenBits(&screenBits);
311                 DragWindow(window, event->where, &screenBits.bounds);
312             }
313 #else
314             DragWindow(window, event->where, &qd.screenBits.bounds);
315 #endif
316             break;
317           case inGrow:
318             mac_growwindow(window, event);
319             break;
320           case inZoomIn:
321           case inZoomOut:
322             if (TrackBox(window, event->where, part))
323                 mac_zoomwindow(window, part);
324             break;
325         }
326         break;
327       case keyDown:
328       case autoKey:
329         mac_keypress(event);
330         break;
331       case activateEvt:
332         mac_activatewindow((WindowPtr)event->message, event);
333         break;
334       case updateEvt:
335         mac_updatewindow((WindowPtr)event->message);
336         break;
337 #if !TARGET_API_MAC_CARBON
338       case diskEvt:
339         if (HiWord(event->message) != noErr) {
340             Point pt;
341
342             SetPt(&pt, 120, 120);
343             DIBadMount(pt, event->message);
344         }
345         break;
346 #endif
347       case osEvt:
348         switch ((event->message & osEvtMessageMask) >> 24) {
349           case suspendResumeMessage:
350             mac_suspendresume(event);
351             break;
352         }
353         break;
354       case kHighLevelEvent:
355         AEProcessAppleEvent(event); /* errors? */
356         break;
357     }
358 }
359
360 static void mac_contentclick(WindowPtr window, EventRecord *event)
361 {
362
363     if (mac_wininfo(window)->click != NULL)
364         (*mac_wininfo(window)->click)(window, event);
365 }
366
367 static void mac_growwindow(WindowPtr window, EventRecord *event)
368 {
369
370     if (mac_wininfo(window)->grow != NULL)
371         (*mac_wininfo(window)->grow)(window, event);
372 }
373
374 static void mac_activatewindow(WindowPtr window, EventRecord *event)
375 {
376
377     mac_adjustmenus();
378     if (mac_wininfo(window)->activate != NULL)
379         (*mac_wininfo(window)->activate)(window, event);
380 }
381
382 static void mac_updatewindow(WindowPtr window)
383 {
384
385     if (mac_wininfo(window)->update != NULL)
386         (*mac_wininfo(window)->update)(window);
387 }
388
389 /*
390  * Work out what kind of window we're dealing with.
391  */
392 static int mac_windowtype(WindowPtr window)
393 {
394
395 #if !TARGET_API_MAC_CARBON
396     if (GetWindowKind(window) < 0)
397         return wDA;
398 #endif
399     return ((WinInfo *)GetWRefCon(window))->wtype;
400 }
401
402 /*
403  * Handle a key press
404  */
405 static void mac_keypress(EventRecord *event) {
406     WindowPtr window;
407
408     window = mac_frontwindow();
409     /*
410      * Check for a command-key combination, but ignore it if it counts
411      * as a meta-key combination and we're in a terminal window.
412      */
413     if (event->what == keyDown && (event->modifiers & cmdKey) /*&&
414         !((event->modifiers & cfg.meta_modifiers) == cfg.meta_modifiers &&
415             mac_windowtype(window) == wTerminal)*/) {
416         mac_adjustmenus();
417         mac_menucommand(MenuKey(event->message & charCodeMask));
418     } else {
419         if (window != NULL && mac_wininfo(window)->key != NULL)
420             (*mac_wininfo(window)->key)(window, event);
421     }       
422 }
423
424 static void mac_menucommand(long result) {
425     short menu, item;
426     WindowPtr window;
427 #if !TARGET_API_MAC_CARBON
428     Str255 da;
429 #endif
430
431     menu = HiWord(result);
432     item = LoWord(result);
433     window = mac_frontwindow();
434     /* Things which do the same whatever window we're in. */
435     switch (menu) {
436       case mApple:
437         switch (item) {
438           case iAbout:
439             mac_openabout();
440             goto done;
441 #if !TARGET_API_MAC_CARBON
442           default:
443             GetMenuItemText(GetMenuHandle(mApple), item, da);
444             OpenDeskAcc(da);
445             goto done;
446 #endif
447         }
448         break;
449       case mFile:
450         switch (item) {
451           case iNew:
452             mac_newsession();
453             goto done;
454           case iOpen:
455             mac_opensession();
456             goto done;
457           case iClose:
458             mac_closewindow(window);
459             goto done;
460           case iSave:
461             mac_savesession();
462             goto done;
463           case iSaveAs:
464             mac_savesessionas();
465             goto done;
466           case iDuplicate:
467             mac_dupsession();
468             goto done;
469           case iQuit:
470             cleanup_exit(0);
471             goto done;
472         }
473         break;
474     }
475     /* If we get here, handling is up to window-specific code. */
476     if (window != NULL && mac_wininfo(window)->menu != NULL)
477         (*mac_wininfo(window)->menu)(window, menu, item);
478
479   done:
480     HiliteMenu(0);
481 }
482
483 static void mac_closewindow(WindowPtr window) {
484
485     switch (mac_windowtype(window)) {
486 #if !TARGET_API_MAC_CARBON
487       case wDA:
488         CloseDeskAcc(GetWindowKind(window));
489         break;
490 #endif
491       default:
492         if (mac_wininfo(window)->close != NULL)
493             (*mac_wininfo(window)->close)(window);
494         break;
495     }
496 }
497
498 static void mac_suspendresume(EventRecord *event)
499 {
500     WindowPtr front;
501     EventRecord fakeevent;
502
503     /*
504      * We're called either before we're suspended or after we're
505      * resumed, so we're the front application at this point.
506      */
507     front = FrontWindow();
508     if (front != NULL) {
509         fakeevent.what = activateEvt;
510         fakeevent.message = (UInt32)front;
511         fakeevent.when = event->when;
512         fakeevent.where = event->where;
513         fakeevent.modifiers =
514             (event->message & resumeFlag) ? activeFlag : 0;
515         mac_activatewindow(front, &fakeevent);
516     }
517 }
518
519 static void mac_zoomwindow(WindowPtr window, short part) {
520
521     /* FIXME: do something */
522 }
523
524 /*
525  * Make the menus look right before the user gets to see them.
526  */
527 #if TARGET_API_MAC_CARBON
528 #define EnableItem EnableMenuItem
529 #define DisableItem DisableMenuItem
530 #endif
531 static void mac_adjustmenus(void) {
532     WindowPtr window;
533     MenuHandle menu;
534
535     window = mac_frontwindow();
536     menu = GetMenuHandle(mApple);
537     EnableItem(menu, 0);
538     EnableItem(menu, iAbout);
539
540     menu = GetMenuHandle(mFile);
541     EnableItem(menu, 0);
542     EnableItem(menu, iNew);
543     if (window != NULL)
544         EnableItem(menu, iClose);
545     else
546         DisableItem(menu, iClose);
547     EnableItem(menu, iQuit);
548
549     if (window != NULL && mac_wininfo(window)->adjustmenus != NULL)
550         (*mac_wininfo(window)->adjustmenus)(window);
551     else {
552         DisableItem(menu, iSave);
553         DisableItem(menu, iSaveAs);
554         DisableItem(menu, iDuplicate);
555         menu = GetMenuHandle(mEdit);
556         DisableItem(menu, 0);
557         menu = GetMenuHandle(mWindow);
558         DisableItem(menu, 0); /* Until we get more than 1 item on it. */
559     }
560     DrawMenuBar();
561 }
562
563 /*
564  * Make sure the right cursor's being displayed.
565  */
566 static void mac_adjustcursor(RgnHandle cursrgn) {
567     Point mouse;
568     WindowPtr window, front;
569     short part;
570 #if TARGET_API_MAC_CARBON
571     Cursor arrow;
572     RgnHandle visrgn;
573 #endif
574
575     GetMouse(&mouse);
576     LocalToGlobal(&mouse);
577     part = FindWindow(mouse, &window);
578     front = FrontWindow();
579     if (part != inContent || window == NULL || window != front) {
580         /* Cursor isn't in the front window, so switch to arrow */
581 #if TARGET_API_MAC_CARBON
582         GetQDGlobalsArrow(&arrow);
583         SetCursor(&arrow);
584 #else
585         SetCursor(&qd.arrow);
586 #endif
587         SetRectRgn(cursrgn, SHRT_MIN, SHRT_MIN, SHRT_MAX, SHRT_MAX);
588         if (front != NULL) {
589 #if TARGET_API_MAC_CARBON
590             visrgn = NewRgn();
591             GetPortVisibleRegion(GetWindowPort(front), visrgn);
592             DiffRgn(cursrgn, visrgn, cursrgn);
593             DisposeRgn(visrgn);
594 #else
595             DiffRgn(cursrgn, front->visRgn, cursrgn);
596 #endif
597         }
598     } else {
599         if (mac_wininfo(window)->adjustcursor != NULL)
600             (*mac_wininfo(window)->adjustcursor)(window, mouse, cursrgn);
601         else {
602 #if TARGET_API_MAC_CARBON
603             GetQDGlobalsArrow(&arrow);
604             SetCursor(&arrow);
605             GetPortVisibleRegion(GetWindowPort(window), cursrgn);
606 #else
607             SetCursor(&qd.arrow);
608             CopyRgn(window->visRgn, cursrgn);
609 #endif
610         }
611     }
612 }
613
614 pascal OSErr mac_aevt_quit(const AppleEvent *req, AppleEvent *reply,
615                                   long refcon)
616 {
617     DescType type;
618     Size size;
619
620     if (AEGetAttributePtr(req, keyMissedKeywordAttr, typeWildCard,
621                           &type, NULL, 0, &size) == noErr)
622         return errAEParamMissed;
623
624     borednow = 1;
625     return noErr;
626 }
627
628 void cleanup_exit(int status)
629 {
630
631 #if !TARGET_RT_MAC_CFM
632     if (mac_gestalts.encvvers != 0)
633         TerminateUnicodeConverter();
634 #endif
635     sk_cleanup();
636     exit(status);
637 }
638
639 /* This should only kill the current session, not the whole application. */
640 void connection_fatal(void *fontend, char *fmt, ...) {
641     va_list ap;
642     Str255 stuff;
643     
644     va_start(ap, fmt);
645     /* We'd like stuff to be a Pascal string */
646     stuff[0] = vsprintf((char *)(&stuff[1]), fmt, ap);
647     va_end(ap);
648     ParamText(stuff, NULL, NULL, NULL);
649     StopAlert(128, NULL);
650     cleanup_exit(1);
651 }
652
653 /* Null SSH agent client -- never finds an agent. */
654
655 int agent_exists(void)
656 {
657
658     return FALSE;
659 }
660
661 void agent_query(void *in, int inlen, void **out, int *outlen)
662 {
663
664     *out = NULL;
665     *outlen = 0;
666 }
667
668 /* Temporary null routines for testing. */
669
670 /*
671  * FIXME: verify_ssh_host_key() should be passed a frontend handle,
672  * but backends have to have a terminal handle instead, because they
673  * pass it to from_backend(), so we accept a terminal handle here as
674  * well, and hope no-one tries to call us with sensible arguments.
675  */
676 void verify_ssh_host_key(void *frontend, char *host, int port, char *keytype,
677                          char *keystr, char *fingerprint)
678 {
679     Str255 stuff;
680     Terminal *term = frontend;
681     Session *s = term->frontend;
682
683     /*
684      * This function is horribly wrong.  For one thing, the alert
685      * shouldn't be modal, it should be movable modal, or a sheet in
686      * Aqua.  Also, PuTTY might be in the background, in which case we
687      * should use the Notification Manager to wake up the user.  In
688      * any case, we shouldn't hold up processing of other connections'
689      * data just because this one's waiting for the user.  It should
690      * also handle a host key cache, of course, and see the note above
691      * about the "frontend" argument and the one below about closing
692      * the connection.  All in all, a bit of a mess really.
693      */
694
695     stuff[0] = sprintf((char *)(&stuff[1]),
696                        "The server's key fingerprint is: %s\n"
697                        "Continue connecting?", fingerprint);
698     ParamText(stuff, NULL, NULL, NULL);
699     if (CautionAlert(wQuestion, NULL) == 2) {
700         /*
701          * User chose "Cancel".  Unfortunately, if I tear the
702          * connection down here, Bad Things happen when I return.  I
703          * think this function should actually return something
704          * telling the SSH code to abandon the connection.
705          */
706     }
707 }
708
709 void askcipher(void *frontend, char *ciphername, int cs)
710 {
711
712 }
713
714 void old_keyfile_warning(void)
715 {
716
717 }
718
719 FontSpec platform_default_fontspec(char const *name)
720 {
721     FontSpec ret;
722     long smfs;
723
724     if (!strcmp(name, "Font")) {
725         smfs = GetScriptVariable(smSystemScript, smScriptMonoFondSize);
726         if (smfs == 0)
727             smfs = GetScriptVariable(smRoman, smScriptMonoFondSize);
728         if (smfs != 0) {
729             GetFontName(HiWord(smfs), ret.name);
730             if (ret.name[0] == 0)
731                 memcpy(ret.name, "\pMonaco", 7);
732             ret.size = LoWord(smfs);
733         } else {
734             memcpy(ret.name, "\pMonaco", 7);
735             ret.size = 9;
736         }
737         ret.face = 0;
738     } else {
739         ret.name[0] = 0;
740     }
741
742     return ret;
743 }
744
745 Filename platform_default_filename(const char *name)
746 {
747     Filename ret;
748     if (!strcmp(name, "LogFileName"))
749         FSMakeFSSpec(0, 0, "\pputty.log", &ret.fss);
750     else
751         memset(&ret, 0, sizeof(ret));
752     return ret;
753 }
754
755 char *platform_default_s(char const *name)
756 {
757     return NULL;
758 }
759
760 int platform_default_i(char const *name, int def)
761 {
762
763     /* Non-raw cut and paste of line-drawing chars works badly on the
764      * current Unix stub implementation of the Unicode functions.
765      * So I'm going to temporarily set the default to raw mode so
766      * that the failure mode isn't quite so drastically horrid.
767      * When Unicode comes in, this can all be put right. */
768     if (!strcmp(name, "RawCNP"))
769         return 1;
770     return def;
771 }
772
773 void platform_get_x11_auth(char *display, int *proto,
774                            unsigned char *data, int *datalen)
775 {
776     /* SGT: I have no idea whether Mac X servers need anything here. */
777 }
778
779 /*
780  * Local Variables:
781  * c-file-style: "simon"
782  * End:
783  */