Merge branch 'escl-delete-noise' into 'master'

escl backend has become noisy

See merge request sane-project/backends!844
734-support-for-canon-i-sensys-mf657cdw-mf650c-series
ThierryFR 2024-06-21 09:33:40 +00:00
commit 7a2a2f841b
11 zmienionych plików z 47 dodań i 47 usunięć

Wyświetl plik

@ -416,7 +416,7 @@ convertFromESCLDev(ESCL_Device *cdev)
unix_path, cdev->https ? "s" : "", cdev->ip_address, cdev->port_nb);
sdev->name = tmp;
DBG( 1, "Escl add device : %s\n", tmp);
DBG( 10, "Escl add device : %s\n", tmp);
sdev->vendor = get_vendor(cdev->model_name);
if (!sdev->vendor)
@ -1888,24 +1888,24 @@ escl_curl_url(CURL *handle, const ESCL_Device *device, SANE_String_Const path)
(device->https ? "https" : "http"), device->ip_address,
device->port_nb, path);
DBG( 1, "escl_curl_url: URL: %s\n", url );
DBG( 10, "escl_curl_url: URL: %s\n", url );
curl_easy_setopt(handle, CURLOPT_URL, url);
free(url);
DBG( 1, "Before use hack\n");
DBG( 10, "Before use hack\n");
if (device->hack) {
DBG( 1, "Use hack\n");
DBG( 10, "Use hack\n");
curl_easy_setopt(handle, CURLOPT_HTTPHEADER, device->hack);
}
DBG( 1, "After use hack\n");
DBG( 10, "After use hack\n");
if (device->https) {
DBG( 1, "Ignoring safety certificates, use https\n");
DBG( 10, "Ignoring safety certificates, use https\n");
curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(handle, CURLOPT_SSL_VERIFYHOST, 0L);
if (device->tls > 0)
curl_easy_setopt(handle, CURLOPT_SSLVERSION, device->tls);
}
if (device->unix_socket != NULL) {
DBG( 1, "Using local socket %s\n", device->unix_socket );
DBG( 10, "Using local socket %s\n", device->unix_socket );
curl_easy_setopt(handle, CURLOPT_UNIX_SOCKET_PATH,
device->unix_socket);
}

Wyświetl plik

@ -48,7 +48,7 @@ header_callback(void *str, size_t size, size_t nmemb, void *userp)
char *content = realloc(header->memory, header->size + realsize + 1);
if (content == NULL) {
DBG( 1, "Not enough memory (realloc returned NULL)\n");
DBG( 10, "Not enough memory (realloc returned NULL)\n");
return (0);
}
header->memory = content;
@ -566,9 +566,9 @@ escl_capabilities(ESCL_Device *device, char *blacklist, SANE_Status *status)
curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 3L);
CURLcode res = curl_easy_perform(curl_handle);
if (res == CURLE_OK)
DBG( 1, "Create NewJob : the scanner header responded : [%s]\n", header->memory);
DBG( 10, "Create NewJob : the scanner header responded : [%s]\n", header->memory);
if (res != CURLE_OK) {
DBG( 1, "The scanner didn't respond: %s\n", curl_easy_strerror(res));
DBG( 10, "The scanner didn't respond: %s\n", curl_easy_strerror(res));
*status = SANE_STATUS_INVAL;
goto clean_data;
}

Wyświetl plik

@ -44,7 +44,7 @@ escl_crop_surface(capabilities_t *scanner,
int real_h = 0;
unsigned char *surface_crop = NULL;
DBG( 1, "Escl Image Crop\n");
DBG( 10, "Escl Image Crop\n");
ratio = (double)w / (double)scanner->caps[scanner->source].width;
scanner->caps[scanner->source].width = w;
if (scanner->caps[scanner->source].pos_x < 0)
@ -62,18 +62,18 @@ escl_crop_surface(capabilities_t *scanner,
y_off = (int)((double)scanner->caps[scanner->source].pos_y * ratio);
real_h = scanner->caps[scanner->source].height - y_off;
DBG( 1, "Escl Image Crop [%dx%d|%dx%d]\n", scanner->caps[scanner->source].pos_x, scanner->caps[scanner->source].pos_y,
DBG( 10, "Escl Image Crop [%dx%d|%dx%d]\n", scanner->caps[scanner->source].pos_x, scanner->caps[scanner->source].pos_y,
scanner->caps[scanner->source].width, scanner->caps[scanner->source].height);
*width = real_w;
*height = real_h;
DBG( 1, "Escl Image Crop [%dx%d]\n", *width, *height);
DBG( 10, "Escl Image Crop [%dx%d]\n", *width, *height);
if (x_off > 0 || real_w < scanner->caps[scanner->source].width ||
y_off > 0 || real_h < scanner->caps[scanner->source].height) {
surface_crop = (unsigned char *)malloc (sizeof (unsigned char) * real_w
* real_h * bps);
if(!surface_crop) {
DBG( 1, "Escl Crop : Surface_crop Memory allocation problem\n");
DBG( 10, "Escl Crop : Surface_crop Memory allocation problem\n");
free(surface);
surface = NULL;
goto finish;

Wyświetl plik

@ -193,21 +193,21 @@ escl_devices(SANE_Status *status)
*status = SANE_STATUS_GOOD;
if (!(simple_poll = avahi_simple_poll_new())) {
DBG( 1, "Failed to create simple poll object.\n");
DBG( 10, "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) {
DBG( 1, "Failed to create client: %s\n", avahi_strerror(error));
DBG( 10, "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))) {
DBG( 1, "Failed to create service browser: %s\n",
DBG( 10, "Failed to create service browser: %s\n",
avahi_strerror(avahi_client_errno(client)));
*status = SANE_STATUS_INVAL;
goto fail;
@ -216,7 +216,7 @@ escl_devices(SANE_Status *status)
AVAHI_PROTO_UNSPEC,
"_uscans._tcp", NULL, 0,
browse_callback, client))) {
DBG( 1, "Failed to create service browser: %s\n",
DBG( 10, "Failed to create service browser: %s\n",
avahi_strerror(avahi_client_errno(client)));
*status = SANE_STATUS_INVAL;
goto fail;

Wyświetl plik

@ -179,7 +179,7 @@ get_JPEG_data(capabilities_t *scanner, int *width, int *height, int *bps)
if (surface != NULL)
free(surface);
fseek(scanner->tmp, start, SEEK_SET);
DBG( 1, "Escl Jpeg : Error reading jpeg\n");
DBG( 10, "Escl Jpeg : Error reading jpeg\n");
if (scanner->tmp) {
fclose(scanner->tmp);
scanner->tmp = NULL;
@ -241,7 +241,7 @@ get_JPEG_data(capabilities_t *scanner, int *width, int *height, int *bps)
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");
DBG( 10, "Escl Jpeg : Memory allocation problem\n");
if (scanner->tmp) {
fclose(scanner->tmp);
scanner->tmp = NULL;

Wyświetl plik

@ -220,7 +220,7 @@ get_PDF_data(capabilities_t *scanner, int *width, int *height, int *bps)
// If necessary, trim the image.
surface = escl_crop_surface(scanner, surface, pix->w, pix->h, pix->n, width, height);
if (!surface) {
DBG( 1, "Escl Pdf : Surface Memory allocation problem\n");
DBG( 10, "Escl Pdf : Surface Memory allocation problem\n");
status = SANE_STATUS_NO_MEM;
goto drop_pix;
}

Wyświetl plik

@ -96,7 +96,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) {
DBG( 1, "Not enough memory (realloc returned NULL)\n");
DBG( 10, "Not enough memory (realloc returned NULL)\n");
return (0);
}
download->memory = content;
@ -144,19 +144,19 @@ escl_newjob (capabilities_t *scanner, const ESCL_Device *device, SANE_Status *st
*status = SANE_STATUS_GOOD;
if (device == NULL || scanner == NULL) {
*status = SANE_STATUS_NO_MEM;
DBG( 1, "Create NewJob : the name or the scan are invalid.\n");
DBG( 10, "Create NewJob : the name or the scan are invalid.\n");
return (NULL);
}
upload = (struct downloading *)calloc(1, sizeof(struct downloading));
if (upload == NULL) {
*status = SANE_STATUS_NO_MEM;
DBG( 1, "Create NewJob : memory allocation failure\n");
DBG( 10, "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");
DBG( 10, "Create NewJob : memory allocation failure\n");
*status = SANE_STATUS_NO_MEM;
return (NULL);
}
@ -205,7 +205,7 @@ escl_newjob (capabilities_t *scanner, const ESCL_Device *device, SANE_Status *st
" <scan:Duplex>%s</scan:Duplex>",
scanner->source == ADFDUPLEX ? "true" : "false");
}
DBG( 1, "Create NewJob : %s\n", scanner->caps[scanner->source].default_format);
DBG( 10, "Create NewJob : %s\n", scanner->caps[scanner->source].default_format);
if (scanner->caps[scanner->source].pos_x > scanner->caps[scanner->source].width)
off_x = (scanner->caps[scanner->source].pos_x > scanner->caps[scanner->source].width) / 2;
if (scanner->caps[scanner->source].pos_y > scanner->caps[scanner->source].height)
@ -278,7 +278,7 @@ escl_newjob (capabilities_t *scanner, const ESCL_Device *device, SANE_Status *st
upload->memory = strdup(cap_data);
upload->size = strlen(cap_data);
wake_up_device:
DBG( 1, "Create NewJob : %s\n", cap_data);
DBG( 10, "Create NewJob : %s\n", cap_data);
download->memory = malloc(1);
download->size = 0;
curl_handle = curl_easy_init();
@ -293,7 +293,7 @@ wake_up_device:
curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 3L);
CURLcode res = curl_easy_perform(curl_handle);
if (res != CURLE_OK) {
DBG( 1, "Create NewJob : the scanner responded incorrectly: %s\n", curl_easy_strerror(res));
DBG( 10, "Create NewJob : the scanner responded incorrectly: %s\n", curl_easy_strerror(res));
*status = SANE_STATUS_INVAL;
}
else {
@ -308,7 +308,7 @@ wake_up_device:
location = strrchr(tmp_location,'/');
if (location) {
result = strdup(location);
DBG( 1, "Create NewJob : %s\n", result);
DBG( 10, "Create NewJob : %s\n", result);
*temporary = '\n';
*location = '\0';
location = strrchr(tmp_location,'/');
@ -316,7 +316,7 @@ wake_up_device:
if (location) {
location++;
scanner->scanJob = strdup(location);
DBG( 1, "Full location header [%s]\n", scanner->scanJob);
DBG( 10, "Full location header [%s]\n", scanner->scanJob);
}
else
scanner->scanJob = strdup("ScanJobs");
@ -324,14 +324,14 @@ wake_up_device:
}
}
if (result == NULL) {
DBG( 1, "Error : Create NewJob, no location: %s\n", download->memory);
DBG( 10, "Error : Create NewJob, no location: %s\n", download->memory);
*status = SANE_STATUS_INVAL;
}
free(download->memory);
download->memory = NULL;
}
else {
DBG( 1, "Create NewJob : The creation of the failed job: %s\n", download->memory);
DBG( 10, "Create NewJob : The creation of the failed job: %s\n", download->memory);
// If "409 Conflict" appear it means that there is no paper in feeder
if (strstr(download->memory, "409 Conflict") != NULL)
*status = SANE_STATUS_NO_DOCS;
@ -346,7 +346,7 @@ wake_up_device:
}
else {
*status = SANE_STATUS_NO_MEM;
DBG( 1, "Create NewJob : The creation of the failed job\n");
DBG( 10, "Create NewJob : The creation of the failed job\n");
return (NULL);
}
}

Wyświetl plik

@ -64,7 +64,7 @@ get_PNG_data(capabilities_t *scanner, int *width, int *height, int *bps)
// check for valid magic number
if (!png_check_sig (magic, sizeof (magic)))
{
DBG( 1, "Escl Png : PNG error is not a valid PNG image!\n");
DBG( 10, "Escl Png : PNG error is not a valid PNG image!\n");
status = SANE_STATUS_INVAL;
goto close_file;
}
@ -73,7 +73,7 @@ get_PNG_data(capabilities_t *scanner, int *width, int *height, int *bps)
(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png_ptr)
{
DBG( 1, "Escl Png : PNG error create a png read struct\n");
DBG( 10, "Escl Png : PNG error create a png read struct\n");
status = SANE_STATUS_INVAL;
goto close_file;
}
@ -81,7 +81,7 @@ get_PNG_data(capabilities_t *scanner, int *width, int *height, int *bps)
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");
DBG( 10, "Escl Png : PNG error create a png info struct\n");
png_destroy_read_struct (&png_ptr, NULL, NULL);
status = SANE_STATUS_INVAL;
goto close_file;
@ -93,7 +93,7 @@ get_PNG_data(capabilities_t *scanner, int *width, int *height, int *bps)
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
if (surface)
free (surface);
DBG( 1, "Escl Png : PNG read error.\n");
DBG( 10, "Escl Png : PNG read error.\n");
status = SANE_STATUS_INVAL;
goto close_file;
}
@ -145,7 +145,7 @@ get_PNG_data(capabilities_t *scanner, int *width, int *height, int *bps)
surface = (unsigned char *)malloc (sizeof (unsigned char) * w
* h * components);
if (!surface) {
DBG( 1, "Escl Png : texels Memory allocation problem\n");
DBG( 10, "Escl Png : texels Memory allocation problem\n");
status = SANE_STATUS_NO_MEM;
goto close_file;
}
@ -153,7 +153,7 @@ get_PNG_data(capabilities_t *scanner, int *width, int *height, int *bps)
// setup a pointer array. Each one points at the begening of a row.
row_pointers = (png_bytep *)malloc (sizeof (png_bytep) * h);
if (!row_pointers) {
DBG( 1, "Escl Png : row_pointers Memory allocation problem\n");
DBG( 10, "Escl Png : row_pointers Memory allocation problem\n");
free(surface);
status = SANE_STATUS_NO_MEM;
goto close_file;
@ -169,7 +169,7 @@ get_PNG_data(capabilities_t *scanner, int *width, int *height, int *bps)
// If necessary, trim the image.
surface = escl_crop_surface(scanner, surface, w, h, components, width, height);
if (!surface) {
DBG( 1, "Escl Png : Surface Memory allocation problem\n");
DBG( 10, "Escl Png : Surface Memory allocation problem\n");
status = SANE_STATUS_NO_MEM;
goto close_file;
}

Wyświetl plik

@ -83,7 +83,7 @@ escl_scan(capabilities_t *scanner, const ESCL_Device *device, char *scanJob, cha
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, scanner);
CURLcode res = curl_easy_perform(curl_handle);
if (res != CURLE_OK) {
DBG( 1, "Unable to scan: %s\n", curl_easy_strerror(res));
DBG( 10, "Unable to scan: %s\n", curl_easy_strerror(res));
scanner->real_read = 0;
fclose(scanner->tmp);
scanner->tmp = NULL;

Wyświetl plik

@ -225,7 +225,7 @@ reload:
curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 3L);
CURLcode res = curl_easy_perform(curl_handle);
if (res != CURLE_OK) {
DBG( 1, "The scanner didn't respond: %s\n", curl_easy_strerror(res));
DBG( 10, "The scanner didn't respond: %s\n", curl_easy_strerror(res));
status = SANE_STATUS_INVAL;
goto clean_data;
}
@ -375,7 +375,7 @@ escl_reset_all_jobs(ESCL_Device *device)
curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 3L);
CURLcode res = curl_easy_perform(curl_handle);
if (res != CURLE_OK) {
DBG( 1, "The scanner didn't respond: %s\n", curl_easy_strerror(res));
DBG( 10, "The scanner didn't respond: %s\n", curl_easy_strerror(res));
status = SANE_STATUS_INVAL;
goto clean_data1;
}

Wyświetl plik

@ -65,7 +65,7 @@ get_TIFF_data(capabilities_t *scanner, int *width, int *height, int *bps)
lseek(fileno(scanner->tmp), 0, SEEK_SET);
tif = TIFFFdOpen(fileno(scanner->tmp), "temp", "r");
if (!tif) {
DBG( 1, "Escl Tiff : Can not open, or not a TIFF file.\n");
DBG( 10, "Escl Tiff : Can not open, or not a TIFF file.\n");
status = SANE_STATUS_INVAL;
goto close_file;
}
@ -76,14 +76,14 @@ get_TIFF_data(capabilities_t *scanner, int *width, int *height, int *bps)
surface = (unsigned char*) malloc(npixels * sizeof (uint32_t));
if (surface == NULL)
{
DBG( 1, "Escl Tiff : raster Memory allocation problem.\n");
DBG( 10, "Escl Tiff : raster Memory allocation problem.\n");
status = SANE_STATUS_INVAL;
goto close_tiff;
}
if (!TIFFReadRGBAImage(tif, w, h, (uint32_t *)surface, 0))
{
DBG( 1, "Escl Tiff : Problem reading image data.\n");
DBG( 10, "Escl Tiff : Problem reading image data.\n");
status = SANE_STATUS_INVAL;
free(surface);
goto close_tiff;
@ -94,7 +94,7 @@ get_TIFF_data(capabilities_t *scanner, int *width, int *height, int *bps)
// If necessary, trim the image.
surface = escl_crop_surface(scanner, surface, w, h, components, width, height);
if (!surface) {
DBG( 1, "Escl Tiff : Surface Memory allocation problem\n");
DBG( 10, "Escl Tiff : Surface Memory allocation problem\n");
status = SANE_STATUS_INVAL;
}