From: Bastian Dehn Date: Sun, 24 Mar 2024 07:45:15 +0000 (+0100) Subject: add curl error message to stderr X-Git-Tag: v1.0.0^2~62 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=41478d5dbba4cf5a49fda22bed5e728fb370b363;p=sane-kds-s2000w-net.git add curl error message to stderr --- diff --git a/src/kds_s2000w_client.c b/src/kds_s2000w_client.c index 063a351..de706bd 100644 --- a/src/kds_s2000w_client.c +++ b/src/kds_s2000w_client.c @@ -79,7 +79,7 @@ int kds_s2000w_client_open_session(response* response) return CURLE_FAILED_INIT; url_handler = curl_url(); - curl_url_set(url_handler, CURLUPART_URL, p_config.scanner_url, 0); + result = curl_url_set(url_handler, CURLUPART_URL, p_config.scanner_url, 0); curl_url_set(url_handler, CURLUPART_PATH, "/api/session", 0); curl_url_get(url_handler, CURLUPART_URL, &url, 0); sprintf(body, "{\"OCPUserName\": \"%s\"}", p_config.username); @@ -94,6 +94,9 @@ int kds_s2000w_client_open_session(response* response) result = curl_easy_perform(curl); curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response->code); + if (result != CURLE_OK) + fprintf(stderr, "ERROR: curl_easy_perform: %s\n", curl_easy_strerror(result)); + curl_url_cleanup(url_handler); url_handler = NULL; curl_free(url); @@ -110,6 +113,7 @@ void kds_s2000w_client_close_session(int64_t sessionid) CURL* curl = NULL; CURLU* url_handler = NULL; struct curl_slist* headers = NULL; + CURLcode result = 0; char header_str[80]; curl = curl_easy_init(); @@ -129,7 +133,10 @@ void kds_s2000w_client_close_session(int64_t sessionid) curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); - curl_easy_perform(curl); + result = curl_easy_perform(curl); + + if (result != CURLE_OK) + fprintf(stderr, "ERROR: curl_easy_perform: %s\n", curl_easy_strerror(result)); curl_url_cleanup(url_handler); url_handler = NULL; @@ -172,6 +179,9 @@ int kds_s2000w_client_status_session(int64_t sessionid, response* response) result = curl_easy_perform(curl); curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response->code); + if (result != CURLE_OK) + fprintf(stderr, "ERROR: curl_easy_perform: %s\n", curl_easy_strerror(result)); + curl_url_cleanup(url_handler); url_handler = NULL; curl_free(url); @@ -215,6 +225,9 @@ int kds_s2000w_client_start_scan(int64_t sessionid, response* response) result = curl_easy_perform(curl); curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response->code); + if (result != CURLE_OK) + fprintf(stderr, "ERROR: curl_easy_perform: %s\n", curl_easy_strerror(result)); + curl_url_cleanup(url_handler); url_handler = NULL; curl_free(url); @@ -257,6 +270,9 @@ int kds_s2000w_client_stop_scan(int64_t sessionid, response* response) result = curl_easy_perform(curl); curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response->code); + if (result != CURLE_OK) + fprintf(stderr, "ERROR: curl_easy_perform: %s\n", curl_easy_strerror(result)); + curl_url_cleanup(url_handler); url_handler = NULL; curl_free(url); @@ -301,6 +317,9 @@ int kds_s2000w_client_get_metadata(int64_t sessionid, int img_number, response* result = curl_easy_perform(curl); curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response->code); + if (result != CURLE_OK) + fprintf(stderr, "ERROR: curl_easy_perform: %s\n", curl_easy_strerror(result)); + curl_url_cleanup(url_handler); url_handler = NULL; curl_free(url); @@ -344,6 +363,9 @@ int kds_s2000w_client_get_image(int64_t sessionid, int img_number, response* res result = curl_easy_perform(curl); curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response->code); + if (result != CURLE_OK) + fprintf(stderr, "ERROR: curl_easy_perform: %s\n", curl_easy_strerror(result)); + curl_url_cleanup(url_handler); url_handler = NULL; curl_free(url); @@ -387,6 +409,9 @@ int kds_s2000w_client_delete_image(int64_t sessionid, int img_number, response* result = curl_easy_perform(curl); curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response->code); + if (result != CURLE_OK) + fprintf(stderr, "ERROR: curl_easy_perform: %s\n", curl_easy_strerror(result)); + curl_url_cleanup(url_handler); url_handler = NULL; curl_free(url); @@ -423,6 +448,9 @@ int kds_s2000w_client_get_capabilities(response* response) result = curl_easy_perform(curl); curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response->code); + if (result != CURLE_OK) + fprintf(stderr, "ERROR: curl_easy_perform: %s\n", curl_easy_strerror(result)); + curl_url_cleanup(url_handler); url_handler = NULL; curl_free(url); @@ -464,6 +492,9 @@ int kds_s2000w_client_get_option(int64_t sessionid, response* response) result = curl_easy_perform(curl); curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response->code); + if (result != CURLE_OK) + fprintf(stderr, "ERROR: curl_easy_perform: %s\n", curl_easy_strerror(result)); + curl_url_cleanup(url_handler); url_handler = NULL; curl_free(url); @@ -505,6 +536,9 @@ int kds_s2000w_client_set_option(int64_t sessionid, response* response) result = curl_easy_perform(curl); curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response->code); + if (result != CURLE_OK) + fprintf(stderr, "ERROR: curl_easy_perform: %s\n", curl_easy_strerror(result)); + curl_url_cleanup(url_handler); url_handler = NULL; curl_free(url);