123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856 |
- /* <!-- copyright */
- /*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2010 Tatsuhiro Tsujikawa
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
- /* copyright --> */
- #include "OptionHandlerImpl.h"
- #include <cassert>
- #include <cstdio>
- #include <cstring>
- #include <utility>
- #include <algorithm>
- #include <numeric>
- #include <sstream>
- #include <iterator>
- #include <vector>
- #include "util.h"
- #include "DlAbortEx.h"
- #include "prefs.h"
- #include "Option.h"
- #include "fmt.h"
- #include "A2STR.h"
- #include "Request.h"
- #include "a2functional.h"
- #include "message.h"
- #include "File.h"
- #include "FileEntry.h"
- #include "a2io.h"
- #include "LogFactory.h"
- #include "uri.h"
- #include "SegList.h"
- #include "array_fun.h"
- #ifdef ENABLE_MESSAGE_DIGEST
- # include "MessageDigest.h"
- #endif // ENABLE_MESSAGE_DIGEST
- namespace aria2 {
- BooleanOptionHandler::BooleanOptionHandler
- (const Pref* pref,
- const char* description,
- const std::string& defaultValue,
- OptionHandler::ARG_TYPE argType,
- char shortName)
- : AbstractOptionHandler(pref, description, defaultValue,
- argType, shortName)
- {}
- BooleanOptionHandler::~BooleanOptionHandler() {}
- void BooleanOptionHandler::parseArg(Option& option, const std::string& optarg)
- {
- if(optarg == "true" ||
- ((argType_ == OptionHandler::OPT_ARG ||
- argType_ == OptionHandler::NO_ARG)
- && optarg.empty())) {
- option.put(pref_, A2_V_TRUE);
- } else if(optarg == "false") {
- option.put(pref_, A2_V_FALSE);
- } else {
- std::string msg = pref_->k;
- strappend(msg, " ", _("must be either 'true' or 'false'."));
- throw DL_ABORT_EX(msg);
- }
- }
- std::string BooleanOptionHandler::createPossibleValuesString() const
- {
- return "true, false";
- }
- IntegerRangeOptionHandler::IntegerRangeOptionHandler
- (const Pref* pref,
- const char* description,
- const std::string& defaultValue,
- int32_t min, int32_t max,
- char shortName)
- : AbstractOptionHandler(pref, description, defaultValue,
- OptionHandler::REQ_ARG, shortName),
- min_(min),
- max_(max)
- {}
- IntegerRangeOptionHandler::~IntegerRangeOptionHandler() {}
- void IntegerRangeOptionHandler::parseArg
- (Option& option, const std::string& optarg)
- {
- SegList<int> sgl;
- util::parseIntSegments(sgl, optarg);
- sgl.normalize();
- while(sgl.hasNext()) {
- int v = sgl.next();
- if(v < min_ || max_ < v) {
- std::string msg = pref_->k;
- strappend(msg, " ", _("must be between %s and %s."));
- throw DL_ABORT_EX
- (fmt(msg.c_str(), util::itos(min_).c_str(),
- util::itos(max_).c_str()));
- }
- option.put(pref_, optarg);
- }
- }
- std::string IntegerRangeOptionHandler::createPossibleValuesString() const
- {
- return util::itos(min_)+"-"+util::itos(max_);
- }
- NumberOptionHandler::NumberOptionHandler
- (const Pref* pref,
- const char* description,
- const std::string& defaultValue,
- int64_t min,
- int64_t max,
- char shortName)
- : AbstractOptionHandler(pref, description, defaultValue,
- OptionHandler::REQ_ARG, shortName),
- min_(min),
- max_(max)
- {}
- NumberOptionHandler::~NumberOptionHandler() {}
- void NumberOptionHandler::parseArg(Option& option, const std::string& optarg)
- {
- parseArg(option, util::parseLLInt(optarg));
- }
- void NumberOptionHandler::parseArg(Option& option, int64_t number)
- {
- if((min_ == -1 || min_ <= number) && (max_ == -1 || number <= max_)) {
- option.put(pref_, util::itos(number));
- } else {
- std::string msg = pref_->k;
- msg += " ";
- if(min_ == -1 && max_ != -1) {
- msg += fmt(_("must be smaller than or equal to %s."),
- util::itos(max_).c_str());
- } else if(min_ != -1 && max_ != -1) {
- msg += fmt(_("must be between %s and %s."),
- util::itos(min_).c_str(),
- util::itos(max_).c_str());
- } else if(min_ != -1 && max_ == -1) {
- msg += fmt(_("must be greater than or equal to %s."),
- util::itos(min_).c_str());
- } else {
- msg += _("must be a number.");
- }
- throw DL_ABORT_EX(msg);
- }
- }
- std::string NumberOptionHandler::createPossibleValuesString() const
- {
- std::string values;
- if(min_ == -1) {
- values += "*";
- } else {
- values += util::itos(min_);
- }
- values += "-";
- if(max_ == -1) {
- values += "*";
- } else {
- values += util::itos(max_);
- }
- return values;
- }
- UnitNumberOptionHandler::UnitNumberOptionHandler
- (const Pref* pref,
- const char* description,
- const std::string& defaultValue,
- int64_t min,
- int64_t max,
- char shortName)
- : NumberOptionHandler(pref, description, defaultValue, min, max,
- shortName)
- {}
- UnitNumberOptionHandler::~UnitNumberOptionHandler() {}
- void UnitNumberOptionHandler::parseArg
- (Option& option, const std::string& optarg)
- {
- int64_t num = util::getRealSize(optarg);
- NumberOptionHandler::parseArg(option, num);
- }
- FloatNumberOptionHandler::FloatNumberOptionHandler
- (const Pref* pref,
- const char* description,
- const std::string& defaultValue,
- double min,
- double max,
- char shortName)
- : AbstractOptionHandler(pref, description, defaultValue,
- OptionHandler::REQ_ARG, shortName),
- min_(min),
- max_(max)
- {}
- FloatNumberOptionHandler::~FloatNumberOptionHandler() {}
- void FloatNumberOptionHandler::parseArg
- (Option& option, const std::string& optarg)
- {
- double number = strtod(optarg.c_str(), 0);
- if((min_ < 0 || min_ <= number) && (max_ < 0 || number <= max_)) {
- option.put(pref_, optarg);
- } else {
- std::string msg = pref_->k;
- msg += " ";
- if(min_ < 0 && max_ >= 0) {
- msg += fmt(_("must be smaller than or equal to %.1f."), max_);
- } else if(min_ >= 0 && max_ >= 0) {
- msg += fmt(_("must be between %.1f and %.1f."), min_, max_);
- } else if(min_ >= 0 && max_ < 0) {
- msg += fmt(_("must be greater than or equal to %.1f."), min_);
- } else {
- msg += _("must be a number.");
- }
- throw DL_ABORT_EX(msg);
- }
- }
- std::string FloatNumberOptionHandler::createPossibleValuesString() const
- {
- std::string valuesString;
- if(min_ < 0) {
- valuesString += "*";
- } else {
- char buf[11];
- snprintf(buf, sizeof(buf), "%.1f", min_);
- valuesString += buf;
- }
- valuesString += "-";
- if(max_ < 0) {
- valuesString += "*";
- } else {
- char buf[11];
- snprintf(buf, sizeof(buf), "%.1f", max_);
- valuesString += buf;
- }
- return valuesString;
- }
- DefaultOptionHandler::DefaultOptionHandler
- (const Pref* pref,
- const char* description,
- const std::string& defaultValue,
- const std::string& possibleValuesString,
- OptionHandler::ARG_TYPE argType,
- char shortName)
- : AbstractOptionHandler(pref, description, defaultValue, argType,
- shortName),
- possibleValuesString_(possibleValuesString)
- {}
- DefaultOptionHandler::~DefaultOptionHandler() {}
- void DefaultOptionHandler::parseArg(Option& option, const std::string& optarg)
- {
- option.put(pref_, optarg);
- }
- std::string DefaultOptionHandler::createPossibleValuesString() const
- {
- return possibleValuesString_;
- }
- CumulativeOptionHandler::CumulativeOptionHandler
- (const Pref* pref,
- const char* description,
- const std::string& defaultValue,
- const std::string& delim,
- const std::string& possibleValuesString,
- OptionHandler::ARG_TYPE argType,
- char shortName)
- : AbstractOptionHandler(pref, description, defaultValue, argType,
- shortName),
- delim_(delim),
- possibleValuesString_(possibleValuesString)
- {}
- CumulativeOptionHandler::~CumulativeOptionHandler() {}
- void CumulativeOptionHandler::parseArg
- (Option& option, const std::string& optarg)
- {
- std::string value = option.get(pref_);
- strappend(value, optarg, delim_);
- option.put(pref_, value);
- }
- std::string CumulativeOptionHandler::createPossibleValuesString() const
- {
- return possibleValuesString_;
- }
- IndexOutOptionHandler::IndexOutOptionHandler
- (const Pref* pref,
- const char* description,
- char shortName)
- : AbstractOptionHandler(pref, description, NO_DEFAULT_VALUE,
- OptionHandler::REQ_ARG, shortName)
- {}
- IndexOutOptionHandler::~IndexOutOptionHandler() {}
- void IndexOutOptionHandler::parseArg(Option& option, const std::string& optarg)
- {
- // See optarg is in the fomrat of "INDEX=PATH"
- util::parseIndexPath(optarg);
- std::string value = option.get(pref_);
- strappend(value, optarg, "\n");
- option.put(pref_, value);
- }
- std::string IndexOutOptionHandler::createPossibleValuesString() const
- {
- return "INDEX=PATH";
- }
- #ifdef ENABLE_MESSAGE_DIGEST
- ChecksumOptionHandler::ChecksumOptionHandler
- (const Pref* pref,
- const char* description,
- char shortName)
- : AbstractOptionHandler(pref, description, NO_DEFAULT_VALUE,
- OptionHandler::REQ_ARG, shortName)
- {}
- ChecksumOptionHandler::~ChecksumOptionHandler() {}
- void ChecksumOptionHandler::parseArg(Option& option, const std::string& optarg)
- {
- std::pair<Scip, Scip> p;
- util::divide(p, optarg.begin(), optarg.end(), '=');
- std::string hashType(p.first.first, p.first.second);
- std::string hexDigest(p.second.first, p.second.second);
- util::lowercase(hashType);
- util::lowercase(hexDigest);
- if(!MessageDigest::isValidHash(hashType, hexDigest)) {
- throw DL_ABORT_EX(_("Unrecognized checksum"));
- }
- option.put(pref_, optarg);
- }
- std::string ChecksumOptionHandler::createPossibleValuesString() const
- {
- return "HASH_TYPE=HEX_DIGEST";
- }
- #endif // ENABLE_MESSAGE_DIGEST
- ParameterOptionHandler::ParameterOptionHandler
- (const Pref* pref,
- const char* description,
- const std::string& defaultValue,
- const std::vector<std::string>& validParamValues,
- char shortName)
- : AbstractOptionHandler(pref, description, defaultValue,
- OptionHandler::REQ_ARG, shortName),
- validParamValues_(validParamValues)
- {}
- ParameterOptionHandler::ParameterOptionHandler
- (const Pref* pref,
- const char* description,
- const std::string& defaultValue,
- const std::string& validParamValue,
- char shortName)
- : AbstractOptionHandler(pref, description, defaultValue,
- OptionHandler::REQ_ARG, shortName)
- {
- validParamValues_.push_back(validParamValue);
- }
- ParameterOptionHandler::ParameterOptionHandler
- (const Pref* pref,
- const char* description,
- const std::string& defaultValue,
- const std::string& validParamValue1,
- const std::string& validParamValue2,
- char shortName)
- : AbstractOptionHandler(pref, description, defaultValue,
- OptionHandler::REQ_ARG, shortName)
- {
- validParamValues_.push_back(validParamValue1);
- validParamValues_.push_back(validParamValue2);
- }
- ParameterOptionHandler::ParameterOptionHandler
- (const Pref* pref,
- const char* description,
- const std::string& defaultValue,
- const std::string& validParamValue1,
- const std::string& validParamValue2,
- const std::string& validParamValue3,
- char shortName)
- : AbstractOptionHandler(pref, description, defaultValue,
- OptionHandler::REQ_ARG, shortName)
- {
- validParamValues_.push_back(validParamValue1);
- validParamValues_.push_back(validParamValue2);
- validParamValues_.push_back(validParamValue3);
- }
-
- ParameterOptionHandler::~ParameterOptionHandler() {}
- void ParameterOptionHandler::parseArg(Option& option, const std::string& optarg)
- {
- std::vector<std::string>::const_iterator itr =
- std::find(validParamValues_.begin(), validParamValues_.end(), optarg);
- if(itr == validParamValues_.end()) {
- std::string msg = pref_->k;
- strappend(msg, " ", _("must be one of the following:"));
- if(validParamValues_.size() == 0) {
- msg += "''";
- } else {
- for(std::vector<std::string>::const_iterator itr =
- validParamValues_.begin(), eoi = validParamValues_.end();
- itr != eoi; ++itr) {
- strappend(msg, "'", *itr, "' ");
- }
- }
- throw DL_ABORT_EX(msg);
- } else {
- option.put(pref_, optarg);
- }
- }
- std::string ParameterOptionHandler::createPossibleValuesString() const
- {
- std::stringstream s;
- std::copy(validParamValues_.begin(), validParamValues_.end(),
- std::ostream_iterator<std::string>(s, ", "));
- return util::strip(s.str(), ", ");
- }
- HostPortOptionHandler::HostPortOptionHandler
- (const Pref* pref,
- const char* description,
- const std::string& defaultValue,
- const Pref* hostOptionName,
- const Pref* portOptionName,
- char shortName)
- : AbstractOptionHandler(pref, description, defaultValue,
- OptionHandler::REQ_ARG, shortName),
- hostOptionName_(hostOptionName),
- portOptionName_(portOptionName)
- {}
- HostPortOptionHandler::~HostPortOptionHandler() {}
- void HostPortOptionHandler::parseArg(Option& option, const std::string& optarg)
- {
- std::string uri = "http://";
- uri += optarg;
- Request req;
- if(!req.setUri(uri)) {
- throw DL_ABORT_EX(_("Unrecognized format"));
- }
- option.put(pref_, optarg);
- setHostAndPort(option, req.getHost(), req.getPort());
- }
- void HostPortOptionHandler::setHostAndPort
- (Option& option, const std::string& hostname, uint16_t port)
- {
- option.put(hostOptionName_, hostname);
- option.put(portOptionName_, util::uitos(port));
- }
- std::string HostPortOptionHandler::createPossibleValuesString() const
- {
- return "HOST:PORT";
- }
- HttpProxyUserOptionHandler::HttpProxyUserOptionHandler
- (const Pref* pref,
- const char* description,
- const std::string& defaultValue,
- char shortName)
- : AbstractOptionHandler(pref, description, defaultValue,
- OptionHandler::REQ_ARG, shortName)
- {}
- void HttpProxyUserOptionHandler::parseArg
- (Option& option, const std::string& optarg)
- {
- static const char A2_USER[] = "-user";
- size_t kLen = strlen(pref_->k);
- if(util::endsWith(pref_->k, pref_->k+kLen, A2_USER, vend(A2_USER)-1)) {
- const Pref* proxyPref = option::k2p(std::string(pref_->k, kLen-5));
- const std::string& olduri = option.get(proxyPref);
- if(!olduri.empty()) {
- Request req;
- bool b = req.setUri(olduri);
- assert(b);
- std::string uri = "http://";
- if(!optarg.empty()) {
- uri += util::percentEncode(optarg);
- }
- if(req.hasPassword()) {
- uri += A2STR::COLON_C;
- uri += util::percentEncode(req.getPassword());
- }
- if(uri.size() > 7) {
- uri += "@";
- }
- strappend(uri, req.getHost(),A2STR::COLON_C,util::uitos(req.getPort()));
- option.put(proxyPref, uri);
- }
- }
- option.put(pref_, optarg);
- }
- std::string HttpProxyUserOptionHandler::createPossibleValuesString() const
- {
- return "";
- }
- HttpProxyPasswdOptionHandler::HttpProxyPasswdOptionHandler
- (const Pref* pref,
- const char* description,
- const std::string& defaultValue,
- char shortName)
- : AbstractOptionHandler(pref, description, defaultValue,
- OptionHandler::REQ_ARG, shortName)
- {}
- void HttpProxyPasswdOptionHandler::parseArg
- (Option& option, const std::string& optarg)
- {
- static const char A2_PASSWD[] = "-passwd";
- size_t kLen = strlen(pref_->k);
- if(util::endsWith(pref_->k, pref_->k+kLen, A2_PASSWD, vend(A2_PASSWD)-1)) {
- const Pref* proxyPref = option::k2p(std::string(pref_->k, kLen-7));
- const std::string& olduri = option.get(proxyPref);
- if(!olduri.empty()) {
- Request req;
- bool b = req.setUri(olduri);
- assert(b);
- std::string uri = "http://";
- if(!req.getUsername().empty()) {
- uri += util::percentEncode(req.getUsername());
- }
- uri += A2STR::COLON_C;
- if(!optarg.empty()) {
- uri += util::percentEncode(optarg);
- }
- if(uri.size() > 7) {
- uri += "@";
- }
- strappend(uri, req.getHost(), A2STR::COLON_C,util::itos(req.getPort()));
- option.put(proxyPref, uri);
- }
- }
- option.put(pref_, optarg);
- }
- std::string HttpProxyPasswdOptionHandler::createPossibleValuesString() const
- {
- return "";
- }
- HttpProxyOptionHandler::HttpProxyOptionHandler
- (const Pref* pref,
- const char* description,
- const std::string& defaultValue,
- char shortName)
- : AbstractOptionHandler(pref, description, defaultValue,
- OptionHandler::REQ_ARG, shortName),
- proxyUserPref_(option::k2p(std::string(pref->k)+"-user")),
- proxyPasswdPref_(option::k2p(std::string(pref->k)+"-passwd"))
- {}
- HttpProxyOptionHandler::~HttpProxyOptionHandler() {}
- void HttpProxyOptionHandler::parseArg(Option& option, const std::string& optarg)
- {
- if(optarg.empty()) {
- option.put(pref_, optarg);
- } else {
- Request req;
- std::string uri;
- static const char A2_HTTP[] = "http://";
- static const char A2_HTTPS[] = "https://";
- static const char A2_FTP[] = "ftp://";
- if(util::startsWith(optarg.begin(), optarg.end(),
- A2_HTTP, vend(A2_HTTP)-1) ||
- util::startsWith(optarg.begin(), optarg.end(),
- A2_HTTPS, vend(A2_HTTPS)-1) ||
- util::startsWith(optarg.begin(), optarg.end(),
- A2_FTP, vend(A2_FTP)-1)) {
- uri = optarg;
- } else {
- uri = "http://";
- uri += optarg;
- }
- uri::UriStruct us;
- if(!uri::parse(us, uri)) {
- throw DL_ABORT_EX(_("unrecognized proxy format"));
- }
- us.protocol = "http";
- if(us.username.empty()) {
- if(option.defined(proxyUserPref_)) {
- us.username = option.get(proxyUserPref_);
- }
- }
- if(!us.hasPassword) {
- if(option.defined(proxyPasswdPref_)) {
- us.password = option.get(proxyPasswdPref_);
- us.hasPassword = true;
- }
- }
- option.put(pref_, uri::construct(us));
- }
- }
- std::string HttpProxyOptionHandler::createPossibleValuesString() const
- {
- return "[http://][USER:PASSWORD@]HOST[:PORT]";
- }
- LocalFilePathOptionHandler::LocalFilePathOptionHandler
- (const Pref* pref,
- const char* description,
- const std::string& defaultValue,
- bool acceptStdin,
- char shortName)
- : AbstractOptionHandler(pref, description, defaultValue,
- OptionHandler::REQ_ARG, shortName),
- acceptStdin_(acceptStdin)
- {}
- void LocalFilePathOptionHandler::parseArg
- (Option& option, const std::string& optarg)
- {
- if(acceptStdin_ && optarg == "-") {
- option.put(pref_, DEV_STDIN);
- } else {
- File f(optarg);
- if(!f.exists() || f.isDir()) {
- throw DL_ABORT_EX(fmt(MSG_NOT_FILE, optarg.c_str()));
- }
- option.put(pref_, optarg);
- }
- }
-
- std::string LocalFilePathOptionHandler::createPossibleValuesString() const
- {
- if(acceptStdin_) {
- return PATH_TO_FILE_STDIN;
- } else {
- return PATH_TO_FILE;
- }
- }
- PrioritizePieceOptionHandler::PrioritizePieceOptionHandler
- (const Pref* pref,
- const char* description,
- const std::string& defaultValue,
- char shortName)
- : AbstractOptionHandler(pref, description, defaultValue,
- OptionHandler::REQ_ARG, shortName)
- {}
- void PrioritizePieceOptionHandler::parseArg
- (Option& option, const std::string& optarg)
- {
- // Parse optarg against empty FileEntry list to detect syntax
- // error.
- std::vector<size_t> result;
- util::parsePrioritizePieceRange
- (result, optarg, std::vector<SharedHandle<FileEntry> >(), 1024);
- option.put(pref_, optarg);
- }
- std::string PrioritizePieceOptionHandler::createPossibleValuesString() const
- {
- return "head[=SIZE], tail[=SIZE]";
- }
- DeprecatedOptionHandler::DeprecatedOptionHandler
- (const SharedHandle<OptionHandler>& depOptHandler,
- const SharedHandle<OptionHandler>& repOptHandler)
- : depOptHandler_(depOptHandler), repOptHandler_(repOptHandler)
- {}
- void DeprecatedOptionHandler::parse(Option& option, const std::string& arg)
- {
- if(repOptHandler_) {
- A2_LOG_WARN(fmt(_("--%s option is deprecated. Use --%s option instead."),
- depOptHandler_->getName(),
- repOptHandler_->getName()));
- repOptHandler_->parse(option, arg);
- } else {
- A2_LOG_WARN(fmt(_("--%s option is deprecated."),
- depOptHandler_->getName()));
- }
- }
- std::string DeprecatedOptionHandler::createPossibleValuesString() const
- {
- return depOptHandler_->createPossibleValuesString();
- }
- bool DeprecatedOptionHandler::hasTag(const std::string& tag) const
- {
- return depOptHandler_->hasTag(tag);
- }
- void DeprecatedOptionHandler::addTag(const std::string& tag)
- {
- depOptHandler_->addTag(tag);
- }
- std::string DeprecatedOptionHandler::toTagString() const
- {
- return depOptHandler_->toTagString();
- }
- const char* DeprecatedOptionHandler::getName() const
- {
- return depOptHandler_->getName();
- }
- const char* DeprecatedOptionHandler::getDescription() const
- {
- return depOptHandler_->getDescription();
- }
- const std::string& DeprecatedOptionHandler::getDefaultValue() const
- {
- return depOptHandler_->getDefaultValue();
- }
- bool DeprecatedOptionHandler::isHidden() const
- {
- return depOptHandler_->isHidden();
- }
- void DeprecatedOptionHandler::hide()
- {
- depOptHandler_->hide();
- }
- const Pref* DeprecatedOptionHandler::getPref() const
- {
- return depOptHandler_->getPref();
- }
- OptionHandler::ARG_TYPE DeprecatedOptionHandler::getArgType() const
- {
- return depOptHandler_->getArgType();
- }
- char DeprecatedOptionHandler::getShortName() const
- {
- return depOptHandler_->getShortName();
- }
- bool DeprecatedOptionHandler::getEraseAfterParse() const
- {
- return depOptHandler_->getEraseAfterParse();
- }
- void DeprecatedOptionHandler::setEraseAfterParse(bool eraseAfterParse)
- {
- depOptHandler_->setEraseAfterParse(eraseAfterParse);
- }
- bool DeprecatedOptionHandler::getInitialOption() const
- {
- return depOptHandler_->getInitialOption();
- }
- void DeprecatedOptionHandler::setInitialOption(bool f)
- {
- depOptHandler_->setInitialOption(f);
- }
- bool DeprecatedOptionHandler::getChangeOption() const
- {
- return depOptHandler_->getChangeOption();
- }
- void DeprecatedOptionHandler::setChangeOption(bool f)
- {
- depOptHandler_->setChangeOption(f);
- }
- bool DeprecatedOptionHandler::getChangeOptionForReserved() const
- {
- return depOptHandler_->getChangeOptionForReserved();
- }
- void DeprecatedOptionHandler::setChangeOptionForReserved(bool f)
- {
- depOptHandler_->setChangeOptionForReserved(f);
- }
- bool DeprecatedOptionHandler::getChangeGlobalOption() const
- {
- return depOptHandler_->getChangeGlobalOption();
- }
- void DeprecatedOptionHandler::setChangeGlobalOption(bool f)
- {
- depOptHandler_->setChangeGlobalOption(f);
- }
- bool DeprecatedOptionHandler::getCumulative() const
- {
- return depOptHandler_->getCumulative();
- }
- void DeprecatedOptionHandler::setCumulative(bool f)
- {
- depOptHandler_->setCumulative(f);
- }
- } // namespace aria2
|