From d54f39f55bd8633be89e18c97fc64b60e4ca88a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Voltz?= Date: Fri, 15 Aug 2003 06:56:24 +0000 Subject: [PATCH] - UTA and custom gamma fix (wrongly inactive ...) - gamma table check on option set --- ChangeLog | 6 ++++++ backend/umax_pp.c | 17 +++++++++++++---- backend/umax_pp.h | 14 +------------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4e609fb02..4a473d3a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2003-08-15 Stéphane Voltz + + * backend/umax_pp.c backend/umax_pp.h: added a check of values passed + in gamma table. Fixed a bug which prevented custom gamm and UTA to be + active + 2003-08-14 Gerhard Jaeger * doc/sane-plustek.man: Added debug description diff --git a/backend/umax_pp.c b/backend/umax_pp.c index b55da2df4..8ccc8e917 100644 --- a/backend/umax_pp.c +++ b/backend/umax_pp.c @@ -102,8 +102,8 @@ * see Changelog */ -#define UMAX_PP_BUILD 12 -#define UMAX_PP_STATE "beta" +#define UMAX_PP_BUILD 13 +#define UMAX_PP_STATE "stable" static int num_devices = 0; static Umax_PP_Descriptor *devlist = NULL; @@ -484,14 +484,14 @@ init_options (Umax_PP_Device * dev) dev->opt[OPT_UTA_CONTROL].size = sizeof (SANE_Word); dev->opt[OPT_UTA_CONTROL].unit = SANE_UNIT_NONE; dev->val[OPT_UTA_CONTROL].w = SANE_TRUE; - dev->opt[OPT_UTA_CONTROL].cap |= SANE_CAP_ADVANCED | SANE_CAP_INACTIVE; + dev->opt[OPT_UTA_CONTROL].cap |= SANE_CAP_ADVANCED; /* custom-gamma table */ dev->opt[OPT_CUSTOM_GAMMA].name = SANE_NAME_CUSTOM_GAMMA; dev->opt[OPT_CUSTOM_GAMMA].title = SANE_TITLE_CUSTOM_GAMMA; dev->opt[OPT_CUSTOM_GAMMA].desc = SANE_DESC_CUSTOM_GAMMA; dev->opt[OPT_CUSTOM_GAMMA].type = SANE_TYPE_BOOL; - dev->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_ADVANCED | SANE_CAP_INACTIVE; + dev->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_ADVANCED; dev->val[OPT_CUSTOM_GAMMA].w = SANE_FALSE; /* grayscale gamma vector */ @@ -1339,6 +1339,7 @@ sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Status status; SANE_Word w, cap, tmpw; int dpi, rc; + unsigned int i; DBG (6, "control_option: option %d, action %d\n", option, action); @@ -1409,6 +1410,14 @@ sane_control_option (SANE_Handle handle, SANE_Int option, case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: + for(i=0;iopt[option].size/sizeof(SANE_Word);i++) + { + if(((SANE_Int *)val)[i]<0 || ((SANE_Int *)val)[i]>255) + { + DBG (2, "Value at index %d out of range\n",i); + return SANE_STATUS_INVAL; + } + } memcpy (val, dev->val[option].wa, dev->opt[option].size); return SANE_STATUS_GOOD; diff --git a/backend/umax_pp.h b/backend/umax_pp.h index 3297e49ea..6247518ea 100644 --- a/backend/umax_pp.h +++ b/backend/umax_pp.h @@ -97,6 +97,7 @@ typedef union { SANE_Word w; SANE_Word *wa; /* word array */ + SANE_Int *ia; /* int array */ SANE_String s; } Option_Value; @@ -192,17 +193,4 @@ Umax_PP_Device; __PRETTY_FUNCTION__, V_MAJOR, V_MINOR, \ UMAX_PP_BUILD, UMAX_PP_STATE, __LINE__) -#define ASSERT(cond) if (!(cond)) \ - { \ - DEBUG(); \ - DBG(1, "ASSERT(%s) failed\n", STRINGIFY(cond)); \ - DBG(1, "expect disaster...\n");\ - } - -/* Please note: ASSERT won't go away if you define NDEBUG, it just won't - * output a message when ASSERT failes. So if "cond" does anything, it will - * be executed, even if NDEBUG is defined... - */ - - #endif /* umax_pp_h */