escl : delete noise

734-support-for-canon-i-sensys-mf657cdw-mf650c-series
ThierryFR 2024-07-20 06:31:59 +00:00
rodzic c6a99e409e
commit eb48ed29ee
5 zmienionych plików z 29 dodań i 29 usunięć

Wyświetl plik

@ -523,7 +523,7 @@ attach_one_config(SANEI_Config __sane_unused__ *config, const char *line,
line = sanei_config_get_string(line + 6, &name_str); line = sanei_config_get_string(line + 6, &name_str);
DBG (10, "New Escl_Device URL [%s].\n", (name_str ? name_str : "VIDE")); DBG (10, "New Escl_Device URL [%s].\n", (name_str ? name_str : "VIDE"));
if (!name_str || !*name_str) { if (!name_str || !*name_str) {
DBG (1, "Escl_Device URL missing.\n"); DBG(10, "Escl_Device URL missing.\n");
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
} }
if (*line) { if (*line) {
@ -1163,19 +1163,19 @@ escl_parse_name(SANE_String_Const name, ESCL_Device *device)
device->type = strdup("http"); device->type = strdup("http");
host = name + 7; host = name + 7;
} else { } else {
DBG(1, "Unknown URL scheme in %s", name); DBG(10, "Unknown URL scheme in %s", name);
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
} }
port_str = strchr(host, ':'); port_str = strchr(host, ':');
if (port_str == NULL) { if (port_str == NULL) {
DBG(1, "Port missing from URL: %s", name); DBG(10, "Port missing from URL: %s", name);
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
} }
port_str++; port_str++;
device->port_nb = atoi(port_str); device->port_nb = atoi(port_str);
if (device->port_nb < 1 || device->port_nb > 65535) { if (device->port_nb < 1 || device->port_nb > 65535) {
DBG(1, "Invalid port number in URL: %s", name); DBG(10, "Invalid port number in URL: %s", name);
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
} }
@ -1201,7 +1201,7 @@ _get_hack(SANE_String_Const name, ESCL_Device *device)
fp = sanei_config_open (ESCL_CONFIG_FILE); fp = sanei_config_open (ESCL_CONFIG_FILE);
if (!fp) if (!fp)
{ {
DBG (2, "_get_hack: couldn't access %s\n", ESCL_CONFIG_FILE); DBG(4, "_get_hack: couldn't access %s\n", ESCL_CONFIG_FILE);
DBG (3, "_get_hack: exit\n"); DBG (3, "_get_hack: exit\n");
} }
@ -1236,7 +1236,7 @@ _get_blacklist_pdf(void)
fp = sanei_config_open (ESCL_CONFIG_FILE); fp = sanei_config_open (ESCL_CONFIG_FILE);
if (!fp) if (!fp)
{ {
DBG (2, "_get_blacklit: couldn't access %s\n", ESCL_CONFIG_FILE); DBG(4, "_get_blacklit: couldn't access %s\n", ESCL_CONFIG_FILE);
DBG (3, "_get_blacklist: exit\n"); DBG (3, "_get_blacklist: exit\n");
} }
@ -1558,7 +1558,7 @@ sane_start(SANE_Handle h)
int bps = 0; int bps = 0;
if (handler->device == NULL) { if (handler->device == NULL) {
DBG(1, "Missing handler device.\n"); DBG(10, "Missing handler device.\n");
return (SANE_STATUS_INVAL); return (SANE_STATUS_INVAL);
} }
handler->cancel = SANE_FALSE; handler->cancel = SANE_FALSE;

Wyświetl plik

@ -137,7 +137,7 @@ get_PDF_data(capabilities_t *scanner, int *width, int *height, int *bps)
ctx = fz_new_context(NULL, NULL, FZ_STORE_UNLIMITED); ctx = fz_new_context(NULL, NULL, FZ_STORE_UNLIMITED);
if (!ctx) if (!ctx)
{ {
DBG(1, "cannot create mupdf context\n"); DBG(10, "cannot create mupdf context\n");
status = SANE_STATUS_INVAL; status = SANE_STATUS_INVAL;
goto close_file; goto close_file;
} }
@ -147,7 +147,7 @@ get_PDF_data(capabilities_t *scanner, int *width, int *height, int *bps)
fz_register_document_handlers(ctx); fz_register_document_handlers(ctx);
fz_catch(ctx) fz_catch(ctx)
{ {
DBG(1, "cannot register document handlers: %s\n", fz_caught_message(ctx)); DBG(10, "cannot register document handlers: %s\n", fz_caught_message(ctx));
status = SANE_STATUS_INVAL; status = SANE_STATUS_INVAL;
goto drop_context; goto drop_context;
} }
@ -157,7 +157,7 @@ get_PDF_data(capabilities_t *scanner, int *width, int *height, int *bps)
stream = fz_open_file_ptr_escl(ctx, scanner->tmp); stream = fz_open_file_ptr_escl(ctx, scanner->tmp);
fz_catch(ctx) fz_catch(ctx)
{ {
DBG(1, "cannot open stream: %s\n", fz_caught_message(ctx)); DBG(10, "cannot open stream: %s\n", fz_caught_message(ctx));
status = SANE_STATUS_INVAL; status = SANE_STATUS_INVAL;
goto drop_context; goto drop_context;
} }
@ -167,7 +167,7 @@ get_PDF_data(capabilities_t *scanner, int *width, int *height, int *bps)
fz_seek(ctx, stream, 0, SEEK_SET); fz_seek(ctx, stream, 0, SEEK_SET);
fz_catch(ctx) fz_catch(ctx)
{ {
DBG(1, "cannot seek stream: %s\n", fz_caught_message(ctx)); DBG(10, "cannot seek stream: %s\n", fz_caught_message(ctx));
status = SANE_STATUS_INVAL; status = SANE_STATUS_INVAL;
goto drop_stream; goto drop_stream;
} }
@ -177,7 +177,7 @@ get_PDF_data(capabilities_t *scanner, int *width, int *height, int *bps)
doc = fz_open_document_with_stream(ctx, "filename.pdf", stream); doc = fz_open_document_with_stream(ctx, "filename.pdf", stream);
fz_catch(ctx) fz_catch(ctx)
{ {
DBG(1, "cannot open document: %s\n", fz_caught_message(ctx)); DBG(10, "cannot open document: %s\n", fz_caught_message(ctx));
status = SANE_STATUS_INVAL; status = SANE_STATUS_INVAL;
goto drop_stream; goto drop_stream;
} }
@ -187,14 +187,14 @@ get_PDF_data(capabilities_t *scanner, int *width, int *height, int *bps)
page_count = fz_count_pages(ctx, doc); page_count = fz_count_pages(ctx, doc);
fz_catch(ctx) fz_catch(ctx)
{ {
DBG(1, "cannot count number of pages: %s\n", fz_caught_message(ctx)); DBG(10, "cannot count number of pages: %s\n", fz_caught_message(ctx));
status = SANE_STATUS_INVAL; status = SANE_STATUS_INVAL;
goto drop_document; goto drop_document;
} }
if (page_number < 0 || page_number >= page_count) if (page_number < 0 || page_number >= page_count)
{ {
DBG(1, "page number out of range: %d (page count %d)\n", page_number + 1, page_count); DBG(10, "page number out of range: %d (page count %d)\n", page_number + 1, page_count);
status = SANE_STATUS_INVAL; status = SANE_STATUS_INVAL;
goto drop_document; goto drop_document;
} }
@ -209,7 +209,7 @@ get_PDF_data(capabilities_t *scanner, int *width, int *height, int *bps)
pix = fz_new_pixmap_from_page_number(ctx, doc, 0, &ctm, fz_device_rgb(ctx), 0); pix = fz_new_pixmap_from_page_number(ctx, doc, 0, &ctm, fz_device_rgb(ctx), 0);
fz_catch(ctx) fz_catch(ctx)
{ {
DBG(1, "cannot render page: %s\n", fz_caught_message(ctx)); DBG(10, "cannot render page: %s\n", fz_caught_message(ctx));
status = SANE_STATUS_INVAL; status = SANE_STATUS_INVAL;
goto drop_document; goto drop_document;
} }

Wyświetl plik

@ -121,21 +121,21 @@ get_PDF_data(capabilities_t *scanner, int *width, int *height, int *bps)
file = g_mapped_file_new_from_fd (fileno (scanner->tmp), 0, NULL); file = g_mapped_file_new_from_fd (fileno (scanner->tmp), 0, NULL);
if (!file) { if (!file) {
DBG(1, "Error : g_mapped_file_new_from_fd"); DBG(10, "Error : g_mapped_file_new_from_fd");
status = SANE_STATUS_INVAL; status = SANE_STATUS_INVAL;
goto close_file; goto close_file;
} }
bytes = g_mapped_file_get_bytes (file); bytes = g_mapped_file_get_bytes (file);
if (!bytes) { if (!bytes) {
DBG(1, "Error : g_mapped_file_get_bytes"); DBG(10, "Error : g_mapped_file_get_bytes");
status = SANE_STATUS_INVAL; status = SANE_STATUS_INVAL;
goto free_file; goto free_file;
} }
doc = poppler_document_new_from_bytes (bytes, NULL, NULL); doc = poppler_document_new_from_bytes (bytes, NULL, NULL);
if (!doc) { if (!doc) {
DBG(1, "Error : poppler_document_new_from_bytes"); DBG(10, "Error : poppler_document_new_from_bytes");
status = SANE_STATUS_INVAL; status = SANE_STATUS_INVAL;
goto free_bytes; goto free_bytes;
} }
@ -145,14 +145,14 @@ get_PDF_data(capabilities_t *scanner, int *width, int *height, int *bps)
data = (char*)set_file_in_buffer(scanner->tmp, &size); data = (char*)set_file_in_buffer(scanner->tmp, &size);
if (!data) { if (!data) {
DBG(1, "Error : set_file_in_buffer"); DBG(10, "Error : set_file_in_buffer");
status = SANE_STATUS_INVAL; status = SANE_STATUS_INVAL;
goto close_file; goto close_file;
} }
doc = poppler_document_new_from_data (data, size, NULL, NULL); doc = poppler_document_new_from_data (data, size, NULL, NULL);
if (!doc) { if (!doc) {
DBG(1, "Error : poppler_document_new_from_data"); DBG(10, "Error : poppler_document_new_from_data");
status = SANE_STATUS_INVAL; status = SANE_STATUS_INVAL;
goto free_data; goto free_data;
} }
@ -160,7 +160,7 @@ get_PDF_data(capabilities_t *scanner, int *width, int *height, int *bps)
page = poppler_document_get_page (doc, 0); page = poppler_document_get_page (doc, 0);
if (!page) { if (!page) {
DBG(1, "Error : poppler_document_get_page"); DBG(10, "Error : poppler_document_get_page");
status = SANE_STATUS_INVAL; status = SANE_STATUS_INVAL;
goto free_doc; goto free_doc;
} }
@ -172,14 +172,14 @@ get_PDF_data(capabilities_t *scanner, int *width, int *height, int *bps)
h = (int)ceil(dh); h = (int)ceil(dh);
cairo_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, w, h); cairo_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, w, h);
if (!cairo_surface) { if (!cairo_surface) {
DBG(1, "Error : cairo_image_surface_create"); DBG(10, "Error : cairo_image_surface_create");
status = SANE_STATUS_INVAL; status = SANE_STATUS_INVAL;
goto free_page; goto free_page;
} }
cr = cairo_create (cairo_surface); cr = cairo_create (cairo_surface);
if (!cairo_surface) { if (!cairo_surface) {
DBG(1, "Error : cairo_create"); DBG(10, "Error : cairo_create");
status = SANE_STATUS_INVAL; status = SANE_STATUS_INVAL;
goto free_surface; goto free_surface;
} }
@ -196,26 +196,26 @@ get_PDF_data(capabilities_t *scanner, int *width, int *height, int *bps)
int st = cairo_status(cr); int st = cairo_status(cr);
if (st) if (st)
{ {
DBG(1, "%s", cairo_status_to_string (st)); DBG(10, "%s", cairo_status_to_string (st));
status = SANE_STATUS_INVAL; status = SANE_STATUS_INVAL;
goto destroy_cr; goto destroy_cr;
} }
*bps = 3; *bps = 3;
DBG(1, "Escl Pdf : Image Size [%dx%d]\n", w, h); DBG(10, "Escl Pdf : Image Size [%dx%d]\n", w, h);
surface = cairo_surface_to_pixels (cairo_surface, *bps); surface = cairo_surface_to_pixels (cairo_surface, *bps);
if (!surface) { if (!surface) {
status = SANE_STATUS_NO_MEM; status = SANE_STATUS_NO_MEM;
DBG(1, "Escl Pdf : Surface Memory allocation problem"); DBG(10, "Escl Pdf : Surface Memory allocation problem");
goto destroy_cr; goto destroy_cr;
} }
// If necessary, trim the image. // If necessary, trim the image.
surface = escl_crop_surface(scanner, surface, w, h, *bps, width, height); surface = escl_crop_surface(scanner, surface, w, h, *bps, width, height);
if (!surface) { if (!surface) {
DBG(1, "Escl Pdf Crop: Surface Memory allocation problem"); DBG(10, "Escl Pdf Crop: Surface Memory allocation problem");
status = SANE_STATUS_NO_MEM; status = SANE_STATUS_NO_MEM;
} }

Wyświetl plik

@ -115,7 +115,7 @@ get_PNG_data(capabilities_t *scanner, int *width, int *height, int *bps)
png_set_palette_to_rgb (png_ptr); png_set_palette_to_rgb (png_ptr);
else if (color_type != PNG_COLOR_TYPE_RGB && color_type != PNG_COLOR_TYPE_RGB_ALPHA) else if (color_type != PNG_COLOR_TYPE_RGB && color_type != PNG_COLOR_TYPE_RGB_ALPHA)
{ {
DBG(1, "PNG format not supported.\n"); DBG(10, "PNG format not supported.\n");
status = SANE_STATUS_NO_MEM; status = SANE_STATUS_NO_MEM;
goto close_file; goto close_file;
} }

Wyświetl plik

@ -53,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); char *str = realloc(mem->memory, mem->size + realsize + 1);
if (str == NULL) { if (str == NULL) {
DBG(1, "not enough memory (realloc returned NULL)\n"); DBG(10, "not enough memory (realloc returned NULL)\n");
return (0); return (0);
} }
mem->memory = str; mem->memory = str;