mirror of
https://github.com/aria2/aria2.git
synced 2026-04-13 16:23:03 +00:00
* src/Option.h (getAsBool): New function. * src/Option.cc (prefs.h): Included. (defined): 0-length value is now recognized as undefined. (getAsInt): Rewritten. (getAsLLInt): Rewritten. (getAsBool): New function. * src/FeatureConfig.h: Rewritten. * src/FeatureConfig.cc: Rewritten. * src/prefs.h (PREF_STDOUT_LOG): New definition. (PREF_LOG): New definition. (PREF_DIR): New definition. (PREF_OUT): New definition. (PREF_SPLIT): New definition. (PREF_DAEMON): New definition. (PREF_REFERER): New definition. (PREF_TORRENT_FILE): New definition. (PREF_LISTEN_PORT): New definition. (PREF_METALINK_FILE): New definition. (PREF_METALINK_VERSION): New definition. (PREF_METALINK_LANGUAGE): New definition. (PREF_METALINK_OS): New definition. (PREF_METALINK_SERVERS): New definition. * src/main.cc (main): Following command-line parameters are now put into Option class: stdoutLog, logfile, dir, ufilename, split, daemonMode, referer, torrentFile, metalinkFile, listenPort, metalinkVersion, metalinkLanguage, metalinkOs, metalinkServers To fix the bug that aria2 can not handle http response header properly. * src/HttpHeader.cc (put): Made name lowercased. (defined): Made name lowercased. (getFirst): Made name lowercased. (get): Made name lowercased. (getFirstAsInt): Rewritten. (getFirstAsLLInt): Rewritten.
72 lines
1.8 KiB
C++
72 lines
1.8 KiB
C++
/* <!-- copyright */
|
|
/*
|
|
* aria2 - a simple utility for downloading files faster
|
|
*
|
|
* Copyright (C) 2006 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*/
|
|
/* copyright --> */
|
|
#include "Option.h"
|
|
#include "prefs.h"
|
|
|
|
Option::Option() {}
|
|
|
|
Option::~Option() {}
|
|
|
|
void Option::put(const string& name, const string& value) {
|
|
table[name] = value;
|
|
}
|
|
|
|
bool Option::defined(const string& name) const {
|
|
return table.count(name) == 1;
|
|
}
|
|
|
|
string Option::get(const string& name) const {
|
|
map<string, string>::const_iterator itr = table.find(name);
|
|
if(itr == table.end()) {
|
|
return "";
|
|
} else {
|
|
return (*itr).second;
|
|
}
|
|
}
|
|
|
|
int Option::getAsInt(const string& name) const {
|
|
string value = get(name);
|
|
if(value == "") {
|
|
return 0;
|
|
} else {
|
|
return (int)strtol(value.c_str(), NULL, 10);
|
|
}
|
|
}
|
|
|
|
long long int Option::getAsLLInt(const string& name) const {
|
|
string value = get(name);
|
|
if(value == "") {
|
|
return 0;
|
|
} else {
|
|
return strtoll(value.c_str(), NULL, 10);
|
|
}
|
|
}
|
|
|
|
bool Option::getAsBool(const string& name) const {
|
|
string value = get(name);
|
|
if(value == V_TRUE) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|