]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
refactor net
authorBastian Dehn <hhaalo@arcor.de>
Thu, 1 Aug 2024 07:38:56 +0000 (09:38 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Thu, 1 Aug 2024 07:38:56 +0000 (09:38 +0200)
src/kds_s2000w_net.c

index 04d96154693cb49d89b144efc0f978e4c0b0b80a..2d3236ea18fcac629aeff67def7005881ec4c39f 100644 (file)
@@ -12,6 +12,8 @@
 #include "kds_s2000w_debug.h"
 #endif
 
+#define SPACE 0x0a
+
 int _sane_kds_s2000w_net_find_first_data_byte(imagedata* image)
 {
 #ifndef NODEBUG
@@ -24,12 +26,11 @@ int _sane_kds_s2000w_net_find_first_data_byte(imagedata* image)
        if (strncmp(data, "P4", 2) == 0)
                header_spaces = 2;
 
-       const char space = 0x0a;
        int space_count = 0;
        int byte_count = 0;
 
        while(space_count < header_spaces && byte_count < image->size) {
-               if (data[byte_count] == space)
+               if (data[byte_count] == SPACE)
                        space_count++;
 
                byte_count++;
@@ -46,6 +47,7 @@ SANE_Status _sane_kds_s2000w_net_init(SANE_Int* version_code, SANE_Auth_Callback
 
        *version_code = SANE_VERSION_CODE(MAJOR, MINOR, PATCH);
        kds_s2000w_option_descriptor_init_option_descriptors();
+
        return SANE_STATUS_GOOD;
 }
 
@@ -63,13 +65,11 @@ SANE_Status _sane_kds_s2000w_net_get_devices(SANE_Device*** device_list,
        debug_printf(ALL, "sane_kds_s2000w_net_get_devices");
 #endif
 
-       SANE_Device** own_device_list = NULL;
-       SANE_Device* device_info = NULL;
        if (local_only)
                return SANE_STATUS_NO_MEM;
 
-       own_device_list = malloc(sizeof(SANE_Device*) * 2);
-       device_info = malloc(sizeof(SANE_Device));
+       SANE_Device** own_device_list = malloc(sizeof(SANE_Device*) * 2);
+       SANE_Device* device_info = malloc(sizeof(SANE_Device));
        device_info->name = "kds_s2000w_net";
        device_info->vendor = "Kodak";
        device_info->model = "Kodak Alaris s2000w series";
@@ -148,6 +148,7 @@ void _sane_kds_s2000w_net_cancel(SANE_Handle handle)
        handler* h = (handler*) handle;
        h->read_info->cancel = 1;
        kds_s2000w_handler_stop_scan(h);
+
        return;
 }
 
@@ -209,6 +210,7 @@ SANE_Status _sane_kds_s2000w_net_start(SANE_Handle handle)
 
        for (int i = 0; i < 30; i++) {
                kds_s2000w_handler_get_parameters(h);
+
                if (h->current_metadata->valid)
                        break;
        }
@@ -271,6 +273,7 @@ SANE_Status _sane_kds_s2000w_net_read(SANE_Handle handle, SANE_Byte* data,
                return SANE_STATUS_GOOD;
        }
 
+       // last frame
        free(h->scanner_image->data);
        h->scanner_image->data = NULL;
        h->scanner_image->size = 0;