summaryrefslogtreecommitdiff
path: root/backend/escl/escl.c
diff options
context:
space:
mode:
Diffstat (limited to 'backend/escl/escl.c')
-rw-r--r--backend/escl/escl.c45
1 files changed, 41 insertions, 4 deletions
diff --git a/backend/escl/escl.c b/backend/escl/escl.c
index bb62219..5f02ec8 100644
--- a/backend/escl/escl.c
+++ b/backend/escl/escl.c
@@ -432,7 +432,8 @@ attach_one_config(SANEI_Config __sane_unused__ *config, const char *line,
int port = 0;
SANE_Status status;
static ESCL_Device *escl_device = NULL;
-
+ if (*line == '#') return SANE_STATUS_GOOD;
+ if (!strncmp(line, "pdfblacklist", 12)) return SANE_STATUS_GOOD;
if (strncmp(line, "device", 6) == 0) {
char *name_str = NULL;
char *opt_model = NULL;
@@ -1135,6 +1136,37 @@ finish_hack:
fclose(fp);
}
+static char*
+_get_blacklist_pdf(void)
+{
+ FILE *fp;
+ char *blacklist = NULL;
+ SANE_Char line[PATH_MAX];
+
+ /* open configuration file */
+ fp = sanei_config_open (ESCL_CONFIG_FILE);
+ if (!fp)
+ {
+ DBG (2, "_get_blacklit: couldn't access %s\n", ESCL_CONFIG_FILE);
+ DBG (3, "_get_blacklist: exit\n");
+ }
+
+ /* loop reading the configuration file, all line beginning by "option " are
+ * parsed for value to store in configuration structure, other line are
+ * used are device to try to attach
+ */
+ while (sanei_config_read (line, PATH_MAX, fp))
+ {
+ if (!strncmp(line, "pdfblacklist", 12)) {
+ blacklist = strdup(line);
+ goto finish_;
+ }
+ }
+finish_:
+ DBG (3, "_get_blacklist_pdf: finish\n");
+ fclose(fp);
+ return blacklist;
+}
/**
@@ -1149,6 +1181,7 @@ finish_hack:
SANE_Status
sane_open(SANE_String_Const name, SANE_Handle *h)
{
+ char *blacklist = NULL;
DBG (10, "escl sane_open\n");
SANE_Status status;
escl_sane_t *handler = NULL;
@@ -1173,7 +1206,8 @@ sane_open(SANE_String_Const name, SANE_Handle *h)
return (SANE_STATUS_NO_MEM);
}
handler->device = device; // Handler owns device now.
- handler->scanner = escl_capabilities(device, &status);
+ blacklist = _get_blacklist_pdf();
+ handler->scanner = escl_capabilities(device, blacklist, &status);
if (status != SANE_STATUS_GOOD) {
escl_free_handler(handler);
return (status);
@@ -1222,9 +1256,11 @@ sane_cancel(SANE_Handle h)
}
handler->scanner->work = SANE_FALSE;
handler->cancel = SANE_TRUE;
- escl_scanner(handler->device, handler->result);
+ escl_scanner(handler->device, handler->scanner->scanJob, handler->result);
free(handler->result);
handler->result = NULL;
+ free(handler->scanner->scanJob);
+ handler->scanner->scanJob = NULL;
}
/**
@@ -1381,6 +1417,7 @@ sane_control_option(SANE_Handle h, SANE_Int n, SANE_Action a, void *v, SANE_Int
break;
case OPT_RESOLUTION:
handler->val[n].w = _get_resolution(handler, (int)(*(SANE_Word *) v));
+ handler->scanner->caps[handler->scanner->source].default_resolution = handler->val[n].w;
if (i)
*i |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS | SANE_INFO_INEXACT;
break;
@@ -1591,7 +1628,7 @@ sane_start(SANE_Handle h)
return SANE_STATUS_NO_DOCS;
}
}
- status = escl_scan(handler->scanner, handler->device, handler->result);
+ status = escl_scan(handler->scanner, handler->device, handler->scanner->scanJob, handler->result);
if (status != SANE_STATUS_GOOD)
return (status);
if (!strcmp(handler->scanner->caps[handler->scanner->source].default_format, "image/jpeg"))