From: Bastian Dehn Date: Sat, 3 Feb 2024 12:27:54 +0000 (+0100) Subject: add cancel X-Git-Tag: v1.0.0^2~362 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=a55da63e1006deb772b64528b490b45ab1fea6a7;p=sane-kds-s2000w-net.git add cancel --- diff --git a/src/kds_s2000w_net.c b/src/kds_s2000w_net.c index e465452..37e798c 100644 --- a/src/kds_s2000w_net.c +++ b/src/kds_s2000w_net.c @@ -8,6 +8,7 @@ SANE_Option_Descriptor* option_descriptors = NULL; SANE_Device* device_info = NULL; +int cancel = 0; SANE_Status _sane_kds_s2000w_net_init(SANE_Int* version_code, SANE_Auth_Callback authorize) { @@ -180,6 +181,7 @@ SANE_Status _sane_kds_s2000w_net_get_parameters(SANE_Handle handle, SANE_Status _sane_kds_s2000w_net_start(SANE_Handle handle) { + cancel = 0; return SANE_STATUS_GOOD; } @@ -187,7 +189,11 @@ SANE_Status _sane_kds_s2000w_net_read(SANE_Handle handle, SANE_Byte* data, SANE_Int max_length, SANE_Int* length) { int length_count = 0; - while(length_count < max_length) { + while(length_count < max_length) { + if (cancel) { + *length = 0; + return SANE_STATUS_CANCELLED; + } data[length_count] = 0; length_count++; } @@ -199,6 +205,7 @@ SANE_Status _sane_kds_s2000w_net_read(SANE_Handle handle, SANE_Byte* data, void _sane_kds_s2000w_net_cancel(SANE_Handle handle) { + cancel = 1; return; }