]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
add curl error message to stderr
authorBastian Dehn <hhaalo@arcor.de>
Sun, 24 Mar 2024 07:45:15 +0000 (08:45 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 24 Mar 2024 07:45:15 +0000 (08:45 +0100)
src/kds_s2000w_client.c

index 063a35145e145d321c3277af92bdf43041c9f55b..de706bd423005eddf6612b66732cf5f9823d8809 100644 (file)
@@ -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);