]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
fix right request data for set option
authorBastian Dehn <hhaalo@arcor.de>
Sun, 28 Jan 2024 19:38:41 +0000 (20:38 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 28 Jan 2024 19:38:41 +0000 (20:38 +0100)
src/kds_s2000w_handler.c

index 9ea8c5488fe6cbb62847f1f1cdb9b94eaead3f69..5b28681e1e12ed26311cf253072f0f550a628a45 100644 (file)
@@ -310,14 +310,15 @@ void kds_s2000w_handler_set_option(int option, void* value)
                        break;
        }
 
-       // TODO: send request
-       // const char* json_string = json_object_to_json_string_ext(resObj, JSON_C_TO_STRING_PLAIN);
-       // resp = kds_s2000w_client_response_init();
-       // resp->data = (char*) json_string;
-       // resp->size = sizeof(char) * strlen(json_string);
-       // resp->code = 0;
-       // kds_s2000w_client_set_option(state->sessionid, resp);
-       // kds_s2000w_client_response_free(resp);
+       const char* json_string = json_object_to_json_string_ext(resObj, JSON_C_TO_STRING_PLAIN);
+       resp = kds_s2000w_client_response_init();
+       resp->size = sizeof(char) * strlen(json_string);
+       resp->code = 0;
+       resp->data = realloc(resp->data, resp->size);
+       resp->data = memcpy(resp->data, json_string, resp->size);
+       kds_s2000w_client_set_option(state->sessionid, resp);
+       kds_s2000w_client_response_free(resp);
+       resp = NULL;
 }
 
 void kds_s2000w_handler_set_option_auto(int option)