|
@@ -53,6 +53,7 @@
|
|
|
#include "File.h"
|
|
#include "File.h"
|
|
|
#include "StringFormat.h"
|
|
#include "StringFormat.h"
|
|
|
#include "OptionHandlerException.h"
|
|
#include "OptionHandlerException.h"
|
|
|
|
|
+#include "DownloadResult.h"
|
|
|
|
|
|
|
|
extern char* optarg;
|
|
extern char* optarg;
|
|
|
extern int optind, opterr, optopt;
|
|
extern int optind, opterr, optopt;
|
|
@@ -107,7 +108,7 @@ Option* option_processing(int argc, char* const argv[])
|
|
|
oparser.parseDefaultValues(op);
|
|
oparser.parseDefaultValues(op);
|
|
|
} catch(Exception& e) {
|
|
} catch(Exception& e) {
|
|
|
std::cerr << e.stackTrace();
|
|
std::cerr << e.stackTrace();
|
|
|
- exit(EXIT_FAILURE);
|
|
|
|
|
|
|
+ exit(DownloadResult::UNKNOWN_ERROR);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
while(1) {
|
|
while(1) {
|
|
@@ -254,12 +255,12 @@ Option* option_processing(int argc, char* const argv[])
|
|
|
std::cout << "--http-proxy-user was deprecated. See --http-proxy,"
|
|
std::cout << "--http-proxy-user was deprecated. See --http-proxy,"
|
|
|
<< " --https-proxy, --ftp-proxy, --all-proxy options."
|
|
<< " --https-proxy, --ftp-proxy, --all-proxy options."
|
|
|
<< std::endl;
|
|
<< std::endl;
|
|
|
- exit(EXIT_FAILURE);
|
|
|
|
|
|
|
+ exit(DownloadResult::UNKNOWN_ERROR);
|
|
|
case 5:
|
|
case 5:
|
|
|
std::cout << "--http-proxy-passwd was deprecated. See --http-proxy,"
|
|
std::cout << "--http-proxy-passwd was deprecated. See --http-proxy,"
|
|
|
<< " --https-proxy, --ftp-proxy, --all-proxy options."
|
|
<< " --https-proxy, --ftp-proxy, --all-proxy options."
|
|
|
<< std::endl;
|
|
<< std::endl;
|
|
|
- exit(EXIT_FAILURE);
|
|
|
|
|
|
|
+ exit(DownloadResult::UNKNOWN_ERROR);
|
|
|
case 6:
|
|
case 6:
|
|
|
cmdstream << PREF_HTTP_AUTH_SCHEME << "=" << optarg << "\n";
|
|
cmdstream << PREF_HTTP_AUTH_SCHEME << "=" << optarg << "\n";
|
|
|
break;
|
|
break;
|
|
@@ -282,12 +283,12 @@ Option* option_processing(int argc, char* const argv[])
|
|
|
std::cout << "--ftp-via-http-proxy was deprecated."
|
|
std::cout << "--ftp-via-http-proxy was deprecated."
|
|
|
<< " Use --http-proxy-method option instead."
|
|
<< " Use --http-proxy-method option instead."
|
|
|
<< std::endl;
|
|
<< std::endl;
|
|
|
- exit(EXIT_FAILURE);
|
|
|
|
|
|
|
+ exit(DownloadResult::UNKNOWN_ERROR);
|
|
|
case 14:
|
|
case 14:
|
|
|
std::cout << "--http-proxy-method was deprecated."
|
|
std::cout << "--http-proxy-method was deprecated."
|
|
|
<< " Use --proxy-method option instead."
|
|
<< " Use --proxy-method option instead."
|
|
|
<< std::endl;
|
|
<< std::endl;
|
|
|
- exit(EXIT_FAILURE);
|
|
|
|
|
|
|
+ exit(DownloadResult::UNKNOWN_ERROR);
|
|
|
case 15:
|
|
case 15:
|
|
|
cmdstream << PREF_LISTEN_PORT << "=" << optarg << "\n";
|
|
cmdstream << PREF_LISTEN_PORT << "=" << optarg << "\n";
|
|
|
break;
|
|
break;
|
|
@@ -553,7 +554,7 @@ Option* option_processing(int argc, char* const argv[])
|
|
|
break;
|
|
break;
|
|
|
case 'v':
|
|
case 'v':
|
|
|
showVersion();
|
|
showVersion();
|
|
|
- exit(EXIT_SUCCESS);
|
|
|
|
|
|
|
+ exit(DownloadResult::FINISHED);
|
|
|
case 'h':
|
|
case 'h':
|
|
|
{
|
|
{
|
|
|
std::string category;
|
|
std::string category;
|
|
@@ -563,11 +564,11 @@ Option* option_processing(int argc, char* const argv[])
|
|
|
category = optarg;
|
|
category = optarg;
|
|
|
}
|
|
}
|
|
|
showUsage(category, oparser);
|
|
showUsage(category, oparser);
|
|
|
- exit(EXIT_SUCCESS);
|
|
|
|
|
|
|
+ exit(DownloadResult::FINISHED);
|
|
|
}
|
|
}
|
|
|
default:
|
|
default:
|
|
|
showUsage(TAG_HELP, oparser);
|
|
showUsage(TAG_HELP, oparser);
|
|
|
- exit(EXIT_FAILURE);
|
|
|
|
|
|
|
+ exit(DownloadResult::UNKNOWN_ERROR);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -588,18 +589,18 @@ Option* option_processing(int argc, char* const argv[])
|
|
|
<< "Usage:" << "\n"
|
|
<< "Usage:" << "\n"
|
|
|
<< oparser.findByName(e.getOptionName())->getDescription()
|
|
<< oparser.findByName(e.getOptionName())->getDescription()
|
|
|
<< std::endl;
|
|
<< std::endl;
|
|
|
- exit(EXIT_FAILURE);
|
|
|
|
|
|
|
+ exit(DownloadResult::UNKNOWN_ERROR);
|
|
|
} catch(Exception& e) {
|
|
} catch(Exception& e) {
|
|
|
std::cerr << "Parse error in " << cfname << "\n"
|
|
std::cerr << "Parse error in " << cfname << "\n"
|
|
|
<< e.stackTrace() << std::endl;
|
|
<< e.stackTrace() << std::endl;
|
|
|
- exit(EXIT_FAILURE);
|
|
|
|
|
|
|
+ exit(DownloadResult::UNKNOWN_ERROR);
|
|
|
}
|
|
}
|
|
|
} else if(!ucfname.empty()) {
|
|
} else if(!ucfname.empty()) {
|
|
|
std::cerr << StringFormat("Configuration file %s is not found.",
|
|
std::cerr << StringFormat("Configuration file %s is not found.",
|
|
|
cfname.c_str())
|
|
cfname.c_str())
|
|
|
<< "\n";
|
|
<< "\n";
|
|
|
showUsage(TAG_HELP, oparser);
|
|
showUsage(TAG_HELP, oparser);
|
|
|
- exit(EXIT_FAILURE);
|
|
|
|
|
|
|
+ exit(DownloadResult::UNKNOWN_ERROR);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
// Override configuration with environment variables.
|
|
// Override configuration with environment variables.
|
|
@@ -616,11 +617,11 @@ Option* option_processing(int argc, char* const argv[])
|
|
|
<< "Usage:" << "\n"
|
|
<< "Usage:" << "\n"
|
|
|
<< oparser.findByName(e.getOptionName())->getDescription()
|
|
<< oparser.findByName(e.getOptionName())->getDescription()
|
|
|
<< std::endl;
|
|
<< std::endl;
|
|
|
- exit(EXIT_FAILURE);
|
|
|
|
|
|
|
+ exit(DownloadResult::UNKNOWN_ERROR);
|
|
|
} catch(Exception& e) {
|
|
} catch(Exception& e) {
|
|
|
std::cerr << e.stackTrace() << std::endl;
|
|
std::cerr << e.stackTrace() << std::endl;
|
|
|
showUsage(TAG_HELP, oparser);
|
|
showUsage(TAG_HELP, oparser);
|
|
|
- exit(EXIT_FAILURE);
|
|
|
|
|
|
|
+ exit(DownloadResult::UNKNOWN_ERROR);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if(
|
|
if(
|
|
@@ -634,14 +635,14 @@ Option* option_processing(int argc, char* const argv[])
|
|
|
if(optind == argc) {
|
|
if(optind == argc) {
|
|
|
std::cerr << MSG_URI_REQUIRED << std::endl;
|
|
std::cerr << MSG_URI_REQUIRED << std::endl;
|
|
|
showUsage(TAG_HELP, oparser);
|
|
showUsage(TAG_HELP, oparser);
|
|
|
- exit(EXIT_FAILURE);
|
|
|
|
|
|
|
+ exit(DownloadResult::UNKNOWN_ERROR);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
#ifdef HAVE_DAEMON
|
|
#ifdef HAVE_DAEMON
|
|
|
if(op->getAsBool(PREF_DAEMON)) {
|
|
if(op->getAsBool(PREF_DAEMON)) {
|
|
|
if(daemon(1, 1) < 0) {
|
|
if(daemon(1, 1) < 0) {
|
|
|
perror(MSG_DAEMON_FAILED);
|
|
perror(MSG_DAEMON_FAILED);
|
|
|
- exit(EXIT_FAILURE);
|
|
|
|
|
|
|
+ exit(DownloadResult::UNKNOWN_ERROR);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
#endif // HAVE_DAEMON
|
|
#endif // HAVE_DAEMON
|