From: Thomas Jarosch Date: Mon, 18 Oct 2010 09:40:00 +0000 (+0200) Subject: Save one indent level in ServiceDyndns::perform_update() X-Git-Tag: v1.1~37 X-Git-Url: http://developer.intra2net.com/git/?p=bpdyndnsd;a=commitdiff_plain;h=25ce914f4431a30f49de2ea039f762b7c98f67a9 Save one indent level in ServiceDyndns::perform_update() --- diff --git a/src/service_dyndns.cpp b/src/service_dyndns.cpp index 9fb1dfc..1ab80f6 100644 --- a/src/service_dyndns.cpp +++ b/src/service_dyndns.cpp @@ -104,43 +104,43 @@ int ServiceDyndns::perform_update(const std::string& ip) 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; }