X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/03e11df5470fd64d9d9a669d0b50b84c2d714736..8f0db49cd26130a7bc49816853ce832324ee85da:/src/mac/gsocket.c diff --git a/src/mac/gsocket.c b/src/mac/gsocket.c index 9a6a0596b1..20e4049f58 100644 --- a/src/mac/gsocket.c +++ b/src/mac/gsocket.c @@ -19,11 +19,8 @@ #if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) -#define OTUNIXERRORS 1 #ifdef __UNIX__ - #include - #include - #include + #include #ifndef FALSE #define FALSE 0 @@ -32,6 +29,7 @@ #define TRUE 1 #endif #else + #define OTUNIXERRORS 1 #include #include #include @@ -123,7 +121,11 @@ OSStatus DoNegotiateIPReuseAddrOption(EndpointRef ep, Boolean enableReuseIPMode) ret.opt.maxlen = kOTFourByteOptionSize; opt->level = INET_IP; // dealing with an IP Level function +#ifdef __UNIX__ + opt->name = kIP_REUSEADDR; +#else opt->name = IP_REUSEADDR; +#endif opt->len = kOTFourByteOptionSize; opt->status = 0; *(UInt32*)opt->value = enableReuseIPMode; // set the desired option level, true or false @@ -193,19 +195,25 @@ static void SetDefaultEndpointModes(EndpointRef ep , void *data ) int GSocket_Init() { - OSStatus err ; + OSStatus err ; #if TARGET_CARBON - InitOpenTransportInContext( kInitOTForApplicationMask , NULL ) ; + // Marc Newsam: added the clientcontext variable + // however, documentation is unclear how this works + OTClientContextPtr clientcontext; + + InitOpenTransportInContext(kInitOTForApplicationMask, &clientcontext); + gInetSvcRef = OTOpenInternetServicesInContext(kDefaultInternetServicesPath, + NULL, &err, clientcontext); #else - InitOpenTransport() ; + InitOpenTransport() ; + gInetSvcRef = OTOpenInternetServices(kDefaultInternetServicesPath, NULL, &err); #endif - gInetSvcRef = OTOpenInternetServices(kDefaultInternetServicesPath, NULL, &err); - if ( gInetSvcRef == NULL || err != kOTNoError ) - { - OTAssert("Could not open Inet Services", err == noErr); - return FALSE ; - } - return TRUE; + if ( gInetSvcRef == NULL || err != kOTNoError ) + { + OTAssert("Could not open Inet Services", err == noErr); + return FALSE ; + } + return TRUE; } void GSocket_Cleanup() @@ -1043,8 +1051,8 @@ int _GSocket_Recv_Stream(GSocket *socket, char *buffer, int size) { OTFlags flags ; OTResult res ; + OTByteCount sz = 0 ; - size_t sz = 0 ; OTCountDataBytes( socket->m_endpoint , &sz ) ; res = OTRcv( socket->m_endpoint , buffer , size , &flags ) ; if ( res < 0 ) @@ -1055,7 +1063,7 @@ int _GSocket_Recv_Stream(GSocket *socket, char *buffer, int size) // we simulate another read event if there are still bytes if ( socket->m_takesEvents ) { - size_t sz = 0 ; + OTByteCount sz = 0 ; OTCountDataBytes( socket->m_endpoint , &sz ) ; if ( sz > 0 ) { @@ -1365,7 +1373,7 @@ GSocketError GAddress_INET_GetHostName(GAddress *address, char *hostname, size_t assert(address != NULL); CHECK_ADDRESS(address, INET, GSOCK_INVADDR); - OTInetAddressToName( gInetSvcRef , address->m_host , &name ) ; + OTInetAddressToName( gInetSvcRef , address->m_host , name ) ; strncpy( hostname , name , sbuf ) ; return GSOCK_NOERROR; } @@ -1397,7 +1405,7 @@ void _GSocket_Enable_Events(GSocket *socket) state = OTGetEndpointState(socket->m_endpoint); { - size_t sz = 0 ; + OTByteCount sz = 0 ; OTCountDataBytes( socket->m_endpoint , &sz ) ; if ( state == T_INCON || sz > 0 ) { @@ -1437,7 +1445,7 @@ GSocketError _GSocket_Input_Timeout(GSocket *socket) while( (now.hi * 4294967296.0 + now.lo) - (start.hi * 4294967296.0 + start.lo) < socket->m_timeout * 1000.0 ) { OTResult state ; - size_t sz = 0 ; + OTByteCount sz = 0 ; state = OTGetEndpointState(socket->m_endpoint); OTCountDataBytes( socket->m_endpoint , &sz ) ;