From fe7c5b707c00364cbc9b30f128b0c7403aedf3a5 Mon Sep 17 00:00:00 2001 From: Julien BLACHE Date: Tue, 5 Aug 2008 09:04:51 +0000 Subject: [PATCH] Get option descriptor for option 0 before getting the value for option 0. --- Changelog | 4 ++++ src/scanadf.c | 22 ++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 35add6e..9c89674 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,7 @@ +2008-08-05 Julien Blache + * src/scanadf.c: fetch_options(): get option descriptor for option 0 + before getting the value for option 0. + 2008-07-03 Peter Kirchgeßner * doc/scanadf.man: Fix description of options for sane-hp-backend. A patch for sane-hp to be used with scanadf is not necessary diff --git a/src/scanadf.c b/src/scanadf.c index e5b976a..96ed570 100644 --- a/src/scanadf.c +++ b/src/scanadf.c @@ -552,15 +552,33 @@ fetch_options (SANE_Device * device) const SANE_Option_Descriptor * opt; SANE_Int num_dev_options; int i, option_count; + SANE_Status status; /* and now build the full table of long options: */ - sane_control_option (device, 0, SANE_ACTION_GET_VALUE, &num_dev_options, 0); + opt = sane_get_option_descriptor (device, 0); + if (opt == NULL) + { + fprintf (stderr, "Could not get option descriptor for option 0\n"); + exit (1); + } + + status = sane_control_option (device, 0, SANE_ACTION_GET_VALUE, &num_dev_options, 0); + if (status != SANE_STATUS_GOOD) + { + fprintf (stderr, "Could not get value for option 0: %s\n", sane_strstatus (status)); + exit (1); + } option_count = 0; - for (i = 0; i < num_dev_options; ++i) + for (i = 1; i < num_dev_options; ++i) { opt = sane_get_option_descriptor (device, i); + if (opt == NULL) + { + fprintf (stderr, "Could not get option descriptor for option %d\n", i); + exit (1); + } if (!SANE_OPTION_IS_SETTABLE (opt->cap)) continue;