From ac4e478015397f4f1840a099d9eda0aa7c54721d Mon Sep 17 00:00:00 2001 From: Ilia Docin Date: Sun, 23 Jun 2024 21:15:09 +0300 Subject: [PATCH] sane.ds: Add SANE option settable flag support. --- dlls/sane.ds/options.c | 3 +++ dlls/sane.ds/unixlib.c | 1 + dlls/sane.ds/unixlib.h | 1 + 3 files changed, 5 insertions(+) diff --git a/dlls/sane.ds/options.c b/dlls/sane.ds/options.c index 1d39844a770..eb6a308b844 100644 --- a/dlls/sane.ds/options.c +++ b/dlls/sane.ds/options.c @@ -59,6 +59,7 @@ TW_UINT16 sane_option_set_int(const char *option_name, int val, BOOL *needs_relo { struct option_descriptor opt; TW_UINT16 rc = sane_find_option(option_name, TYPE_INT, &opt); + if (!opt.is_settable) return TWCC_OPERATIONERROR; if (rc == TWCC_SUCCESS) rc = sane_option_set_value( opt.optno, &val, needs_reload ); return rc; @@ -77,6 +78,7 @@ TW_UINT16 sane_option_set_bool(const char *option_name, int val ) { struct option_descriptor opt; TW_UINT16 rc = sane_find_option(option_name, TYPE_BOOL, &opt); + if (!opt.is_settable) return TWCC_OPERATIONERROR; if (rc == TWCC_SUCCESS) rc = sane_option_set_value( opt.optno, &val, NULL ); return rc; @@ -102,6 +104,7 @@ TW_UINT16 sane_option_set_str(const char *option_name, char *val, BOOL *needs_re { struct option_descriptor opt; TW_UINT16 rc = sane_find_option(option_name, TYPE_STRING, &opt); + if (!opt.is_settable) return TWCC_OPERATIONERROR; if (rc == TWCC_SUCCESS) rc = sane_option_set_value( opt.optno, val, needs_reload ); return rc; diff --git a/dlls/sane.ds/unixlib.c b/dlls/sane.ds/unixlib.c index 897aa09e5ef..69f085450a8 100644 --- a/dlls/sane.ds/unixlib.c +++ b/dlls/sane.ds/unixlib.c @@ -159,6 +159,7 @@ static void map_descr( struct option_descriptor *descr, const SANE_Option_Descri descr->constraint_type = map_constraint_type( opt->constraint_type ); descr->size = opt->size; descr->is_active = SANE_OPTION_IS_ACTIVE( opt->cap ); + descr->is_settable = SANE_OPTION_IS_SETTABLE( opt->cap ); if (opt->title) len = ntdll_umbstowcs( opt->title, strlen(opt->title), descr->title, ARRAY_SIZE(descr->title) ); descr->title[len] = 0; diff --git a/dlls/sane.ds/unixlib.h b/dlls/sane.ds/unixlib.h index d3ffbf1878d..34e7a9a9796 100644 --- a/dlls/sane.ds/unixlib.h +++ b/dlls/sane.ds/unixlib.h @@ -39,6 +39,7 @@ struct option_descriptor int optno; int size; int is_active; + int is_settable; enum { TYPE_BOOL, TYPE_INT, TYPE_FIXED, TYPE_STRING, TYPE_BUTTON, TYPE_GROUP } type; enum { UNIT_NONE, UNIT_PIXEL, UNIT_BIT, UNIT_MM, UNIT_DPI, UNIT_PERCENT, UNIT_MICROSECOND } unit; enum { CONSTRAINT_NONE, CONSTRAINT_RANGE, CONSTRAINT_WORD_LIST, CONSTRAINT_STRING_LIST } constraint_type;