Convert protocol to lower case.
authorBjoern Sikora <bjoern.sikora@intra2net.com>
Mon, 10 Aug 2009 15:20:34 +0000 (17:20 +0200)
committerBjoern Sikora <bjoern.sikora@intra2net.com>
Mon, 10 Aug 2009 15:20:34 +0000 (17:20 +0200)
src/config.cpp
src/config.h

index 205cac0..517f5f8 100644 (file)
@@ -258,7 +258,7 @@ int Config::parse_cmd_line(int argc, char *argv[])
             string login = VariablesMap["login"].as<string>();
             string password = VariablesMap["password"].as<string>();
 
-            //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>();
                 string password = vm["password"].as<string>();
 
-                // 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 )
index c9a6985..841ac8c 100644 (file)
@@ -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: