ObjXMPP  Diff

Differences From Artifact [dde19bea60]:

To Artifact [54b7d6a8f6]:


21
22
23
24
25
26
27


28
29
30
31
32
33
34
 * POSSIBILITY OF SUCH DAMAGE.
 */

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif



#include <assert.h>

#include <arpa/inet.h>
#include <netdb.h>
#include <sys/types.h>
#include <openssl/rand.h>








>
>







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 * POSSIBILITY OF SUCH DAMAGE.
 */

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <stdlib.h>

#include <assert.h>

#include <arpa/inet.h>
#include <netdb.h>
#include <sys/types.h>
#include <openssl/rand.h>

51
52
53
54
55
56
57

58

59
60

61

62
63
64
65
66
67
68
{
	return [[[self alloc] initWithResourceRecord: resourceRecord
					      handle: handle] autorelease];
}

- init
{

	Class c = [self class];

	[self release];
	@throw [OFNotImplementedException exceptionWithClass: c

						    selector: _cmd];

}

- initWithPriority: (uint16_t)priority
	    weight: (uint16_t)weight
	      port: (uint16_t)port
	    target: (OFString*)target
{







>
|
>
|
|
>
|
>







53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
{
	return [[[self alloc] initWithResourceRecord: resourceRecord
					      handle: handle] autorelease];
}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithPriority: (uint16_t)priority
	    weight: (uint16_t)weight
	      port: (uint16_t)port
	    target: (OFString*)target
{
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
	@try {
		int answerLen, resourceRecordCount, i;
		ns_rr resourceRecord;
		ns_msg handle;

		if (res_ninit(&_resState))
			@throw [OFAddressTranslationFailedException
			    exceptionWithClass: [self class]
					socket: nil
					  host: _domain];

		answer = [self allocMemoryWithSize: pageSize];
		answerLen = res_nsearch(&_resState,
		    [request cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
		    ns_c_in, ns_t_srv, answer, (int)pageSize);

		if ((answerLen == -1) && ((h_errno == HOST_NOT_FOUND) ||
		    (h_errno == NO_DATA)))
			return;

		if (answerLen < 1 || answerLen > pageSize) {
			@throw [OFAddressTranslationFailedException
			    exceptionWithClass: [self class]
					socket: nil
					  host: _domain];
		}

		if (ns_initparse(answer, answerLen, &handle))
			@throw [OFAddressTranslationFailedException
			    exceptionWithClass: [self class]
					socket: nil
					  host: _domain];

		resourceRecordCount = ns_msg_count(handle, ns_s_an);
		for (i = 0; i < resourceRecordCount; i++) {
			if (ns_parserr(&handle, ns_s_an, i, &resourceRecord))
				continue;

			if (ns_rr_type(resourceRecord) != ns_t_srv ||







<
<
|










|

<
<
|
<



<
<
|







210
211
212
213
214
215
216


217
218
219
220
221
222
223
224
225
226
227
228
229


230

231
232
233


234
235
236
237
238
239
240
241
	@try {
		int answerLen, resourceRecordCount, i;
		ns_rr resourceRecord;
		ns_msg handle;

		if (res_ninit(&_resState))
			@throw [OFAddressTranslationFailedException


			    exceptionWithHost: _domain];

		answer = [self allocMemoryWithSize: pageSize];
		answerLen = res_nsearch(&_resState,
		    [request cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
		    ns_c_in, ns_t_srv, answer, (int)pageSize);

		if ((answerLen == -1) && ((h_errno == HOST_NOT_FOUND) ||
		    (h_errno == NO_DATA)))
			return;

		if (answerLen < 1 || answerLen > pageSize)
			@throw [OFAddressTranslationFailedException


			    exceptionWithHost: _domain];


		if (ns_initparse(answer, answerLen, &handle))
			@throw [OFAddressTranslationFailedException


			    exceptionWithHost: _domain];

		resourceRecordCount = ns_msg_count(handle, ns_s_an);
		for (i = 0; i < resourceRecordCount; i++) {
			if (ns_parserr(&handle, ns_s_an, i, &resourceRecord))
				continue;

			if (ns_rr_type(resourceRecord) != ns_t_srv ||