kopia lustrzana https://gitlab.com/sane-project/backends
Merge branch 'escl-hack-scanjob-request' into 'master'
Escl hack scanjob request See merge request sane-project/backends!574escl-fix-sleep-mode
commit
ece6d7d5e7
|
@ -13,6 +13,7 @@
|
|||
|
||||
#device http://123.456.789.10:8080 OptionalModel1
|
||||
#device https://123.456.789.10:443 "Optional Model 2"
|
||||
#device https://123.456.789.10:443 "HP Color LaserJet FlowMFP M578" "hack=localhost"
|
||||
#device unix:/run/proxy.sock:http://123.456.789.10:80
|
||||
|
||||
#[device]
|
||||
|
|
|
@ -29,8 +29,6 @@
|
|||
|
||||
#include <setjmp.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
#include "../include/sane/saneopts.h"
|
||||
#include "../include/sane/sanei.h"
|
||||
#include "../include/sane/sanei_backend.h"
|
||||
|
@ -96,6 +94,7 @@ escl_free_device(ESCL_Device *current)
|
|||
free((void*)current->is);
|
||||
free((void*)current->uuid);
|
||||
free((void*)current->unix_socket);
|
||||
curl_slist_free_all(current->hack);
|
||||
free(current);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -229,6 +228,9 @@ escl_device_add(int port_nb,
|
|||
}
|
||||
model = (char*)(tmp[0] != 0 ? tmp : model_name);
|
||||
current->model_name = strdup(model);
|
||||
if (strcasestr(current->model_name, "LaserJet FlowMFP M578") ||
|
||||
strcasestr(current->model_name, "LaserJet MFP M630"))
|
||||
current->hack = curl_slist_append(NULL, "Host: localhost");
|
||||
current->ip_address = strdup(ip_address);
|
||||
memset(tmp, 0, PATH_MAX);
|
||||
snprintf(tmp, sizeof(tmp), "%s scanner", (is ? is : "flatbed or ADF"));
|
||||
|
@ -437,6 +439,7 @@ attach_one_config(SANEI_Config __sane_unused__ *config, const char *line,
|
|||
if (strncmp(line, "device", 6) == 0) {
|
||||
char *name_str = NULL;
|
||||
char *opt_model = NULL;
|
||||
char *opt_hack = NULL;
|
||||
|
||||
line = sanei_config_get_string(line + 6, &name_str);
|
||||
DBG (10, "New Escl_Device URL [%s].\n", (name_str ? name_str : "VIDE"));
|
||||
|
@ -448,6 +451,10 @@ attach_one_config(SANEI_Config __sane_unused__ *config, const char *line,
|
|||
line = sanei_config_get_string(line, &opt_model);
|
||||
DBG (10, "New Escl_Device model [%s].\n", opt_model);
|
||||
}
|
||||
if (*line) {
|
||||
line = sanei_config_get_string(line, &opt_hack);
|
||||
DBG (10, "New Escl_Device hack [%s].\n", opt_hack);
|
||||
}
|
||||
|
||||
escl_free_device(escl_device);
|
||||
escl_device = (ESCL_Device*)calloc(1, sizeof(ESCL_Device));
|
||||
|
@ -467,6 +474,8 @@ attach_one_config(SANEI_Config __sane_unused__ *config, const char *line,
|
|||
escl_device->is = strdup("flatbed or ADF scanner");
|
||||
escl_device->type = strdup("In url");
|
||||
escl_device->uuid = NULL;
|
||||
if (opt_hack && !strcmp(opt_hack, "hack=localhost"))
|
||||
escl_device->hack = curl_slist_append(NULL, "Host: localhost");
|
||||
}
|
||||
|
||||
if (strncmp(line, "[device]", 8) == 0) {
|
||||
|
@ -477,7 +486,7 @@ attach_one_config(SANEI_Config __sane_unused__ *config, const char *line,
|
|||
return (SANE_STATUS_NO_MEM);
|
||||
}
|
||||
}
|
||||
if (strncmp(line, "ip", 2) == 0) {
|
||||
else if (strncmp(line, "ip", 2) == 0) {
|
||||
const char *ip_space = sanei_config_skip_whitespace(line + 2);
|
||||
DBG (10, "New Escl_Device IP [%s].", (ip_space ? ip_space : "VIDE"));
|
||||
if (escl_device != NULL && ip_space != NULL) {
|
||||
|
@ -485,14 +494,14 @@ attach_one_config(SANEI_Config __sane_unused__ *config, const char *line,
|
|||
escl_device->ip_address = strdup(ip_space);
|
||||
}
|
||||
}
|
||||
if (sscanf(line, "port %i", &port) == 1 && port != 0) {
|
||||
else if (sscanf(line, "port %i", &port) == 1 && port != 0) {
|
||||
DBG (10, "New Escl_Device PORT [%d].", port);
|
||||
if (escl_device != NULL) {
|
||||
DBG (10, "New Escl_Device PORT Affected.");
|
||||
escl_device->port_nb = port;
|
||||
}
|
||||
}
|
||||
if (strncmp(line, "model", 5) == 0) {
|
||||
else if (strncmp(line, "model", 5) == 0) {
|
||||
const char *model_space = sanei_config_skip_whitespace(line + 5);
|
||||
DBG (10, "New Escl_Device MODEL [%s].", (model_space ? model_space : "VIDE"));
|
||||
if (escl_device != NULL && model_space != NULL) {
|
||||
|
@ -500,7 +509,7 @@ attach_one_config(SANEI_Config __sane_unused__ *config, const char *line,
|
|||
escl_device->model_name = strdup(model_space);
|
||||
}
|
||||
}
|
||||
if (strncmp(line, "type", 4) == 0) {
|
||||
else if (strncmp(line, "type", 4) == 0) {
|
||||
const char *type_space = sanei_config_skip_whitespace(line + 4);
|
||||
DBG (10, "New Escl_Device TYPE [%s].", (type_space ? type_space : "VIDE"));
|
||||
if (escl_device != NULL && type_space != NULL) {
|
||||
|
@ -1714,6 +1723,8 @@ escl_curl_url(CURL *handle, const ESCL_Device *device, SANE_String_Const path)
|
|||
DBG( 1, "escl_curl_url: URL: %s\n", url );
|
||||
curl_easy_setopt(handle, CURLOPT_URL, url);
|
||||
free(url);
|
||||
if (device->hack)
|
||||
curl_easy_setopt(handle, CURLOPT_HTTPHEADER, device->hack);
|
||||
if (device->https) {
|
||||
DBG( 1, "Ignoring safety certificates, use https\n");
|
||||
curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
|
|
|
@ -48,6 +48,8 @@
|
|||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
#ifndef BACKEND_NAME
|
||||
#define BACKEND_NAME escl
|
||||
#endif
|
||||
|
@ -97,6 +99,7 @@ typedef struct ESCL_Device {
|
|||
char *uuid;
|
||||
char *type;
|
||||
SANE_Bool https;
|
||||
struct curl_slist *hack;
|
||||
char *unix_socket;
|
||||
} ESCL_Device;
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <libxml/parser.h>
|
||||
|
||||
#include "../include/sane/saneopts.h"
|
||||
|
|
|
@ -78,7 +78,7 @@ resolve_callback(AvahiServiceResolver *r, AVAHI_GCC_UNUSED AvahiIfIndex interfac
|
|||
if (s && s->size > 3)
|
||||
is = (const char*)s->text + 3;
|
||||
else
|
||||
uuid = (const char*)NULL;
|
||||
is = (const char*)NULL;
|
||||
s = avahi_string_list_find(txt, "uuid");
|
||||
if (s && s->size > 5)
|
||||
uuid = (const char*)s->text + 5;
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
#ifdef PATH_MAX
|
||||
# undef PATH_MAX
|
||||
#endif
|
||||
|
|
|
@ -29,8 +29,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
static size_t
|
||||
write_callback(void __sane_unused__*str,
|
||||
size_t __sane_unused__ size,
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
#include "../include/sane/sanei.h"
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <libxml/parser.h>
|
||||
|
||||
struct idle
|
||||
|
|
Ładowanie…
Reference in New Issue