diff options
Diffstat (limited to 'backend/umax_pp.c')
-rw-r--r-- | backend/umax_pp.c | 57 |
1 files changed, 24 insertions, 33 deletions
diff --git a/backend/umax_pp.c b/backend/umax_pp.c index 0f7ce4e..16adbe3 100644 --- a/backend/umax_pp.c +++ b/backend/umax_pp.c @@ -1,5 +1,5 @@ /* sane - Scanner Access Now Easy. - Copyright (C) 2001-2012 Stéphane Voltz <stef.dev@free.fr> + Copyright (C) 2001-2012 Stéphane Voltz <stef.dev@free.fr> This file is part of the SANE package. This program is free software; you can redistribute it and/or @@ -41,10 +41,10 @@ This file implements a SANE backend for Umax PP flatbed scanners. */ /* CREDITS: - Started by being a mere copy of mustek_pp - by Jochen Eisinger <jochen.eisinger@gmx.net> - then evolved in its own thing - + Started by being a mere copy of mustek_pp + by Jochen Eisinger <jochen.eisinger@gmx.net> + then evolved in its own thing + support for the 610P has been made possible thank to an hardware donation from William Stuart */ @@ -103,10 +103,6 @@ * 129 if you want to know which parameters are unused */ -/* history: - * see Changelog - */ - #define UMAX_PP_BUILD 2301 #define UMAX_PP_STATE "release" @@ -206,34 +202,28 @@ umax_pp_attach (SANEI_Config * config, const char *devname) SANE_Status status = SANE_STATUS_GOOD; int ret, prt = 0, mdl; char model[32]; - char name[64]; - char *val; - - memset (name, 0, 64); + const char *name = NULL; + const char *val; - if ((strlen (devname) < 3)) + if (!devname || (strlen (devname) < 3)) return SANE_STATUS_INVAL; sanei_umax_pp_setastra (atoi((SANE_Char *) config->values[CFG_ASTRA])); /* if the name begins with a slash, it's a device, else it's an addr */ - if (devname != NULL) + if ((devname[0] == '/')) { - if ((devname[0] == '/')) - { - strncpy (name, devname, 64); - } + name = devname; + } + else + { + if ((devname[0] == '0') + && ((devname[1] == 'x') || (devname[1] == 'X'))) + prt = strtol (devname + 2, NULL, 16); else - { - if ((devname[0] == '0') - && ((devname[1] == 'x') || (devname[1] == 'X'))) - prt = strtol (devname + 2, NULL, 16); - else - prt = atoi (devname); - } + prt = atoi (devname); } - for (i = 0; i < num_devices; i++) { if (devname[0] == '/') @@ -295,7 +285,7 @@ umax_pp_attach (SANEI_Config * config, const char *devname) devname); return SANE_STATUS_IO_ERROR; } - sprintf (model, "Astra %dP", mdl); + snprintf (model, sizeof(model), "Astra %dP", mdl); dev = malloc (sizeof (Umax_PP_Descriptor) * (num_devices + 1)); @@ -319,12 +309,12 @@ umax_pp_attach (SANEI_Config * config, const char *devname) num_devices++; /* if there are user provided values, use them */ - val=(SANE_Char *) config->values[CFG_NAME]; + val=(const SANE_Char *) config->values[CFG_NAME]; if(strlen(val)==0) dev->sane.name = strdup (devname); else dev->sane.name = strdup (val); - val=(SANE_Char *) config->values[CFG_VENDOR]; + val=(const SANE_Char *) config->values[CFG_VENDOR]; if(strlen(val)==0) dev->sane.vendor = strdup ("UMAX"); else @@ -351,11 +341,11 @@ umax_pp_attach (SANEI_Config * config, const char *devname) dev->max_h_size = 2550; dev->max_v_size = 3500; } - val=(SANE_Char *) config->values[CFG_MODEL]; + val=(const SANE_Char *) config->values[CFG_MODEL]; if(strlen(val)==0) - dev->sane.model = strdup (model); + dev->sane.model = strdup (model); else - dev->sane.model = strdup (val); + dev->sane.model = strdup (val); DBG (3, "umax_pp_attach: device %s attached\n", devname); @@ -1462,6 +1452,7 @@ sane_control_option (SANE_Handle handle, SANE_Int option, if (info) *info |= SANE_INFO_RELOAD_PARAMS; + // fall through case OPT_GRAY_GAIN: case OPT_GREEN_GAIN: case OPT_RED_GAIN: |