summaryrefslogtreecommitdiff
path: root/backend/escl
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2024-06-30 15:46:39 +0200
committerJörg Frings-Fürst <debian@jff.email>2024-06-30 15:46:39 +0200
commit73365252941d4053dca0e7fa06f4c205194cf1b8 (patch)
tree3eff4566f12e48cfee6b35955d262e46ee5a5da1 /backend/escl
parent52c7d661296d9efb9a51b52c38dda22516cf981a (diff)
parent3c9b873509b5c2278d4e345bf86a22c1ff26f3c0 (diff)
Merge branch 'release/debian/1.3.0-1'debian/1.3.0-1
Diffstat (limited to 'backend/escl')
-rw-r--r--backend/escl/escl.c14
-rw-r--r--backend/escl/escl.h2
-rw-r--r--backend/escl/escl_capabilities.c11
-rw-r--r--backend/escl/escl_jpeg.c14
-rw-r--r--backend/escl/escl_newjob.c22
5 files changed, 42 insertions, 21 deletions
diff --git a/backend/escl/escl.c b/backend/escl/escl.c
index cbbdb60..77b753f 100644
--- a/backend/escl/escl.c
+++ b/backend/escl/escl.c
@@ -621,16 +621,20 @@ sane_get_devices(const SANE_Device ***device_list, SANE_Bool local_only)
ESCL_Device *dev = NULL;
static const SANE_Device **devlist = 0;
SANE_Status status;
+ SANE_Status status2;
if (device_list == NULL)
return (SANE_STATUS_INVAL);
- status = sanei_configure_attach(ESCL_CONFIG_FILE, NULL,
+ status2 = sanei_configure_attach(ESCL_CONFIG_FILE, NULL,
attach_one_config, NULL);
- if (status != SANE_STATUS_GOOD)
- return (status);
escl_devices(&status);
- if (status != SANE_STATUS_GOOD)
- return (status);
+ if (status != SANE_STATUS_GOOD && status2 != SANE_STATUS_GOOD)
+ {
+ if (status2 != SANE_STATUS_GOOD)
+ return (status2);
+ if (status != SANE_STATUS_GOOD)
+ return (status);
+ }
if (devlist)
free(devlist);
devlist = (const SANE_Device **) calloc (num_devices + 1, sizeof (devlist[0]));
diff --git a/backend/escl/escl.h b/backend/escl/escl.h
index f99bff9..b59a3ff 100644
--- a/backend/escl/escl.h
+++ b/backend/escl/escl.h
@@ -92,7 +92,7 @@ typedef struct {
typedef struct ESCL_Device {
struct ESCL_Device *next;
- double version;
+ char *version;
char *model_name;
int port_nb;
char *ip_address;
diff --git a/backend/escl/escl_capabilities.c b/backend/escl/escl_capabilities.c
index efbd547..950efaa 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 HAVE_POPPLER_GLIB
if (type == PLATEN || strcmp(color, "BlackAndWhite1"))
+#else
+ if (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;
@@ -432,7 +436,7 @@ print_xml_c(xmlNode *node, ESCL_Device *device, capabilities_t *scanner, int typ
}
if (!strcmp((const char *)node->name, "Version")&& node->ns && node->ns->prefix){
if (!strcmp((const char*)node->ns->prefix, "pwg"))
- device->version = atof ((const char *)xmlNodeGetContent(node));
+ device->version = strdup((const char *)xmlNodeGetContent(node));
}
if (!strcmp((const char *)node->name, "MakeAndModel")){
device->model_name = strdup((const char *)xmlNodeGetContent(node));
@@ -588,7 +592,6 @@ escl_capabilities(ESCL_Device *device, char *blacklist, SANE_Status *status)
strstr(header->memory, "Server: HP_Compact_Server"))
device->hack = curl_slist_append(NULL, "Host: localhost");
- device->version = 0.0;
scanner->source = 0;
scanner->Sources = (SANE_String_Const *)malloc(sizeof(SANE_String_Const) * 4);
for (i = 0; i < 4; i++)
diff --git a/backend/escl/escl_jpeg.c b/backend/escl/escl_jpeg.c
index 1dd3ec9..62c20c0 100644
--- a/backend/escl/escl_jpeg.c
+++ b/backend/escl/escl_jpeg.c
@@ -232,7 +232,13 @@ get_JPEG_data(capabilities_t *scanner, int *width, int *height, int *bps)
y_off,
w,
h);
- surface = malloc(w * h * cinfo.output_components);
+ jpeg_start_decompress(&cinfo);
+ if (x_off > 0 || w < cinfo.output_width)
+ jpeg_crop_scanline(&cinfo, &x_off, &w);
+ lineSize = w * cinfo.output_components;
+ if (y_off > 0)
+ jpeg_skip_scanlines(&cinfo, y_off);
+ surface = malloc(cinfo.output_width * cinfo.output_height * cinfo.output_components);
if (surface == NULL) {
jpeg_destroy_decompress(&cinfo);
DBG( 1, "Escl Jpeg : Memory allocation problem\n");
@@ -242,12 +248,6 @@ get_JPEG_data(capabilities_t *scanner, int *width, int *height, int *bps)
}
return (SANE_STATUS_NO_MEM);
}
- jpeg_start_decompress(&cinfo);
- if (x_off > 0 || w < cinfo.output_width)
- jpeg_crop_scanline(&cinfo, &x_off, &w);
- lineSize = w * cinfo.output_components;
- if (y_off > 0)
- jpeg_skip_scanlines(&cinfo, y_off);
pos = 0;
while (cinfo.output_scanline < (unsigned int)rh) {
rowptr[0] = (JSAMPROW)surface + (lineSize * pos); // ..cinfo.output_scanline);
diff --git a/backend/escl/escl_newjob.c b/backend/escl/escl_newjob.c
index e1b326f..cb48bd1 100644
--- a/backend/escl/escl_newjob.c
+++ b/backend/escl/escl_newjob.c
@@ -46,7 +46,7 @@ struct downloading
static const char settings[] =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" \
"<scan:ScanSettings xmlns:pwg=\"http://www.pwg.org/schemas/2010/12/sm\" xmlns:scan=\"http://schemas.hp.com/imaging/escl/2011/05/03\">" \
- " <pwg:Version>%.2f</pwg:Version>" \
+ " <pwg:Version>%s</pwg:Version>" \
" <pwg:ScanRegions>" \
" <pwg:ScanRegion>" \
" <pwg:ContentRegionUnits>escl:ThreeHundredthsOfInches</pwg:ContentRegionUnits>" \
@@ -184,10 +184,24 @@ 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 (device->version <= 2.0)
+ if (atof ((const char *)device->version) <= 2.0)
{
// For eSCL 2.0 and older clients
snprintf(f_ext_tmp, sizeof(f_ext_tmp),