]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
remove cancel flage use in struct
authorBastian Dehn <hhaalo@arcor.de>
Sun, 11 Feb 2024 18:50:19 +0000 (19:50 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 11 Feb 2024 18:58:31 +0000 (19:58 +0100)
src/kds_s2000w_net.c
tests/kds_s2000w_net_tests.c

index bcf725025c992f10ac604001af00c9bc5b15b3de..97ad293707d3c19627485d3bc64a222cedd7e953 100644 (file)
@@ -13,11 +13,17 @@ typedef struct {
        int scan_started;
        int readed_bytes_per_line;
        int readed_lines;
-} read_info;
+} readinfo;
 
+readinfo read_info;
 SANE_Option_Descriptor* option_descriptors = NULL;
 SANE_Device* device_info = NULL;
 
+readinfo* get_read_info()
+{
+       return &read_info;
+}
+
 [[deprecated("use reade_info instead")]]
 int cancel = 0;
 [[deprecated("use reade_info instead")]]
@@ -237,7 +243,7 @@ SANE_Status _sane_kds_s2000w_net_control_option(SANE_Handle handle,
 
 void _sane_kds_s2000w_net_cancel(SANE_Handle handle)
 {
-       cancel = 1;
+       read_info.cancel = 1;
        return;
 }
 
@@ -279,7 +285,7 @@ SANE_Status _sane_kds_s2000w_net_start(SANE_Handle handle)
        if (scan_started)
                return SANE_STATUS_GOOD;
 
-       cancel = 0;
+       read_info.cancel = 0;
        scan_started = 1;
        kds_s2000w_handler_start_scan();
        return SANE_STATUS_GOOD;
@@ -288,7 +294,7 @@ SANE_Status _sane_kds_s2000w_net_start(SANE_Handle handle)
 SANE_Status _sane_kds_s2000w_net_read(SANE_Handle handle, SANE_Byte* data,
        SANE_Int max_length, SANE_Int* length)
 {
-       if (cancel) {
+       if (read_info.cancel) {
                scan_started = 0;
                *length = 0;
                kds_s2000w_handler_stop_scan();
index 9fb5e299d84a2febda0a4fc94763c96d60f9f900..2311f03d6736de686ac62a43cc1c8bc9ffc8f9ef 100644 (file)
@@ -30,10 +30,10 @@ END_TEST
 
 START_TEST(sane_kds_s2000w_net_read_cancel_test)
 {
+       readinfo* read_info = get_read_info();
+       read_info->cancel = 1;
        int* length = malloc(sizeof(int));
        *length = 0;
-       int* cancel = get_cancel();
-       *cancel = 1;
 
        SANE_Status status = _sane_kds_s2000w_net_read(NULL, NULL, 0, length);
 
@@ -46,8 +46,8 @@ END_TEST
 
 START_TEST(sane_kds_s2000w_net_read_all_lines_test)
 {
-       int* cancel = get_cancel();
-       *cancel = 0;
+       readinfo* read_info = get_read_info();
+       read_info->cancel = 0;
        metadata* current_metadata_ptr = get_current_metadata();
        int* read_size = get_read_size();
        *read_size = 0;