From f14f4525a8e960aa2f902663b6f993204cca6e5d Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Fri, 17 Oct 2025 19:30:23 +0200 Subject: [PATCH] change rename option descriptor type --- src/kds_s2000w_handler_opts.c | 20 ++++++++++---------- src/kds_s2000w_option_descriptors.c | 18 +++++++++--------- src/kds_s2000w_option_descriptors.h | 4 ++-- tests/kds_s2000w_option_descriptor_tests.c | 4 ++-- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/kds_s2000w_handler_opts.c b/src/kds_s2000w_handler_opts.c index 9d9c33e..a15bc80 100644 --- a/src/kds_s2000w_handler_opts.c +++ b/src/kds_s2000w_handler_opts.c @@ -84,7 +84,7 @@ void _kds_s2000w_handler_opts_set_option_to_default(handler_t* h) resp = NULL; } -json_object* _kds_s2000w_handler_opts_reset(const option_descriptor* descriptor, handler_t* h) +json_object* _kds_s2000w_handler_opts_reset(const option_descriptor_t* descriptor, handler_t* h) { if (strcmp(descriptor->config_name, RESET) != 0) return json_object_object_get(h->scanner_config, CONFIGURATION); @@ -125,7 +125,7 @@ json_object* _kds_s2000w_handler_opts_load_config(handler_t* h) return config; } -void _kds_s2000w_handler_opts_set_valid_coord_x(option_descriptor* descriptor, handler_t* h) +void _kds_s2000w_handler_opts_set_valid_coord_x(option_descriptor_t* descriptor, handler_t* h) { bool valid = h->coord->offset_x >= 0 && h->coord->offset_x <= 75; valid = valid && h->coord->width >= 10 && h->coord->width <= 85; @@ -146,7 +146,7 @@ void _kds_s2000w_handler_opts_set_valid_coord_x(option_descriptor* descriptor, h json_object_set_int(value_object, h->coord->width); } -void _kds_s2000w_handler_opts_set_valid_coord_y(option_descriptor* descriptor, handler_t* h) +void _kds_s2000w_handler_opts_set_valid_coord_y(option_descriptor_t* descriptor, handler_t* h) { bool valid = h->coord->offset_y >= 0 && h->coord->offset_y <= 130; valid = valid && h->coord->height >= 10 && h->coord->height <= 140; @@ -323,7 +323,7 @@ void _kds_s2000w_handler_opts_set_enable_color_drop_out_aggressiveness(json_obje color_drop_out_aggressiveness->cap &= ~SANE_CAP_SOFT_SELECT; } -void _kds_s2000w_handler_opts_set_offset_x(const option_descriptor* descriptor, handler_t* h, const void* value) +void _kds_s2000w_handler_opts_set_offset_x(const option_descriptor_t* descriptor, handler_t* h, const void* value) { if (strcmp(descriptor->config_name, IMAGE_OFFSET_X) != 0) return; @@ -333,7 +333,7 @@ void _kds_s2000w_handler_opts_set_offset_x(const option_descriptor* descriptor, h->coord->offset_x = tenth_inch; } -void _kds_s2000w_handler_opts_set_offset_y(const option_descriptor* descriptor, handler_t* h, const void* value) +void _kds_s2000w_handler_opts_set_offset_y(const option_descriptor_t* descriptor, handler_t* h, const void* value) { if (strcmp(descriptor->config_name, IMAGE_OFFSET_Y) != 0) return; @@ -343,7 +343,7 @@ void _kds_s2000w_handler_opts_set_offset_y(const option_descriptor* descriptor, h->coord->offset_y = tenth_inch; } -void _kds_s2000w_handler_opts_set_width(const option_descriptor* descriptor, handler_t* h, const void* value) +void _kds_s2000w_handler_opts_set_width(const option_descriptor_t* descriptor, handler_t* h, const void* value) { if (strcmp(descriptor->config_name, IMAGE_WIDTH) != 0) return; @@ -355,7 +355,7 @@ void _kds_s2000w_handler_opts_set_width(const option_descriptor* descriptor, han h->coord->width = tenth_inch_width; } -void _kds_s2000w_handler_opts_set_height(const option_descriptor* descriptor, handler_t* h, const void* value) +void _kds_s2000w_handler_opts_set_height(const option_descriptor_t* descriptor, handler_t* h, const void* value) { if (strcmp(descriptor->config_name, IMAGE_HEIGHT) != 0) return; @@ -367,7 +367,7 @@ void _kds_s2000w_handler_opts_set_height(const option_descriptor* descriptor, ha h->coord->height = tenth_inch_height; } -void _kds_s2000w_handler_opts_set_info_option(const option_descriptor* descriptor, int32_t* info) { +void _kds_s2000w_handler_opts_set_info_option(const option_descriptor_t* descriptor, int32_t* info) { if (info == NULL) return; @@ -442,7 +442,7 @@ void kds_s2000w_handler_opts_get_option(handler_t* h, uint32_t option, void* val { json_object* config = _kds_s2000w_handler_opts_load_config(h); - option_descriptor* descriptor = kds_s2000w_option_descriptors_full_get_by_number(option); + option_descriptor_t* descriptor = kds_s2000w_option_descriptors_full_get_by_number(option); if (strcmp(descriptor->config_name, OPTION_COUNT) == 0) { int32_t* int_value = (int32_t*) value; *int_value = kds_s2000w_option_descriptors_get_max_option_count(); @@ -498,7 +498,7 @@ void kds_s2000w_handler_opts_set_option(handler_t* h, uint32_t option, void* val return; json_object* config = _kds_s2000w_handler_opts_load_config(h); - option_descriptor* descriptor = kds_s2000w_option_descriptors_full_get_by_number(option); + option_descriptor_t* descriptor = kds_s2000w_option_descriptors_full_get_by_number(option); json_object* value_object = json_object_object_get(config, descriptor->config_name); _kds_s2000w_handler_opts_set_offset_x(descriptor, h, value); diff --git a/src/kds_s2000w_option_descriptors.c b/src/kds_s2000w_option_descriptors.c index e305573..0bb90da 100644 --- a/src/kds_s2000w_option_descriptors.c +++ b/src/kds_s2000w_option_descriptors.c @@ -8,10 +8,10 @@ #define PROFILE_230802_V1_0_36_MAX_OPTION_COUNT 26 #define PROFILE_MIN_MAX_OPTION_COUNT 12 -option_descriptor** descriptors = NULL; +option_descriptor_t** descriptors = NULL; uint8_t max_option_count = 0; -void _kds_s2000w_option_descriptor_descriptor_free(option_descriptor* descriptor) +void _kds_s2000w_option_descriptor_descriptor_free(option_descriptor_t* descriptor) { if (descriptor == NULL) return; @@ -1519,12 +1519,12 @@ SANE_Status _kds_s2000w_option_descriptors_init_min_profile() { max_option_count = PROFILE_MIN_MAX_OPTION_COUNT; - descriptors = malloc(sizeof(option_descriptor*) * max_option_count); + descriptors = malloc(sizeof(option_descriptor_t*) * max_option_count); if (descriptors == NULL) return SANE_STATUS_NO_MEM; for (int i = 0; i < max_option_count; i++) { - descriptors[i] = malloc(sizeof(option_descriptor)); + descriptors[i] = malloc(sizeof(option_descriptor_t)); if (descriptors[i] == NULL) { kds_s2000w_option_descriptors_free(descriptors); descriptors = NULL; @@ -1564,12 +1564,12 @@ SANE_Status _kds_s2000w_option_descriptors_init_230802_v1_0_36_profile() { max_option_count = PROFILE_230802_V1_0_36_MAX_OPTION_COUNT; - descriptors = malloc(sizeof(option_descriptor*) * max_option_count); + descriptors = malloc(sizeof(option_descriptor_t*) * max_option_count); if (descriptors == NULL) return SANE_STATUS_NO_MEM; for (int i = 0; i < max_option_count; i++) { - descriptors[i] = malloc(sizeof(option_descriptor)); + descriptors[i] = malloc(sizeof(option_descriptor_t)); if (descriptors[i] == NULL) { kds_s2000w_option_descriptors_free(descriptors); descriptors = NULL; @@ -1637,12 +1637,12 @@ SANE_Status _kds_s2000w_option_descriptors_init_full_profile() { max_option_count = PROFILE_FULL_MAX_OPTION_COUNT; - descriptors = malloc(sizeof(option_descriptor*) * max_option_count); + descriptors = malloc(sizeof(option_descriptor_t*) * max_option_count); if (descriptors == NULL) return SANE_STATUS_NO_MEM; for (int i = 0; i < max_option_count; i++) { - descriptors[i] = malloc(sizeof(option_descriptor)); + descriptors[i] = malloc(sizeof(option_descriptor_t)); if (descriptors[i] == NULL) { kds_s2000w_option_descriptors_free(descriptors); descriptors = NULL; @@ -1793,7 +1793,7 @@ uint8_t kds_s2000w_option_descriptors_get_max_option_count() return max_option_count; } -option_descriptor* kds_s2000w_option_descriptors_full_get_by_number(uint32_t number) +option_descriptor_t* kds_s2000w_option_descriptors_full_get_by_number(uint32_t number) { kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_full_get_by_number"); diff --git a/src/kds_s2000w_option_descriptors.h b/src/kds_s2000w_option_descriptors.h index 3f2be1e..3732d78 100644 --- a/src/kds_s2000w_option_descriptors.h +++ b/src/kds_s2000w_option_descriptors.h @@ -67,13 +67,13 @@ enum { typedef struct { const char* config_name; SANE_Option_Descriptor* descriptor; -} option_descriptor; +} option_descriptor_t; SANE_Status kds_s2000w_option_descriptors_init(uint8_t profile); void kds_s2000w_option_descriptors_free(); uint8_t kds_s2000w_option_descriptors_get_max_option_count(); -option_descriptor* kds_s2000w_option_descriptors_full_get_by_number(uint32_t number); +option_descriptor_t* kds_s2000w_option_descriptors_full_get_by_number(uint32_t number); SANE_Option_Descriptor* kds_s2000w_option_descriptors_get_by_number(uint32_t number); SANE_Option_Descriptor* kds_s2000w_option_descriptors_get_by_config_name(const char* name); diff --git a/tests/kds_s2000w_option_descriptor_tests.c b/tests/kds_s2000w_option_descriptor_tests.c index eadb364..93c13c8 100644 --- a/tests/kds_s2000w_option_descriptor_tests.c +++ b/tests/kds_s2000w_option_descriptor_tests.c @@ -853,7 +853,7 @@ void kds_s2000w_option_get_descriptor_over_max_options_test() void kds_s2000w_option_full_get_descriptor_by_number() { - option_descriptor* option = kds_s2000w_option_descriptors_full_get_by_number(31); + option_descriptor_t* option = kds_s2000w_option_descriptors_full_get_by_number(31); assert_string_equal(option->config_name, "Reset"); } @@ -862,7 +862,7 @@ void kds_s2000w_option_full_get_descriptor_over_max_options_test() { uint8_t max_option_count = kds_s2000w_option_descriptors_get_max_option_count(); - option_descriptor* option = kds_s2000w_option_descriptors_full_get_by_number(max_option_count); + option_descriptor_t* option = kds_s2000w_option_descriptors_full_get_by_number(max_option_count); assert_null(option); } -- 2.47.3