X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d84afea9d1ec41ee4e2ebb3bf6b87926cf5f04d1..1d3216f76d60e8382cac4503b12a02599b4323dc:/src/mac/carbon/gsocket.c diff --git a/src/mac/carbon/gsocket.c b/src/mac/carbon/gsocket.c index bbeaa29fcf..073d97c483 100644 --- a/src/mac/carbon/gsocket.c +++ b/src/mac/carbon/gsocket.c @@ -36,7 +36,7 @@ #include #include #endif -#if TARGET_CARBON +#if TARGET_CARBON && !defined(OTAssert) #define OTAssert( str , cond ) /* does not exists in Carbon */ #endif @@ -76,6 +76,13 @@ #endif /* __GSOCKET_STANDALONE__ */ +#ifndef ntohl +#define ntohl(x) (x) +#define ntohs(x) (x) +#define htonl(x) (x) +#define htons(x) (x) +#endif + void wxCYield() ; #ifdef __WXDEBUG__ #define qDebug 1 @@ -87,6 +94,7 @@ extern pascal void OTDebugStr(const char* str); #endif InetSvcRef gInetSvcRef = 0 ; int gOTInited = 0 ; +OTNotifyUPP gOTNotifierUPP = NULL ; OSStatus DoNegotiateIPReuseAddrOption(EndpointRef ep, Boolean enableReuseIPMode); @@ -185,7 +193,7 @@ static void SetDefaultEndpointModes(EndpointRef ep , void *data ) junk = OTSetBlocking(ep); OTAssert("SetDefaultEndpointModes: Could not set blocking", junk == noErr); */ - junk = OTInstallNotifier(ep, OTInetEventHandler, data); + junk = OTInstallNotifier(ep, gOTNotifierUPP, data); OTAssert("SetDefaultEndpointModes: Could not install notifier", junk == noErr); /* junk = OTUseSyncIdleEvents(ep, true); @@ -195,6 +203,11 @@ static void SetDefaultEndpointModes(EndpointRef ep , void *data ) /* Global initialisers */ +void GSocket_SetGUIFunctions(struct GSocketGUIFunctionsTable *table) +{ + // do nothing, wxMac doesn't have wxBase-GUI separation yet +} + int GSocket_Init() { return TRUE; @@ -229,6 +242,7 @@ int GSocket_Verify_Inited() OTAssert("Could not open Inet Services", err == noErr); return FALSE ; } + gOTNotifierUPP = NewOTNotifyUPP( OTInetEventHandler ) ; return TRUE ; } @@ -243,6 +257,8 @@ void GSocket_Cleanup() #else CloseOpenTransport() ; #endif + if ( gOTNotifierUPP ) + DisposeOTNotifyUPP( gOTNotifierUPP ) ; } } @@ -473,9 +489,6 @@ GAddress *GSocket_GetPeer(GSocket *socket) */ GSocketError GSocket_SetServer(GSocket *sck) { - int type; - int arg = 1; - assert(sck != NULL); /* must not be in use */ @@ -545,9 +558,6 @@ GSocketError GSocket_SetServer(GSocket *sck) GSocket *GSocket_WaitConnection(GSocket *socket) { GSocket *connection = NULL ; - GSocketError err; - - int arg = 1; assert(socket != NULL); @@ -640,8 +650,6 @@ GSocket *GSocket_WaitConnection(GSocket *socket) */ GSocketError GSocket_SetNonOriented(GSocket *sck) { - int arg = 1; - assert(sck != NULL); if (sck->m_endpoint != kOTInvalidEndpointRef ) @@ -726,12 +734,9 @@ GSocketError GSocket_SetNonOriented(GSocket *sck) */ GSocketError GSocket_Connect(GSocket *sck, GSocketStream stream) { - int ret; - int arg = 1; InetAddress addr ; TEndpointInfo info; - OTFlags flags = 0; - OSStatus err = kOTNoError; + OSStatus err = kOTNoError; TCall peer ; assert(sck != NULL); @@ -932,7 +937,6 @@ int GSocket_Write(GSocket *socket, const char *buffer, int size) */ GSocketEventFlags GSocket_Select(GSocket *socket, GSocketEventFlags flags) { - OTResult state ; assert(socket != NULL); wxMacProcessNotifierEvents() ; /* @@ -1079,7 +1083,7 @@ int _GSocket_Recv_Stream(GSocket *socket, char *buffer, int size) OTByteCount sz = 0 ; OTCountDataBytes( socket->m_endpoint , &sz ) ; - if ( size > sz ) + if ( size > (int)sz ) size = sz ; res = OTRcv( socket->m_endpoint , buffer , size , &flags ) ; if ( res < 0 ) @@ -1327,13 +1331,11 @@ GSocketError GAddress_INET_SetAnyAddress(GAddress *address) GSocketError GAddress_INET_SetHostAddress(GAddress *address, unsigned long hostaddr) { - struct in_addr *addr; - assert(address != NULL); CHECK_ADDRESS(address, INET, GSOCK_INVADDR); - address->m_host = hostaddr ; + address->m_host = htonl(hostaddr) ; return GSOCK_NOERROR; } @@ -1354,8 +1356,7 @@ service_entry gServices[] = GSocketError GAddress_INET_SetPortName(GAddress *address, const char *port, const char *protocol) { - InetAddress *addr; - int i ; + size_t i ; assert(address != NULL); CHECK_ADDRESS(address, INET, GSOCK_INVADDR); @@ -1389,8 +1390,6 @@ GSocketError GAddress_INET_SetPortName(GAddress *address, const char *port, GSocketError GAddress_INET_SetPort(GAddress *address, unsigned short port) { - InetAddress *addr; - assert(address != NULL); CHECK_ADDRESS(address, INET, GSOCK_INVADDR); address->m_port = port ; @@ -1417,7 +1416,7 @@ unsigned long GAddress_INET_GetHostAddress(GAddress *address) assert(address != NULL); CHECK_ADDRESS(address, INET, 0); - return address->m_host; + return ntohl(address->m_host); } unsigned short GAddress_INET_GetPort(GAddress *address)