]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
rename image to pnm image
authorBastian Dehn <hhaalo@arcor.de>
Sun, 10 Mar 2024 14:42:27 +0000 (15:42 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 10 Mar 2024 14:42:27 +0000 (15:42 +0100)
src/kds_s2000w_handler.c
src/kds_s2000w_handler.h
src/kds_s2000w_net.c
tests/kds_s2000w_net_read_tests.c

index d2379fdf8293ac46f0cc957642a34cd40929cb0a..866f335c3860470c2ae3316b1bc1a49903f3b899 100644 (file)
@@ -42,7 +42,7 @@ void _get_current_metadata(handler* h)
        mdata_value = NULL;
 
        mdata_value = json_object_object_get(metadata, "ImageSize");
-       h->image->size = json_object_get_int(mdata_value);
+       h->pnm_image->size = json_object_get_int(mdata_value); // TODO
        mdata_value = NULL;
 
        mdata_value = json_object_object_get(metadata, "ImageWidth");
@@ -73,14 +73,14 @@ void _get_current_metadata(handler* h)
 
        if (h->current_metadata->depth > 8) {
                h->current_metadata->depth = 8;
-               pnm_image = (blobdata*) h->image;
+               pnm_image = (blobdata*) h->pnm_image;
                kds_s2000w_convert_jpg_to_pnm_with_depth(&image, pnm_image, h->current_metadata->depth);
        } else {
-               pnm_image = (blobdata*) h->image;
+               pnm_image = (blobdata*) h->pnm_image;
                kds_s2000w_convert_jpg_to_pnm(&image, pnm_image);
        }
 
-       debug_printf_int(DEBUG, "size of pnm image", h->image->size);
+       debug_printf_int(DEBUG, "size of pnm image", h->pnm_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);
@@ -171,7 +171,7 @@ handler* init_handler()
        h->current_scan_status = malloc(sizeof(scanstatus));
        h->current_metadata = malloc(sizeof(metadata));
        h->read_info = malloc(sizeof(readinfo));
-       h->image = malloc(sizeof(imagedata));
+       h->pnm_image = malloc(sizeof(imagedata));
 
        h->sessionid = 0;
        h->state = NOTCONNECTED;
@@ -193,8 +193,8 @@ handler* init_handler()
        h->read_info->read_size = 0;
        h->read_info->readed_bytes_per_line = 0;
        h->read_info->readed_lines = 0;
-       h->image->size = 0;
-       h->image->data = NULL;
+       h->pnm_image->size = 0;
+       h->pnm_image->data = NULL;
 
        return h;
 }
@@ -208,10 +208,10 @@ void free_handler(handler* h)
        h->current_metadata = NULL;
        free(h->read_info);
        h->read_info = NULL;
-       free(h->image->data);
-       h->image->data = NULL;
-       free(h->image);
-       h->image = NULL;
+       free(h->pnm_image->data);
+       h->pnm_image->data = NULL;
+       free(h->pnm_image);
+       h->pnm_image = NULL;
        free(h);
        h = NULL;
 }
@@ -219,8 +219,8 @@ void free_handler(handler* h)
 void reset_handler(handler* h)
 {
        debug_printf(ALL, "reset handler");
-       free(h->image->data);
-       h->image->data = NULL;
+       free(h->pnm_image->data);
+       h->pnm_image->data = NULL;
 
        h->state = NOTCONNECTED;
        h->current_scan_status->current_image_number = 1;
@@ -295,8 +295,8 @@ void kds_s2000w_handler_open(const char* devicename, void** handle)
 
        image.size = 0;
        image.data = NULL;
-       h->image->size = 0;
-       h->image->data = NULL;
+       h->pnm_image->size = 0;
+       h->pnm_image->data = NULL;
 
        resp = kds_s2000w_client_response_init();
        int result = kds_s2000w_client_open_session(resp);
index 55d6b8ae7ebefc0078750522f84c3428a0622be4..c334fbd6dc1c2f30fa43f6071cda4f6366a48ee8 100644 (file)
@@ -49,7 +49,7 @@ typedef struct {
        scanstatus* current_scan_status;
        metadata* current_metadata;
        readinfo* read_info;
-       imagedata* image;
+       imagedata* pnm_image;
 } handler;
 
 handler* init_handler();
index dff77be0e2fe52f4c52eee3f55c091f409b30c8e..28b4dec82a6d429192663fa9441cf81ba15e54ce 100644 (file)
@@ -213,7 +213,7 @@ SANE_Status _sane_kds_s2000w_net_read(SANE_Handle handle, SANE_Byte* data,
        }
 
        // last frame
-       if (h->read_info->read_size >= h->image->size) {
+       if (h->read_info->read_size >= h->pnm_image->size) {
                *length = 0;
                h->current_metadata->is_last = 1;
 
@@ -222,18 +222,18 @@ SANE_Status _sane_kds_s2000w_net_read(SANE_Handle handle, SANE_Byte* data,
 
        // calc max length
        int maxlen = max_length;
-       if (h->image->size - h->read_info->read_size < max_length)
-               maxlen = h->image->size - h->read_info->read_size;
+       if (h->pnm_image->size - h->read_info->read_size < max_length)
+               maxlen = h->pnm_image->size - h->read_info->read_size;
 
        // read image
-       if (h->image->data != NULL) {
-               int skip_header_bytes = _sane_kds_s2000w_net_find_first_data_byte(h->image->data);
+       if (h->pnm_image->data != NULL) {
+               int skip_header_bytes = _sane_kds_s2000w_net_find_first_data_byte(h->pnm_image->data);
                if (h->read_info->read_size <= 0)
                        h->read_info->read_size += skip_header_bytes;
        }
 
        *length = maxlen;
-       memcpy(data, h->image->data + h->read_info->read_size, *length);
+       memcpy(data, h->pnm_image->data + h->read_info->read_size, *length);
        h->read_info->read_size += *length;
 
        return SANE_STATUS_GOOD;
index a8a472df4d25e1a10d87b5670b2b80bc1f836551..bee8d41cf4b0df96e4f17081f197f88c1c357cc8 100644 (file)
@@ -58,11 +58,11 @@ START_TEST(sane_kds_s2000w_net_read_empty_image)
 {
        int length = 0;
        handler* h = init_handler();
-       h->image->size = 1;
+       h->pnm_image->size = 1;
        char* image = malloc(sizeof(char));
        image[0] = 0;
-       h->image->data = image;
-       h->image->size = 0;
+       h->pnm_image->data = image;
+       h->pnm_image->size = 0;
        char* dataptr = malloc(sizeof(char));
 
        SANE_Status status = _sane_kds_s2000w_net_read(h, dataptr, 65536, &length);
@@ -83,13 +83,13 @@ START_TEST(sane_kds_s2000w_net_read_test)
        h->read_info->cancel = 0;
        h->read_info->read_size = 0;
        h->current_metadata->format = 0;
-       h->image->size = 65539;
+       h->pnm_image->size = 65539;
        char* image = malloc(sizeof(char) * 65539);
        for (int i = 0; i < 3; i++) {
                image[i] = 0x0a;
        }
        image[3] = 0xff;
-       h->image->data = image;
+       h->pnm_image->data = image;
 
        SANE_Int maxlen = 65536;
        char* dataptr = malloc(sizeof(char) * maxlen);
@@ -118,13 +118,13 @@ START_TEST(sane_kds_s2000w_net_read_bytes_per_line_bigger_test)
        h->read_info->cancel = 0;
        h->read_info->read_size = 0;
        h->current_metadata->format = 0;
-       h->image->size = 95003;
+       h->pnm_image->size = 95003;
        char* image = malloc(sizeof(char) * 95003);
        for (int i = 0; i < 3; i++) {
                image[i] = 0x0a;
        }
        image[3] = 0xff;
-       h->image->data = image;
+       h->pnm_image->data = image;
 
        SANE_Int maxlen = 65536;
        char* dataptr = malloc(sizeof(char) * maxlen);