diff --git a/Makefile.mpw b/Makefile.mpw index b08c1789..5a8eb61a 100644 --- a/Makefile.mpw +++ b/Makefile.mpw @@ -1,4 +1,4 @@ -# $Id: Makefile.mpw,v 1.1.2.12 1999/04/04 18:23:33 ben Exp $ +# $Id: Makefile.mpw,v 1.1.2.13 1999/08/02 08:04:31 ben Exp $ # This is the Makefile for building PuTTY for the Mac OS. # Users of non-Mac systems will see some pretty strange characters around. @@ -16,9 +16,10 @@ Objects dnr.c.o ¶ mac.c.o ¶ maccfg.c.o ¶ - macnet.c.o ¶ +# macnet.c.o ¶ macterm.c.o ¶ misc.c.o ¶ + opentpt.c.o ¶ # ssh.c.o ¶ # sshcrc.c.o ¶ # sshdes.c.o ¶ @@ -37,6 +38,7 @@ Objects macnet.c.x ¶ macterm.c.x ¶ misc.c.x ¶ + opentpt.c.x ¶ # ssh.c.x ¶ # sshcrc.c.x ¶ # sshdes.c.x ¶ @@ -52,14 +54,31 @@ Objects Libs¥68K = "{CLibraries}StdCLib.o" ¶ "{Libraries}MacRuntime.o" ¶ "{Libraries}IntEnv.o" ¶ - "{Libraries}Interface.o" + "{Libraries}Interface.o" ¶ + "{Libraries}OpenTransport.o" ¶ + "{Libraries}OpenTptInet.o" Libs¥PPC = "{SharedLibraries}InterfaceLib" ¶ "{SharedLibraries}StdCLib" ¶ "{SharedLibraries}MathLib" ¶ - "{SharedLibraries}AppearanceLib" -weaklib AppearanceLib ¶ + "{SharedLibraries}AppearanceLib" ¶ + -weaklib AppearanceLib ¶ + "{SharedLibraries}OpenTransportLib" ¶ + -weaklib OTGlobalLib ¶ + -weaklib OTUtilityLib ¶ + -weaklib OTClientUtilLib ¶ + -weaklib OTClientLib ¶ + -weaklib OTStreamUnixLib ¶ + -weaklib OTXTILib ¶ + -weaklib OTConfigLib ¶ + -weaklib OTNtvUtilLib ¶ + -weaklib OTNativeClientLib ¶ + "{SharedLibraries}OpenTptInternetLib" ¶ + -weaklib OTInetClientLib ¶ "{PPCLibraries}StdCRuntime.o" ¶ - "{PPCLibraries}PPCCRuntime.o" + "{PPCLibraries}PPCCRuntime.o" ¶ + "{PPCLibraries}OpenTransportAppPPC.o" ¶ + "{PPCLibraries}OpenTptInetPPC.o" # pseudo-targets all Ä 68k ppc fat @@ -130,6 +149,7 @@ maccfg.c.o maccfg.c.x macnet.c.o macnet.c.x Ä putty.h macterm.c.o macterm.c.x Ä putty.h mac.h misc.c.o misc.c.x Ä putty.h +opentpt.c.o opentpt.c.x Ä putty.h mac.h ssh.c.o ssh.c.x Ä putty.h ssh.h sshcrc.c.o sshcrc.c.x Ä sshdes.c.o sshdes.c.x Ä ssh.h diff --git a/mac.c b/mac.c index 2d43626e..6de37685 100644 --- a/mac.c +++ b/mac.c @@ -1,4 +1,4 @@ -/* $Id: mac.c,v 1.1.2.24 1999/04/04 18:23:33 ben Exp $ */ +/* $Id: mac.c,v 1.1.2.25 1999/08/02 08:04:31 ben Exp $ */ /* * Copyright (c) 1999 Ben Harris * All rights reserved. @@ -145,6 +145,22 @@ static void mac_startup(void) { InitCursor(); windows.about = NULL; windows.licence = NULL; + + /* Initialise networking */ +#ifdef WITH_OPENTRANSPORT + if ((*opentpt_stack.init)() == 0) + net_stack = &opentpt_stack; + else +#endif +#ifdef WITH_MACTCP + if ((*mactcp_stack.init)() == 0) + net_stack = &mactcp_stack; + else +#endif + fatalbox("No useful TCP/IP stack found"); + + + } static void mac_eventloop(void) { @@ -159,7 +175,7 @@ static void mac_eventloop(void) { mac_adjustcursor(cursrgn); if (gotevent) mac_event(&event); - macnet_eventcheck(); + net_poll(); } DisposeRgn(cursrgn); } @@ -494,6 +510,7 @@ static void mac_adjustcursor(RgnHandle cursrgn) { static void mac_shutdown(void) { + net_shutdown(); exit(0); } diff --git a/putty.h b/putty.h index 5b5aa17f..0ddcb2fc 100644 --- a/putty.h +++ b/putty.h @@ -111,7 +111,7 @@ typedef enum { } Net_Event_Type; #ifdef macintosh -typedef Socket *SOCKET; +typedef void *SOCKET; #define INVALID_SOCKET NULL #endif @@ -124,6 +124,29 @@ typedef struct { void (*shutdown) (Session *); } Backend; +#ifdef macintosh +typedef struct { + int (*init)(void); + SOCKET (*open)(Session *, char const *, int); + int (*recv)(SOCKET, void *, int, int); + int (*send)(SOCKET, void *, int, int); + void (*poll)(void); + void (*close)(SOCKET); + void (*destroy)(SOCKET); + void (*shutdown)(void); +} Network_Stack; + +GLOBAL Network_Stack *net_stack; + +#define net_open(s, h, p) ((*net_stack->open)((s), (h), (p))) +#define net_recv(s, b, l, f) ((*net_stack->recv)((s), (b), (l), (f))) +#define net_send(s, b, l, f) ((*net_stack->send)((s), (b), (l), (f))) +#define net_poll() ((*net_stack->poll)()) +#define net_close(s) ((*net_stack->close)(s)) +#define net_destroy(s) ((*net_stack->destroy)(s)) +#define net_shutdown() ((*net_stack->shutdown)()) +#endif + typedef struct { /* Basic options */ char host[512]; @@ -300,14 +323,17 @@ extern void lognegot(const char *); * Exports from the network system */ +#ifndef macintosh extern Socket *net_open(Session *, char *host, int port); extern char *net_realname(Socket *); extern int net_recv(Socket *, void *, int, int); extern int net_send(Socket *, void *, int, int); -#define SEND_PUSH 0x01 -#define SEND_URG 0x02 extern void net_close(Socket *); /* ask the remote end to close */ extern void net_destroy(Socket *); /* Tidy up */ +#endif +#define SEND_PUSH 0x01 +#define SEND_URG 0x02 + /* * Exports from noise.c. diff --git a/testback.c b/testback.c index a0fcbf5a..b5299a47 100644 --- a/testback.c +++ b/testback.c @@ -1,4 +1,4 @@ -/* $Id: testback.c,v 1.1.2.6 1999/04/04 18:23:35 ben Exp $ */ +/* $Id: testback.c,v 1.1.2.7 1999/08/02 08:04:31 ben Exp $ */ /* * Copyright (c) 1999 Simon Tatham * Copyright (c) 1999 Ben Harris @@ -34,7 +34,7 @@ #include "putty.h" static char *null_init(Session *); -static int null_msg(Session *, Socket *, Net_Event_Type); +static int null_msg(Session *, SOCKET, Net_Event_Type); static void null_send(Session *, char *, int); static void loop_send(Session *, char *, int); static void hexdump_send(Session *, char *, int); @@ -58,7 +58,7 @@ static char *null_init(Session *s) { return NULL; } -static int null_msg(Session *s, Socket *sock, Net_Event_Type ne) { +static int null_msg(Session *s, SOCKET sock, Net_Event_Type ne) { return 1; }