]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
chnage get all option from capabilities
authorBastian Dehn <hhaalo@arcor.de>
Mon, 22 Jan 2024 19:58:51 +0000 (20:58 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Mon, 22 Jan 2024 19:58:51 +0000 (20:58 +0100)
src/kds_s2000w_client.c
src/kds_s2000w_client.h
src/kds_s2000w_handler.c

index 628fe64bcc79fffb0f645f3a0e25fa2bac724973..48f75f78679893b39703a76565cbf3ed54c88352 100644 (file)
@@ -89,6 +89,32 @@ void kds_s2000w_client_close_session(int64_t sessionid)
        curl = NULL;
 }
 
+int kds_s2000w_client_get_all_options(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", 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 ca0b123f73ecf76f476e0cafde1574a994ad40f9..316889c2d75a2d4e65aaa59f10736749179ebe3c 100644 (file)
@@ -9,5 +9,6 @@ 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_all_options(response* response);
 int kds_s2000w_client_get_option(int64_t sessionid, response* response);
 #endif
\ No newline at end of file
index 268f4a2b07ef5c2f1c0437772a456b1a4705efef..cbcfc4b437d20921852bf194437c1475df5cd62e 100644 (file)
@@ -61,7 +61,7 @@ void kds_s2000w_handler_get_option(int option, void* value)
                return;
 
        response* resp = kds_s2000w_client_response_init();
-       int result = kds_s2000w_client_get_option(_sessionid, resp);
+       int result = kds_s2000w_client_get_all_options(resp);
 
        if (result != 0 || resp->code == 404)
                return;