ObjFW  Diff

Differences From Artifact [e5254d8f80]:

To Artifact [1e35fdb00e]:


49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
OF_CONSTRUCTOR()
{
	if (!of_mutex_new(&mutex))
		@throw [OFInitializationFailedException exception];
}
#endif

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;







|







49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
OF_CONSTRUCTOR()
{
	if (!of_mutex_new(&mutex))
		@throw [OFInitializationFailedException exception];
}
#endif

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;
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
			addr->sin_family = AF_INET;
			addr->sin_port = OF_BSWAP16_IF_LE(port);
			addr->sin_addr.s_addr = s_addr;

			tmp->family = AF_INET;
			tmp->type = type;
			tmp->protocol = 0;
			tmp->address = (struct sockaddr*)addr;
#ifndef OF_WII
			tmp->addressLength = sizeof(*addr);
#else
			tmp->addressLength = 8;
#endif

			ret[0] = tmp;







|







171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
			addr->sin_family = AF_INET;
			addr->sin_port = OF_BSWAP16_IF_LE(port);
			addr->sin_addr.s_addr = s_addr;

			tmp->family = AF_INET;
			tmp->type = type;
			tmp->protocol = 0;
			tmp->address = (struct sockaddr *)addr;
#ifndef OF_WII
			tmp->addressLength = sizeof(*addr);
#else
			tmp->addressLength = 8;
#endif

			ret[0] = tmp;
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
				@throw [OFOutOfRangeException exception];

			memcpy(&addrsIter->sin_addr.s_addr, *ip, he->h_length);

			resultsIter->family = he->h_addrtype;
			resultsIter->type = type;
			resultsIter->protocol = 0;
			resultsIter->address = (struct sockaddr*)addrsIter;
			resultsIter->addressLength = sizeof(*addrsIter);

			*retIter = resultsIter;
		}
# ifdef OF_HAVE_THREADS
	} @finally {
		if (!of_mutex_unlock(&mutex))







|







231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
				@throw [OFOutOfRangeException exception];

			memcpy(&addrsIter->sin_addr.s_addr, *ip, he->h_length);

			resultsIter->family = he->h_addrtype;
			resultsIter->type = type;
			resultsIter->protocol = 0;
			resultsIter->address = (struct sockaddr *)addrsIter;
			resultsIter->addressLength = sizeof(*addrsIter);

			*retIter = resultsIter;
		}
# ifdef OF_HAVE_THREADS
	} @finally {
		if (!of_mutex_unlock(&mutex))
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
# 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







|








|







306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
# 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