]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
change config read from one global variable
authorBastian Dehn <hhaalo@arcor.de>
Sun, 10 Mar 2024 15:40:15 +0000 (16:40 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 10 Mar 2024 15:41:58 +0000 (16:41 +0100)
src/kds_s2000w_handler.c
src/kds_s2000w_handler_opts.c

index 577cfb1e2724dd7b99f84013237fb353d44c18b4..ddf10fff61a7d65fbf8d66111bfc65a26deaa38d 100644 (file)
@@ -10,7 +10,6 @@
 #include "kds_s2000w_debug.h"
 
 json_object* resp_config = NULL;
-json_object* config = NULL;
 
 void _get_current_metadata(handler* h)
 {
@@ -18,6 +17,7 @@ void _get_current_metadata(handler* h)
        json_object* metadataResp = NULL;
        json_object* metadata = NULL;
        json_object* mdata_value = NULL;
+       json_object* config = NULL;
        blobdata* jpg_image = NULL;
        blobdata* pnm_image = NULL;
        response* resp = NULL;
@@ -55,6 +55,7 @@ void _get_current_metadata(handler* h)
 
        json_object_put(metadataResp);
        metadata = NULL;
+       config = json_object_object_get(resp_config, "Configuration");
        metadata = json_object_object_get(config, "ColorMode");
        const char* color_value = json_object_get_string(metadata);
        mdata_value = NULL;
index 0466f74d0b965d6fc24c1a3f89ce690353578768..6232f8db1fedadfa70c4fabe0ffed73cb4ddc5a8 100644 (file)
@@ -9,7 +9,6 @@
 #define COUNT_CUSTOM_OPTIONS 2
 
 extern json_object* resp_config;
-extern json_object* config;
 
 void _write_string_value(json_object* value_object, void* value)
 {
@@ -46,7 +45,6 @@ void _load_options(handler* h)
        resp = kds_s2000w_client_response_init();
        int result = kds_s2000w_client_get_option(h->sessionid, resp);
        resp_config = json_tokener_parse(resp->data);
-       config = json_object_object_get(resp_config, "Configuration");
 
        if (result != 0 || resp->code != 200) {
                debug_printf_int(ERROR, "load options response code", resp->code);
@@ -63,11 +61,15 @@ void _load_options(handler* h)
 
 void kds_s2000w_handler_get_option(handler* h, int option, void* value, int* info)
 {
-       config = json_object_object_get(resp_config, "Configuration");
+       json_object* config = NULL;
        json_object* value_object = NULL;
+       if (resp_config != NULL)
+               config = json_object_object_get(resp_config, "Configuration");
+
        switch(option) {
                case 0:
                        _load_options(h);
+                       config = json_object_object_get(resp_config, "Configuration");
                        int* int_value_ptr = (int*) value;
                        *int_value_ptr = json_object_object_length(config) + COUNT_CUSTOM_OPTIONS;
                        break;
@@ -168,6 +170,7 @@ void kds_s2000w_handler_set_option(handler* h, int option, void* value, int* inf
        json_object* default_values = NULL;
        json_object* autostart = NULL;
        json_object* default_config = NULL;
+       json_object* config = NULL;
 
        config = json_object_object_get(resp_config, "Configuration");