Bugfix: User \n as delimiter for easydns.
authorBjoern Sikora <bjoern.sikora@intra2net.com>
Tue, 22 Sep 2009 17:30:54 +0000 (19:30 +0200)
committerBjoern Sikora <bjoern.sikora@intra2net.com>
Tue, 22 Sep 2009 17:30:54 +0000 (19:30 +0200)
src/service_easydns.cpp
src/util.cpp
src/util.h

index 70d33c2..66d96ab 100644 (file)
@@ -8,6 +8,7 @@
 */
 
 #include "service_easydns.h"
+#include "util.h"
 
 #include <time.h>
 #include <boost/foreach.hpp>
@@ -194,12 +195,13 @@ int ServiceEasydns::perform_update(const std::string& ip)
     {
         // Get the received http data.
         string curl_data = HTTPHelp->get_curl_data();
+        string status_code = Util::parse_status_code(curl_data,"\n");
 
-        if ( curl_data == "NOERROR" )
+        if ( status_code == "NOERROR" )
         {
             return 0;
         }
-        else if ( curl_data == "NOACCESS" )
+        else if ( status_code == "NOACCESS" )
         {
             get_logger()->print_service_not_authorized(url,get_login(),get_password());
         }
index c3132bd..a043dda 100644 (file)
@@ -87,4 +87,18 @@ std::string parse_status_code(std::string data)
     boost::algorithm::split(tokens,data,boost::is_any_of(" "));
     return tokens.front();
 }
+
+
+/**
+ * Get the status code from the given data.
+ * @param data The data containing the status code at front, limited by " ".
+ * @param delimiter The delimiter to use.
+ * @return The parsed status code.
+ */
+std::string parse_status_code(std::string data, std::string delimiter)
+{
+    std::list<std::string> tokens;
+    boost::algorithm::split(tokens,data,boost::is_any_of(delimiter));
+    return tokens.front();
+}
 };
index b8262ee..a77f33c 100644 (file)
@@ -19,6 +19,7 @@ namespace Util
 {
     std::string compute_md5_digest(std::string data) throw (std::invalid_argument);
     std::string parse_status_code(std::string data);
+    std::string parse_status_code(std::string data, std::string delimiter);
 }
 
 #endif