From 8fb7a083e3cdf2b3970896933be63900e8a41aee Mon Sep 17 00:00:00 2001 From: Bjoern Sikora Date: Tue, 22 Sep 2009 19:30:54 +0200 Subject: [PATCH] Bugfix: User \n as delimiter for easydns. --- src/service_easydns.cpp | 6 ++++-- src/util.cpp | 14 ++++++++++++++ src/util.h | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/service_easydns.cpp b/src/service_easydns.cpp index 70d33c2..66d96ab 100644 --- a/src/service_easydns.cpp +++ b/src/service_easydns.cpp @@ -8,6 +8,7 @@ */ #include "service_easydns.h" +#include "util.h" #include #include @@ -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()); } diff --git a/src/util.cpp b/src/util.cpp index c3132bd..a043dda 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -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 tokens; + boost::algorithm::split(tokens,data,boost::is_any_of(delimiter)); + return tokens.front(); +} }; diff --git a/src/util.h b/src/util.h index b8262ee..a77f33c 100644 --- a/src/util.h +++ b/src/util.h @@ -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 -- 1.7.1