ObjFW  Diff

Differences From Artifact [995314850c]:

To Artifact [92fa7c4194]:


30
31
32
33
34
35
36

37
38
39
40
41
42
43
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44







+







#ifdef OF_WINDOWS
# import "OFWindowsRegistryKey.h"
#endif

#import "OFInvalidFormatException.h"
#import "OFOpenItemFailedException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"

#ifdef OF_WINDOWS
# define interface struct
# include <iphlpapi.h>
# undef interface
#endif

67
68
69
70
71
72
73
74

75
76
77
78
79
80
81
68
69
70
71
72
73
74

75
76
77
78
79
80
81
82







-
+







#endif

#ifndef OF_WII
static OFString *
domainFromHostname(void)
{
	char hostname[256];
	OFString *domain;
	OFString *domain, *ret;

	if (gethostname(hostname, 256) != 0)
		return nil;

	domain = [OFString stringWithCString: hostname
				    encoding: [OFLocale encoding]];

90
91
92
93
94
95
96
97

98
99


100
101
102
103
104
105
106
91
92
93
94
95
96
97

98
99
100
101
102
103
104
105
106
107
108
109







-
+


+
+







	} @catch (OFInvalidFormatException *e) {
		/* Not an IP address -> we can use it if it contains a dot. */
		size_t pos = [domain rangeOfString: @"."].location;

		if (pos == OF_NOT_FOUND)
			return nil;

		return [domain substringWithRange:
		ret = [domain substringWithRange:
		    of_range(pos + 1, domain.length - pos - 1)];
	}

	return ret;
}
#endif

@implementation OFDNSResolverSettings
- (void)dealloc
{
	[_staticHosts release];
234
235
236
237
238
239
240


241
242

243



244

245
246
247
248
249
250

251


252
253

254



255

256
257
258
259
260

261
262
263
264
265
266
267
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252

253

254
255
256
257

258
259
260
261
262
263
264
265
266
267
268

269
270
271
272
273

274
275
276
277
278
279
280
281







+
+


+

+
+
+
-
+
-




-
+

+
+


+

+
+
+
-
+




-
+







}

# if !defined(OF_WINDOWS) && !defined(OF_AMIGAOS4)
- (void)parseResolvConfOption: (OFString *)option
{
	@try {
		if ([option hasPrefix: @"ndots:"]) {
			unsigned long long number;

			option = [option substringWithRange:
			    of_range(6, option.length - 6)];
			number = option.unsignedLongLongValue;

			if (number > UINT_MAX)
				@throw [OFOutOfRangeException exception];

			_minNumberOfDotsInAbsoluteName =
			_minNumberOfDotsInAbsoluteName = (unsigned int)number;
			    (unsigned int)option.decimalValue;
		} else if ([option hasPrefix: @"timeout:"]) {
			option = [option substringWithRange:
			    of_range(8, option.length - 8)];

			_timeout = option.decimalValue;
			_timeout = option.unsignedLongLongValue;
		} else if ([option hasPrefix: @"attempts:"]) {
			unsigned long long number;

			option = [option substringWithRange:
			    of_range(9, option.length - 9)];
			number = option.unsignedLongLongValue;

			if (number > UINT_MAX)
				@throw [OFOutOfRangeException exception];

			_maxAttempts = (unsigned int)option.decimalValue;
			_maxAttempts = (unsigned int)number;
		} else if ([option hasPrefix: @"reload-period:"]) {
			option = [option substringWithRange:
			    of_range(14, option.length - 14)];

			_configReloadInterval = option.decimalValue;
			_configReloadInterval = option.unsignedLongLongValue;
		} else if ([option isEqual: @"tcp"])
			_usesTCP = true;
	} @catch (OFInvalidFormatException *e) {
	}
}

- (void)parseResolvConf: (OFString *)path