summaryrefslogtreecommitdiff
path: root/src/option_processing.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2009-01-12 12:27:34 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2009-01-12 12:27:34 +0000
commit8a9d921465f80e231f9e1a99a0d93beafb474402 (patch)
tree85963269afe6e95da564e23f4c2da61c023c9a97 /src/option_processing.cc
parent0a4f43d0edeefb5bc49329b791984c7b2072d1df (diff)
2009-01-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Applied exit-status patch from Pascal Rigaux at Mandriva. aria2 now returns last error encountered in the HTTP/FTP downloads as a exit status value. If all downloads finished successfully, aria2 returns 0. The error code is defined in src/DownloadResult.h. The error occurred in the download currently in progress is not reported as a last error. If no error has encountered but there are in progress or waiting downloads, aria2 returns 7. * src/AbstractCommand.cc * src/DlAbortEx.h * src/DlRetryEx.h * src/DownloadCommand.cc * src/DownloadFailureException.h * src/DownloadResult.h * src/FtpNegotiationCommand.cc * src/HttpSkipResponseCommand.cc * src/Makefile.am * src/MultiUrlRequestInfo.cc * src/MultiUrlRequestInfo.h * src/RecoverableException.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/RequestGroupMan.h * src/URIResult.cc * src/URIResult.h * src/main.cc * src/option_processing.cc * test/RequestGroupTest.cc
Diffstat (limited to 'src/option_processing.cc')
-rw-r--r--src/option_processing.cc31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/option_processing.cc b/src/option_processing.cc
index 035cf1db..bc8d33d4 100644
--- a/src/option_processing.cc
+++ b/src/option_processing.cc
@@ -53,6 +53,7 @@
#include "File.h"
#include "StringFormat.h"
#include "OptionHandlerException.h"
+#include "DownloadResult.h"
extern char* optarg;
extern int optind, opterr, optopt;
@@ -107,7 +108,7 @@ Option* option_processing(int argc, char* const argv[])
oparser.parseDefaultValues(op);
} catch(Exception& e) {
std::cerr << e.stackTrace();
- exit(EXIT_FAILURE);
+ exit(DownloadResult::UNKNOWN_ERROR);
}
while(1) {
@@ -254,12 +255,12 @@ Option* option_processing(int argc, char* const argv[])
std::cout << "--http-proxy-user was deprecated. See --http-proxy,"
<< " --https-proxy, --ftp-proxy, --all-proxy options."
<< std::endl;
- exit(EXIT_FAILURE);
+ exit(DownloadResult::UNKNOWN_ERROR);
case 5:
std::cout << "--http-proxy-passwd was deprecated. See --http-proxy,"
<< " --https-proxy, --ftp-proxy, --all-proxy options."
<< std::endl;
- exit(EXIT_FAILURE);
+ exit(DownloadResult::UNKNOWN_ERROR);
case 6:
cmdstream << PREF_HTTP_AUTH_SCHEME << "=" << optarg << "\n";
break;
@@ -282,12 +283,12 @@ Option* option_processing(int argc, char* const argv[])
std::cout << "--ftp-via-http-proxy was deprecated."
<< " Use --http-proxy-method option instead."
<< std::endl;
- exit(EXIT_FAILURE);
+ exit(DownloadResult::UNKNOWN_ERROR);
case 14:
std::cout << "--http-proxy-method was deprecated."
<< " Use --proxy-method option instead."
<< std::endl;
- exit(EXIT_FAILURE);
+ exit(DownloadResult::UNKNOWN_ERROR);
case 15:
cmdstream << PREF_LISTEN_PORT << "=" << optarg << "\n";
break;
@@ -553,7 +554,7 @@ Option* option_processing(int argc, char* const argv[])
break;
case 'v':
showVersion();
- exit(EXIT_SUCCESS);
+ exit(DownloadResult::FINISHED);
case 'h':
{
std::string category;
@@ -563,11 +564,11 @@ Option* option_processing(int argc, char* const argv[])
category = optarg;
}
showUsage(category, oparser);
- exit(EXIT_SUCCESS);
+ exit(DownloadResult::FINISHED);
}
default:
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"
<< oparser.findByName(e.getOptionName())->getDescription()
<< std::endl;
- exit(EXIT_FAILURE);
+ exit(DownloadResult::UNKNOWN_ERROR);
} catch(Exception& e) {
std::cerr << "Parse error in " << cfname << "\n"
<< e.stackTrace() << std::endl;
- exit(EXIT_FAILURE);
+ exit(DownloadResult::UNKNOWN_ERROR);
}
} else if(!ucfname.empty()) {
std::cerr << StringFormat("Configuration file %s is not found.",
cfname.c_str())
<< "\n";
showUsage(TAG_HELP, oparser);
- exit(EXIT_FAILURE);
+ exit(DownloadResult::UNKNOWN_ERROR);
}
}
// Override configuration with environment variables.
@@ -616,11 +617,11 @@ Option* option_processing(int argc, char* const argv[])
<< "Usage:" << "\n"
<< oparser.findByName(e.getOptionName())->getDescription()
<< std::endl;
- exit(EXIT_FAILURE);
+ exit(DownloadResult::UNKNOWN_ERROR);
} catch(Exception& e) {
std::cerr << e.stackTrace() << std::endl;
showUsage(TAG_HELP, oparser);
- exit(EXIT_FAILURE);
+ exit(DownloadResult::UNKNOWN_ERROR);
}
}
if(
@@ -634,14 +635,14 @@ Option* option_processing(int argc, char* const argv[])
if(optind == argc) {
std::cerr << MSG_URI_REQUIRED << std::endl;
showUsage(TAG_HELP, oparser);
- exit(EXIT_FAILURE);
+ exit(DownloadResult::UNKNOWN_ERROR);
}
}
#ifdef HAVE_DAEMON
if(op->getAsBool(PREF_DAEMON)) {
if(daemon(1, 1) < 0) {
perror(MSG_DAEMON_FAILED);
- exit(EXIT_FAILURE);
+ exit(DownloadResult::UNKNOWN_ERROR);
}
}
#endif // HAVE_DAEMON