diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2022-02-07 06:56:10 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2022-02-07 06:56:10 +0100 |
commit | 43f33c72804e63306580755049c09d5a81ad83e3 (patch) | |
tree | 805caeb00a832ed96a331907987d4e6a2056a391 /backend/escl/escl.c | |
parent | 0f86c5490ea7c2218a4394bf4c21bf3f9267a47c (diff) | |
parent | 6427d36e269d8c14e6bc55373102a4ebc971ca38 (diff) |
Merge branch 'release/debian/1.1.1-1'debian/1.1.1-1
Diffstat (limited to 'backend/escl/escl.c')
-rw-r--r-- | backend/escl/escl.c | 45 |
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")) |