@@ -252,88 +252,10 @@ #endif return ret; } -void -of_address_to_string_and_port(struct sockaddr *address, socklen_t addressLength, - OFString *__autoreleasing *host, uint16_t *port) -{ -#ifdef HAVE_GETADDRINFO - char hostCString[NI_MAXHOST]; - char portCString[NI_MAXSERV]; - -# if !defined(HAVE_THREADSAFE_GETADDRINFO) && defined(OF_HAVE_THREADS) - if (!of_mutex_lock(&mutex)) - @throw [OFLockFailedException exception]; - - @try { -# endif - int error; - - /* FIXME: Add NI_DGRAM for UDP? */ - if ((error = getnameinfo(address, addressLength, hostCString, - NI_MAXHOST, portCString, NI_MAXSERV, - NI_NUMERICHOST | NI_NUMERICSERV)) != 0) - @throw [OFAddressTranslationFailedException - exceptionWithError: error]; - - if (host != NULL) - *host = [OFString stringWithUTF8String: hostCString]; - - if (port != NULL) { - char *endptr; - long tmp; - - if ((tmp = strtol(portCString, &endptr, 10)) > - UINT16_MAX) - @throw [OFOutOfRangeException exception]; - - if (endptr != NULL && *endptr != '\0') - @throw [OFAddressTranslationFailedException - exception]; - - *port = (uint16_t)tmp; - } -# if !defined(HAVE_THREADSAFE_GETADDRINFO) && defined(OF_HAVE_THREADS) - } @finally { - if (!of_mutex_unlock(&mutex)) - @throw [OFUnlockFailedException exception]; - } -# endif -#else - char *hostCString; - - if (address->sa_family != AF_INET) - @throw [OFInvalidArgumentException exception]; - -# if OF_HAVE_THREADS - if (!of_mutex_lock(&mutex)) - @throw [OFLockFailedException exception]; - - @try { -# endif - if ((hostCString = inet_ntoa( - ((struct sockaddr_in *)(void *)address)->sin_addr)) == NULL) - @throw [OFAddressTranslationFailedException - exceptionWithError: h_errno]; - - if (host != NULL) - *host = [OFString stringWithUTF8String: hostCString]; - - if (port != NULL) - *port = OF_BSWAP16_IF_LE( - ((struct sockaddr_in *)(void *)address)->sin_port); -# if OF_HAVE_THREADS - } @finally { - if (!of_mutex_unlock(&mutex)) - @throw [OFUnlockFailedException exception]; - } -# endif -#endif -} - void of_resolver_free(of_resolver_result_t **results) { #ifdef HAVE_GETADDRINFO freeaddrinfo(results[0]->private_);