ObjFW  Diff

Differences From Artifact [94502fce5f]:

To Artifact [27f5b4db4d]:


62
63
64
65
66
67
68




69
70
71
72
73
74
75
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79







+
+
+
+







#elif defined(OF_AMIGAOS)
# define HOSTS_PATH @"AmiTCP:db/hosts"
# define RESOLV_CONF_PATH @"AmiTCP:db/resolv.conf"
#else
# define HOSTS_PATH @"/etc/hosts"
# define RESOLV_CONF_PATH @"/etc/resolv.conf"
#endif

#ifndef HOST_NAME_MAX
# define HOST_NAME_MAX 255
#endif

#ifndef OF_WII
static OFString *
domainFromHostname(OFString *hostname)
{
	OFString *ret;

98
99
100
101
102
103
104
105

106
107

108
109
110
111
112
113
114
102
103
104
105
106
107
108

109
110

111
112
113
114
115
116
117
118







-
+

-
+







}
#endif

#if !defined(OF_WII) && !defined(OF_MORPHOS)
static OFString *
obtainHostname(void)
{
	char hostname[256];
	char hostname[HOST_NAME_MAX + 1];

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

	return [OFString stringWithCString: hostname
				  encoding: [OFLocale encoding]];
}
#endif

174
175
176
177
178
179
180
181

182
183
184
185
186
187
188
178
179
180
181
182
183
184

185
186
187
188
189
190
191
192







-
+








static OFArray OF_GENERIC(OFString *) *
parseNetStackArray(OFString *string)
{
	if (![string hasPrefix: @"["] || ![string hasSuffix: @"]"])
		return nil;

	string = [string substringWithRange: OFRangeMake(1, string.length - 2)];
	string = [string substringWithRange: OFMakeRange(1, string.length - 2)];

	return [string componentsSeparatedByString: @"|"];
}
#endif

@implementation OFDNSResolverSettings
- (void)dealloc
278
279
280
281
282
283
284
285

286
287
288
289
290
291
292
282
283
284
285
286
287
288

289
290
291
292
293
294
295
296







-
+







		    options: OFStringSkipEmptyComponents];

		if (components.count < 2)
			continue;

		address = components.firstObject;
		hosts = [components objectsInRange:
		    OFRangeMake(1, components.count - 1)];
		    OFMakeRange(1, components.count - 1)];

		for (OFString *host in hosts) {
			OFMutableArray *addresses =
			    [staticHosts objectForKey: host];

			if (addresses == nil) {
				addresses = [OFMutableArray array];
381
382
383
384
385
386
387
388

389
390
391
392
393
394
395
385
386
387
388
389
390
391

392
393
394
395
396
397
398
399







-
+







		if (components.count < 2) {
			objc_autoreleasePoolPop(pool2);
			continue;
		}

		option = components.firstObject;
		arguments = [components objectsInRange:
		    OFRangeMake(1, components.count - 1)];
		    OFMakeRange(1, components.count - 1)];

		if ([option isEqual: @"nameserver"]) {
			if (arguments.count != 1) {
				objc_autoreleasePoolPop(pool2);
				continue;
			}

480
481
482
483
484
485
486
487

488
489
490
491
492
493
494
484
485
486
487
488
489
490

491
492
493
494
495
496
497
498







-
+







		OFArray *hosts;

		if (components.count < 2)
			continue;

		address = components.firstObject;
		hosts = [components objectsInRange:
		    OFRangeMake(1, components.count - 1)];
		    OFMakeRange(1, components.count - 1)];

		for (OFString *host in hosts) {
			OFMutableArray *addresses =
			    [staticHosts objectForKey: host];

			if (addresses == nil) {
				addresses = [OFMutableArray array];
615
616
617
618
619
620
621
622


623
624
625
626
627
628
629
619
620
621
622
623
624
625

626
627
628
629
630
631
632
633
634







-
+
+







	[self setDefaults];

#if defined(OF_WINDOWS)
# ifdef OF_HAVE_FILES
	OFWindowsRegistryKey *key = [[OFWindowsRegistryKey localMachineKey]
		   openSubkeyAtPath: @"SYSTEM\\CurrentControlSet\\Services\\"
				     @"Tcpip\\Parameters"
	    securityAndAccessRights: KEY_QUERY_VALUE];
		       accessRights: KEY_QUERY_VALUE
			    options: 0];
	path = [[[key stringForValueNamed: @"DataBasePath"]
	    stringByAppendingPathComponent: @"hosts"]
	    stringByExpandingWindowsEnvironmentStrings];

	if (path != nil)
		[self parseHosts: path];
# endif