@@ -197,19 +197,19 @@ - (void)resolver: (OFDNSResolver *)resolver didResolveCNAME: (OFString *)CNAME answerRecords: (OFDictionary *)answerRecords authorityRecords: (OFDictionary *)authorityRecords additionalRecords: (OFDictionary *)additionalRecords - context: (id)context + context: (OFNumber *)context exception: (id)exception; - (void)done; - (void)resolver: (OFDNSResolver *)resolver didResolveDomainName: (OFString *)domainName answerRecords: (OFDictionary *)answerRecords authorityRecords: (OFDictionary *)authorityRecords additionalRecords: (OFDictionary *)additionalRecords - context: (id)context + context: (OFNumber *)context exception: (id)exception; @end @interface OFDNSResolver_ResolveSocketAddressesDelegate: OFObject @@ -290,20 +290,20 @@ if (pos == OF_NOT_FOUND) return nil; return [domain substringWithRange: - of_range(pos + 1, [domain length] - pos - 1)]; + of_range(pos + 1, domain.length - pos - 1)]; } } #endif static bool isFQDN(OFString *host, OFDNSResolverSettings *settings) { - const char *UTF8String = [host UTF8String]; - size_t length = [host UTF8StringLength]; + const char *UTF8String = host.UTF8String; + size_t length = host.UTF8StringLength; unsigned int dots = 0; if ([host hasSuffix: @"."]) return true; @@ -369,11 +369,11 @@ exception]; suffix = parseName(buffer, length, &j, pointerLevel - 1); - if ([components count] == 0) + if (components.count == 0) return suffix; else { [components addObject: suffix]; return [components componentsJoinedByString: @"."]; @@ -759,11 +759,11 @@ queryData = [OFMutableData dataWithCapacity: 512]; /* Header */ - tmp = OF_BSWAP16_IF_LE([ID uInt16Value]); + tmp = OF_BSWAP16_IF_LE(ID.uInt16Value); [queryData addItems: &tmp count: 2]; /* RD */ tmp = OF_BSWAP16_IF_LE(1 << 8); @@ -781,19 +781,19 @@ /* Question */ /* QNAME */ for (OFString *component in [domainName componentsSeparatedByString: @"."]) { - size_t length = [component UTF8StringLength]; + size_t length = component.UTF8StringLength; uint8_t length8; - if (length > 63 || [queryData count] + length > 512) + if (length > 63 || queryData.count + length > 512) @throw [OFOutOfRangeException exception]; length8 = (uint8_t)length; [queryData addItem: &length8]; - [queryData addItems: [component UTF8String] + [queryData addItems: component.UTF8String count: length]; } /* QTYPE */ tmp = OF_BSWAP16_IF_LE(recordType); @@ -870,20 +870,20 @@ recursion: (unsigned int)recursion result: (OFMutableArray *)result { bool found = false; - for (OF_KINDOF(OFDNSResourceRecord *) record in records) { - if ([record recordClass] != OF_DNS_RESOURCE_RECORD_CLASS_IN) + for (OFDNSResourceRecord *record in records) { + if (record.recordClass != OF_DNS_RESOURCE_RECORD_CLASS_IN) continue; - if ([record recordType] == recordType) { + if (record.recordType == recordType) { [result addObject: record]; found = true; - } else if ([record recordType] == + } else if (record.recordType == OF_DNS_RESOURCE_RECORD_TYPE_CNAME) { - [self resolveCNAME: record + [self resolveCNAME: (OFCNAMEDNSResourceRecord *)record answerRecords: answerRecords additionalRecords: additionalRecords recordType: recordType recursion: recursion result: result]; @@ -899,11 +899,11 @@ additionalRecords: (OFDictionary *)additionalRecords recordType: (of_dns_resource_record_type_t)recordType recursion: (unsigned int)recursion result: (OFMutableArray *)result { - OFString *alias = [CNAME alias]; + OFString *alias = CNAME.alias; bool found = false; if (recursion == 0) return; @@ -923,11 +923,11 @@ result: result]) found = true; if (!found) { of_run_loop_mode_t runLoopMode = - [[OFRunLoop currentRunLoop] currentMode]; + [OFRunLoop currentRunLoop].currentMode; OFNumber *recordTypeNumber = [OFNumber numberWithInt: recordType]; _expectedResponses++; @@ -953,19 +953,19 @@ - (void)resolver: (OFDNSResolver *)resolver didResolveCNAME: (OFString *)CNAME answerRecords: (OFDictionary *)answerRecords authorityRecords: (OFDictionary *)authorityRecords additionalRecords: (OFDictionary *)additionalRecords - context: (id)context + context: (OFNumber *)context exception: (id)exception { /* * TODO: Error handling could be improved. Ignore error if there are * responses, otherwise propagate error. */ - of_dns_resource_record_type_t recordType = [context unsignedIntValue]; + of_dns_resource_record_type_t recordType = context.unsignedIntValue; bool found = false; OFMutableArray *records; size_t count; OF_ENSURE(resolver == _resolver); @@ -1002,11 +1002,11 @@ [self done]; return; } - count = [_records count]; + count = _records.count; for (size_t i = 0; i < count; i++) { id object = [_records objectAtIndex: i]; if (![object isKindOfClass: [OFPair class]]) continue; @@ -1018,11 +1018,11 @@ continue; [_records removeObjectAtIndex: i]; [_records insertObjectsFromArray: records atIndex: i]; - i += [records count] - 1; + i += records.count - 1; } if (_expectedResponses == 0) [self done]; } @@ -1047,11 +1047,11 @@ } } [addresses makeImmutable]; - if ([addresses count] == 0) + if (addresses.count == 0) exception = [OFResolveHostFailedException exceptionWithHost: _host recordClass: OF_DNS_RESOURCE_RECORD_CLASS_IN recordType: 0 error: OF_DNS_RESOLVER_ERROR_UNKNOWN]; @@ -1067,19 +1067,19 @@ - (void)resolver: (OFDNSResolver *)resolver didResolveDomainName: (OFString *)domainName answerRecords: (OFDictionary *)answerRecords authorityRecords: (OFDictionary *)authorityRecords additionalRecords: (OFDictionary *)additionalRecords - context: (id)context + context: (OFNumber *)context exception: (id)exception { /* * TODO: Error handling could be improved. Ignore error if there are * responses, otherwise propagate error. */ - of_dns_resource_record_type_t recordType = [context unsignedIntValue]; + of_dns_resource_record_type_t recordType = context.unsignedIntValue; if (_resolver != nil) OF_ENSURE(resolver == _resolver); else _resolver = [resolver retain]; @@ -1315,18 +1315,18 @@ components = [line componentsSeparatedByCharactersInSet: whitespaceCharacterSet options: OF_STRING_SKIP_EMPTY]; - if ([components count] < 2) { + if (components.count < 2) { objc_autoreleasePoolPop(pool2); continue; } - address = [components firstObject]; + address = components.firstObject; hosts = [components objectsInRange: - of_range(1, [components count] - 1)]; + of_range(1, components.count - 1)]; for (OFString *host in hosts) { addresses = [staticHosts objectForKey: host]; if (addresses == nil) { @@ -1388,34 +1388,34 @@ components = [line componentsSeparatedByCharactersInSet: whitespaceCharacterSet options: OF_STRING_SKIP_EMPTY]; - if ([components count] < 2) { + if (components.count < 2) { objc_autoreleasePoolPop(pool2); continue; } - option = [components firstObject]; + option = components.firstObject; arguments = [components objectsInRange: - of_range(1, [components count] - 1)]; + of_range(1, components.count - 1)]; if ([option isEqual: @"nameserver"]) { - if ([arguments count] != 1) { + if (arguments.count != 1) { objc_autoreleasePoolPop(pool2); continue; } [nameServers addObject: [arguments firstObject]]; } else if ([option isEqual: @"domain"]) { - if ([arguments count] != 1) { + if (arguments.count != 1) { objc_autoreleasePoolPop(pool2); continue; } [_localDomain release]; - _localDomain = [[arguments firstObject] copy]; + _localDomain = [arguments.firstObject copy]; } else if ([option isEqual: @"search"]) { [_searchDomains release]; _searchDomains = [arguments copy]; } else if ([option isEqual: @"options"]) for (OFString *argument in arguments) @@ -1435,29 +1435,29 @@ - (void)of_parseResolvConfOption: (OFString *)option { @try { if ([option hasPrefix: @"ndots:"]) { option = [option substringWithRange: - of_range(6, [option length] - 6)]; + of_range(6, option.length - 6)]; _minNumberOfDotsInAbsoluteName = - (unsigned int)[option decimalValue]; + (unsigned int)option.decimalValue; } else if ([option hasPrefix: @"timeout:"]) { option = [option substringWithRange: - of_range(8, [option length] - 8)]; + of_range(8, option.length - 8)]; - _timeout = [option decimalValue]; + _timeout = option.decimalValue; } else if ([option hasPrefix: @"attempts:"]) { option = [option substringWithRange: - of_range(9, [option length] - 9)]; + of_range(9, option.length - 9)]; - _maxAttempts = (unsigned int)[option decimalValue]; + _maxAttempts = (unsigned int)option.decimalValue; } else if ([option hasPrefix: @"reload-period:"]) { option = [option substringWithRange: - of_range(14, [option length] - 14)]; + of_range(14, option.length - 14)]; - _configReloadInterval = [option decimalValue]; + _configReloadInterval = option.decimalValue; } else if ([option isEqual: @"tcp"]) _usesTCP = true; } @catch (OFInvalidFormatException *e) { } } @@ -1486,11 +1486,11 @@ for (iter = &fixedInfo->DnsServerList; iter != NULL; iter = iter->Next) [nameServers addObject: [OFString stringWithCString: iter->IpAddress.String encoding: encoding]]; - if ([nameServers count] > 0) { + if (nameServers.count > 0) { [nameServers makeImmutable]; _nameServers = [nameServers copy]; } if (fixedInfo->DomainName[0] != '\0') @@ -1530,11 +1530,11 @@ } } @finally { ReleaseDomainNameServerList(nameServerList); } - if ([nameServers count] > 0) { + if (nameServers.count > 0) { [nameServers makeImmutable]; _nameServers = [nameServers copy]; } if (GetDefaultDomainName(buffer, sizeof(buffer))) @@ -1577,11 +1577,11 @@ [nameServers addObject: [OFString stringWithFormat: @"%u.%u.%u.%u", (ip >> 24) & 0xFF, (ip >> 16) & 0xFF, (ip >> 8) & 0xFF, ip & 0xFF]]; } - if ([nameServers count] > 0) { + if (nameServers.count > 0) { [nameServers makeImmutable]; _nameServers = [nameServers copy]; } } #endif @@ -1592,11 +1592,11 @@ * TODO: Rather than reparsing every, check what actually changed * (mtime) and only reset those. */ if (_lastConfigReload != nil && _configReloadInterval > 0 && - [_lastConfigReload timeIntervalSinceNow] < _configReloadInterval) + _lastConfigReload.timeIntervalSinceNow < _configReloadInterval) return; [_staticHosts release]; _staticHosts = nil; @@ -1651,11 +1651,11 @@ domainName = [OFString stringWithFormat: @"%@.%@.", host, searchDomain]; } - if ([domainName UTF8StringLength] > 253) + if (domainName.UTF8StringLength > 253) @throw [OFOutOfRangeException exception]; query = [[[OFDNSResolverQuery alloc] initWithHost: host domainName: domainName @@ -1806,12 +1806,12 @@ of_socket_address_parse_ip(@"::", 0); _IPv6Socket = [[OFUDPSocket alloc] init]; [_IPv6Socket of_bindToAddress: &address extraType: SOCK_DNS]; - [_IPv6Socket setBlocking: false]; - [_IPv6Socket setDelegate: self]; + _IPv6Socket.blocking = false; + _IPv6Socket.delegate = self; [_IPv6Socket asyncReceiveIntoBuffer: _buffer length: BUFFER_LENGTH]; } sock = _IPv6Socket; @@ -1823,12 +1823,12 @@ of_socket_address_parse_ip(@"0.0.0.0", 0); _IPv4Socket = [[OFUDPSocket alloc] init]; [_IPv4Socket of_bindToAddress: &address extraType: SOCK_DNS]; - [_IPv4Socket setBlocking: false]; - [_IPv4Socket setDelegate: self]; + _IPv4Socket.blocking = false; + _IPv4Socket.delegate = self; [_IPv4Socket asyncReceiveIntoBuffer: _buffer length: BUFFER_LENGTH]; } sock = _IPv4Socket; @@ -1848,22 +1848,22 @@ if (query == nil) return; if (query->_nameServersIndex + 1 < - [query->_settings->_nameServers count]) { + query->_settings->_nameServers.count) { query->_nameServersIndex++; [self of_sendQuery: query - runLoopMode: [[OFRunLoop currentRunLoop] currentMode]]; + runLoopMode: [OFRunLoop currentRunLoop].currentMode]; return; } if (query->_attempt < query->_settings->_maxAttempts) { query->_attempt++; query->_nameServersIndex = 0; [self of_sendQuery: query - runLoopMode: [[OFRunLoop currentRunLoop] currentMode]]; + runLoopMode: [OFRunLoop currentRunLoop].currentMode]; return; } query = [[query retain] autorelease]; [_queries removeObjectForKey: query->_ID]; @@ -1889,11 +1889,11 @@ callback(query->_target, query->_selector, self, query->_domainName, nil, nil, nil, query->_context, exception); } -- (bool)socket: (OF_KINDOF(OFUDPSocket *))sock +- (bool)socket: (OFUDPSocket *)sock didReceiveIntoBuffer: (void *)buffer_ length: (size_t)length sender: (const of_socket_address_t *)sender exception: (id)exception { @@ -1932,15 +1932,15 @@ uint16_t numAdditionalRecords; if (length < 12) @throw [OFTruncatedDataException exception]; - if ([query->_queryData itemSize] != 1 || - [query->_queryData count] < 12) + if (query->_queryData.itemSize != 1 || + query->_queryData.count < 12) @throw [OFInvalidArgumentException exception]; - queryDataBuffer = [query->_queryData items]; + queryDataBuffer = query->_queryData.items; /* QR */ if ((buffer[2] & 0x80) == 0) @throw [OFInvalidServerReplyException exception]; @@ -1962,13 +1962,13 @@ case 2: error = OF_DNS_RESOLVER_ERROR_SERVER_FAILURE; break; case 3: if (query->_searchDomainsIndex + 1 < - [query->_settings->_searchDomains count]) { + query->_settings->_searchDomains.count) { of_run_loop_mode_t runLoopMode = - [[OFRunLoop currentRunLoop] currentMode]; + [OFRunLoop currentRunLoop].currentMode; query->_searchDomainsIndex++; [self of_resolveHost: query->_host recordClass: query->_recordClass @@ -2127,11 +2127,11 @@ [addresses addItem: &address]; } [addresses makeImmutable]; - if ([addresses count] == 0) { + if (addresses.count == 0) { of_dns_resource_record_type_t recordType = 0; addresses = nil; switch (addressFamily) {