Don't allow to set options that don't have SANE_CAP_SOFT_SELECT and don't

allow read and write for options that are inactive. New version: 1.0.5.
Henning Meier-Geinitz <henning@meier-geinitz.de>
DEVEL_2_0_BRANCH-1
Henning Geinitz 2002-03-21 20:33:31 +00:00
rodzic 935595911f
commit c40aeba6b1
2 zmienionych plików z 23 dodań i 4 usunięć

Wyświetl plik

@ -40,7 +40,7 @@
whether to permit this exception to apply to your modifications.
If you do not wish that, delete this exception notice. */
#define BUILD 4
#define BUILD 5
#include "../include/sane/config.h"
@ -591,14 +591,28 @@ sane_control_option (SANE_Handle handle, SANE_Int option,
handle, option, action, value, info);
if (handle != MAGIC || !is_open)
return SANE_STATUS_INVAL; /* Unknown handle ... */
{
DBG(1, "sane_control_option: unknown handle or not open\n");
return SANE_STATUS_INVAL; /* Unknown handle ... */
}
if (option < 0 || option >= NELEMS(sod))
return SANE_STATUS_INVAL; /* Unknown option ... */
{
DBG(1, "sane_control_option: option %d < 0 or >= number of options\n",
option);
return SANE_STATUS_INVAL; /* Unknown option ... */
}
if (!SANE_OPTION_IS_ACTIVE (sod[option].cap))
{
DBG(4, "sane_control_option: option is inactive\n");
return SANE_STATUS_INVAL;
}
switch (action)
{
case SANE_ACTION_SET_AUTO:
status = sanei_constrain_value (sod + option, (void*)&v, &myinfo);
if (status != SANE_STATUS_GOOD)
return status;
@ -613,6 +627,11 @@ sane_control_option (SANE_Handle handle, SANE_Int option,
}
break;
case SANE_ACTION_SET_VALUE:
if (!SANE_OPTION_IS_SETTABLE (sod[option].cap))
{
DBG(4, "sane_control_option: option is not setable\n");
return SANE_STATUS_INVAL;
}
status = sanei_constrain_value (sod + option, value, &myinfo);
if (status != SANE_STATUS_GOOD)
return status;

Wyświetl plik

@ -1,5 +1,5 @@
:backend "pnm"
:version "1.0.4"
:version "1.0.5"
:status :beta
:manpage "sane-pnm"
:url "mailto:henning@meier-geinitz.de"