ObjFW  Diff

Differences From Artifact [1037374b48]:

To Artifact [f6383b3c0c]:


55
56
57
58
59
60
61
62
63
64
65
66
67
68
69





70
71
72
73
74
75
76

of_resolver_result_t**
of_resolve_host(OFString *host, uint16_t port, int type)
{
	of_resolver_result_t **ret, **retIter;
	of_resolver_result_t *results, *resultsIter;
	size_t count;
#ifdef HAVE_THREADSAFE_GETADDRINFO
	struct addrinfo hints = { 0 }, *res, *res0;
	char portCString[7];

	hints.ai_family = AF_UNSPEC;
	hints.ai_socktype = type;
	hints.ai_flags = AI_NUMERICSERV;
	snprintf(portCString, 7, "%" PRIu16, port);






	if (getaddrinfo([host UTF8String], portCString, &hints, &res0))
		@throw [OFAddressTranslationFailedException
		    exceptionWithHost: host];

	count = 0;
	for (res = res0; res != NULL; res = res->ai_next)







|







>
>
>
>
>







55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

of_resolver_result_t**
of_resolve_host(OFString *host, uint16_t port, int type)
{
	of_resolver_result_t **ret, **retIter;
	of_resolver_result_t *results, *resultsIter;
	size_t count;
#ifdef HAVE_GETADDRINFO
	struct addrinfo hints = { 0 }, *res, *res0;
	char portCString[7];

	hints.ai_family = AF_UNSPEC;
	hints.ai_socktype = type;
	hints.ai_flags = AI_NUMERICSERV;
	snprintf(portCString, 7, "%" PRIu16, port);

# if !defined(HAVE_THREADSAFE_GETADDRINFO) && defined(OF_HAVE_THREADS)
	if (!of_mutex_lock(&mutex))
		@throw [OFLockFailedException exception];
# endif

	if (getaddrinfo([host UTF8String], portCString, &hints, &res0))
		@throw [OFAddressTranslationFailedException
		    exceptionWithHost: host];

	count = 0;
	for (res = res0; res != NULL; res = res->ai_next)
99
100
101
102
103
104
105





106
107
108
109
110
111
112
		resultsIter->addressLength = res->ai_addrlen;

		*retIter = resultsIter;
	}
	*retIter = NULL;

	ret[0]->private_ = res0;





#else
	struct hostent *he;
	in_addr_t s_addr;
	char **ip;
	struct sockaddr_in *addrs, *addrsIter;

	/*







>
>
>
>
>







104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
		resultsIter->addressLength = res->ai_addrlen;

		*retIter = resultsIter;
	}
	*retIter = NULL;

	ret[0]->private_ = res0;

# if !defined(HAVE_THREADSAFE_GETADDRINFO) && defined(OF_HAVE_THREADS)
	if (!of_mutex_unlock(&mutex))
		@throw [OFUnlockFailedException exception];
# endif
#else
	struct hostent *he;
	in_addr_t s_addr;
	char **ip;
	struct sockaddr_in *addrs, *addrsIter;

	/*