From 9251b47f6cccc7cd5175ab6858c3330eb0752061 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 3 Aug 2006 12:36:02 +0000 Subject: 2006-08-03 Tatsuhiro Tsujikawa * 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. --- src/FeatureConfig.h | 70 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 29 deletions(-) (limited to 'src/FeatureConfig.h') diff --git a/src/FeatureConfig.h b/src/FeatureConfig.h index 3c048ef3..744f8a42 100644 --- a/src/FeatureConfig.h +++ b/src/FeatureConfig.h @@ -25,48 +25,60 @@ #include "common.h" #include -typedef map ProtocolPortMap; -typedef map SupportedFeatureMap; +typedef map PortMap; +typedef map FeatureMap; class FeatureConfig { private: - static ProtocolPortMap defaultPorts; - static SupportedFeatureMap supportedFeatures; + static FeatureConfig* featureConfig; + + PortMap defaultPorts; + FeatureMap supportedFeatures; + Strings features; + + FeatureConfig(); + ~FeatureConfig() {} public: - static string FEATURE_HTTP; - static string FEATURE_HTTPS; - static string FEATURE_FTP; - static string FEATURE_BITTORRENT; - static string FEATURE_METALINK; + static FeatureConfig* getInstance() { + if(!featureConfig) { + featureConfig = new FeatureConfig(); + } + return featureConfig; + } - static int getDefaultPort(const string& protocol) { - if(defaultPorts.count(protocol)) { - return defaultPorts[protocol]; - } else { + static void release() { + delete featureConfig; + featureConfig = 0; + } + + int getDefaultPort(const string& protocol) const { + PortMap::const_iterator itr = defaultPorts.find(protocol); + if(itr == defaultPorts.end()) { return 0; + } else { + return itr->second; } } - static bool isSupported(const string& protocol) { - if(supportedFeatures.count(protocol)) { - return supportedFeatures[protocol]; - } else { + bool isSupported(const string& feature) const { + FeatureMap::const_iterator itr = supportedFeatures.find(feature); + if(itr == supportedFeatures.end()) { return false; + } else { + return itr->second; } } - - static string getConfigurationSummary() { - string protos[] = { - FEATURE_HTTP, - FEATURE_HTTPS, - FEATURE_FTP, - FEATURE_BITTORRENT, - FEATURE_METALINK - }; + + const Strings& getFeatures() const { + return features; + } + + string getConfigurationSummary() const { string summary; - for(int i = 0; i < (int)(sizeof(protos)/sizeof(string)); i++) { - summary += protos[i]; - if(isSupported(protos[i])) { + for(Strings::const_iterator itr = features.begin(); + itr != features.end(); itr++) { + summary += *itr; + if(isSupported(*itr)) { summary += ": yes"; } else { summary += ": no"; -- cgit