response* resp = NULL;
current_state* state = NULL;
-json_object* resObj = NULL;
+json_object* resp_config = NULL;
json_object* config = NULL;
void _write_string_value(json_object* value_object, void* value)
void _load_options()
{
- json_object_put(resObj);
- resObj = NULL;
+ json_object_put(resp_config);
+ resp_config = 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");
+ resp_config = json_tokener_parse(resp->data);
+ config = json_object_object_get(resp_config, "Configuration");
if (result != 0 || resp->code == 404) {
kds_s2000w_client_response_free(resp);
resp = NULL;
- json_object_put(resObj);
- resObj = NULL;
+ json_object_put(resp_config);
+ resp_config = NULL;
return;
}
}
if (resp->code == 200) {
- resObj = json_tokener_parse(resp->data);
+ resp_config = json_tokener_parse(resp->data);
json_object* value_object = NULL;
- json_object_object_get_ex(resObj, "SessionId", &value_object);
+ json_object_object_get_ex(resp_config, "SessionId", &value_object);
state->sessionid = json_object_get_int64(value_object);
state->state = OPENED;
value_object = NULL;
}
- json_object_put(resObj);
- resObj = NULL;
+ json_object_put(resp_config);
+ resp_config = NULL;
kds_s2000w_client_response_free(resp);
resp = NULL;
state->sessionid = 0;
free(state);
state = NULL;
- json_object_put(resObj);
- resObj = NULL;
+ json_object_put(resp_config);
+ resp_config = NULL;
kds_s2000w_client_response_free(resp);
resp = NULL;
}
void kds_s2000w_handler_get_option(int option, void* value)
{
- config = json_object_object_get(resObj, "Configuration");
+ config = json_object_object_get(resp_config, "Configuration");
json_object* value_object = NULL;
switch(option) {
case 0:
void kds_s2000w_handler_set_option(int option, void* value, int* info)
{
- config = json_object_object_get(resObj, "Configuration");
+ config = json_object_object_get(resp_config, "Configuration");
json_object* value_object = NULL;
switch(option) {
case 2:
break;
}
- const char* json_string = json_object_to_json_string_ext(resObj, JSON_C_TO_STRING_PLAIN);
+ const char* json_string = json_object_to_json_string_ext(resp_config, JSON_C_TO_STRING_PLAIN);
resp = kds_s2000w_client_response_init();
resp->size = sizeof(char) * strlen(json_string);
resp->code = 0;
kds_s2000w_client_stop_scan(state->sessionid, resp);
kds_s2000w_client_response_free(resp);
resp = NULL;
+}
+
+metadata kds_s2000w_handler_get_parameters(int image_number)
+{
+ metadata mdata;
+ json_object* metadata = NULL;
+ json_object* mdata_value = NULL;
+ resp = kds_s2000w_client_response_init();
+ kds_s2000w_client_get_metadata(state->sessionid, image_number, resp);
+
+ metadata = json_tokener_parse(resp->data);
+ mdata_value = json_object_object_get(metadata, "BitDepth");
+ mdata.depth = json_object_get_int(mdata_value);
+ mdata_value = NULL;
+ mdata_value = json_object_object_get(metadata, "ImageSize");
+ mdata.size = json_object_get_int(mdata_value);
+ mdata_value = NULL;
+ mdata.format = 1;
+ mdata.is_last = 0;
+
+ json_object_put(metadata);
+ kds_s2000w_client_response_free(resp);
+ resp = NULL;
}
\ No newline at end of file