Commit 999d05f6 authored by Alexandre Julliard's avatar Alexandre Julliard

sane.ds: Convert the SANE option descriptor to a private structure.

parent 383bb720
......@@ -293,19 +293,6 @@ static BOOL pixeltype_to_sane_mode(TW_UINT16 pixeltype, SANE_String mode, int le
strcpy(mode, m);
return TRUE;
}
static BOOL sane_mode_to_pixeltype(SANE_String_Const mode, TW_UINT16 *pixeltype)
{
if (strcmp(mode, SANE_VALUE_SCAN_MODE_LINEART) == 0)
*pixeltype = TWPT_BW;
else if (memcmp(mode, SANE_VALUE_SCAN_MODE_GRAY, strlen(SANE_VALUE_SCAN_MODE_GRAY)) == 0)
*pixeltype = TWPT_GRAY;
else if (strcmp(mode, SANE_VALUE_SCAN_MODE_COLOR) == 0)
*pixeltype = TWPT_RGB;
else
return FALSE;
return TRUE;
}
/* ICAP_PIXELTYPE */
static TW_UINT16 SANE_ICAPPixelType (pTW_CAPABILITY pCapability, TW_UINT16 action)
......@@ -315,22 +302,18 @@ static TW_UINT16 SANE_ICAPPixelType (pTW_CAPABILITY pCapability, TW_UINT16 actio
int possible_value_count;
TW_UINT32 val;
BOOL reload = FALSE;
const char * const *choices;
char current_mode[64];
TW_UINT16 current_pixeltype = TWPT_BW;
SANE_Char mode[64];
TRACE("ICAP_PIXELTYPE\n");
twCC = sane_option_probe_mode(&choices, current_mode, sizeof(current_mode));
twCC = sane_option_probe_mode(&current_pixeltype, possible_values, &possible_value_count);
if (twCC != TWCC_SUCCESS)
{
ERR("Unable to retrieve mode from sane, ICAP_PIXELTYPE unsupported\n");
return twCC;
}
sane_mode_to_pixeltype(current_mode, &current_pixeltype);
/* Sane does not support a concept of a default mode, so we simply cache
* the first mode we find */
if (! activeDS.PixelTypeSet)
......@@ -347,12 +330,6 @@ static TW_UINT16 SANE_ICAPPixelType (pTW_CAPABILITY pCapability, TW_UINT16 actio
break;
case MSG_GET:
for (possible_value_count = 0; choices && *choices && possible_value_count < 3; choices++)
{
TW_UINT16 pix;
if (sane_mode_to_pixeltype(*choices, &pix))
possible_values[possible_value_count++] = pix;
}
twCC = msg_get_enum(pCapability, possible_values, possible_value_count,
TWTY_UINT16, current_pixeltype, activeDS.defaultPixelType);
break;
......
......@@ -47,6 +47,25 @@ struct frame_parameters
int depth;
};
struct option_descriptor
{
int optno;
int size;
int is_active;
enum { TYPE_BOOL, TYPE_INT, TYPE_FIXED, TYPE_STRING, TYPE_BUTTON, TYPE_GROUP } type;
enum { UNIT_NONE, UNIT_PIXEL, UNIT_BIT, UNIT_MM, UNIT_DPI, UNIT_PERCENT, UNIT_MICROSECOND } unit;
enum { CONSTRAINT_NONE, CONSTRAINT_RANGE, CONSTRAINT_WORD_LIST, CONSTRAINT_STRING_LIST } constraint_type;
WCHAR title[256];
union
{
WCHAR strings[256];
int word_list[256]; /* first element is list-length */
struct { int min, max, quant; } range;
} constraint;
};
/* internal information about an active data source */
struct tagActiveDS
{
......@@ -216,12 +235,13 @@ HWND ScanningDialogBox(HWND dialog, LONG progress) DECLSPEC_HIDDEN;
/* Option functions */
TW_UINT16 sane_option_get_value( int optno, void *val ) DECLSPEC_HIDDEN;
TW_UINT16 sane_option_set_value( int optno, void *val, BOOL *reload ) DECLSPEC_HIDDEN;
TW_UINT16 sane_option_get_descriptor( struct option_descriptor *descr ) DECLSPEC_HIDDEN;
TW_UINT16 sane_option_get_int( const char *option_name, int *val ) DECLSPEC_HIDDEN;
TW_UINT16 sane_option_set_int( const char *option_name, int val, BOOL *reload ) DECLSPEC_HIDDEN;
TW_UINT16 sane_option_get_str( const char *option_name, char *val, int len ) DECLSPEC_HIDDEN;
TW_UINT16 sane_option_set_str( const char *option_name, char *val, BOOL *reload ) DECLSPEC_HIDDEN;
TW_UINT16 sane_option_probe_resolution( const char *option_name, int *minval, int *maxval, int *quant) DECLSPEC_HIDDEN;
TW_UINT16 sane_option_probe_mode(const char * const **choices, char *current, int current_size) DECLSPEC_HIDDEN;
TW_UINT16 sane_option_probe_mode(TW_UINT16 *current, TW_UINT32 *choices, int *count) DECLSPEC_HIDDEN;
TW_UINT16 sane_option_get_bool( const char *option_name, BOOL *val ) DECLSPEC_HIDDEN;
TW_UINT16 sane_option_set_bool( const char *option_name, BOOL val ) DECLSPEC_HIDDEN;
TW_UINT16 sane_option_get_scan_area( int *tlx, int *tly, int *brx, int *bry ) DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment