@@ -22,10 +22,11 @@ #import "OFCharacterSet.h" #import "OFDate.h" #import "OFDictionary.h" #import "OFFile.h" #import "OFLocale.h" +#import "OFSocket+Private.h" #import "OFString.h" #ifdef OF_WINDOWS # import "OFWindowsRegistryKey.h" #endif @@ -51,12 +52,10 @@ # include # include # include #endif -#import "socket_helpers.h" - #if defined(OF_HAIKU) # define HOSTS_PATH @"/system/settings/network/hosts" # define RESOLV_CONF_PATH @"/system/settings/network/resolv.conf" #elif defined(OF_AMIGAOS4) # define HOSTS_PATH @"DEVS:Internet/hosts" @@ -74,11 +73,11 @@ { if (hostname == nil) return nil; @try { - of_socket_address_parse_ip(hostname, 0); + OFSocketAddressParseIP(hostname, 0); /* * If we are still here, the host name is a valid IP address. * We can't use that as local domain. */ @@ -85,11 +84,11 @@ return nil; } @catch (OFInvalidFormatException *e) { /* Not an IP address -> we can use it if it contains a dot. */ size_t pos = [hostname rangeOfString: @"."].location; - if (pos == OF_NOT_FOUND) + if (pos == OFNotFound) return nil; return [hostname substringFromIndex: pos + 1]; } } @@ -173,11 +172,11 @@ parseNetStackArray(OFString *string) { if (![string hasPrefix: @"["] || ![string hasSuffix: @"]"]) return nil; - string = [string substringWithRange: of_range(1, string.length - 2)]; + string = [string substringWithRange: OFRangeMake(1, string.length - 2)]; return [string componentsSeparatedByString: @"|"]; } #endif @@ -251,12 +250,11 @@ OFMutableDictionary *staticHosts; OFFile *file; OFString *line; @try { - file = [OFFile fileWithPath: path - mode: @"r"]; + file = [OFFile fileWithPath: path mode: @"r"]; } @catch (OFOpenItemFailedException *e) { objc_autoreleasePoolPop(pool); return; } @@ -266,32 +264,31 @@ OFArray *components, *hosts; size_t pos; OFString *address; pos = [line rangeOfString: @"#"].location; - if (pos != OF_NOT_FOUND) + if (pos != OFNotFound) line = [line substringToIndex: pos]; components = [line componentsSeparatedByCharactersInSet: whitespaceCharacterSet - options: OF_STRING_SKIP_EMPTY]; + options: OFStringSkipEmptyComponents]; if (components.count < 2) continue; address = components.firstObject; hosts = [components objectsInRange: - of_range(1, components.count - 1)]; + OFRangeMake(1, components.count - 1)]; for (OFString *host in hosts) { OFMutableArray *addresses = [staticHosts objectForKey: host]; if (addresses == nil) { addresses = [OFMutableArray array]; - [staticHosts setObject: addresses - forKey: host]; + [staticHosts setObject: addresses forKey: host]; } [addresses addObject: address]; } } @@ -352,12 +349,11 @@ OFMutableArray *nameServers = [[_nameServers mutableCopy] autorelease]; OFFile *file; OFString *line; @try { - file = [OFFile fileWithPath: path - mode: @"r"]; + file = [OFFile fileWithPath: path mode: @"r"]; } @catch (OFOpenItemFailedException *e) { objc_autoreleasePoolPop(pool); return; } @@ -369,33 +365,33 @@ size_t pos; OFArray *components, *arguments; OFString *option; pos = [line indexOfCharacterFromSet: commentCharacters]; - if (pos != OF_NOT_FOUND) + if (pos != OFNotFound) line = [line substringToIndex: pos]; components = [line componentsSeparatedByCharactersInSet: whitespaceCharacterSet - options: OF_STRING_SKIP_EMPTY]; + options: OFStringSkipEmptyComponents]; if (components.count < 2) { objc_autoreleasePoolPop(pool2); continue; } option = components.firstObject; arguments = [components objectsInRange: - of_range(1, components.count - 1)]; + OFRangeMake(1, components.count - 1)]; if ([option isEqual: @"nameserver"]) { if (arguments.count != 1) { objc_autoreleasePoolPop(pool2); continue; } - [nameServers addObject: [arguments firstObject]]; + [nameServers addObject: arguments.firstObject]; } else if ([option isEqual: @"domain"]) { if (arguments.count != 1) { objc_autoreleasePoolPop(pool2); continue; } @@ -423,11 +419,11 @@ #endif #ifdef OF_WINDOWS - (void)obtainWindowsSystemConfig { - of_string_encoding_t encoding = [OFLocale encoding]; + OFStringEncoding encoding = [OFLocale encoding]; OFMutableArray *nameServers; /* * We need more space than FIXED_INFO in case we have more than one * name server, but we also want it to be properly aligned, meaning we * can't just get a buffer of bytes. Thus, we just get space for 8. @@ -482,20 +478,19 @@ if (components.count < 2) continue; address = components.firstObject; hosts = [components objectsInRange: - of_range(1, components.count - 1)]; + OFRangeMake(1, components.count - 1)]; for (OFString *host in hosts) { OFMutableArray *addresses = [staticHosts objectForKey: host]; if (addresses == nil) { addresses = [OFMutableArray array]; - [staticHosts setObject: addresses - forKey: host]; + [staticHosts setObject: addresses forKey: host]; } [addresses addObject: address]; } } @@ -511,11 +506,11 @@ #ifdef OF_AMIGAOS4 - (void)obtainAmigaOS4SystemConfig { OFMutableArray *nameServers = [OFMutableArray array]; - of_string_encoding_t encoding = [OFLocale encoding]; + OFStringEncoding encoding = [OFLocale encoding]; struct List *nameServerList = ObtainDomainNameServerList(); char buffer[MAXHOSTNAMELEN]; if (nameServerList == NULL) @throw [OFOutOfMemoryException exception]; @@ -576,11 +571,11 @@ */ if (optLen < sizeof(buffer.entries)) return; for (uint_fast8_t i = 0; i < 2; i++) { - uint32_t ip = OF_BSWAP32_IF_LE(buffer.entries[i].ip.s_addr); + uint32_t ip = OFFromBigEndian32(buffer.entries[i].ip.s_addr); if (ip == 0) continue; [nameServers addObject: [OFString stringWithFormat: @@ -619,11 +614,11 @@ # ifdef OF_HAVE_FILES OFWindowsRegistryKey *key = [[OFWindowsRegistryKey localMachineKey] openSubkeyAtPath: @"SYSTEM\\CurrentControlSet\\Services\\" @"Tcpip\\Parameters" securityAndAccessRights: KEY_QUERY_VALUE]; - path = [[[key stringForValue: @"DataBasePath"] + path = [[[key stringForValueNamed: @"DataBasePath"] stringByAppendingPathComponent: @"hosts"] stringByExpandingWindowsEnvironmentStrings]; if (path != nil) [self parseHosts: path];