kopia lustrzana https://gitlab.com/sane-project/backends
Allows to activate the hack from the configuration file, only the first form supports it.
rodzic
cb8b6d2ace
commit
4b6418476e
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#device http://123.456.789.10:8080 OptionalModel1
|
#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 "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 unix:/run/proxy.sock:http://123.456.789.10:80
|
||||||
|
|
||||||
#[device]
|
#[device]
|
||||||
|
|
|
@ -94,7 +94,7 @@ escl_free_device(ESCL_Device *current)
|
||||||
free((void*)current->is);
|
free((void*)current->is);
|
||||||
free((void*)current->uuid);
|
free((void*)current->uuid);
|
||||||
free((void*)current->unix_socket);
|
free((void*)current->unix_socket);
|
||||||
curl_slist_free_all(current->localhost);
|
curl_slist_free_all(current->hack);
|
||||||
free(current);
|
free(current);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ escl_device_add(int port_nb,
|
||||||
current->model_name = strdup(model);
|
current->model_name = strdup(model);
|
||||||
if (strcasestr(current->model_name, "LaserJet FlowMFP M578") ||
|
if (strcasestr(current->model_name, "LaserJet FlowMFP M578") ||
|
||||||
strcasestr(current->model_name, "LaserJet MFP M630"))
|
strcasestr(current->model_name, "LaserJet MFP M630"))
|
||||||
current->localhost = curl_slist_append(NULL, "Host: localhost");
|
current->hack = curl_slist_append(NULL, "Host: localhost");
|
||||||
current->ip_address = strdup(ip_address);
|
current->ip_address = strdup(ip_address);
|
||||||
memset(tmp, 0, PATH_MAX);
|
memset(tmp, 0, PATH_MAX);
|
||||||
snprintf(tmp, sizeof(tmp), "%s scanner", (is ? is : "flatbed or ADF"));
|
snprintf(tmp, sizeof(tmp), "%s scanner", (is ? is : "flatbed or ADF"));
|
||||||
|
@ -439,6 +439,7 @@ attach_one_config(SANEI_Config __sane_unused__ *config, const char *line,
|
||||||
if (strncmp(line, "device", 6) == 0) {
|
if (strncmp(line, "device", 6) == 0) {
|
||||||
char *name_str = NULL;
|
char *name_str = NULL;
|
||||||
char *opt_model = NULL;
|
char *opt_model = NULL;
|
||||||
|
char *opt_hack = NULL;
|
||||||
|
|
||||||
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"));
|
||||||
|
@ -450,6 +451,10 @@ attach_one_config(SANEI_Config __sane_unused__ *config, const char *line,
|
||||||
line = sanei_config_get_string(line, &opt_model);
|
line = sanei_config_get_string(line, &opt_model);
|
||||||
DBG (10, "New Escl_Device model [%s].\n", 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_free_device(escl_device);
|
||||||
escl_device = (ESCL_Device*)calloc(1, sizeof(ESCL_Device));
|
escl_device = (ESCL_Device*)calloc(1, sizeof(ESCL_Device));
|
||||||
|
@ -469,6 +474,8 @@ attach_one_config(SANEI_Config __sane_unused__ *config, const char *line,
|
||||||
escl_device->is = strdup("flatbed or ADF scanner");
|
escl_device->is = strdup("flatbed or ADF scanner");
|
||||||
escl_device->type = strdup("In url");
|
escl_device->type = strdup("In url");
|
||||||
escl_device->uuid = NULL;
|
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) {
|
if (strncmp(line, "[device]", 8) == 0) {
|
||||||
|
@ -479,7 +486,7 @@ attach_one_config(SANEI_Config __sane_unused__ *config, const char *line,
|
||||||
return (SANE_STATUS_NO_MEM);
|
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);
|
const char *ip_space = sanei_config_skip_whitespace(line + 2);
|
||||||
DBG (10, "New Escl_Device IP [%s].", (ip_space ? ip_space : "VIDE"));
|
DBG (10, "New Escl_Device IP [%s].", (ip_space ? ip_space : "VIDE"));
|
||||||
if (escl_device != NULL && ip_space != NULL) {
|
if (escl_device != NULL && ip_space != NULL) {
|
||||||
|
@ -487,14 +494,14 @@ attach_one_config(SANEI_Config __sane_unused__ *config, const char *line,
|
||||||
escl_device->ip_address = strdup(ip_space);
|
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);
|
DBG (10, "New Escl_Device PORT [%d].", port);
|
||||||
if (escl_device != NULL) {
|
if (escl_device != NULL) {
|
||||||
DBG (10, "New Escl_Device PORT Affected.");
|
DBG (10, "New Escl_Device PORT Affected.");
|
||||||
escl_device->port_nb = port;
|
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);
|
const char *model_space = sanei_config_skip_whitespace(line + 5);
|
||||||
DBG (10, "New Escl_Device MODEL [%s].", (model_space ? model_space : "VIDE"));
|
DBG (10, "New Escl_Device MODEL [%s].", (model_space ? model_space : "VIDE"));
|
||||||
if (escl_device != NULL && model_space != NULL) {
|
if (escl_device != NULL && model_space != NULL) {
|
||||||
|
@ -502,7 +509,7 @@ attach_one_config(SANEI_Config __sane_unused__ *config, const char *line,
|
||||||
escl_device->model_name = strdup(model_space);
|
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);
|
const char *type_space = sanei_config_skip_whitespace(line + 4);
|
||||||
DBG (10, "New Escl_Device TYPE [%s].", (type_space ? type_space : "VIDE"));
|
DBG (10, "New Escl_Device TYPE [%s].", (type_space ? type_space : "VIDE"));
|
||||||
if (escl_device != NULL && type_space != NULL) {
|
if (escl_device != NULL && type_space != NULL) {
|
||||||
|
@ -1716,8 +1723,8 @@ escl_curl_url(CURL *handle, const ESCL_Device *device, SANE_String_Const path)
|
||||||
DBG( 1, "escl_curl_url: URL: %s\n", url );
|
DBG( 1, "escl_curl_url: URL: %s\n", url );
|
||||||
curl_easy_setopt(handle, CURLOPT_URL, url);
|
curl_easy_setopt(handle, CURLOPT_URL, url);
|
||||||
free(url);
|
free(url);
|
||||||
if (device->localhost)
|
if (device->hack)
|
||||||
curl_easy_setopt(handle, CURLOPT_HTTPHEADER, device->localhost);
|
curl_easy_setopt(handle, CURLOPT_HTTPHEADER, device->hack);
|
||||||
if (device->https) {
|
if (device->https) {
|
||||||
DBG( 1, "Ignoring safety certificates, use https\n");
|
DBG( 1, "Ignoring safety certificates, use https\n");
|
||||||
curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 0L);
|
curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||||
|
|
|
@ -99,7 +99,7 @@ typedef struct ESCL_Device {
|
||||||
char *uuid;
|
char *uuid;
|
||||||
char *type;
|
char *type;
|
||||||
SANE_Bool https;
|
SANE_Bool https;
|
||||||
struct curl_slist *localhost;
|
struct curl_slist *hack;
|
||||||
char *unix_socket;
|
char *unix_socket;
|
||||||
} ESCL_Device;
|
} ESCL_Device;
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue