]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
get option numbers by option zero
authorBastian Dehn <hhaalo@arcor.de>
Sun, 21 Jan 2024 16:59:22 +0000 (17:59 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 21 Jan 2024 16:59:22 +0000 (17:59 +0100)
src/kds_s2000w_handler.c
src/kds_s2000w_net.c

index a7dceb85d54eebbedd2432bd03252cc84a67d923..b6a75d4cea06cb291ea6f1fac0d83cc6a3a3537d 100644 (file)
@@ -43,21 +43,22 @@ void kds_s2000w_handler_get_option(int option, void* value)
        curl_url_set(url_handler, CURLUPART_QUERY, query, CURLU_APPENDQUERY | CURLU_URLENCODE);
        char* url = NULL;
        curl_url_get(url_handler, CURLUPART_URL, &url, 0);
-       printf(url);
 
-       curl_easy_setopt(curl, CURLOPT_URL, url);
-       curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
-       curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
-       curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*) &resp);
-       CURLcode result = curl_easy_perform(curl);
-       curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &resp.code);
-
-       json_object* resObj = json_tokener_parse(resp.data);
-       json_object* config = json_object_object_get(resObj, "Configuration");
-       int* num_options = (int*) value;
-       num_options = malloc(sizeof(int));
-       *num_options = 0;
-       *num_options = json_object_object_length(config);
+       if (option == 0) {
+               curl_easy_setopt(curl, CURLOPT_URL, url);
+               curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
+               curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
+               curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*) &resp);
+               CURLcode result = curl_easy_perform(curl);
+               curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &resp.code);
+
+               json_object* resObj = json_tokener_parse(resp.data);
+               json_object* config = json_object_object_get(resObj, "Configuration");
+               int* num_options = (int*) value;
+               num_options = malloc(sizeof(int));
+               *num_options = 0;
+               *num_options = json_object_object_length(config);
+       }
 
        curl_url_cleanup(url_handler);
        url_handler = NULL;
index 9810eec92f7b3109eb1bb4fea9153942d64ce768..be49cccb35861ce48ae1ea4e3c60721a1130a3b2 100644 (file)
@@ -99,7 +99,7 @@ SANE_Status _sane_kds_s2000w_net_control_option(SANE_Handle handle,
        if (action == SANE_ACTION_SET_AUTO)
                kds_s2000w_handler_set_option_auto(option);
 
-       return SANE_STATUS_UNSUPPORTED;
+       return SANE_STATUS_GOOD;
 }
 
 SANE_Status _sane_kds_s2000w_net_get_parameters(SANE_Handle handle,