30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#ifdef OF_WINDOWS
# import "OFWindowsRegistryKey.h"
#endif
#import "OFInvalidFormatException.h"
#import "OFOpenItemFailedException.h"
#import "OFOutOfMemoryException.h"
#ifdef OF_WINDOWS
# define interface struct
# include <iphlpapi.h>
# undef interface
#endif
|
>
|
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
|
#endif
#ifndef OF_WII
static OFString *
domainFromHostname(void)
{
char hostname[256];
OFString *domain;
if (gethostname(hostname, 256) != 0)
return nil;
domain = [OFString stringWithCString: hostname
encoding: [OFLocale encoding]];
|
|
|
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, *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
|
} @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:
of_range(pos + 1, domain.length - pos - 1)];
}
}
#endif
@implementation OFDNSResolverSettings
- (void)dealloc
{
[_staticHosts release];
|
|
>
>
|
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;
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
|
}
# if !defined(OF_WINDOWS) && !defined(OF_AMIGAOS4)
- (void)parseResolvConfOption: (OFString *)option
{
@try {
if ([option hasPrefix: @"ndots:"]) {
option = [option substringWithRange:
of_range(6, option.length - 6)];
_minNumberOfDotsInAbsoluteName =
(unsigned int)option.decimalValue;
} else if ([option hasPrefix: @"timeout:"]) {
option = [option substringWithRange:
of_range(8, option.length - 8)];
_timeout = option.decimalValue;
} else if ([option hasPrefix: @"attempts:"]) {
option = [option substringWithRange:
of_range(9, option.length - 9)];
_maxAttempts = (unsigned int)option.decimalValue;
} else if ([option hasPrefix: @"reload-period:"]) {
option = [option substringWithRange:
of_range(14, option.length - 14)];
_configReloadInterval = option.decimalValue;
} else if ([option isEqual: @"tcp"])
_usesTCP = true;
} @catch (OFInvalidFormatException *e) {
}
}
- (void)parseResolvConf: (OFString *)path
|
>
>
>
>
>
>
|
<
|
>
>
>
>
>
>
|
|
|
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 = (unsigned int)number;
} else if ([option hasPrefix: @"timeout:"]) {
option = [option substringWithRange:
of_range(8, option.length - 8)];
_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)number;
} else if ([option hasPrefix: @"reload-period:"]) {
option = [option substringWithRange:
of_range(14, option.length - 14)];
_configReloadInterval = option.unsignedLongLongValue;
} else if ([option isEqual: @"tcp"])
_usesTCP = true;
} @catch (OFInvalidFormatException *e) {
}
}
- (void)parseResolvConf: (OFString *)path
|