From: Bastian Dehn Date: Sun, 16 Feb 2025 08:12:50 +0000 (+0100) Subject: add option descriptor for image border X-Git-Tag: v1.1.0^2~4^2~36 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=8a9100f3d56047e2b7dc475e3b33c6cc42dd9f9a;p=sane-kds-s2000w-net.git add option descriptor for image border --- diff --git a/src/kds_s2000w_option_descriptors.c b/src/kds_s2000w_option_descriptors.c index 1bd3617..84efe63 100644 --- a/src/kds_s2000w_option_descriptors.c +++ b/src/kds_s2000w_option_descriptors.c @@ -3,7 +3,7 @@ #include "kds_s2000w_option_descriptors.h" #include "kds_s2000w_debug.h" -#define MAX_OPTION_COUNT 27 +#define MAX_OPTION_COUNT 28 SANE_Option_Descriptor* descriptor_array = NULL; @@ -31,6 +31,7 @@ SANE_String_Const* constraint_multifeed_sensitivity = NULL; SANE_String_Const* constraint_multifeed_response = NULL; SANE_String_Const* constraint_post_scan_rotation = NULL; SANE_String_Const* constraint_edge_fill = NULL; +SANE_String_Const* constraint_image_border = NULL; SANE_Option_Descriptor _kds_s2000w_option_descriptor_standard_group() { @@ -603,7 +604,7 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_post_scan_rotation() SANE_Option_Descriptor _kds_s2000w_option_descriptor_edge_fill() { - kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_post_scan_rotation"); + kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_edge_fill"); constraint_edge_fill = malloc(sizeof(SANE_String_Const*) * 4); constraint_edge_fill[0] = "None"; @@ -626,6 +627,31 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_edge_fill() return descriptor; } +SANE_Option_Descriptor _kds_s2000w_option_descriptor_image_border() +{ + kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_image_border"); + + constraint_image_border = malloc(sizeof(SANE_String_Const*) * 4); + constraint_image_border[0] = "None"; + constraint_image_border[1] = "Add"; + constraint_image_border[2] = "Remove"; + constraint_image_border[3] = NULL; + + SANE_Option_Descriptor descriptor = { + "image-border", + "Image Border", + "Image Border", + SANE_TYPE_STRING, + SANE_UNIT_NONE, + sizeof(SANE_String_Const*) * 4, + SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT, + SANE_CONSTRAINT_STRING_LIST, + {.string_list = constraint_image_border} + }; + + return descriptor; +} + void kds_s2000w_option_descriptors_init() { kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_init_option_descriptors"); @@ -657,7 +683,8 @@ void kds_s2000w_option_descriptors_init() descriptor_array[23] = _kds_s2000w_option_descriptor_multifeed_response(); descriptor_array[24] = _kds_s2000w_option_descriptor_post_scan_rotation(); descriptor_array[25] = _kds_s2000w_option_descriptor_edge_fill(); - descriptor_array[26] = _kds_s2000w_option_descriptor_config_reset(); + descriptor_array[26] = _kds_s2000w_option_descriptor_image_border(); + descriptor_array[27] = _kds_s2000w_option_descriptor_config_reset(); } void kds_s2000w_option_descriptors_free() @@ -694,6 +721,8 @@ void kds_s2000w_option_descriptors_free() constraint_post_scan_rotation = NULL; free(constraint_edge_fill); constraint_edge_fill = NULL; + free(constraint_image_border); + constraint_image_border = NULL; free(descriptor_array); descriptor_array = NULL; } diff --git a/tests/kds_s2000w_option_descriptor_tests.c b/tests/kds_s2000w_option_descriptor_tests.c index ce423ca..e914611 100644 --- a/tests/kds_s2000w_option_descriptor_tests.c +++ b/tests/kds_s2000w_option_descriptor_tests.c @@ -4,7 +4,7 @@ #include "kds_s2000w_client_mock.h" #include "../src/kds_s2000w_option_descriptors.h" -#define MAX_OPTION_COUNT 27 +#define MAX_OPTION_COUNT 28 int setup(void** state) { @@ -477,6 +477,24 @@ void kds_s2000w_option_get_descriptor_twentysix_test() { SANE_Option_Descriptor* option = kds_s2000w_option_descriptors_get(26); + assert_string_equal("image-border", option->name); + assert_string_equal("Image Border", option->title); + assert_string_equal("Image Border", option->desc); + assert_int_equal(SANE_TYPE_STRING, option->type); + assert_int_equal(SANE_UNIT_NONE, option->unit); + assert_int_equal(sizeof(SANE_String_Const*) * 4, option->size); + assert_int_equal(SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT, option->cap); + assert_int_equal(SANE_CONSTRAINT_STRING_LIST, option->constraint_type); + assert_string_equal("None", option->constraint.string_list[0]); + assert_string_equal("Add", option->constraint.string_list[1]); + assert_string_equal("Remove", option->constraint.string_list[2]); + assert_null(option->constraint.string_list[3]); +} + +void kds_s2000w_option_get_descriptor_twentyseven_test() +{ + SANE_Option_Descriptor* option = kds_s2000w_option_descriptors_get(27); + assert_string_equal("config-reset", option->name); assert_string_equal("reset config", option->title); assert_string_equal("load default configuration from scanner", option->desc);