@@ -141,12 +141,12 @@ if (contentDisposition == nil) return nil; pool = objc_autoreleasePoolPush(); - UTF8String = [contentDisposition UTF8String]; - UTF8StringLength = [contentDisposition UTF8StringLength]; + UTF8String = contentDisposition.UTF8String; + UTF8StringLength = contentDisposition.UTF8StringLength; state = DISPOSITION_TYPE; params = [OFMutableDictionary dictionary]; last = 0; for (size_t i = 0; i < UTF8StringLength; i++) { @@ -230,11 +230,11 @@ (fileName = [params objectForKey: @"filename"]) == nil) { objc_autoreleasePoolPop(pool); return nil; } - fileName = [fileName lastPathComponent]; + fileName = fileName.lastPathComponent; [fileName retain]; objc_autoreleasePoolPop(pool); return [fileName autorelease]; } @@ -250,11 +250,11 @@ _clientHeaders = [[OFMutableDictionary alloc] initWithObject: @"OFHTTP" forKey: @"User-Agent"]; _HTTPClient = [[OFHTTPClient alloc] init]; - [_HTTPClient setDelegate: self]; + _HTTPClient.delegate = self; _buffer = [self allocMemoryWithSize: [OFSystemInfo pageSize]]; } @catch (id e) { [self release]; @throw e; @@ -274,15 +274,15 @@ @"prog", [OFApplication programName])]; [OFApplication terminateWithStatus: 1]; } name = [header substringWithRange: of_range(0, pos)]; - name = [name stringByDeletingEnclosingWhitespaces]; + name = name.stringByDeletingEnclosingWhitespaces; value = [header substringWithRange: - of_range(pos + 1, [header length] - pos - 1)]; - value = [value stringByDeletingEnclosingWhitespaces]; + of_range(pos + 1, header.length - pos - 1)]; + value = value.stringByDeletingEnclosingWhitespaces; [_clientHeaders setObject: value forKey: name]; } @@ -292,21 +292,21 @@ [_body release]; _body = [[OFFile alloc] initWithPath: path mode: @"r"]; - bodySize = [[[OFFileManager defaultManager] - attributesOfItemAtPath: path] fileSize]; + bodySize = [[OFFileManager defaultManager] attributesOfItemAtPath: path] + .fileSize; [_clientHeaders setObject: [OFString stringWithFormat: @"%ju", bodySize] forKey: @"Content-Length"]; } - (void)setMethod: (OFString *)method { void *pool = objc_autoreleasePoolPush(); - method = [method uppercaseString]; + method = method.uppercaseString; if ([method isEqual: @"GET"]) _method = OF_HTTP_REQUEST_METHOD_GET; else if ([method isEqual: @"HEAD"]) _method = OF_HTTP_REQUEST_METHOD_HEAD; @@ -340,12 +340,12 @@ if (pos == OF_NOT_FOUND) @throw [OFInvalidFormatException exception]; host = [proxy substringWithRange: of_range(0, pos)]; - port = [[proxy substringWithRange: - of_range(pos + 1, [proxy length] - pos - 1)] decimalValue]; + port = [proxy substringWithRange: + of_range(pos + 1, proxy.length - pos - 1)].decimalValue; if (port > UINT16_MAX) @throw [OFOutOfRangeException exception]; [OFTCPSocket setSOCKS5Host: host]; @@ -379,20 +379,20 @@ OFOptionsParser *optionsParser; of_unichar_t option; #ifdef OF_HAVE_SANDBOX OFSandbox *sandbox = [OFSandbox sandbox]; - [sandbox setAllowsStdIO: true]; - [sandbox setAllowsReadingFiles: true]; - [sandbox setAllowsWritingFiles: true]; - [sandbox setAllowsCreatingFiles: true]; - [sandbox setAllowsIPSockets: true]; - [sandbox setAllowsDNS: true]; - [sandbox setAllowsUserDatabaseReading: true]; - [sandbox setAllowsTTY: true]; + sandbox.allowsStdIO = true; + sandbox.allowsReadingFiles = true; + sandbox.allowsWritingFiles = true; + sandbox.allowsCreatingFiles = true; + sandbox.allowsIPSockets = true; + sandbox.allowsDNS = true; + sandbox.allowsUserDatabaseReading = true; + sandbox.allowsTTY = true; /* Dropped after parsing options */ - [sandbox setAllowsUnveil: true]; + sandbox.allowsUnveil = true; [OFApplication activateSandbox: sandbox]; #endif #ifndef OF_AMIGAOS @@ -403,36 +403,36 @@ optionsParser = [OFOptionsParser parserWithOptions: options]; while ((option = [optionsParser nextOption]) != '\0') { switch (option) { case 'b': - [self setBody: [optionsParser argument]]; + self.body = optionsParser.argument; break; case 'h': help(of_stdout, true, 0); break; case 'H': - [self addHeader: [optionsParser argument]]; + [self addHeader: optionsParser.argument]; break; case 'm': - [self setMethod: [optionsParser argument]]; + self.method = optionsParser.argument; break; case 'P': - [self setProxy: [optionsParser argument]]; + self.proxy = optionsParser.argument; break; case ':': - if ([optionsParser lastLongOption] != nil) + if (optionsParser.lastLongOption != nil) [of_stderr writeLine: OF_LOCALIZED(@"long_argument_missing", @"%[prog]: Argument for option --%[opt] " @"missing" @"prog", [OFApplication programName], - @"opt", [optionsParser lastLongOption])]; + @"opt", optionsParser.lastLongOption)]; else { OFString *optStr = [OFString stringWithFormat: @"%c", - [optionsParser lastOption]]; + optionsParser.lastOption]; [of_stderr writeLine: OF_LOCALIZED(@"argument_missing", @"%[prog]: Argument for option -%[opt] " @"missing", @"prog", [OFApplication programName], @@ -444,25 +444,25 @@ case '=': [of_stderr writeLine: OF_LOCALIZED(@"option_takes_no_argument", @"%[prog]: Option --%[opt] takes no argument", @"prog", [OFApplication programName], - @"opt", [optionsParser lastLongOption])]; + @"opt", optionsParser.lastLongOption)]; [OFApplication terminateWithStatus: 1]; break; case '?': - if ([optionsParser lastLongOption] != nil) + if (optionsParser.lastLongOption != nil) [of_stderr writeLine: OF_LOCALIZED(@"unknown_long_option", @"%[prog]: Unknown option: --%[opt]", @"prog", [OFApplication programName], - @"opt", [optionsParser lastLongOption])]; + @"opt", optionsParser.lastLongOption)]; else { OFString *optStr = [OFString stringWithFormat: @"%c", - [optionsParser lastOption]]; + optionsParser.lastOption]; [of_stderr writeLine: OF_LOCALIZED(@"unknown_option", @"%[prog]: Unknown option: -%[opt]", @"prog", [OFApplication programName], @"opt", optStr)]; @@ -479,18 +479,18 @@ permissions: @"wc"]; /* In case we use ObjOpenSSL for https later */ [sandbox unveilPath: @"/etc/ssl" permissions: @"r"]; - [sandbox setAllowsUnveil: false]; + sandbox.allowsUnveil = false; [OFApplication activateSandbox: sandbox]; #endif _outputPath = [outputPath copy]; - _URLs = [[optionsParser remainingArguments] retain]; + _URLs = [optionsParser.remainingArguments copy]; - if ([_URLs count] < 1) + if (_URLs.count < 1) help(of_stderr, false, 1); if (_quiet && _verbose) { [of_stderr writeLine: OF_LOCALIZED(@"quiet_xor_verbose", @"%[prog]: -q / --quiet and -v / --verbose are mutually " @@ -497,21 +497,21 @@ @"exclusive!", @"prog", [OFApplication programName])]; [OFApplication terminateWithStatus: 1]; } - if (_outputPath != nil && [_URLs count] > 1) { + if (_outputPath != nil && _URLs.count > 1) { [of_stderr writeLine: OF_LOCALIZED(@"output_only_with_one_url", @"%[prog]: Cannot use -o / --output when more than one URL " @"has been specified!", @"prog", [OFApplication programName])]; [OFApplication terminateWithStatus: 1]; } if (_insecure) - [_HTTPClient setInsecureRedirectsAllowed: true]; + _HTTPClient.insecureRedirectsAllowed = true; [self performSelector: @selector(downloadNextURL) afterDelay: 0]; } @@ -527,11 +527,11 @@ - (void)client: (OFHTTPClient *)client wantsRequestBody: (OFStream *)body request: (OFHTTPRequest *)request { /* TODO: Do asynchronously and print status */ - while (![_body isAtEndOfStream]) { + while (!_body.atEndOfStream) { char buffer[4096]; size_t length; length = [_body readIntoBuffer: buffer length: 4096]; @@ -547,14 +547,13 @@ response: (OFHTTPResponse *)response { if (_verbose) { void *pool = objc_autoreleasePoolPush(); OFDictionary OF_GENERIC(OFString *, OFString *) *headers = - [response headers]; + response.headers; OFEnumerator *keyEnumerator = [headers keyEnumerator]; - OFEnumerator *objectEnumerator = - [headers objectEnumerator]; + OFEnumerator *objectEnumerator = [headers objectEnumerator]; OFString *key, *object; while ((key = [keyEnumerator nextObject]) != nil && (object = [objectEnumerator nextObject]) != nil) [of_stdout writeFormat: @" %@: %@\n", @@ -562,11 +561,11 @@ objc_autoreleasePoolPop(pool); } if (!_quiet) - [of_stdout writeFormat: @"☇ %@", [URL string]]; + [of_stdout writeFormat: @"☇ %@", URL.string]; return true; } - (void)client: (OFHTTPClient *)client @@ -580,11 +579,11 @@ [of_stderr writeLine: OF_LOCALIZED(@"download_failed_resolve_host_failed", @"%[prog]: Failed to download <%[url]>!\n" @" Failed to resolve host: %[exception]", @"prog", [OFApplication programName], - @"url", [[request URL] string], + @"url", request.URL.string, @"exception", e)]; } else if ([e isKindOfClass: [OFConnectionFailedException class]]) { if (!_quiet) [of_stdout writeString: @"\n"]; @@ -591,11 +590,11 @@ [of_stderr writeLine: OF_LOCALIZED(@"download_failed_connection_failed", @"%[prog]: Failed to download <%[url]>!\n" @" Connection failed: %[exception]", @"prog", [OFApplication programName], - @"url", [[request URL] string], + @"url", request.URL.string, @"exception", e)]; } else if ([e isKindOfClass: [OFInvalidServerReplyException class]]) { if (!_quiet) [of_stdout writeString: @"\n"]; @@ -602,11 +601,11 @@ [of_stderr writeLine: OF_LOCALIZED(@"download_failed_invalid_server_reply", @"%[prog]: Failed to download <%[url]>!\n" @" Invalid server reply!", @"prog", [OFApplication programName], - @"url", [[request URL] string])]; + @"url", request.URL.string)]; } else if ([e isKindOfClass: [OFUnsupportedProtocolException class]]) { if (!_quiet) [of_stdout writeString: @"\n"]; [of_stderr writeLine: OF_LOCALIZED(@"no_ssl_library", @@ -635,18 +634,18 @@ [of_stderr writeLine: OF_LOCALIZED(@"download_failed_read_or_write_failed", @"%[prog]: Failed to download <%[url]>!\n" @" %[error]: %[exception]", @"prog", [OFApplication programName], - @"url", [[request URL] string], + @"url", request.URL.string, @"error", error, @"exception", e)]; } else if ([e isKindOfClass: [OFHTTPRequestFailedException class]]) { [of_stderr writeLine: OF_LOCALIZED(@"download_failed", @"%[prog]: Failed to download <%[url]>!", @"prog", [OFApplication programName], - @"url", [[request URL] string])]; + @"url", request.URL.string)]; } else @throw e; [self performSelector: @selector(downloadNextURL) afterDelay: 0]; @@ -685,14 +684,13 @@ _received += length; [_output writeBuffer: buffer length: length]; - [_progressBar setReceived: _received]; + _progressBar.received = _received; - if ([response isAtEndOfStream] || - (_length >= 0 && _received >= _length)) { + if (response.atEndOfStream || (_length >= 0 && _received >= _length)) { [_progressBar stop]; [_progressBar draw]; [_progressBar release]; _progressBar = nil; @@ -724,11 +722,11 @@ if (type == nil) type = OF_LOCALIZED(@"type_unknown", @"unknown"); if (lengthString != nil) - _length = [lengthString decimalValue]; + _length = lengthString.decimalValue; if (_length >= 0) { if (_resumedFrom + _length >= GIBIBYTE) { lengthString = [OFString stringWithFormat: @"%,.2f", @@ -804,11 +802,11 @@ didPerformRequest: (OFHTTPRequest *)request response: (OFHTTPResponse *)response { if (_detectFileNameRequest) { _currentFileName = [fileNameFromContentDisposition( - [[response headers] objectForKey: @"Content-Disposition"]) + [response.headers objectForKey: @"Content-Disposition"]) copy]; _detectedFileName = true; /* Handle this URL on the next -[downloadNextURL] call */ _URLIndex--; @@ -833,11 +831,11 @@ goto next; } @try { OFString *mode = - ([response statusCode] == 206 ? @"a" : @"w"); + (response.statusCode == 206 ? @"a" : @"w"); _output = [[OFFile alloc] initWithPath: _currentFileName mode: mode]; } @catch (OFOpenItemFailedException *e) { [of_stderr writeLine: OF_LOCALIZED(@"failed_to_open_output", @@ -854,18 +852,18 @@ if (!_quiet) { _progressBar = [[ProgressBar alloc] initWithLength: _length resumedFrom: _resumedFrom]; - [_progressBar setReceived: _received]; + _progressBar.received = _received; [_progressBar draw]; } [_currentFileName release]; _currentFileName = nil; - [response setDelegate: self]; + response.delegate = self; [response asyncReadIntoBuffer: _buffer length: [OFSystemInfo pageSize]]; return; next: @@ -888,11 +886,11 @@ if (_output != of_stdout) [_output release]; _output = nil; - if (_URLIndex >= [_URLs count]) + if (_URLIndex >= _URLs.count) [OFApplication terminateWithStatus: _errorCode]; @try { URLString = [_URLs objectAtIndex: _URLIndex++]; URL = [OFURL URLWithString: URLString]; @@ -904,12 +902,11 @@ _errorCode = 1; goto next; } - if (![[URL scheme] isEqual: @"http"] && - ![[URL scheme] isEqual: @"https"]) { + if (![URL.scheme isEqual: @"http"] && ![URL.scheme isEqual: @"https"]) { [of_stderr writeLine: OF_LOCALIZED(@"invalid_scheme", @"%[prog]: Invalid scheme: <%[url]>!", @"prog", [OFApplication programName], @"url", URLString)]; @@ -919,15 +916,15 @@ clientHeaders = [[_clientHeaders mutableCopy] autorelease]; if (_detectFileName && !_detectedFileName) { if (!_quiet) - [of_stdout writeFormat: @"⠒ %@", [URL string]]; + [of_stdout writeFormat: @"⠒ %@", URL.string]; request = [OFHTTPRequest requestWithURL: URL]; - [request setHeaders: clientHeaders]; - [request setMethod: OF_HTTP_REQUEST_METHOD_HEAD]; + request.headers = clientHeaders; + request.method = OF_HTTP_REQUEST_METHOD_HEAD; _detectFileNameRequest = true; [_HTTPClient asyncPerformRequest: request]; return; } @@ -935,22 +932,22 @@ [_currentFileName release]; _currentFileName = nil; _detectedFileName = false; if (!_quiet) - [of_stdout writeFormat: @"⇣ %@", [URL string]]; + [of_stdout writeFormat: @"⇣ %@", URL.string]; if (_outputPath != nil) _currentFileName = [_outputPath copy]; if (_currentFileName == nil) - _currentFileName = [[[URL path] lastPathComponent] copy]; + _currentFileName = [URL.path.lastPathComponent copy]; if (_continue) { @try { - uintmax_t size = [[[OFFileManager defaultManager] - attributesOfItemAtPath: _currentFileName] fileSize]; + uintmax_t size = [[OFFileManager defaultManager] + attributesOfItemAtPath: _currentFileName].fileSize; OFString *range; if (size > INTMAX_MAX) @throw [OFOutOfRangeException exception]; @@ -963,12 +960,12 @@ } @catch (OFRetrieveItemAttributesFailedException *e) { } } request = [OFHTTPRequest requestWithURL: URL]; - [request setHeaders: clientHeaders]; - [request setMethod: _method]; + request.headers = clientHeaders; + request.method = _method; _detectFileNameRequest = false; [_HTTPClient asyncPerformRequest: request]; return;