[sane-devel] New function: sanei_check_value(), changed sanei_constrain_value()

Henning Meier-Geinitz henning@meier-geinitz.de
Tue, 4 Mar 2003 23:50:03 +0100


Hi,

The existing function sanei_constrain_value() is used by many backends
to check if a value given by a frontend fits into the contraint of an
option. It isn't absolutely clear if that function was intended to
only check if the value fits but also tries to modify it if it doesn't.

The latest update to that function checks if a value fits in a word
list constraint and changes the value to the nearest of the word list
if it doesn't. This is a change in current behaviour but I think it's
appropriate as values for tring lists and ranges are "rounded", too.

You may see that change if you e.g. use scanimage to set the
resolution of a backend that uses a wordlist. E.g. if 100 and 300 are
possible resolutions and the user sets 250, 300 is selected (with a
warning). Before the change, the backend would return an error.

As a backend may need to really only check the validity of an option
value there is now sanei_check_value() which does no rounding at all.

Both functions are documented in sanei.h and
http://sanei.meier-geinitz.de/sanei_8h.html

Comments and fixes (also for the docs) are welcome.

Thanks to Abel for his contributions to this topic!

Bye,
  Henning