From 4821377f72cbb873d27e41d22ee77643ee37a641 Mon Sep 17 00:00:00 2001 From: Bjoern Sikora Date: Mon, 10 Aug 2009 17:20:34 +0200 Subject: [PATCH] Convert protocol to lower case. --- src/config.cpp | 22 +++++++++++++++++++--- src/config.h | 1 + 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index 205cac0..517f5f8 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -258,7 +258,7 @@ int Config::parse_cmd_line(int argc, char *argv[]) string login = VariablesMap["login"].as(); string password = VariablesMap["password"].as(); - //TODO: convert protocol option to lowercase + protocol = to_lower(protocol); Service::Ptr service = create_service(protocol,host,login,password); if ( service ) @@ -332,6 +332,23 @@ Service::Ptr Config::create_service(const string &protocol,const string &hostnam /** + * Converts first ten characters of given string to lowercase. + * @param input String. + * @return String in lowercase. + */ +string Config::to_lower(string input) +{ + int i = 0; + while ( input[i] && i<10 ) + { + input[i] = tolower(input[i]); + i++; + } + return input; +} + + +/** * Loads a service config file, invoked by load_config_from_files. * @param full_filename Filename of the service config file to load. * @return 0 if all is fine, -1 otherwise. @@ -358,8 +375,7 @@ int Config::load_service_config_file(const string& full_filename) string login = vm["login"].as(); string password = vm["password"].as(); - // TODO: convert protocol to lowercase - //protocol = tolower(protocol.c_str()); + protocol = to_lower(protocol); Service::Ptr service = create_service(protocol,host,login,password); if ( service ) diff --git a/src/config.h b/src/config.h index c9a6985..841ac8c 100644 --- a/src/config.h +++ b/src/config.h @@ -44,6 +44,7 @@ private: Service::Ptr create_service(const std::string&,const std::string&,const std::string&,const std::string&); int load_main_config_file(const std::string&); int load_service_config_file(const std::string&); + std::string to_lower(std::string); public: -- 1.7.1