From 9b3d7dc8b69590508d4eb9bd23dbaf3d83eb86a8 Mon Sep 17 00:00:00 2001 From: thierry1970 Date: Wed, 6 May 2020 10:12:52 +0200 Subject: [PATCH 1/2] Fix name of sources. --- backend/escl/escl_capabilities.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/backend/escl/escl_capabilities.c b/backend/escl/escl_capabilities.c index cbef05fa9..88cff4d42 100644 --- a/backend/escl/escl_capabilities.c +++ b/backend/escl/escl_capabilities.c @@ -330,31 +330,22 @@ print_xml_c(xmlNode *node, capabilities_t *scanner, int type) find_true_variables(node, scanner, type); } if (!strcmp((const char *)node->name, "PlatenInputCaps")) { - scanner->Sources = - char_to_array(scanner->Sources, - &scanner->SourcesSize, - (SANE_String_Const)SANE_I18N ("Flatbed"), - 0); + scanner->Sources[PLATEN] = (SANE_String_Const)strdup(SANE_I18N ("Flatbed")); + scanner->SourcesSize++; scanner->source = PLATEN; print_xml_c(node->children, scanner, PLATEN); scanner->caps[PLATEN].duplex = 0; } else if (!strcmp((const char *)node->name, "AdfSimplexInputCaps")) { - scanner->Sources = - char_to_array(scanner->Sources, - &scanner->SourcesSize, - (SANE_String_Const)SANE_I18N("ADF"), - 0); + scanner->Sources[ADFSIMPLEX] = (SANE_String_Const)strdup(SANE_I18N("ADF")); + scanner->SourcesSize++; if (scanner->source == -1) scanner->source = ADFSIMPLEX; print_xml_c(node->children, scanner, ADFSIMPLEX); scanner->caps[ADFSIMPLEX].duplex = 0; } else if (!strcmp((const char *)node->name, "AdfDuplexInputCaps")) { - scanner->Sources = - char_to_array(scanner->Sources, - &scanner->SourcesSize, - (SANE_String_Const)SANE_I18N ("ADF Duplex"), - 0); + scanner->Sources[ADFDUPLEX] = (SANE_String_Const)strdup(SANE_I18N ("ADF Duplex")); + scanner->SourcesSize++; if (scanner->source == -1) scanner->source = ADFDUPLEX; print_xml_c(node->children, scanner, ADFDUPLEX); scanner->caps[ADFDUPLEX].duplex = 1; @@ -406,6 +397,7 @@ escl_capabilities(const ESCL_Device *device, SANE_Status *status) struct cap *var = NULL; xmlDoc *data = NULL; xmlNode *node = NULL; + int i = 0; const char *scanner_capabilities = "/eSCL/ScannerCapabilities"; *status = SANE_STATUS_GOOD; @@ -438,6 +430,9 @@ escl_capabilities(const ESCL_Device *device, SANE_Status *status) } scanner->source = 0; + scanner->Sources = (SANE_String_Const *)malloc(sizeof(SANE_String_Const) * 4); + for (i = 0; i < 4; i++) + scanner->Sources[i] = NULL; print_xml_c(node, scanner, -1); _reduce_color_modes(scanner); clean: From c9fdb62060cecb3fbc44cfe0f31facfbf9b5a668 Mon Sep 17 00:00:00 2001 From: thierry1970 Date: Wed, 6 May 2020 10:44:31 +0200 Subject: [PATCH 2/2] The duplex tag is only sent to the device if the device supports AdfDuplex. --- backend/escl/escl_newjob.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/escl/escl_newjob.c b/backend/escl/escl_newjob.c index 8e8314307..a16f06a77 100644 --- a/backend/escl/escl_newjob.c +++ b/backend/escl/escl_newjob.c @@ -169,7 +169,7 @@ escl_newjob (capabilities_t *scanner, const ESCL_Device *device, SANE_Status *st } else format_ext = f_ext; - if(scanner->source > PLATEN) { + if(scanner->source > PLATEN && scanner->Sources[ADFDUPLEX]) { snprintf(duplex_mode, sizeof(duplex_mode), " %s", scanner->source == ADFDUPLEX ? "true" : "false");