]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
add load capabilities and print stdout
authorBastian Dehn <hhaalo@arcor.de>
Sun, 28 Jan 2024 19:54:15 +0000 (20:54 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 28 Jan 2024 19:54:21 +0000 (20:54 +0100)
src/kds_s2000w_client.c
src/kds_s2000w_client.h
src/kds_s2000w_handler.c

index 350fd6a270cb65c964b35fecb143aa000edabfe3..5cffaeaeb913a939094c75b9a3ae20b61502b1e0 100644 (file)
@@ -100,6 +100,32 @@ void kds_s2000w_client_close_session(int64_t sessionid)
        curl = NULL;
 }
 
+int kds_s2000w_client_get_capabilities(response* response)
+{
+       CURL *curl = curl_easy_init();
+       if(!curl)
+               return CURLE_FAILED_INIT;
+
+       CURLU* url_handler = curl_url();
+       curl_url_set(url_handler, CURLUPART_URL, "http://scanner.lan.hhaalo.de/api/scanner/capabilities?V2", 0);
+       char* url = NULL;
+       curl_url_get(url_handler, CURLUPART_URL, &url, 0);
+
+       curl_easy_setopt(curl, CURLOPT_URL, url);
+       curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
+       curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _kds_s2000w_client_callback);
+       curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*) response);
+       CURLcode result = curl_easy_perform(curl);
+       curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response->code);
+
+       curl_url_cleanup(url_handler);
+       url_handler = NULL;
+       curl_free(url);
+       url = NULL;
+
+       return result;
+}
+
 int kds_s2000w_client_get_option(int64_t sessionid, response* response)
 {
        CURL *curl = curl_easy_init();
index 8c0e5bf1c6d4aa626af2da9f35dd744f0438e6a2..5f646c61c31f37798254c2252a0628066bd1123b 100644 (file)
@@ -9,6 +9,7 @@ response* kds_s2000w_client_response_init();
 void kds_s2000w_client_response_free(response* response);
 int kds_s2000w_client_open_session(const char* username, response* response);
 void kds_s2000w_client_close_session(int64_t sessionid);
+int kds_s2000w_client_get_capabilities(response* response);
 int kds_s2000w_client_get_option(int64_t sessionid, response* response);
 int kds_s2000w_client_set_option(int64_t sessionid, response* response);
 #endif
\ No newline at end of file
index 5b28681e1e12ed26311cf253072f0f550a628a45..9fef227c2b21b2d8eebfa2b54fbd0dec90ce3381 100644 (file)
@@ -306,6 +306,14 @@ void kds_s2000w_handler_set_option(int option, void* value)
                        value_object = json_object_object_get(config, "ScanSource");
                        _write_string_value_to_json(value_object, value);
                        break;
+               case 24:
+                       printf("Konfiguration reset\n");
+                       resp = kds_s2000w_client_response_init();
+                       kds_s2000w_client_get_capabilities(resp);
+                       printf("capabilities: %s\n", resp->data);
+                       kds_s2000w_client_response_free(resp);
+                       resp = NULL;
+                       break;
                default:
                        break;
        }