From: Bastian Dehn Date: Sat, 27 Jan 2024 11:26:59 +0000 (+0100) Subject: add read option nine fix string length X-Git-Tag: v1.0.0^2~442 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=d5ebfd5c29584ea0d9345931f49a8a0c385ff8f2;p=sane-kds-s2000w-net.git add read option nine fix string length --- diff --git a/src/kds_s2000w_handler.c b/src/kds_s2000w_handler.c index f445c98..bd85f57 100644 --- a/src/kds_s2000w_handler.c +++ b/src/kds_s2000w_handler.c @@ -77,7 +77,7 @@ void kds_s2000w_handler_get_option(int option, void* value) return; } - printf("DEBUG response: \n%s\n", resp->data); + json_object* value_object = NULL; int value_length = 0; const char* string_value = NULL; @@ -89,7 +89,7 @@ void kds_s2000w_handler_get_option(int option, void* value) int_value_ptr = (int*) value; int_value = json_object_object_length(config); printf("option number count: %i\n", int_value); - *int_value_ptr = 9; + *int_value_ptr = 10; break; case 1: value_object = json_object_object_get(config, "DPI"); @@ -101,14 +101,14 @@ void kds_s2000w_handler_get_option(int option, void* value) value_object = json_object_object_get(config, "ScanSide"); string_value = json_object_get_string(value_object); char_value = (char*) value; - value_length = strlen(char_value); + value_length = strlen(string_value) + 1; memcpy(char_value, string_value, sizeof(char) * value_length); break; case 3: value_object = json_object_object_get(config, "ColorMode"); string_value = json_object_get_string(value_object); char_value = (char*) value; - value_length = strlen(char_value); + value_length = strlen(string_value) + 1; memcpy(char_value, string_value, sizeof(char) * value_length); break; case 4: @@ -127,7 +127,7 @@ void kds_s2000w_handler_get_option(int option, void* value) value_object = json_object_object_get(config, "ColorDropOut"); string_value = json_object_get_string(value_object); char_value = (char*) value; - value_length = strlen(char_value); + value_length = strlen(string_value) + 1; memcpy(char_value, string_value, sizeof(char) * value_length); break; case 7: @@ -140,7 +140,16 @@ void kds_s2000w_handler_get_option(int option, void* value) value_object = json_object_object_get(config, "OutputType"); string_value = json_object_get_string(value_object); char_value = (char*) value; - value_length = strlen(char_value); + value_length = strlen(string_value) + 1; + memcpy(char_value, string_value, sizeof(char) * value_length); + break; + case 9: + printf("DEBUG response: \n%s\n", resp->data); + value_object = json_object_object_get(config, "ColorAutoBrightnessMode"); + string_value = json_object_get_string(value_object); + printf("DEBUG value: %s\n", string_value); + char_value = (char*) value; + value_length = strlen(string_value) + 1; memcpy(char_value, string_value, sizeof(char) * value_length); break; default: diff --git a/src/kds_s2000w_net.c b/src/kds_s2000w_net.c index 8c05cf8..6e00bba 100644 --- a/src/kds_s2000w_net.c +++ b/src/kds_s2000w_net.c @@ -200,6 +200,17 @@ const SANE_Option_Descriptor* _sane_kds_s2000w_net_get_option_descriptor( option_descriptor_array.option_descriptors[option]->constraint_type = SANE_CONSTRAINT_NONE; option_descriptor_array.option_descriptors[option]->constraint.string_list = NULL; break; + case 9: + free(option_descriptor_array.option_descriptors[option]); + option_descriptor_array.option_descriptors[option] = NULL; + option_descriptor_array.option_descriptors[option] = malloc(sizeof(SANE_Option_Descriptor)); + option_descriptor_array.option_descriptors[option]->name = "colorautobrightnessmode"; + option_descriptor_array.option_descriptors[option]->title = "colorautobrightnessmode"; + option_descriptor_array.option_descriptors[option]->desc = "colorautobrightnessmode"; + option_descriptor_array.option_descriptors[option]->cap = SANE_CAP_SOFT_DETECT; + option_descriptor_array.option_descriptors[option]->constraint_type = SANE_CONSTRAINT_NONE; + option_descriptor_array.option_descriptors[option]->constraint.string_list = NULL; + break; default: return NULL; break; @@ -219,6 +230,7 @@ const SANE_Option_Descriptor* _sane_kds_s2000w_net_get_option_descriptor( case 3: case 6: case 8: + case 9: option_descriptor_array.option_descriptors[option]->type = SANE_TYPE_STRING; option_descriptor_array.option_descriptors[option]->unit = SANE_UNIT_NONE; option_descriptor_array.option_descriptors[option]->size = sizeof(SANE_String) * 50;