]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
add cancel
authorBastian Dehn <hhaalo@arcor.de>
Sat, 3 Feb 2024 12:27:54 +0000 (13:27 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sat, 3 Feb 2024 12:27:54 +0000 (13:27 +0100)
src/kds_s2000w_net.c

index e465452a684dfa03c164d459864a0113ce178050..37e798c2e52f3f88e21c69c5b8f53ba262c2462c 100644 (file)
@@ -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;
 }