]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
change rename scan status
authorBastian Dehn <hhaalo@arcor.de>
Fri, 17 Oct 2025 15:39:25 +0000 (17:39 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Fri, 17 Oct 2025 15:39:25 +0000 (17:39 +0200)
src/kds_s2000w_handler.c
src/kds_s2000w_handler.h
src/kds_s2000w_net.c
tests/kds_s2000w_net_tests.c

index 04b30be036e413253bb8b4aecfbaf64347dabcef..bfc80d50a2ec9d4787d0168b707222d1a803433c 100644 (file)
@@ -100,7 +100,7 @@ handler* kds_s2000w_handler_init()
                return NULL;
 
        h->current_scanner_config = NULL;
-       h->current_scan_status = malloc(sizeof(scanstatus));
+       h->scan_status = malloc(sizeof(scan_status_t));
        h->read_info = malloc(sizeof(readinfo));
        h->image = malloc(sizeof(imagedata));
        h->coord = malloc(sizeof(coord_t));
@@ -108,10 +108,10 @@ handler* kds_s2000w_handler_init()
        h->profile = 0;
        h->sessionid = 0;
        h->state = NOTCONNECTED;
-       h->current_scan_status->current_image_number = 1;
-       h->current_scan_status->available_images = 0;
-       h->current_scan_status->downloaded_images = 0;
-       h->current_scan_status->complete_scanned = false;
+       h->scan_status->current_image_number = 1;
+       h->scan_status->available_images = 0;
+       h->scan_status->downloaded_images = 0;
+       h->scan_status->complete_scanned = false;
        h->read_info->scan_started = false;
        h->read_info->cancel = false;
        h->read_info->read_size = 0;
@@ -134,8 +134,8 @@ void kds_s2000w_handler_free(handler* h)
 
        json_object_put(h->current_scanner_config);
        h->current_scanner_config = NULL;
-       free(h->current_scan_status);
-       h->current_scan_status = NULL;
+       free(h->scan_status);
+       h->scan_status = NULL;
        free(h->read_info);
        h->read_info = NULL;
        free(h->image->data);
@@ -157,10 +157,10 @@ void kds_s2000w_handler_reset(handler* h)
        free(h->image->data);
        h->image->data = NULL;
 
-       h->current_scan_status->current_image_number = 1;
-       h->current_scan_status->available_images = 0;
-       h->current_scan_status->downloaded_images = 0;
-       h->current_scan_status->complete_scanned = false;
+       h->scan_status->current_image_number = 1;
+       h->scan_status->available_images = 0;
+       h->scan_status->downloaded_images = 0;
+       h->scan_status->complete_scanned = false;
        h->read_info->scan_started = false;
        h->read_info->cancel = false;
        h->read_info->read_size = 0;
@@ -368,7 +368,7 @@ void kds_s2000w_handler_get_current_scan_status(handler* h)
 {
        kds_s2000w_debug_printf(ALL, "get_current_scan_status");
 
-       if (h->current_scan_status->available_images > 1)
+       if (h->scan_status->available_images > 1)
                return;
 
        response* resp = kds_s2000w_client_response_init();
@@ -378,13 +378,13 @@ void kds_s2000w_handler_get_current_scan_status(handler* h)
        json_object* status_resp_obj = json_tokener_parse(resp->data);
        json_object* status_obj = json_object_object_get(status_resp_obj, "Status");
        json_object* status_value_obj = json_object_object_get(status_obj, "NumImagesStored");
-       h->current_scan_status->available_images = json_object_get_int(status_value_obj);
+       h->scan_status->available_images = json_object_get_int(status_value_obj);
        status_value_obj = NULL;
 
        status_value_obj = json_object_object_get(status_obj, "State");
        const char* scanner_state = json_object_get_string(status_value_obj);
        if (strcmp(scanner_state, "Scanning") != 0)
-               h->current_scan_status->complete_scanned = true;
+               h->scan_status->complete_scanned = true;
 
        json_object_put(status_resp_obj);
        status_resp_obj = NULL;
@@ -401,20 +401,20 @@ void kds_s2000w_handler_download_current_image(handler* h)
        h->image->size = 0;
 
        response* resp = kds_s2000w_client_response_init();
-       kds_s2000w_client_get_image(h->sessionid, h->current_scan_status->current_image_number, resp);
+       kds_s2000w_client_get_image(h->sessionid, h->scan_status->current_image_number, resp);
        h->image->size = resp->size;
        h->image->data = malloc(sizeof(char) * resp->size);
        memcpy(h->image->data, resp->data, resp->size);
 
        kds_s2000w_client_response_free(resp);
        resp = NULL;
-       h->current_scan_status->downloaded_images++;
+       h->scan_status->downloaded_images++;
 }
 
 void kds_s2000w_handler_delete_current_image(handler* h)
 {
        kds_s2000w_debug_printf(ALL, "delete_current_image");
 
-       kds_s2000w_client_delete_image(h->sessionid, h->current_scan_status->current_image_number);
-       h->current_scan_status->available_images--;
+       kds_s2000w_client_delete_image(h->sessionid, h->scan_status->current_image_number);
+       h->scan_status->available_images--;
 }
\ No newline at end of file
index db676bce28f67248b31e196cf3e87ed2b9c690ca..dc450ebb96234eec4c651ef8fba418a06a4d0278 100644 (file)
@@ -47,7 +47,7 @@ typedef struct {
        uint8_t available_images;
        uint8_t downloaded_images;
        bool complete_scanned;
-} scanstatus;
+} scan_status_t;
 
 typedef struct {
        bool scan_started;
@@ -60,7 +60,7 @@ typedef struct {
        uint64_t sessionid;
        uint8_t state;
        json_object* current_scanner_config;
-       scanstatus* current_scan_status;
+       scan_status_t* scan_status;
        readinfo* read_info;
        imagedata* image;
        coord_t* coord;
index 6c09425556cfa657a9442b8cb8d00419ca9c4351..256faa0d43519552ab6357211bde1a12652afb19 100644 (file)
@@ -167,18 +167,18 @@ SANE_Status sane_kds_s2000w_net_start(SANE_Handle handle)
        for (uint32_t i = 0; i < 30; i++) {
                kds_s2000w_handler_get_current_scan_status(h);
 
-               if (h->current_scan_status->available_images > 0)
+       if (h->scan_status->available_images > 0)
                        break;
        }
 
-       if (h->current_scan_status->available_images < 1)
+       if (h->scan_status->available_images < 1)
                return SANE_STATUS_NO_DOCS;
 
        kds_s2000w_handler_download_current_image(h);
        kds_s2000w_handler_delete_current_image(h);
-       h->current_scan_status->current_image_number++;
+       h->scan_status->current_image_number++;
 
-       if (h->current_scan_status->complete_scanned) {
+       if (h->scan_status->complete_scanned) {
                kds_s2000w_handler_stop_scan(h);
                return SANE_STATUS_GOOD;
        }
@@ -228,13 +228,13 @@ void sane_kds_s2000w_net_cancel(SANE_Handle handle)
 
        kds_s2000w_handler_get_current_scan_status(h);
 
-       if (h->current_scan_status->complete_scanned) {
+       if (h->scan_status->complete_scanned) {
                kds_s2000w_debug_printf(DEBUG, "scan completed");
                kds_s2000w_handler_reset(h);
                return;
        }
 
-       if (h->current_scan_status->available_images == 0) {
+       if (h->scan_status->available_images == 0) {
                kds_s2000w_debug_printf(DEBUG, "scan completed no availible images");
                kds_s2000w_handler_reset(h);
                kds_s2000w_handler_recreate_session(h);
index 7bddfd22cb0c6d8bfec953575b799a7096539dde..53744d3cfeeb56f541071c086b036bb6a739706d 100644 (file)
@@ -358,7 +358,7 @@ void sane_kds_s2000w_net_start_test(void** state)
        int result = sane_kds_s2000w_net_start(h);
 
        assert_int_equal(result, SANE_STATUS_GOOD);
-       assert_false(h->current_scan_status->complete_scanned);
+       assert_false(h->scan_status->complete_scanned);
 
        json_object_put(h->current_scanner_config);
        h->current_scanner_config = NULL;
@@ -403,7 +403,7 @@ void sane_kds_s2000w_net_start_one_page_per_flatscan_test(void** state)
        int result = sane_kds_s2000w_net_start(h);
 
        assert_int_equal(result, SANE_STATUS_GOOD);
-       assert_false(h->current_scan_status->complete_scanned);
+       assert_false(h->scan_status->complete_scanned);
 
        json_object_put(h->current_scanner_config);
        h->current_scanner_config = NULL;
@@ -450,7 +450,7 @@ void sane_kds_s2000w_net_start_one_page_per_feeder_test(void** state)
        int result = sane_kds_s2000w_net_start(h);
 
        assert_int_equal(result, SANE_STATUS_GOOD);
-       assert_true(h->current_scan_status->complete_scanned);
+       assert_true(h->scan_status->complete_scanned);
 
        json_object_put(h->current_scanner_config);
        h->current_scanner_config = NULL;
@@ -526,7 +526,7 @@ void sane_kds_s2000w_net_start_two_pages_per_feeder_test(void** state)
        int32_t result = sane_kds_s2000w_net_start(h);
 
        assert_int_equal(result, SANE_STATUS_GOOD);
-       assert_true(h->current_scan_status->complete_scanned);
+       assert_true(h->scan_status->complete_scanned);
 
        json_object_put(h->current_scanner_config);
        h->current_scanner_config = NULL;
@@ -562,7 +562,7 @@ void sane_kds_s2000w_net_cancel_test()
        expect_function_call(__wrap_kds_s2000w_client_status_session);
        expect_function_call(__wrap_kds_s2000w_client_stop_scan);
        handler* h = kds_s2000w_handler_init();
-       h->current_scan_status->available_images = 1;
+       h->scan_status->available_images = 1;
 
        sane_kds_s2000w_net_cancel(h);
 
@@ -648,7 +648,7 @@ void sane_kds_s2000w_net_cancel_completed_scan_feeder_test()
        sane_kds_s2000w_net_cancel(h);
 
        assert_false(h->read_info->cancel);
-       assert_false(h->current_scan_status->complete_scanned);
+       assert_false(h->scan_status->complete_scanned);
 
        kds_s2000w_client_response_free(resp_status);
        resp_status = NULL;
@@ -698,7 +698,7 @@ void sane_kds_s2000w_net_cancel_completed_scan_flatbed_test()
        sane_kds_s2000w_net_cancel(h);
 
        assert_false(h->read_info->cancel);
-       assert_false(h->current_scan_status->complete_scanned);
+       assert_false(h->scan_status->complete_scanned);
 
        kds_s2000w_client_response_free(resp_status);
        resp_status = NULL;