*/
#include "service_easydns.h"
+#include "util.h"
#include <time.h>
#include <boost/foreach.hpp>
{
// 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());
}
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();
+}
};
{
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