json_object_set_int(value_object, *int_value_ptr);
}
+void _load_options()
+{
+ json_object_put(resObj);
+ resObj = NULL;
+
+ resp = kds_s2000w_client_response_init();
+ int result = kds_s2000w_client_get_option(state->sessionid, resp);
+ resObj = json_tokener_parse(resp->data);
+ config = json_object_object_get(resObj, "Configuration");
+
+ if (result != 0 || resp->code == 404) {
+ kds_s2000w_client_response_free(resp);
+ resp = NULL;
+ json_object_put(resObj);
+ resObj = NULL;
+ return;
+ }
+
+ kds_s2000w_client_response_free(resp);
+ resp = NULL;
+}
+
current_state* kds_s2000w_handler_open()
{
state = malloc(sizeof(current_state));
json_object* value_object = NULL;
switch(option) {
case 0:
- resp = kds_s2000w_client_response_init();
- int result = kds_s2000w_client_get_option(state->sessionid, resp);
- resObj = json_tokener_parse(resp->data);
- config = json_object_object_get(resObj, "Configuration");
-
- if (result != 0 || resp->code == 404) {
- kds_s2000w_client_response_free(resp);
- resp = NULL;
- json_object_put(resObj);
- resObj = NULL;
- return;
- }
-
+ _load_options();
int* int_value_ptr = (int*) value;
*int_value_ptr = json_object_object_length(config) + 3;
- kds_s2000w_client_response_free(resp);
- resp = NULL;
break;
case 2:
value_object = json_object_object_get(config, "DPI");
resp = NULL;
json_object_put(capabilities);
+ capabilities = NULL;
*info = RELOAD_OPTIONS;
+ _load_options();
+ return;
break;
default:
break;