Add user configuration and password

escl-add-user-and-password
Ordissimo 2022-04-25 23:09:12 +02:00
rodzic e0aad8e814
commit 6cd207dcef
3 zmienionych plików z 14 dodań i 3 usunięć

Wyświetl plik

@ -18,7 +18,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 https://user:password@123.456.789.10:443 "HP Color LaserJet FlowMFP M578" "hack=localhost"
#device unix:/run/proxy.sock:http://123.456.789.10:80
#[device]

Wyświetl plik

@ -1135,6 +1135,7 @@ SANE_Status
escl_parse_name(SANE_String_Const name, ESCL_Device *device)
{
SANE_String_Const host = NULL;
SANE_String_Const host2 = NULL;
SANE_String_Const port_str = NULL;
DBG(10, "escl_parse_name\n");
if (name == NULL || device == NULL) {
@ -1153,16 +1154,25 @@ escl_parse_name(SANE_String_Const name, ESCL_Device *device)
if (strncmp(name, "https://", 8) == 0) {
device->https = SANE_TRUE;
device->type = strdup("https");
host = name + 8;
host2 = name + 8;
} else if (strncmp(name, "http://", 7) == 0) {
device->https = SANE_FALSE;
device->type = strdup("http");
host = name + 7;
host2 = name + 7;
} else {
DBG(1, "Unknown URL scheme in %s", name);
return SANE_STATUS_INVAL;
}
host = strchr(host2, '@');
if (host) {
host++;
device->user_passwd = strndup(host2, host - host2 - 1);
}
else {
host = host2;
}
port_str = strchr(host, ':');
if (port_str == NULL) {
DBG(1, "Port missing from URL: %s", name);

Wyświetl plik

@ -102,6 +102,7 @@ typedef struct ESCL_Device {
SANE_Bool https;
struct curl_slist *hack;
char *unix_socket;
char *user_passwd;
} ESCL_Device;
typedef struct capst