json_object* resp_config = NULL;
json_object* config = NULL;
-blobdata image;
void _get_current_metadata(handler* h)
{
json_object* metadataResp = NULL;
json_object* metadata = NULL;
json_object* mdata_value = NULL;
+ blobdata* jpg_image = NULL;
blobdata* pnm_image = NULL;
response* resp = NULL;
mdata_value = NULL;
mdata_value = json_object_object_get(metadata, "ImageSize");
- h->pnm_image->size = json_object_get_int(mdata_value); // TODO
+ h->jpg_image->size = json_object_get_int(mdata_value);
mdata_value = NULL;
mdata_value = json_object_object_get(metadata, "ImageWidth");
if (h->current_metadata->format == 1)
h->current_metadata->channels = 3;
+ jpg_image = (blobdata*) h->jpg_image;
+ pnm_image = (blobdata*) h->pnm_image;
if (h->current_metadata->depth > 8) {
h->current_metadata->depth = 8;
- pnm_image = (blobdata*) h->pnm_image;
- kds_s2000w_convert_jpg_to_pnm_with_depth(&image, pnm_image, h->current_metadata->depth);
+ kds_s2000w_convert_jpg_to_pnm_with_depth(jpg_image, pnm_image, h->current_metadata->depth);
} else {
- pnm_image = (blobdata*) h->pnm_image;
- kds_s2000w_convert_jpg_to_pnm(&image, pnm_image);
+ kds_s2000w_convert_jpg_to_pnm(jpg_image, pnm_image);
}
debug_printf_int(DEBUG, "size of pnm image", h->pnm_image->size);
debug_printf(ALL, "download_current_image");
response* resp = NULL;
- if (image.size > 0) {
- free(image.data);
- image.data = NULL;
- image.size = 0;
+ if (h->jpg_image->size > 0) {
+ free(h->jpg_image->data);
+ h->jpg_image->data = NULL;
+ h->jpg_image->size = 0;
}
resp = kds_s2000w_client_response_init();
if (resp->code != 200)
debug_printf_int(ERROR, "download current image response code", resp->code);
- image.size = resp->size;
- image.data = malloc(sizeof(char) * resp->size);
- memcpy(image.data, resp->data, resp->size);
+ h->jpg_image->size = resp->size;
+ h->jpg_image->data = malloc(sizeof(char) * resp->size);
+ memcpy(h->jpg_image->data, resp->data, resp->size);
kds_s2000w_client_response_free(resp);
resp = NULL;
h->current_scan_status->downloaded_images++;
h->current_scan_status = malloc(sizeof(scanstatus));
h->current_metadata = malloc(sizeof(metadata));
h->read_info = malloc(sizeof(readinfo));
+ h->jpg_image = malloc(sizeof(imagedata));
h->pnm_image = malloc(sizeof(imagedata));
h->sessionid = 0;
h->read_info->read_size = 0;
h->read_info->readed_bytes_per_line = 0;
h->read_info->readed_lines = 0;
+ h->jpg_image->size = 0;
+ h->jpg_image->data = NULL;
h->pnm_image->size = 0;
h->pnm_image->data = NULL;
h->current_metadata = NULL;
free(h->read_info);
h->read_info = NULL;
+ free(h->jpg_image->data);
+ h->jpg_image->data = NULL;
+ free(h->jpg_image);
+ h->jpg_image = NULL;
free(h->pnm_image->data);
h->pnm_image->data = NULL;
free(h->pnm_image);
h = init_handler();
*handle = h;
- image.size = 0;
- image.data = NULL;
+ h->jpg_image->size = 0;
+ h->jpg_image->data = NULL;
h->pnm_image->size = 0;
h->pnm_image->data = NULL;
debug_printf(ALL, "kds_s2000w_handler_close");
json_object_put(resp_config);
resp_config = NULL;
- free(image.data);
- image.data = NULL;
if (h == NULL)
return;