From ac77a699232885fcccd4c1fa38c101cdc86e2b8e Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Fri, 17 Oct 2025 17:39:25 +0200 Subject: [PATCH] change rename scan status --- src/kds_s2000w_handler.c | 36 ++++++++++++++++++------------------ src/kds_s2000w_handler.h | 4 ++-- src/kds_s2000w_net.c | 12 ++++++------ tests/kds_s2000w_net_tests.c | 14 +++++++------- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/kds_s2000w_handler.c b/src/kds_s2000w_handler.c index 04b30be..bfc80d5 100644 --- a/src/kds_s2000w_handler.c +++ b/src/kds_s2000w_handler.c @@ -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 diff --git a/src/kds_s2000w_handler.h b/src/kds_s2000w_handler.h index db676bc..dc450eb 100644 --- a/src/kds_s2000w_handler.h +++ b/src/kds_s2000w_handler.h @@ -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; diff --git a/src/kds_s2000w_net.c b/src/kds_s2000w_net.c index 6c09425..256faa0 100644 --- a/src/kds_s2000w_net.c +++ b/src/kds_s2000w_net.c @@ -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); diff --git a/tests/kds_s2000w_net_tests.c b/tests/kds_s2000w_net_tests.c index 7bddfd2..53744d3 100644 --- a/tests/kds_s2000w_net_tests.c +++ b/tests/kds_s2000w_net_tests.c @@ -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; -- 2.47.3