]> asedeno.scripts.mit.edu Git - PuTTY.git/blob - mac/mac.c
Alert box to support host-key checking.
[PuTTY.git] / mac / mac.c
1 /* $Id: mac.c,v 1.54 2003/03/06 23:44:47 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     mac_adjustmenus();
200     DrawMenuBar();
201     InitCursor();
202     windows.about = NULL;
203     windows.licence = NULL;
204
205     default_protocol = be_default_protocol;
206     /* Find the appropriate default port. */
207     {
208         int i;
209         default_port = 0; /* illegal */
210         for (i = 0; backends[i].backend != NULL; i++)
211             if (backends[i].protocol == default_protocol) {
212                 default_port = backends[i].backend->default_port;
213                 break;
214             }
215     }
216     flags = FLAG_INTERACTIVE;
217
218 #if !TARGET_API_MAC_CARBON
219     {
220         short vol;
221         long dirid;
222
223         /* Set the default directory for loading and saving settings. */
224         /* XXX Should we create it? */
225         if (get_session_dir(FALSE, &vol, &dirid) == noErr) {
226             LMSetSFSaveDisk(-vol);
227             LMSetCurDirStore(dirid);
228         }
229     }
230 #endif
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     sleeptime = 0;
250     for (;;) {
251         mac_adjustcursor(cursrgn);
252         gotevent = WaitNextEvent(everyEvent, &event, sleeptime, cursrgn);
253         /*
254          * XXX For now, limit sleep time to 1/10 s to work around
255          * wake-before-sleep race in MacTCP code.
256          */
257         sleeptime = 6;
258         mac_adjustcursor(cursrgn);
259         if (gotevent) {
260             /* Ensure we get a null event when the real ones run out. */
261             sleeptime = 0;
262             mac_event(&event);
263             if (borednow)
264                 cleanup_exit(0);
265         }
266         sk_poll();
267         if (!gotevent)
268             mac_pollterm();
269     }
270     DisposeRgn(cursrgn);
271 }
272
273 static void mac_event(EventRecord *event) {
274     short part;
275     WindowPtr window;
276
277     switch (event->what) {
278       case mouseDown:
279         part = FindWindow(event->where, &window);
280         switch (part) {
281           case inMenuBar:
282             mac_adjustmenus();
283             mac_menucommand(MenuSelect(event->where));
284             break;
285 #if !TARGET_API_MAC_CARBON
286           case inSysWindow:
287             SystemClick(event, window);
288             break;
289 #endif
290           case inContent:
291             if (window != FrontWindow())
292                 /* XXX: check for movable modal dboxes? */
293                 SelectWindow(window);
294             else
295                 mac_contentclick(window, event);
296             break;
297           case inGoAway:
298             if (TrackGoAway(window, event->where))
299                 mac_closewindow(window);
300             break;
301           case inDrag:
302             /* XXX: moveable modal check? */
303 #if TARGET_API_MAC_CARBON
304             {
305                 BitMap screenBits;
306
307                 GetQDGlobalsScreenBits(&screenBits);
308                 DragWindow(window, event->where, &screenBits.bounds);
309             }
310 #else
311             DragWindow(window, event->where, &qd.screenBits.bounds);
312 #endif
313             break;
314           case inGrow:
315             mac_growwindow(window, event);
316             break;
317           case inZoomIn:
318           case inZoomOut:
319             if (TrackBox(window, event->where, part))
320                 mac_zoomwindow(window, part);
321             break;
322         }
323         break;
324       case keyDown:
325       case autoKey:
326         mac_keypress(event);
327         break;
328       case activateEvt:
329         mac_activatewindow((WindowPtr)event->message, event);
330         break;
331       case updateEvt:
332         mac_updatewindow((WindowPtr)event->message);
333         break;
334 #if !TARGET_API_MAC_CARBON
335       case diskEvt:
336         if (HiWord(event->message) != noErr) {
337             Point pt;
338
339             SetPt(&pt, 120, 120);
340             DIBadMount(pt, event->message);
341         }
342         break;
343 #endif
344       case osEvt:
345         switch ((event->message & osEvtMessageMask) >> 24) {
346           case suspendResumeMessage:
347             mac_suspendresume(event);
348             break;
349         }
350         break;
351       case kHighLevelEvent:
352         AEProcessAppleEvent(event); /* errors? */
353         break;
354     }
355 }
356
357 static void mac_contentclick(WindowPtr window, EventRecord *event)
358 {
359
360     if (mac_wininfo(window)->click != NULL)
361         (*mac_wininfo(window)->click)(window, event);
362 }
363
364 static void mac_growwindow(WindowPtr window, EventRecord *event)
365 {
366
367     if (mac_wininfo(window)->grow != NULL)
368         (*mac_wininfo(window)->grow)(window, event);
369 }
370
371 static void mac_activatewindow(WindowPtr window, EventRecord *event)
372 {
373
374     mac_adjustmenus();
375     if (mac_wininfo(window)->activate != NULL)
376         (*mac_wininfo(window)->activate)(window, event);
377 }
378
379 static void mac_updatewindow(WindowPtr window)
380 {
381
382     if (mac_wininfo(window)->update != NULL)
383         (*mac_wininfo(window)->update)(window);
384 }
385
386 /*
387  * Work out what kind of window we're dealing with.
388  */
389 static int mac_windowtype(WindowPtr window)
390 {
391
392 #if !TARGET_API_MAC_CARBON
393     if (GetWindowKind(window) < 0)
394         return wDA;
395 #endif
396     return ((WinInfo *)GetWRefCon(window))->wtype;
397 }
398
399 /*
400  * Handle a key press
401  */
402 static void mac_keypress(EventRecord *event) {
403     WindowPtr window;
404
405     window = mac_frontwindow();
406     /*
407      * Check for a command-key combination, but ignore it if it counts
408      * as a meta-key combination and we're in a terminal window.
409      */
410     if (event->what == keyDown && (event->modifiers & cmdKey) /*&&
411         !((event->modifiers & cfg.meta_modifiers) == cfg.meta_modifiers &&
412             mac_windowtype(window) == wTerminal)*/) {
413         mac_adjustmenus();
414         mac_menucommand(MenuKey(event->message & charCodeMask));
415     } else {
416         if (window != NULL && mac_wininfo(window)->key != NULL)
417             (*mac_wininfo(window)->key)(window, event);
418     }       
419 }
420
421 static void mac_menucommand(long result) {
422     short menu, item;
423     WindowPtr window;
424 #if !TARGET_API_MAC_CARBON
425     Str255 da;
426 #endif
427
428     menu = HiWord(result);
429     item = LoWord(result);
430     window = mac_frontwindow();
431     /* Things which do the same whatever window we're in. */
432     switch (menu) {
433       case mApple:
434         switch (item) {
435           case iAbout:
436             mac_openabout();
437             goto done;
438 #if !TARGET_API_MAC_CARBON
439           default:
440             GetMenuItemText(GetMenuHandle(mApple), item, da);
441             OpenDeskAcc(da);
442             goto done;
443 #endif
444         }
445         break;
446       case mFile:
447         switch (item) {
448           case iNew:
449             mac_newsession();
450             goto done;
451           case iOpen:
452             mac_opensession();
453             goto done;
454           case iClose:
455             mac_closewindow(window);
456             goto done;
457           case iSave:
458             mac_savesession();
459             goto done;
460           case iSaveAs:
461             mac_savesessionas();
462             goto done;
463           case iDuplicate:
464             mac_dupsession();
465             goto done;
466           case iQuit:
467             cleanup_exit(0);
468             goto done;
469         }
470         break;
471     }
472     /* If we get here, handling is up to window-specific code. */
473     if (window != NULL && mac_wininfo(window)->menu != NULL)
474         (*mac_wininfo(window)->menu)(window, menu, item);
475
476   done:
477     HiliteMenu(0);
478 }
479
480 static void mac_closewindow(WindowPtr window) {
481
482     switch (mac_windowtype(window)) {
483 #if !TARGET_API_MAC_CARBON
484       case wDA:
485         CloseDeskAcc(GetWindowKind(window));
486         break;
487 #endif
488       default:
489         if (mac_wininfo(window)->close != NULL)
490             (*mac_wininfo(window)->close)(window);
491         break;
492     }
493 }
494
495 static void mac_suspendresume(EventRecord *event)
496 {
497     WindowPtr front;
498     EventRecord fakeevent;
499
500     /*
501      * We're called either before we're suspended or after we're
502      * resumed, so we're the front application at this point.
503      */
504     front = FrontWindow();
505     if (front != NULL) {
506         fakeevent.what = activateEvt;
507         fakeevent.message = (UInt32)front;
508         fakeevent.when = event->when;
509         fakeevent.where = event->where;
510         fakeevent.modifiers =
511             (event->message & resumeFlag) ? activeFlag : 0;
512         mac_activatewindow(front, &fakeevent);
513     }
514 }
515
516 static void mac_zoomwindow(WindowPtr window, short part) {
517
518     /* FIXME: do something */
519 }
520
521 /*
522  * Make the menus look right before the user gets to see them.
523  */
524 #if TARGET_API_MAC_CARBON
525 #define EnableItem EnableMenuItem
526 #define DisableItem DisableMenuItem
527 #endif
528 static void mac_adjustmenus(void) {
529     WindowPtr window;
530     MenuHandle menu;
531
532     window = mac_frontwindow();
533     menu = GetMenuHandle(mApple);
534     EnableItem(menu, 0);
535     EnableItem(menu, iAbout);
536
537     menu = GetMenuHandle(mFile);
538     EnableItem(menu, 0);
539     EnableItem(menu, iNew);
540     if (window != NULL)
541         EnableItem(menu, iClose);
542     else
543         DisableItem(menu, iClose);
544     EnableItem(menu, iQuit);
545
546     if (window != NULL && mac_wininfo(window)->adjustmenus != NULL)
547         (*mac_wininfo(window)->adjustmenus)(window);
548     else {
549         DisableItem(menu, iSave);
550         DisableItem(menu, iSaveAs);
551         DisableItem(menu, iDuplicate);
552         menu = GetMenuHandle(mEdit);
553         DisableItem(menu, 0);
554         menu = GetMenuHandle(mWindow);
555         DisableItem(menu, 0); /* Until we get more than 1 item on it. */
556     }
557     DrawMenuBar();
558 }
559
560 /*
561  * Make sure the right cursor's being displayed.
562  */
563 static void mac_adjustcursor(RgnHandle cursrgn) {
564     Point mouse;
565     WindowPtr window, front;
566     short part;
567 #if TARGET_API_MAC_CARBON
568     Cursor arrow;
569     RgnHandle visrgn;
570 #endif
571
572     GetMouse(&mouse);
573     LocalToGlobal(&mouse);
574     part = FindWindow(mouse, &window);
575     front = FrontWindow();
576     if (part != inContent || window == NULL || window != front) {
577         /* Cursor isn't in the front window, so switch to arrow */
578 #if TARGET_API_MAC_CARBON
579         GetQDGlobalsArrow(&arrow);
580         SetCursor(&arrow);
581 #else
582         SetCursor(&qd.arrow);
583 #endif
584         SetRectRgn(cursrgn, SHRT_MIN, SHRT_MIN, SHRT_MAX, SHRT_MAX);
585         if (front != NULL) {
586 #if TARGET_API_MAC_CARBON
587             visrgn = NewRgn();
588             GetPortVisibleRegion(GetWindowPort(front), visrgn);
589             DiffRgn(cursrgn, visrgn, cursrgn);
590             DisposeRgn(visrgn);
591 #else
592             DiffRgn(cursrgn, front->visRgn, cursrgn);
593 #endif
594         }
595     } else {
596         if (mac_wininfo(window)->adjustcursor != NULL)
597             (*mac_wininfo(window)->adjustcursor)(window, mouse, cursrgn);
598         else {
599 #if TARGET_API_MAC_CARBON
600             GetQDGlobalsArrow(&arrow);
601             SetCursor(&arrow);
602             GetPortVisibleRegion(GetWindowPort(window), cursrgn);
603 #else
604             SetCursor(&qd.arrow);
605             CopyRgn(window->visRgn, cursrgn);
606 #endif
607         }
608     }
609 }
610
611 pascal OSErr mac_aevt_quit(const AppleEvent *req, AppleEvent *reply,
612                                   long refcon)
613 {
614     DescType type;
615     Size size;
616
617     if (AEGetAttributePtr(req, keyMissedKeywordAttr, typeWildCard,
618                           &type, NULL, 0, &size) == noErr)
619         return errAEParamMissed;
620
621     borednow = 1;
622     return noErr;
623 }
624
625 void cleanup_exit(int status)
626 {
627
628 #if !TARGET_RT_MAC_CFM
629     if (mac_gestalts.encvvers != 0)
630         TerminateUnicodeConverter();
631 #endif
632     sk_cleanup();
633     exit(status);
634 }
635
636 /* This should only kill the current session, not the whole application. */
637 void connection_fatal(void *fontend, char *fmt, ...) {
638     va_list ap;
639     Str255 stuff;
640     
641     va_start(ap, fmt);
642     /* We'd like stuff to be a Pascal string */
643     stuff[0] = vsprintf((char *)(&stuff[1]), fmt, ap);
644     va_end(ap);
645     ParamText(stuff, NULL, NULL, NULL);
646     StopAlert(128, NULL);
647     cleanup_exit(1);
648 }
649
650 /* Null SSH agent client -- never finds an agent. */
651
652 int agent_exists(void)
653 {
654
655     return FALSE;
656 }
657
658 void agent_query(void *in, int inlen, void **out, int *outlen)
659 {
660
661     *out = NULL;
662     *outlen = 0;
663 }
664
665 /* Temporary null routines for testing. */
666
667 /*
668  * FIXME: verify_ssh_host_key() should be passed a frontend handle,
669  * but backends have to have a terminal handle instead, because they
670  * pass it to from_backend(), so we accept a terminal handle here as
671  * well, and hope no-one tries to call us with sensible arguments.
672  */
673 void verify_ssh_host_key(void *frontend, char *host, int port, char *keytype,
674                          char *keystr, char *fingerprint)
675 {
676     Str255 stuff;
677     Terminal *term = frontend;
678     Session *s = term->frontend;
679
680     /*
681      * This function is horribly wrong.  For one thing, the alert
682      * shouldn't be modal, it should be movable modal, or a sheet in
683      * Aqua.  Also, PuTTY might be in the background, in which case we
684      * should use the Notification Manager to wake up the user.  In
685      * any case, we shouldn't hold up processing of other connections'
686      * data just because this one's waiting for the user.  It should
687      * also handle a host key cache, of course, and see the note above
688      * about the "frontend" argument and the one below about closing
689      * the connection.  All in all, a bit of a mess really.
690      */
691
692     stuff[0] = sprintf((char *)(&stuff[1]),
693                        "The server's key fingerprint is: %s\n"
694                        "Continue connecting?", fingerprint);
695     ParamText(stuff, NULL, NULL, NULL);
696     if (CautionAlert(wQuestion, NULL) == 2) {
697         /*
698          * User chose "Cancel".  Unfortunately, if I tear the
699          * connection down here, Bad Things happen when I return.  I
700          * think this function should actually return something
701          * telling the SSH code to abandon the connection.
702          */
703     }
704 }
705
706 void askcipher(void *frontend, char *ciphername, int cs)
707 {
708
709 }
710
711 void old_keyfile_warning(void)
712 {
713
714 }
715
716 FontSpec platform_default_fontspec(char const *name)
717 {
718     FontSpec ret;
719     long smfs;
720
721     if (!strcmp(name, "Font")) {
722         smfs = GetScriptVariable(smSystemScript, smScriptMonoFondSize);
723         if (smfs == 0)
724             smfs = GetScriptVariable(smRoman, smScriptMonoFondSize);
725         if (smfs != 0) {
726             GetFontName(HiWord(smfs), ret.name);
727             if (ret.name[0] == 0)
728                 memcpy(ret.name, "\pMonaco", 7);
729             ret.size = LoWord(smfs);
730         } else {
731             memcpy(ret.name, "\pMonaco", 7);
732             ret.size = 9;
733         }
734         ret.face = 0;
735     } else {
736         ret.name[0] = 0;
737     }
738
739     return ret;
740 }
741
742 Filename platform_default_filename(const char *name)
743 {
744     Filename ret;
745     if (!strcmp(name, "LogFileName"))
746         FSMakeFSSpec(0, 0, "\pputty.log", &ret.fss);
747     else
748         memset(&ret, 0, sizeof(ret));
749     return ret;
750 }
751
752 char *platform_default_s(char const *name)
753 {
754     return NULL;
755 }
756
757 int platform_default_i(char const *name, int def)
758 {
759
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
770 void 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
776 /*
777  * Local Variables:
778  * c-file-style: "simon"
779  * End:
780  */