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