string url = BaseUrl;
url.append(ip);
- if ( HTTPHelp->is_initialized() )
+ if ( !HTTPHelp->is_initialized() )
{
- // Perform curl operation on given url
- long http_status_code = HTTPHelp->http_get(url);
+ get_logger()->print_httphelper_not_initialized();
+ HTTPHelp->re_initialize();
+ return -1;
+ }
- get_logger()->print_http_status_code(url,http_status_code);
+ // Perform curl operation on given url
+ long http_status_code = HTTPHelp->http_get(url);
+
+ get_logger()->print_http_status_code(url,http_status_code);
+
+ // HTTP operation completed successful.
+ // Now we have to parse the data received by curl,
+ // cause http status code is not significant for dyndns update errors
+ if ( http_status_code == 200 )
+ {
+ // Get the received http data.
+ string curl_data = HTTPHelp->get_curl_data();
- // HTTP operation completed successful.
- // Now we have to parse the data received by curl,
- // cause http status code is not significant for dyndns update errors
- if ( http_status_code == 200 )
+ if ( curl_data == good )
{
- // Get the received http data.
- string curl_data = HTTPHelp->get_curl_data();
-
- if ( curl_data == good )
- {
- return 0;
- }
- else if ( curl_data == "badauth" )
- {
- get_logger()->print_service_not_authorized(url,get_login(),get_password());
- }
- else
- {
- get_logger()->print_update_failure(url, curl_data);
- }
+ return 0;
+ }
+ else if ( curl_data == "badauth" )
+ {
+ get_logger()->print_service_not_authorized(url,get_login(),get_password());
}
else
{
- get_logger()->print_update_failure(url,http_status_code);
+ get_logger()->print_update_failure(url, curl_data);
}
}
else
{
- get_logger()->print_httphelper_not_initialized();
- HTTPHelp->re_initialize();
+ get_logger()->print_update_failure(url,http_status_code);
}
+
return -1;
}