@@ -33,11 +33,11 @@ #endif #import "OFTCPSocket.h" #import "OFTCPSocket+SOCKS5.h" #import "OFString.h" -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS # import "OFThread.h" #endif #import "OFTimer.h" #import "OFRunLoop.h" @@ -57,11 +57,11 @@ #ifndef INVALID_SOCKET # define INVALID_SOCKET -1 #endif -#if defined(OF_THREADS) && !defined(HAVE_THREADSAFE_GETADDRINFO) +#if defined(OF_HAVE_THREADS) && !defined(HAVE_THREADSAFE_GETADDRINFO) # import "OFMutex.h" # import "OFDataArray.h" static OFMutex *mutex = nil; #endif @@ -79,11 +79,11 @@ Class of_tls_socket_class = Nil; static OFString *defaultSOCKS5Host = nil; static uint16_t defaultSOCKS5Port = 1080; -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS @interface OFTCPSocket_ConnectThread: OFThread { OFThread *sourceThread; OFTCPSocket *sock; OFString *host; @@ -214,11 +214,11 @@ } @end #endif @implementation OFTCPSocket -#if defined(OF_THREADS) && !defined(HAVE_THREADSAFE_GETADDRINFO) +#if defined(OF_HAVE_THREADS) && !defined(HAVE_THREADSAFE_GETADDRINFO) + (void)initialize { if (self == [OFTCPSocket class]) mutex = [[OFMutex alloc] init]; } @@ -342,20 +342,20 @@ #else BOOL connected = NO; struct hostent *he; struct sockaddr_in addr; char **ip; -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS OFDataArray *addrlist; addrlist = [[OFDataArray alloc] initWithItemSize: sizeof(char**)]; [mutex lock]; # endif if ((he = gethostbyname([host cStringWithEncoding: OF_STRING_ENCODING_NATIVE])) == NULL) { -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS [addrlist release]; [mutex unlock]; # endif @throw [OFAddressTranslationFailedException exceptionWithClass: [self class] @@ -367,11 +367,11 @@ addr.sin_family = AF_INET; addr.sin_port = OF_BSWAP16_IF_LE(port); if (he->h_addrtype != AF_INET || (sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) { -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS [addrlist release]; [mutex unlock]; # endif @throw [OFConnectionFailedException exceptionWithClass: [self class] @@ -378,11 +378,11 @@ socket: self host: host port: port]; } -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS @try { for (ip = he->h_addr_list; *ip != NULL; ip++) [addrlist addItem: ip]; /* Add the terminating NULL */ @@ -405,11 +405,11 @@ connected = YES; break; } -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS [addrlist release]; # endif if (!connected) { close(sock); @@ -427,11 +427,11 @@ if (SOCKS5Host != nil) [self OF_SOCKS5ConnectToHost: destinationHost port: destinationPort]; } -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS - (void)asyncConnectToHost: (OFString*)host port: (uint16_t)port target: (id)target selector: (SEL)selector { @@ -529,17 +529,17 @@ freeaddrinfo(res); #else struct hostent *he; -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS [mutex lock]; # endif if ((he = gethostbyname([host cStringWithEncoding: OF_STRING_ENCODING_NATIVE])) == NULL) { -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS [mutex unlock]; # endif @throw [OFAddressTranslationFailedException exceptionWithClass: [self class] socket: self @@ -549,11 +549,11 @@ memset(&addr, 0, sizeof(addr)); addr.in.sin_family = AF_INET; addr.in.sin_port = OF_BSWAP16_IF_LE(port); if (he->h_addrtype != AF_INET || he->h_addr_list[0] == NULL) { -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS [mutex unlock]; # endif @throw [OFAddressTranslationFailedException exceptionWithClass: [self class] socket: self @@ -560,11 +560,11 @@ host: host]; } memcpy(&addr.in.sin_addr.s_addr, he->h_addr_list[0], he->h_length); -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS [mutex unlock]; # endif if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) @throw [OFBindFailedException exceptionWithClass: [self class] socket: self @@ -703,11 +703,11 @@ encoding: OF_STRING_ENCODING_NATIVE]; } @finally { [self freeMemory: host]; } #else -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS [mutex lock]; @try { # endif host = inet_ntoa(((struct sockaddr_in*)sockAddr)->sin_addr); @@ -716,11 +716,11 @@ @throw [OFAddressTranslationFailedException exceptionWithClass: [self class]]; return [OFString stringWithCString: host encoding: OF_STRING_ENCODING_NATIVE]; -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS } @finally { [mutex unlock]; } # endif #endif