diff --git a/backend/escl/ScannerCapabilities.xml b/backend/escl/ScannerCapabilities.xml
new file mode 100644
index 000000000..15d8ca408
--- /dev/null
+++ b/backend/escl/ScannerCapabilities.xml
@@ -0,0 +1,193 @@
+
+
+ 2.63
+ EPSON ET-3750 Series
+ 583445553030353862
+ cfe92100-67c4-11d4-a45f-f8d0273406ee
+ http://192.168.0.73:80/PRESENTATION/BONJOUR
+ https://192.168.0.73:443/PRESENTATION/AIRPRINT/PRINTER_128.PNG
+
+
+ 96
+ 2550
+ 96
+ 3510
+ 1
+
+
+
+ BlackAndWhite1
+ Grayscale8
+ RGB24
+
+
+ application/pdf
+ image/jpeg
+ application/pdf
+ image/jpeg
+
+
+
+
+ 100
+ 100
+
+
+ 200
+ 200
+
+
+ 300
+ 300
+
+
+ 600
+ 600
+
+
+ 1200
+ 1200
+
+
+
+
+ sRGB
+
+
+ NTSC
+
+
+ Threshold
+ Halftone
+
+
+ Photo
+ Text
+ TextAndPhoto
+
+
+
+
+ Document
+ TextAndGraphic
+ Photo
+ Preview
+
+ 1200
+ 1200
+ 17
+ 17
+ 17
+ 17
+
+
+
+
+ 96
+ 2550
+ 96
+ 4200
+ 1
+
+
+
+ BlackAndWhite1
+ Grayscale8
+ RGB24
+
+
+ application/pdf
+ image/jpeg
+ application/pdf
+ image/jpeg
+
+
+
+
+ 100
+ 100
+
+
+ 200
+ 200
+
+
+ 300
+ 300
+
+
+ 600
+ 600
+
+
+
+
+ sRGB
+
+
+ NTSC
+
+
+ Threshold
+ Halftone
+
+
+ Photo
+ Text
+ TextAndPhoto
+
+
+
+
+ Document
+ TextAndGraphic
+ Photo
+ Preview
+
+ 600
+ 600
+ 17
+ 17
+ 35
+ 35
+
+ 50
+
+ Right
+ Top
+
+
+ DetectPaperLoaded
+
+
+
+ -100
+ 100
+ 0
+ 1
+
+
+ 1
+ 3
+ 2
+ 1
+
+
+ -100
+ 100
+ 0
+ 1
+
+
+ 0
+ 3
+ 2
+ 1
+
+
+ 0
+ 255
+ 186
+ 1
+
+
diff --git a/backend/escl/escl.c b/backend/escl/escl.c
index c309cc2f2..da3a22332 100644
--- a/backend/escl/escl.c
+++ b/backend/escl/escl.c
@@ -35,7 +35,6 @@
#include "../include/sane/sanei.h"
#include "../include/sane/sanei_backend.h"
#include "../include/sane/sanei_config.h"
-#include "../include/sane/sanei_debug.h"
#define min(A,B) (((A)<(B)) ? (A) : (B))
#define max(A,B) (((A)>(B)) ? (A) : (B))
@@ -150,6 +149,7 @@ convertFromESCLDev(ESCL_Device *cdev)
snprintf(tmp, sizeof(tmp), "http://%s:%d", cdev->ip_address, cdev->port_nb);
else
snprintf(tmp, sizeof(tmp), "https://%s:%d", cdev->ip_address, cdev->port_nb);
+ DBG( 1, "Escl add device : %s\n", tmp);
sdev->name = strdup(tmp);
sdev->model = strdup(cdev->model_name);
sdev->vendor = strdup("ESCL");
diff --git a/backend/escl/escl.h b/backend/escl/escl.h
index 8f9315265..82910bdfe 100644
--- a/backend/escl/escl.h
+++ b/backend/escl/escl.h
@@ -48,6 +48,19 @@
#define BACKEND_NAME escl
#endif
+#define DEBUG_NOT_STATIC
+#include "../include/sane/sanei_debug.h"
+
+#ifndef DBG_LEVEL
+#define DBG_LEVEL PASTE(sanei_debug_, BACKEND_NAME)
+#endif
+#ifndef NDEBUG
+# define DBGDUMP(level, buf, size) \
+ do { if (DBG_LEVEL >= (level)) sanei_escl_dbgdump(buf, size); } while (0)
+#else
+# define DBGDUMP(level, buf, size)
+#endif
+
#define ESCL_CONFIG_FILE "escl.conf"
typedef struct {
diff --git a/backend/escl/escl_capabilities.c b/backend/escl/escl_capabilities.c
index 7de67143f..690ff1eff 100644
--- a/backend/escl/escl_capabilities.c
+++ b/backend/escl/escl_capabilities.c
@@ -21,6 +21,8 @@
This file implements a SANE backend for eSCL scanners. */
+#define DEBUG_DECLARE_ONLY
+#include "../include/sane/config.h"
#include "escl.h"
@@ -346,15 +348,17 @@ escl_capabilities(SANE_String_Const name, SANE_Status *status)
curl_handle = curl_easy_init();
strcpy(tmp, name);
strcat(tmp, scanner_capabilities);
+ DBG( 1, "Get Capabilities : %s\n", tmp);
curl_easy_setopt(curl_handle, CURLOPT_URL, tmp);
if (strncmp(name, "https", 5) == 0) {
+ DBG( 1, "Ignoring safety certificates, use https\n");
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0L);
}
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, memory_callback_c);
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)var);
if (curl_easy_perform(curl_handle) != CURLE_OK) {
- fprintf(stderr, "THERE IS NO SCANNER\n");
+ DBG( 1, "The scanner didn't respond.\n");
*status = SANE_STATUS_INVAL;
}
data = xmlReadMemory(var->memory, var->size, "file.xml", NULL, 0);
diff --git a/backend/escl/escl_devices.c b/backend/escl/escl_devices.c
index b1182b920..7ecbe31e8 100644
--- a/backend/escl/escl_devices.c
+++ b/backend/escl/escl_devices.c
@@ -21,6 +21,9 @@
This file implements a SANE backend for eSCL scanners. */
+#define DEBUG_DECLARE_ONLY
+#include "../include/sane/config.h"
+
#include "escl.h"
#include
@@ -142,21 +145,21 @@ escl_devices(SANE_Status *status)
*status = SANE_STATUS_GOOD;
if (!(simple_poll = avahi_simple_poll_new())) {
- fprintf(stderr, "Failed to create simple poll object.\n");
+ DBG( 1, "Failed to create simple poll object.\n");
*status = SANE_STATUS_INVAL;
goto fail;
}
client = avahi_client_new(avahi_simple_poll_get(simple_poll), 0,
client_callback, NULL, &error);
if (!client) {
- fprintf(stderr, "Failed to create client: %s\n", avahi_strerror(error));
+ DBG( 1, "Failed to create client: %s\n", avahi_strerror(error));
*status = SANE_STATUS_INVAL;
goto fail;
}
if (!(sb = avahi_service_browser_new(client, AVAHI_IF_UNSPEC,
AVAHI_PROTO_UNSPEC, "_uscan._tcp",
NULL, 0, browse_callback, client))) {
- fprintf(stderr, "Failed to create service browser: %s\n",
+ DBG( 1, "Failed to create service browser: %s\n",
avahi_strerror(avahi_client_errno(client)));
*status = SANE_STATUS_INVAL;
goto fail;
@@ -165,7 +168,7 @@ escl_devices(SANE_Status *status)
AVAHI_PROTO_UNSPEC,
"_uscans._tcp", NULL, 0,
browse_callback, client))) {
- fprintf(stderr, "Failed to create service browser: %s\n",
+ DBG( 1, "Failed to create service browser: %s\n",
avahi_strerror(avahi_client_errno(client)));
*status = SANE_STATUS_INVAL;
goto fail;
diff --git a/backend/escl/escl_jpeg.c b/backend/escl/escl_jpeg.c
index d0935b743..d6287efb0 100644
--- a/backend/escl/escl_jpeg.c
+++ b/backend/escl/escl_jpeg.c
@@ -1,3 +1,29 @@
+/* sane - Scanner Access Now Easy.
+
+ Copyright (C) 2019 Touboul Nathane
+ Copyright (C) 2019 Thierry HUCHARD
+
+ This file is part of the SANE package.
+
+ SANE is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at your
+ option) any later version.
+
+ SANE is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with sane; see the file COPYING. If not, write to the Free
+ Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ This file implements a SANE backend for eSCL scanners. */
+
+#define DEBUG_DECLARE_ONLY
+#include "../include/sane/config.h"
+
#include "escl.h"
#include "../include/sane/sanei.h"
@@ -148,6 +174,7 @@ get_JPEG_data(capabilities_t *scanner, int *w, int *h, int *bps)
jpeg_destroy_decompress(&cinfo);
if (surface != NULL)
free(surface);
+ DBG( 1, "Escl Jpeg : Error reading jpeg\n");
if (scanner->tmp) {
fclose(scanner->tmp);
scanner->tmp = NULL;
@@ -164,6 +191,7 @@ get_JPEG_data(capabilities_t *scanner, int *w, int *h, int *bps)
if (surface == NULL) {
jpeg_destroy_decompress(&cinfo);
fseek(scanner->tmp, start, SEEK_SET);
+ DBG( 1, "Escl Jpeg : Memory allocation problem\n");
if (scanner->tmp) {
fclose(scanner->tmp);
scanner->tmp = NULL;
diff --git a/backend/escl/escl_newjob.c b/backend/escl/escl_newjob.c
index 998fd7665..279b9df8c 100644
--- a/backend/escl/escl_newjob.c
+++ b/backend/escl/escl_newjob.c
@@ -21,6 +21,9 @@
This file implements a SANE backend for eSCL scanners. */
+#define DEBUG_DECLARE_ONLY
+#include "../include/sane/config.h"
+
#include "escl.h"
#include
@@ -108,7 +111,7 @@ download_callback(void *str, size_t size, size_t nmemb, void *userp)
char *content = realloc(download->memory, download->size + realsize + 1);
if (content == NULL) {
- fprintf(stderr, "not enough memory (realloc returned NULL)\n");
+ DBG( 1, "Not enough memory (realloc returned NULL)\n");
return (0);
}
download->memory = content;
@@ -145,16 +148,19 @@ escl_newjob (capabilities_t *scanner, SANE_String_Const name, SANE_Status *statu
*status = SANE_STATUS_GOOD;
if (name == NULL || scanner == NULL) {
*status = SANE_STATUS_NO_MEM;
+ DBG( 1, "Create NewJob : the name or the scan are invalid.\n");
return (NULL);
}
upload = (struct uploading *)calloc(1, sizeof(struct uploading));
if (upload == NULL) {
*status = SANE_STATUS_NO_MEM;
+ DBG( 1, "Create NewJob : memory allocation failure\n");
return (NULL);
}
download = (struct downloading *)calloc(1, sizeof(struct downloading));
if (download == NULL) {
free(upload);
+ DBG( 1, "Create NewJob : memory allocation failure\n");
*status = SANE_STATUS_NO_MEM;
return (NULL);
}
@@ -172,11 +178,12 @@ escl_newjob (capabilities_t *scanner, SANE_String_Const name, SANE_Status *statu
}
else
format_ext = f_ext;
+ DBG( 1, "Create NewJob : %s\n", scanner->default_format);
if (curl_handle != NULL) {
snprintf(cap_data, sizeof(cap_data), settings, scanner->height, scanner->width, 0, 0, scanner->default_format,
format_ext,
scanner->default_color, scanner->default_resolution, scanner->default_resolution);
- // fprintf(stderr, "CAP_DATA = %s\n", cap_data);
+ DBG( 1, "Create NewJob : %s\n", cap_data);
upload->read_data = strdup(cap_data);
upload->size = strlen(cap_data);
download->memory = malloc(1);
@@ -194,7 +201,7 @@ escl_newjob (capabilities_t *scanner, SANE_String_Const name, SANE_Status *statu
curl_easy_setopt(curl_handle, CURLOPT_HEADERFUNCTION, download_callback);
curl_easy_setopt(curl_handle, CURLOPT_HEADERDATA, (void *)download);
if (curl_easy_perform(curl_handle) != CURLE_OK) {
- fprintf(stderr, "THERE IS NO SCANNER\n");
+ DBG( 1, "Create NewJob : the scanner responded incorrectly.\n");
*status = SANE_STATUS_INVAL;
}
else {
@@ -209,16 +216,18 @@ escl_newjob (capabilities_t *scanner, SANE_String_Const name, SANE_Status *statu
*location = '\0';
result = strdup(temporary);
}
+ DBG( 1, "Create NewJob : %s\n", result);
}
free(download->memory);
}
else {
- fprintf(stderr, "THERE IS NO LOCATION\n");
+ DBG( 1, "Create NewJob : The creation of the failed job\n");
*status = SANE_STATUS_INVAL;
}
}
else {
*status = SANE_STATUS_NO_MEM;
+ DBG( 1, "Create NewJob : The creation of the failed job\n");
return (NULL);
}
}
diff --git a/backend/escl/escl_png.c b/backend/escl/escl_png.c
index 75fb104f7..18f6f3510 100644
--- a/backend/escl/escl_png.c
+++ b/backend/escl/escl_png.c
@@ -1,3 +1,29 @@
+/* sane - Scanner Access Now Easy.
+
+ Copyright (C) 2019 Touboul Nathane
+ Copyright (C) 2019 Thierry HUCHARD
+
+ This file is part of the SANE package.
+
+ SANE is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at your
+ option) any later version.
+
+ SANE is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with sane; see the file COPYING. If not, write to the Free
+ Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ This file implements a SANE backend for eSCL scanners. */
+
+#define DEBUG_DECLARE_ONLY
+#include "../include/sane/config.h"
+
#include "escl.h"
#include "../include/sane/sanei.h"
@@ -37,7 +63,7 @@ get_PNG_data(capabilities_t *scanner, int *w, int *h, int *components)
// check for valid magic number
if (!png_check_sig (magic, sizeof (magic)))
{
- fprintf(stderr,"PNG error: is not a valid PNG image!\n");
+ DBG( 1, "Escl Png : PNG error is not a valid PNG image!\n");
if (scanner->tmp) {
fclose(scanner->tmp);
scanner->tmp = NULL;
@@ -49,6 +75,8 @@ get_PNG_data(capabilities_t *scanner, int *w, int *h, int *components)
(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png_ptr)
{
+ DBG( 1, "Escl Png : PNG error create a png read struct\n");
+ if (scanner->tmp)
if (scanner->tmp) {
fclose(scanner->tmp);
scanner->tmp = NULL;
@@ -59,6 +87,7 @@ get_PNG_data(capabilities_t *scanner, int *w, int *h, int *components)
png_infop info_ptr = png_create_info_struct (png_ptr);
if (!info_ptr)
{
+ DBG( 1, "Escl Png : PNG error create a png info struct\n");
png_destroy_read_struct (&png_ptr, NULL, NULL);
if (scanner->tmp) {
fclose(scanner->tmp);
@@ -78,6 +107,7 @@ get_PNG_data(capabilities_t *scanner, int *w, int *h, int *components)
fclose(scanner->tmp);
scanner->tmp = NULL;
}
+ DBG( 1, "Escl Png : PNG read error.\n");
return (SANE_STATUS_INVAL);
}
// setup libpng for using standard C fread() function
diff --git a/backend/escl/escl_reset.c b/backend/escl/escl_reset.c
index c7b34e229..7722d898d 100644
--- a/backend/escl/escl_reset.c
+++ b/backend/escl/escl_reset.c
@@ -21,6 +21,9 @@
This file implements a SANE backend for eSCL scanners. */
+#define DEBUG_DECLARE_ONLY
+#include "../include/sane/config.h"
+
#include "escl.h"
#include
@@ -53,7 +56,9 @@ CURL_CALL:
strcat(scan_cmd, result);
strcat(scan_cmd, scanner_start);
curl_easy_setopt(curl_handle, CURLOPT_URL, scan_cmd);
+ DBG( 1, "Reset Job : %s.\n", scan_cmd);
if (strncmp(name, "https", 5) == 0) {
+ DBG( 1, "Ignoring safety certificates, use https\n");
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0L);
}
diff --git a/backend/escl/escl_scan.c b/backend/escl/escl_scan.c
index 589f5f34d..8f077a132 100644
--- a/backend/escl/escl_scan.c
+++ b/backend/escl/escl_scan.c
@@ -21,6 +21,9 @@
This file implements a SANE backend for eSCL scanners. */
+#define DEBUG_DECLARE_ONLY
+#include "../include/sane/config.h"
+
#include "escl.h"
#include
@@ -72,7 +75,9 @@ escl_scan(capabilities_t __sane_unused__ *scanner, SANE_String_Const name, char
strcat(scan_cmd, result);
strcat(scan_cmd, scanner_start);
curl_easy_setopt(curl_handle, CURLOPT_URL, scan_cmd);
- if (strncmp(name, "https", 5) == 0) {
+ DBG( 1, "Scan : %s.\n", scan_cmd);
+ if (strncmp(name, "https", 5) == 0) {
+ DBG( 1, "Ignoring safety certificates, use https\n");
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0L);
}
diff --git a/backend/escl/escl_status.c b/backend/escl/escl_status.c
index ab0c8007b..68b51dcfa 100644
--- a/backend/escl/escl_status.c
+++ b/backend/escl/escl_status.c
@@ -21,6 +21,9 @@
This file implements a SANE backend for eSCL scanners. */
+#define DEBUG_DECLARE_ONLY
+#include "../include/sane/config.h"
+
#include "escl.h"
#include
@@ -50,7 +53,7 @@ memory_callback_s(void *contents, size_t size, size_t nmemb, void *userp)
char *str = realloc(mem->memory, mem->size + realsize + 1);
if (str == NULL) {
- fprintf(stderr, "not enough memory (realloc returned NULL)\n");
+ DBG(1, "not enough memory (realloc returned NULL)\n");
return (0);
}
mem->memory = str;
@@ -136,14 +139,16 @@ escl_status(SANE_String_Const name)
strcpy(tmp, name);
strcat(tmp, scanner_status);
curl_easy_setopt(curl_handle, CURLOPT_URL, tmp);
+ DBG( 1, "Get Status : %s.\n", tmp);
if (strncmp(name, "https", 5) == 0) {
+ DBG( 1, "Ignoring safety certificates, use https\n");
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0L);
}
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, memory_callback_s);
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)var);
if (curl_easy_perform(curl_handle) != CURLE_OK) {
- fprintf(stderr, "THERE IS NO SCANNER\n");
+ DBG( 1, "The scanner didn't respond.\n");
status = SANE_STATUS_INVAL;
goto clean_data;
}
diff --git a/backend/escl/escl_tiff.c b/backend/escl/escl_tiff.c
index 3ff4b1a43..52aec204a 100644
--- a/backend/escl/escl_tiff.c
+++ b/backend/escl/escl_tiff.c
@@ -1,3 +1,29 @@
+/* sane - Scanner Access Now Easy.
+
+ Copyright (C) 2019 Touboul Nathane
+ Copyright (C) 2019 Thierry HUCHARD
+
+ This file is part of the SANE package.
+
+ SANE is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at your
+ option) any later version.
+
+ SANE is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with sane; see the file COPYING. If not, write to the Free
+ Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ This file implements a SANE backend for eSCL scanners. */
+
+#define DEBUG_DECLARE_ONLY
+#include "../include/sane/config.h"
+
#include "escl.h"
#include "../include/sane/sanei.h"
@@ -36,7 +62,7 @@ get_TIFF_data(capabilities_t *scanner, int *w, int *h, int *components)
lseek(fileno(scanner->tmp), 0, SEEK_SET);
tif = TIFFFdOpen(fileno(scanner->tmp), "temp", "r");
if (!tif) {
- fprintf(stderr, "Can not open, or not a TIFF file.\n");
+ DBG( 1, "Escl Tiff : Can not open, or not a TIFF file.\n");
if (scanner->tmp) {
fclose(scanner->tmp);
scanner->tmp = NULL;
@@ -50,7 +76,7 @@ get_TIFF_data(capabilities_t *scanner, int *w, int *h, int *components)
raster = (unsigned char*) malloc(npixels * sizeof (uint32));
if (raster != NULL)
{
- fprintf(stderr, "Memory allocation problem.\n");
+ DBG( 1, "Escl Tiff : Memory allocation problem.\n");
if (scanner->tmp) {
fclose(scanner->tmp);
scanner->tmp = NULL;
@@ -60,7 +86,7 @@ get_TIFF_data(capabilities_t *scanner, int *w, int *h, int *components)
if (!TIFFReadRGBAImage(tif, width, height, (uint32 *)raster, 0))
{
- fprintf(stderr, "Problem reading image data.\n");
+ DBG( 1, "Escl Tiff : Problem reading image data.\n");
if (scanner->tmp) {
fclose(scanner->tmp);
scanner->tmp = NULL;