From: Bastian Dehn Date: Sun, 11 Feb 2024 18:50:19 +0000 (+0100) Subject: remove cancel flage use in struct X-Git-Tag: v1.0.0^2~292^2~5 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=e7d63fdf4b9573688b078bbf76b20426ef21b7b1;p=sane-kds-s2000w-net.git remove cancel flage use in struct --- diff --git a/src/kds_s2000w_net.c b/src/kds_s2000w_net.c index bcf7250..97ad293 100644 --- a/src/kds_s2000w_net.c +++ b/src/kds_s2000w_net.c @@ -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(); diff --git a/tests/kds_s2000w_net_tests.c b/tests/kds_s2000w_net_tests.c index 9fb5e29..2311f03 100644 --- a/tests/kds_s2000w_net_tests.c +++ b/tests/kds_s2000w_net_tests.c @@ -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;