@@ -81,11 +81,11 @@ OF_APPLICATION_DELEGATE(OFHTTP) static void help(OFStream *stream, bool full, int status) { - [of_stderr writeLine: + [OFStdErr writeLine: OF_LOCALIZED(@"usage", @"Usage: %[prog] -[cehHmoOPqv] url1 [url2 ...]", @"prog", [OFApplication programName])]; if (full) { @@ -283,11 +283,11 @@ { if (self != [OFHTTP class]) return; /* Opportunistically try loading ObjOpenSSL and ignore any errors. */ - OFDlopen(@LIB_PREFIX @"objopenssl" @LIB_SUFFIX, OF_RTLD_LAZY); + OFDlOpen(@LIB_PREFIX @"objopenssl" @LIB_SUFFIX, OF_RTLD_LAZY); } #endif - (instancetype)init { @@ -316,11 +316,11 @@ { size_t pos = [header rangeOfString: @":"].location; OFString *name, *value; if (pos == OFNotFound) { - [of_stderr writeLine: OF_LOCALIZED(@"invalid_input_header", + [OFStdErr writeLine: OF_LOCALIZED(@"invalid_input_header", @"%[prog]: Headers must to be in format name:value!", @"prog", [OFApplication programName])]; [OFApplication terminateWithStatus: 1]; } @@ -339,11 +339,11 @@ [_body release]; _body = nil; if ([path isEqual: @"-"]) - _body = [of_stdin copy]; + _body = [OFStdIn copy]; else { _body = [[OFFile alloc] initWithPath: path mode: @"r"]; @try { unsigned long long fileSize = @@ -370,11 +370,11 @@ method = method.uppercaseString; @try { _method = OFHTTPRequestMethodParseName(method); } @catch (OFInvalidArgumentException *e) { - [of_stderr writeLine: OF_LOCALIZED(@"invalid_input_method", + [OFStdErr writeLine: OF_LOCALIZED(@"invalid_input_method", @"%[prog]: Invalid request method %[method]!", @"prog", [OFApplication programName], @"method", method)]; [OFApplication terminateWithStatus: 1]; } @@ -402,11 +402,11 @@ @throw [OFOutOfRangeException exception]; [OFTCPSocket setSOCKS5Host: host]; [OFTCPSocket setSOCKS5Port: (uint16_t)port]; } @catch (OFInvalidFormatException *e) { - [of_stderr writeLine: OF_LOCALIZED(@"invalid_input_proxy", + [OFStdErr writeLine: OF_LOCALIZED(@"invalid_input_proxy", @"%[prog]: Proxy must to be in format host:port!", @"prog", [OFApplication programName])]; [OFApplication terminateWithStatus: 1]; } } @@ -460,11 +460,11 @@ switch (option) { case 'b': [self setBody: optionsParser.argument]; break; case 'h': - help(of_stdout, true, 0); + help(OFStdOut, true, 0); break; case 'H': [self addHeader: optionsParser.argument]; break; case 'm': @@ -473,21 +473,21 @@ case 'P': [self setProxy: optionsParser.argument]; break; case ':': if (optionsParser.lastLongOption != nil) - [of_stderr writeLine: + [OFStdErr writeLine: OF_LOCALIZED(@"long_argument_missing", @"%[prog]: Argument for option --%[opt] " @"missing" @"prog", [OFApplication programName], @"opt", optionsParser.lastLongOption)]; else { OFString *optStr = [OFString stringWithFormat: @"%c", optionsParser.lastOption]; - [of_stderr writeLine: + [OFStdErr writeLine: OF_LOCALIZED(@"argument_missing", @"%[prog]: Argument for option -%[opt] " @"missing", @"prog", [OFApplication programName], @"opt", optStr)]; @@ -494,30 +494,30 @@ } [OFApplication terminateWithStatus: 1]; break; case '=': - [of_stderr writeLine: + [OFStdErr writeLine: OF_LOCALIZED(@"option_takes_no_argument", @"%[prog]: Option --%[opt] takes no argument", @"prog", [OFApplication programName], @"opt", optionsParser.lastLongOption)]; [OFApplication terminateWithStatus: 1]; break; case '?': if (optionsParser.lastLongOption != nil) - [of_stderr writeLine: + [OFStdErr writeLine: OF_LOCALIZED(@"unknown_long_option", @"%[prog]: Unknown option: --%[opt]", @"prog", [OFApplication programName], @"opt", optionsParser.lastLongOption)]; else { OFString *optStr = [OFString stringWithFormat: @"%c", optionsParser.lastOption]; - [of_stderr writeLine: + [OFStdErr writeLine: OF_LOCALIZED(@"unknown_option", @"%[prog]: Unknown option: -%[opt]", @"prog", [OFApplication programName], @"opt", optStr)]; } @@ -540,31 +540,31 @@ _outputPath = [outputPath copy]; _URLs = [optionsParser.remainingArguments copy]; if (_URLs.count < 1) - help(of_stderr, false, 1); + help(OFStdErr, false, 1); if (_quiet && _verbose) { - [of_stderr writeLine: OF_LOCALIZED(@"quiet_xor_verbose", + [OFStdErr writeLine: OF_LOCALIZED(@"quiet_xor_verbose", @"%[prog]: -q / --quiet and -v / --verbose are mutually " @"exclusive!", @"prog", [OFApplication programName])]; [OFApplication terminateWithStatus: 1]; } if (_outputPath != nil && _detectFileName) { - [of_stderr writeLine: OF_LOCALIZED( + [OFStdErr writeLine: OF_LOCALIZED( @"output_xor_detect_filename", @"%[prog]: -o / --output and -O / --detect-filename are " @"mutually exclusive!", @"prog", [OFApplication programName])]; [OFApplication terminateWithStatus: 1]; } if (_outputPath != nil && _URLs.count > 1) { - [of_stderr writeLine: + [OFStdErr 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]; @@ -613,20 +613,20 @@ OFEnumerator *objectEnumerator = [headers objectEnumerator]; OFString *key, *object; while ((key = [keyEnumerator nextObject]) != nil && (object = [objectEnumerator nextObject]) != nil) - [of_stdout writeFormat: @" %@: %@\n", key, object]; + [OFStdOut writeFormat: @" %@: %@\n", key, object]; objc_autoreleasePoolPop(pool); } if (!_quiet) { if (_useUnicode) - [of_stdout writeFormat: @"☇ %@", URL.string]; + [OFStdOut writeFormat: @"☇ %@", URL.string]; else - [of_stdout writeFormat: @"< %@", URL.string]; + [OFStdOut writeFormat: @"< %@", URL.string]; } _length = 0; return true; @@ -644,17 +644,17 @@ [_progressBar draw]; [_progressBar release]; _progressBar = nil; if (!_quiet) { - [of_stdout writeString: @"\n "]; - [of_stdout writeLine: OF_LOCALIZED(@"download_error", + [OFStdOut writeString: @"\n "]; + [OFStdOut writeLine: OF_LOCALIZED(@"download_error", @"Error!")]; } URL = [_URLs objectAtIndex: _URLIndex - 1]; - [of_stderr writeLine: OF_LOCALIZED( + [OFStdErr writeLine: OF_LOCALIZED( @"download_failed_exception", @"%[prog]: Failed to download <%[url]>!\n" @" %[exception]", @"prog", [OFApplication programName], @"url", URL, @@ -676,12 +676,12 @@ [_progressBar draw]; [_progressBar release]; _progressBar = nil; if (!_quiet) { - [of_stdout writeString: @"\n "]; - [of_stdout writeLine: + [OFStdOut writeString: @"\n "]; + [OFStdOut writeLine: OF_LOCALIZED(@"download_done", @"Done!")]; } [self performSelector: @selector(downloadNextURL) afterDelay: 0]; @@ -703,13 +703,13 @@ OFString *lengthString = [headers objectForKey: @"Content-Length"]; OFString *type = [headers objectForKey: @"Content-Type"]; if (_useUnicode) - [of_stdout writeFormat: @" ➜ %hd\n", statusCode]; + [OFStdOut writeFormat: @" ➜ %hd\n", statusCode]; else - [of_stdout writeFormat: @" -> %hd\n", statusCode]; + [OFStdOut writeFormat: @" -> %hd\n", statusCode]; if (type == nil) type = OF_LOCALIZED(@"type_unknown", @"unknown"); if (lengthString != nil) { @@ -759,37 +759,37 @@ OFEnumerator OF_GENERIC(OFString *) *objectEnumerator = [headers objectEnumerator]; OFString *key, *object; if (statusCode / 100 == 2 && _currentFileName != nil) { - [of_stdout writeString: @" "]; - [of_stdout writeLine: OF_LOCALIZED( + [OFStdOut writeString: @" "]; + [OFStdOut writeLine: OF_LOCALIZED( @"info_name_unaligned", @"Name: %[name]", @"name", _currentFileName)]; } while ((key = [keyEnumerator nextObject]) != nil && (object = [objectEnumerator nextObject]) != nil) - [of_stdout writeFormat: @" %@: %@\n", - key, object]; + [OFStdOut writeFormat: @" %@: %@\n", + key, object]; objc_autoreleasePoolPop(pool); } else if (statusCode / 100 == 2 && !_detectFileNameRequest) { - [of_stdout writeString: @" "]; + [OFStdOut writeString: @" "]; if (_currentFileName != nil) - [of_stdout writeLine: OF_LOCALIZED(@"info_name", + [OFStdOut writeLine: OF_LOCALIZED(@"info_name", @"Name: %[name]", @"name", _currentFileName)]; - [of_stdout writeString: @" "]; - [of_stdout writeLine: OF_LOCALIZED(@"info_type", + [OFStdOut writeString: @" "]; + [OFStdOut writeLine: OF_LOCALIZED(@"info_type", @"Type: %[type]", @"type", type)]; - [of_stdout writeString: @" "]; - [of_stdout writeLine: OF_LOCALIZED(@"info_size", + [OFStdOut writeString: @" "]; + [OFStdOut writeLine: OF_LOCALIZED(@"info_size", @"Size: %[size]", @"size", lengthString)]; } } } @@ -801,48 +801,48 @@ { if (exception != nil) { if ([exception isKindOfClass: [OFResolveHostFailedException class]]) { if (!_quiet) - [of_stdout writeString: @"\n"]; + [OFStdOut writeString: @"\n"]; - [of_stderr writeLine: + [OFStdErr writeLine: OF_LOCALIZED(@"download_resolve_host_failed", @"%[prog]: Failed to download <%[url]>!\n" @" Failed to resolve host: %[exception]", @"prog", [OFApplication programName], @"url", request.URL.string, @"exception", exception)]; } else if ([exception isKindOfClass: [OFConnectionFailedException class]]) { if (!_quiet) - [of_stdout writeString: @"\n"]; + [OFStdOut writeString: @"\n"]; - [of_stderr writeLine: + [OFStdErr writeLine: OF_LOCALIZED(@"download_failed_connection_failed", @"%[prog]: Failed to download <%[url]>!\n" @" Connection failed: %[exception]", @"prog", [OFApplication programName], @"url", request.URL.string, @"exception", exception)]; } else if ([exception isKindOfClass: [OFInvalidServerReplyException class]]) { if (!_quiet) - [of_stdout writeString: @"\n"]; + [OFStdOut writeString: @"\n"]; - [of_stderr writeLine: OF_LOCALIZED( + [OFStdErr writeLine: OF_LOCALIZED( @"download_failed_invalid_server_reply", @"%[prog]: Failed to download <%[url]>!\n" @" Invalid server reply!", @"prog", [OFApplication programName], @"url", request.URL.string)]; } else if ([exception isKindOfClass: [OFUnsupportedProtocolException class]]) { if (!_quiet) - [of_stdout writeString: @"\n"]; + [OFStdOut writeString: @"\n"]; - [of_stderr writeLine: OF_LOCALIZED(@"no_ssl_library", + [OFStdErr writeLine: OF_LOCALIZED(@"no_ssl_library", @"%[prog]: No TLS library loaded!\n" @" In order to download via https, you need to " @"preload an TLS library for ObjFW\n" @" such as ObjOpenSSL!", @"prog", [OFApplication programName])]; @@ -851,11 +851,11 @@ OFString *error = OF_LOCALIZED( @"download_failed_read_or_write_failed_any", @"Read or write failed"); if (!_quiet) - [of_stdout writeString: @"\n"]; + [OFStdOut writeString: @"\n"]; if ([exception isKindOfClass: [OFReadFailedException class]]) error = OF_LOCALIZED( @"download_failed_read_or_write_failed_" @@ -866,11 +866,11 @@ error = OF_LOCALIZED( @"download_failed_read_or_write_failed_" @"write", @"Write failed"); - [of_stderr writeLine: OF_LOCALIZED( + [OFStdErr writeLine: OF_LOCALIZED( @"download_failed_read_or_write_failed", @"%[prog]: Failed to download <%[url]>!\n" @" %[error]: %[exception]", @"prog", [OFApplication programName], @"url", request.URL.string, @@ -887,11 +887,11 @@ } statusCode = response.statusCode; codeString = [OFString stringWithFormat: @"%hd %@", statusCode, OFHTTPStatusCodeString(statusCode)]; - [of_stderr writeLine: OF_LOCALIZED(@"download_failed", + [OFStdErr writeLine: OF_LOCALIZED(@"download_failed", @"%[prog]: Failed to download <%[url]>!\n" @" HTTP status code: %[code]", @"prog", [OFApplication programName], @"url", request.URL.string, @"code", codeString)]; @@ -921,15 +921,15 @@ afterDelay: 0]; return; } if ([_outputPath isEqual: @"-"]) - _output = of_stdout; + _output = [OFStdOut copy]; else { if (!_continue && !_force && [[OFFileManager defaultManager] fileExistsAtPath: _currentFileName]) { - [of_stderr writeLine: + [OFStdErr writeLine: OF_LOCALIZED(@"output_already_exists", @"%[prog]: File %[filename] already exists!", @"prog", [OFApplication programName], @"filename", _currentFileName)]; @@ -941,11 +941,11 @@ OFString *mode = (response.statusCode == 206 ? @"a" : @"w"); _output = [[OFFile alloc] initWithPath: _currentFileName mode: mode]; } @catch (OFOpenItemFailedException *e) { - [of_stderr writeLine: + [OFStdErr writeLine: OF_LOCALIZED(@"failed_to_open_output", @"%[prog]: Failed to open file %[filename]: " @"%[exception]", @"prog", [OFApplication programName], @"filename", _currentFileName, @@ -986,11 +986,11 @@ OFMutableDictionary *clientHeaders; OFHTTPRequest *request; _received = _length = _resumedFrom = 0; - if (_output != of_stdout) + if (_output != OFStdOut) [_output release]; _output = nil; if (_URLIndex >= _URLs.count) [OFApplication terminateWithStatus: _errorCode]; @@ -997,21 +997,21 @@ @try { URLString = [_URLs objectAtIndex: _URLIndex++]; URL = [OFURL URLWithString: URLString]; } @catch (OFInvalidFormatException *e) { - [of_stderr writeLine: OF_LOCALIZED(@"invalid_url", + [OFStdErr writeLine: OF_LOCALIZED(@"invalid_url", @"%[prog]: Invalid URL: <%[url]>!", @"prog", [OFApplication programName], @"url", URLString)]; _errorCode = 1; goto next; } if (![URL.scheme isEqual: @"http"] && ![URL.scheme isEqual: @"https"]) { - [of_stderr writeLine: OF_LOCALIZED(@"invalid_scheme", + [OFStdErr writeLine: OF_LOCALIZED(@"invalid_scheme", @"%[prog]: Invalid scheme: <%[url]>!", @"prog", [OFApplication programName], @"url", URLString)]; _errorCode = 1; @@ -1021,13 +1021,13 @@ clientHeaders = [[_clientHeaders mutableCopy] autorelease]; if (_detectFileName && !_detectedFileName) { if (!_quiet) { if (_useUnicode) - [of_stdout writeFormat: @"⠒ %@", URL.string]; + [OFStdOut writeFormat: @"⠒ %@", URL.string]; else - [of_stdout writeFormat: @"? %@", URL.string]; + [OFStdOut writeFormat: @"? %@", URL.string]; } request = [OFHTTPRequest requestWithURL: URL]; request.headers = clientHeaders; request.method = OFHTTPRequestMethodHead; @@ -1076,13 +1076,13 @@ } } if (!_quiet) { if (_useUnicode) - [of_stdout writeFormat: @"⇣ %@", URL.string]; + [OFStdOut writeFormat: @"⇣ %@", URL.string]; else - [of_stdout writeFormat: @"< %@", URL.string]; + [OFStdOut writeFormat: @"< %@", URL.string]; } request = [OFHTTPRequest requestWithURL: URL]; request.headers = clientHeaders; request.method = _method;