]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
check read five lines
authorBastian Dehn <hhaalo@arcor.de>
Sun, 11 Feb 2024 18:13:41 +0000 (19:13 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 11 Feb 2024 18:13:41 +0000 (19:13 +0100)
src/kds_s2000w_net.c
tests/kds_s2000w_net_tests.c

index cd7ea9bce93873eb55f5df93194fb96c9cb94f8f..c9d7027c40919dcd9013799e1aa8b645b6e295c3 100644 (file)
@@ -298,9 +298,9 @@ SANE_Status _sane_kds_s2000w_net_read(SANE_Handle handle, SANE_Byte* data,
 
        readed_bytes_per_line += *length;
        read_size += *length;
-       printf("read size %i\n", read_size);
 
        if (readed_bytes_per_line >= current_metadata.bytes_per_line) {
+               readed_bytes_per_line = 0;
                readed_lines++;
        }
 
index 051eee72bab9469f57319becb198974724b80e3a..4cfbab1cb7bf17e01bb083d182dc555b14f65470 100644 (file)
@@ -49,23 +49,32 @@ START_TEST(sane_kds_s2000w_net_read_all_lines_test)
        int* cancel = get_cancel();
        *cancel = 0;
        metadata* current_metadata_ptr = get_current_metadata();
-       char* image = malloc(sizeof(char) * 4);
+       char* image = malloc(sizeof(char) * 53);
        for (int i = 0; i < 3; i++) {
                image[i] = 0x0a;
        }
        image[4] = 0xff;
-       current_metadata.image = image;
-       current_metadata_ptr->lines = 1;
+       current_metadata_ptr->image = image;
+       current_metadata_ptr->bytes_per_line = 10;
+       current_metadata_ptr->lines = 5;
+
        int* readed_lines = get_readed_lines();
        *readed_lines = 0;
        int* length = malloc(sizeof(int));
        *length = 0;
 
-       _sane_kds_s2000w_net_read(NULL, NULL, 0, length);
-       SANE_Status status = _sane_kds_s2000w_net_read(NULL, NULL, 0, length);
+       SANE_Int maxlen = 65536;
+       char* dataptr = malloc(sizeof(char) * maxlen);
+
+       SANE_Status status = 0;
+       for (int i = 0; i < 6; i++) {
+               status = _sane_kds_s2000w_net_read(NULL, dataptr, 65535, length);
+       }
 
        ck_assert_int_eq(status, SANE_STATUS_EOF);
 
+       free(dataptr);
+       dataptr = NULL;
        free(length);
        length = NULL;
        free(image);