From: Bastian Dehn Date: Sun, 9 Feb 2025 18:36:34 +0000 (+0100) Subject: change complete scan to bool X-Git-Tag: v1.0.34^2~7 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=e1a47038d2231fca8a986ad870b4051f4705222c;p=sane-kds-s2000w-net.git change complete scan to bool --- diff --git a/src/kds_s2000w_handler.c b/src/kds_s2000w_handler.c index 5c882e1..5669b6f 100644 --- a/src/kds_s2000w_handler.c +++ b/src/kds_s2000w_handler.c @@ -48,7 +48,7 @@ handler* kds_s2000w_handler_init() 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 = 0; + h->current_scan_status->complete_scanned = false; h->current_scan_status->feeder = 1; h->read_info->scan_started = 0; h->read_info->cancel = 0; @@ -93,7 +93,7 @@ void kds_s2000w_handler_reset(handler* h) 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 = 0; + h->current_scan_status->complete_scanned = false; h->read_info->scan_started = 0; h->read_info->cancel = 0; h->read_info->read_size = 0; @@ -324,7 +324,7 @@ void kds_s2000w_handler_get_current_scan_status(handler* h) 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 = 1; + h->current_scan_status->complete_scanned = true; json_object_put(status_resp_obj); status_resp_obj = NULL; diff --git a/src/kds_s2000w_handler.h b/src/kds_s2000w_handler.h index ab4105d..cb8a6b0 100644 --- a/src/kds_s2000w_handler.h +++ b/src/kds_s2000w_handler.h @@ -1,6 +1,7 @@ #ifndef KDS_S2000W_HANDLER_H #define KDS_S2000W_HANDLER_H #include +#include #include enum { @@ -32,7 +33,7 @@ typedef struct { uint8_t current_image_number; uint8_t available_images; uint8_t downloaded_images; - uint8_t complete_scanned; + bool complete_scanned; uint8_t feeder; } scanstatus; diff --git a/src/kds_s2000w_net.c b/src/kds_s2000w_net.c index c77d228..ee59493 100644 --- a/src/kds_s2000w_net.c +++ b/src/kds_s2000w_net.c @@ -201,7 +201,7 @@ void sane_kds_s2000w_net_cancel(SANE_Handle handle) kds_s2000w_handler_get_current_scan_status(h); - if (h->current_scan_status->complete_scanned > 0) { + if (h->current_scan_status->complete_scanned) { kds_s2000w_debug_printf(DEBUG, "scan completed"); kds_s2000w_handler_reset(h); return; diff --git a/tests/kds_s2000w_net_tests.c b/tests/kds_s2000w_net_tests.c index 7299adb..05220b8 100644 --- a/tests/kds_s2000w_net_tests.c +++ b/tests/kds_s2000w_net_tests.c @@ -241,7 +241,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_int_equal(h->current_scan_status->complete_scanned, 0); + assert_false(h->current_scan_status->complete_scanned); json_object_put(h->current_scanner_config); h->current_scanner_config = NULL; @@ -289,7 +289,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_int_equal(h->current_scan_status->complete_scanned, 0); + assert_false(h->current_scan_status->complete_scanned); json_object_put(h->current_scanner_config); h->current_scanner_config = NULL; @@ -339,7 +339,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_int_equal(h->current_scan_status->complete_scanned, 1); + assert_true(h->current_scan_status->complete_scanned); json_object_put(h->current_scanner_config); h->current_scanner_config = NULL; @@ -420,7 +420,7 @@ void sane_kds_s2000w_net_start_two_pages_per_feeder_test(void** state) result = sane_kds_s2000w_net_start(h); assert_int_equal(result, SANE_STATUS_GOOD); - assert_int_equal(h->current_scan_status->complete_scanned, 1); + assert_true(h->current_scan_status->complete_scanned); json_object_put(h->current_scanner_config); h->current_scanner_config = NULL; @@ -543,7 +543,7 @@ void sane_kds_s2000w_net_cancel_completed_scan_feeder_test() sane_kds_s2000w_net_cancel(h); assert_int_equal(h->read_info->cancel, 0); - assert_int_equal(h->current_scan_status->complete_scanned, 0); + assert_false(h->current_scan_status->complete_scanned); kds_s2000w_client_response_free(resp_status); resp_status = NULL; @@ -593,7 +593,7 @@ void sane_kds_s2000w_net_cancel_completed_scan_flatbed_test() sane_kds_s2000w_net_cancel(h); assert_int_equal(h->read_info->cancel, 0); - assert_int_equal(h->current_scan_status->complete_scanned, 0); + assert_false(h->current_scan_status->complete_scanned); kds_s2000w_client_response_free(resp_status); resp_status = NULL;