From f9951e3b318909df582696d9c1e094fd121d5e87 Mon Sep 17 00:00:00 2001 From: Ordissimo Date: Sat, 5 Aug 2023 17:55:14 +0200 Subject: [PATCH] escl - Fix constant build . --- backend/escl/escl_capabilities.c | 10 +++++++--- backend/escl/escl_newjob.c | 18 ++++++++++++++++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/backend/escl/escl_capabilities.c b/backend/escl/escl_capabilities.c index 2f8089066..ba635f8ff 100644 --- a/backend/escl/escl_capabilities.c +++ b/backend/escl/escl_capabilities.c @@ -72,7 +72,7 @@ convert_elements(SANE_String_Const str) return (SANE_VALUE_SCAN_MODE_GRAY); else if (strcmp(str, "RGB24") == 0) return (SANE_VALUE_SCAN_MODE_COLOR); -#if(defined HAVE_POPPLER_GLIB) +#if HAVE_POPPLER_GLIB else if (strcmp(str, "BlackAndWhite1") == 0) return (SANE_VALUE_SCAN_MODE_LINEART); #endif @@ -202,7 +202,11 @@ find_valor_of_array_variables(xmlNode *node, capabilities_t *scanner, int type) const char *name = (const char *)node->name; if (strcmp(name, "ColorMode") == 0) { const char *color = (SANE_String_Const)xmlNodeGetContent(node); - if (type == PLATEN || strcmp(color, "BlackAndWhite1")) + if (type == PLATEN +#if HAVE_POPPLER_GLIB + || strcmp(color, "BlackAndWhite1") +#endif + ) scanner->caps[type].ColorModes = char_to_array(scanner->caps[type].ColorModes, &scanner->caps[type].ColorModesSize, (SANE_String_Const)xmlNodeGetContent(node), 1); } else if (strcmp(name, "ContentType") == 0) @@ -237,7 +241,7 @@ find_valor_of_array_variables(xmlNode *node, capabilities_t *scanner, int type) scanner->caps[type].have_tiff = i; } #endif -#if(defined HAVE_POPPLER_GLIB) +#if HAVE_POPPLER_GLIB else if(type == PLATEN && !strcmp(scanner->caps[type].DocumentFormats[i], "application/pdf")) { have_pdf = SANE_TRUE; diff --git a/backend/escl/escl_newjob.c b/backend/escl/escl_newjob.c index 5e3568cda..cb48bd1aa 100644 --- a/backend/escl/escl_newjob.c +++ b/backend/escl/escl_newjob.c @@ -184,8 +184,22 @@ escl_newjob (capabilities_t *scanner, const ESCL_Device *device, SANE_Status *st } } else { - scanner->caps[scanner->source].default_format = - strdup(scanner->caps[scanner->source].DocumentFormats[have_pdf]); + if (have_pdf != -1) { + scanner->caps[scanner->source].default_format = + strdup(scanner->caps[scanner->source].DocumentFormats[have_pdf]); + } + else if (have_tiff != -1) { + scanner->caps[scanner->source].default_format = + strdup(scanner->caps[scanner->source].DocumentFormats[have_tiff]); + } + else if (have_png != -1) { + scanner->caps[scanner->source].default_format = + strdup(scanner->caps[scanner->source].DocumentFormats[have_png]); + } + else if (have_jpeg != -1) { + scanner->caps[scanner->source].default_format = + strdup(scanner->caps[scanner->source].DocumentFormats[have_jpeg]); + } } if (atof ((const char *)device->version) <= 2.0) {