ObjXMPP  Check-in [0ef261ea0e]

Overview
Comment:Adjust to ObjFW changes
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 0ef261ea0eb8a6c6a6cfa8330dd3a464ef5b100b50c57bb874377e63ea0559eb
User & Date: js on 2015-01-05 21:50:58
Other Links: manifest | tags
Context
2015-05-24
19:42
Adjust to new ObjOpenSSL check-in: d23ac2b580 user: js tags: trunk
2015-01-05
21:50
Adjust to ObjFW changes check-in: 0ef261ea0e user: js tags: trunk
2014-06-18
11:24
Update buildsys check-in: f43f54ba69 user: js tags: trunk
Changes

Modified src/XMPPSRVLookup.m from [bc94aa9c37] to [890298a587].

1

2

3
4
5
6
7
8
9
1
2

3
4
5
6
7
8
9
10

+
-
+







/*
 * Copyright (c) 2011, 2012, 2013, 2014, 2015
 * Copyright (c) 2011, Jonathan Schleifer <js@webkeks.org>
 *     Jonathan Schleifer <js@webkeks.org>
 * Copyright (c) 2011, Florian Zeitz <florob@babelmonkeys.de>
 *
 * https://webkeks.org/git/?p=objxmpp.git
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice is present in all copies.
31
32
33
34
35
36
37


38
39
40
41
42
43
44
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47







+
+








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

#import "XMPPSRVLookup.h"

#import <ObjFW/OFSystemInfo.h>

@implementation XMPPSRVEntry
+ (instancetype)entryWithPriority: (uint16_t)priority
			   weight: (uint16_t)weight
			     port: (uint16_t)port
			   target: (OFString*)target
{
104
105
106
107
108
109
110
111

112
113
114
115
116
117
118
107
108
109
110
111
112
113

114
115
116
117
118
119
120
121







-
+







		if (dn_expand(ns_msg_base(handle), ns_msg_end(handle),
		    (uint8_t*)&rdata[3], buffer, NS_MAXDNAME) < 1)
			@throw [OFInitializationFailedException
			    exceptionWithClass: [self class]];

		_target = [[OFString alloc]
		    initWithCString: buffer
			   encoding: [OFString nativeOSEncoding]];
			   encoding: [OFSystemInfo native8BitEncoding]];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}
213
214
215
216
217
218
219
220
221


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


223
224
225
226
227
228
229
230
231







-
-
+
+







		ns_msg handle;

		if (res_ninit(&_resState))
			@throw [OFAddressTranslationFailedException
			    exceptionWithHost: _domain];

		answer = [self allocMemoryWithSize: pageSize];
		answerLen = res_nsearch(&_resState,
		    [request cStringWithEncoding: [OFString nativeOSEncoding]],
		answerLen = res_nsearch(&_resState, [request
		    cStringWithEncoding: [OFSystemInfo native8BitEncoding]],
		    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)
260
261
262
263
264
265
266


267

268
269
270
271
272
273
274
275
276
277
278
279
280
281

282
283
284
285
286
287
288
263
264
265
266
267
268
269
270
271

272
273
274
275
276
277
278
279
280
281
282
283
284
285

286
287
288
289
290
291
292
293







+
+
-
+













-
+







{
	OFAutoreleasePool *pool;
	OFList *subList;
	of_list_object_t *iter;

	/* Look if there already is a list with the priority */
	for (iter = [_list firstListObject]; iter != NULL; iter = iter->next) {
		XMPPSRVEntry *first = [iter->object firstObject];

		if ([[iter->object firstObject] priority] == [entry priority]) {
		if ([first priority] == [entry priority]) {
			/*
			 * RFC 2782 says those with weight 0 should be at the
			 * beginning of the list.
			 */
			if ([entry weight] > 0)
				[iter->object appendObject: entry];
			else
				[iter->object prependObject: entry];

			return;
		}

		/* We can't have one if the priority is already bigger */
		if ([[iter->object firstObject] priority] > [entry priority])
		if ([first priority] > [entry priority])
			break;
	}

	pool = [[OFAutoreleasePool alloc] init];

	subList = [OFList list];
	[subList appendObject: entry];