]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
move cancle to handler
authorBastian Dehn <hhaalo@arcor.de>
Sun, 18 Feb 2024 10:22:54 +0000 (11:22 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 18 Feb 2024 10:22:54 +0000 (11:22 +0100)
src/kds_s2000w_net.c
tests/kds_s2000w_net_read_tests.c

index ab7754a4f173ca7947249dbeab219526a0cb39aa..6a8456e2eeebb13fef65e6d7419308ff5feedf7a 100644 (file)
@@ -116,7 +116,8 @@ SANE_Status _sane_kds_s2000w_net_control_option(SANE_Handle handle,
 void _sane_kds_s2000w_net_cancel(SANE_Handle handle)
 {
        debug_printf(ALL, "sane_kds_s2000w_net_cancel");
-       read_info.cancel = 1;
+       handler* h = (handler*) handle;
+       h->read_info.cancel = 1;
        return;
 }
 
@@ -161,7 +162,7 @@ SANE_Status _sane_kds_s2000w_net_start(SANE_Handle handle)
 {
        debug_printf(ALL, "sane_kds_s2000w_net_start");
        handler* h = (handler*) handle;
-       read_info.cancel = 0;
+       h->read_info.cancel = 0;
        h->read_info.scan_started = 1;
        kds_s2000w_handler_start_scan(handle);
        return SANE_STATUS_GOOD;
@@ -172,7 +173,7 @@ SANE_Status _sane_kds_s2000w_net_read(SANE_Handle handle, SANE_Byte* data,
 {
        debug_printf(ALL, "sane_kds_s2000w_net_read");
        handler* h = (handler*) handle;
-       if (read_info.cancel) {
+       if (h->read_info.cancel) {
                h->read_info.scan_started = 0;
                *length = 0;
                kds_s2000w_handler_stop_scan(handle);
index dca71e50ca7f88016bcbfc30cbda47b4ea216fc6..9e823b83d4099d168f6ea76402bc7ee4a2111a4e 100644 (file)
@@ -19,10 +19,9 @@ END_TEST
 
 START_TEST(sane_kds_s2000w_net_read_cancel_test)
 {
-       readinfo* read_info = get_read_info();
        handler h;
        h.read_info.scan_started = 1;
-       read_info->cancel = 1;
+       h.read_info.cancel = 1;
        int* length = malloc(sizeof(int));
        *length = 0;
 
@@ -38,7 +37,8 @@ END_TEST
 START_TEST(sane_kds_s2000w_net_read_all_lines_test)
 {
        readinfo* read_info = get_read_info();
-       read_info->cancel = 0;
+       handler h;
+       h.read_info.cancel = 0;
        read_info->read_size = 0;
        char* image = malloc(sizeof(char) * 53);
        for (int i = 0; i < 3; i++) {
@@ -58,7 +58,7 @@ START_TEST(sane_kds_s2000w_net_read_all_lines_test)
 
        SANE_Status status = 0;
        for (int i = 0; i < 6; i++) {
-               status = _sane_kds_s2000w_net_read(NULL, dataptr, 65535, length);
+               status = _sane_kds_s2000w_net_read(&h, dataptr, 65535, length);
        }
 
        ck_assert_int_eq(status, SANE_STATUS_EOF);
@@ -76,6 +76,8 @@ END_TEST
 START_TEST(sane_kds_s2000w_net_read_test)
 {
        readinfo* read_info = get_read_info();
+       handler h;
+       h.read_info.cancel = 0;
        read_info->read_size = 0;
        read_info->current_metadata.format = 0;
        read_info->current_metadata.lines = 1;
@@ -91,7 +93,7 @@ START_TEST(sane_kds_s2000w_net_read_test)
        char* dataptr = malloc(sizeof(char) * maxlen);
        SANE_Int* length = malloc(sizeof(SANE_Int));
 
-       _sane_kds_s2000w_net_read(NULL, (void*) dataptr, maxlen, length);
+       _sane_kds_s2000w_net_read(&h, dataptr, maxlen, length);
 
        ck_assert_int_eq(*length, 65536);
        ck_assert_mem_eq(dataptr, image + 3, 65536);
@@ -110,6 +112,8 @@ END_TEST
 START_TEST(sane_kds_s2000w_net_read_bytes_per_line_bigger_test)
 {
        readinfo* read_info = get_read_info();
+       handler h;
+       h.read_info.cancel = 0;
        read_info->read_size = 0;
        read_info->current_metadata.format = 0;
        read_info->current_metadata.lines = 1;
@@ -125,8 +129,8 @@ START_TEST(sane_kds_s2000w_net_read_bytes_per_line_bigger_test)
        char* dataptr = malloc(sizeof(char) * maxlen);
        SANE_Int* length = malloc(sizeof(SANE_Int));
 
-       _sane_kds_s2000w_net_read(NULL, (void*) dataptr, maxlen, length);
-       _sane_kds_s2000w_net_read(NULL, (void*) dataptr, maxlen, length);
+       _sane_kds_s2000w_net_read(&h, dataptr, maxlen, length);
+       _sane_kds_s2000w_net_read(&h, dataptr, maxlen, length);
 
        ck_assert_int_eq(read_info->read_size, 95003);