json_object* resp_config = NULL;
json_object* config = NULL;
blobdata image;
-blobdata pnm_image;
void _get_current_metadata(handler* h)
{
json_object* metadataResp = NULL;
json_object* metadata = NULL;
json_object* mdata_value = NULL;
+ blobdata* pnm_image = NULL;
response* resp = NULL;
resp = kds_s2000w_client_response_init();
if (h->current_metadata->depth > 8) {
h->current_metadata->depth = 8;
- kds_s2000w_convert_jpg_to_pnm_with_depth(&image, &pnm_image, h->current_metadata->depth);
+ pnm_image = (blobdata*) h->image;
+ kds_s2000w_convert_jpg_to_pnm_with_depth(&image, pnm_image, h->current_metadata->depth);
} else {
- kds_s2000w_convert_jpg_to_pnm(&image, &pnm_image);
+ pnm_image = (blobdata*) h->image;
+ kds_s2000w_convert_jpg_to_pnm(&image, pnm_image);
}
- h->current_metadata->size = pnm_image.size;
- h->current_metadata->image = pnm_image.data;
- debug_printf_int(DEBUG, "size of pnm image", pnm_image.size);
+ debug_printf_int(DEBUG, "size of pnm image", h->image->size);
if (h->current_metadata->depth == 1)
h->current_metadata->bytes_per_line = h->current_metadata->channels * floor((h->current_metadata->pixels_per_line + 7) / 8);
image.size = 0;
image.data = NULL;
- pnm_image.size = 0;
- pnm_image.data = NULL;
+ h->image->size = 0;
+ h->image->data = NULL;
resp = kds_s2000w_client_response_init();
int result = kds_s2000w_client_open_session(resp);
}
// last frame
- if (h->read_info->read_size >= h->current_metadata->size) {
+ if (h->read_info->read_size >= h->image->size) {
*length = 0;
h->current_metadata->is_last = 1;
// calc max length
int maxlen = max_length;
- if (h->current_metadata->size - h->read_info->read_size < max_length)
- maxlen = h->current_metadata->size - h->read_info->read_size;
+ if (h->image->size - h->read_info->read_size < max_length)
+ maxlen = h->image->size - h->read_info->read_size;
// read image
- if (h->current_metadata->image != NULL) {
- int skip_header_bytes = _sane_kds_s2000w_net_find_first_data_byte(h->current_metadata->image);
+ if (h->image->data != NULL) {
+ int skip_header_bytes = _sane_kds_s2000w_net_find_first_data_byte(h->image->data);
if (h->read_info->read_size <= 0)
h->read_info->read_size += skip_header_bytes;
}
*length = maxlen;
- memcpy(data, h->current_metadata->image + h->read_info->read_size, *length);
+ memcpy(data, h->image->data + h->read_info->read_size, *length);
h->read_info->read_size += *length;
return SANE_STATUS_GOOD;
h->current_metadata->size = 1;
char* image = malloc(sizeof(char));
image[0] = 0;
- h->current_metadata->image = image;
- h->current_metadata->size = 0;
+ h->image->data = image;
+ h->image->size = 0;
char* dataptr = malloc(sizeof(char));
SANE_Status status = _sane_kds_s2000w_net_read(h, dataptr, 65536, &length);
h->read_info->cancel = 0;
h->read_info->read_size = 0;
h->current_metadata->format = 0;
- h->current_metadata->size = 65539;
+ h->image->size = 65539;
char* image = malloc(sizeof(char) * 65539);
for (int i = 0; i < 3; i++) {
image[i] = 0x0a;
}
image[3] = 0xff;
- h->current_metadata->image = image;
+ h->image->data = image;
SANE_Int maxlen = 65536;
char* dataptr = malloc(sizeof(char) * maxlen);
h->read_info->cancel = 0;
h->read_info->read_size = 0;
h->current_metadata->format = 0;
- h->current_metadata->size = 95003;
+ h->image->size = 95003;
char* image = malloc(sizeof(char) * 95003);
for (int i = 0; i < 3; i++) {
image[i] = 0x0a;
}
image[3] = 0xff;
- h->current_metadata->image = image;
+ h->image->data = image;
SANE_Int maxlen = 65536;
char* dataptr = malloc(sizeof(char) * maxlen);