diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2020-09-10 19:11:27 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2020-09-10 19:11:27 +0200 |
commit | 7e9455b3b15671ff99ed168638c405e2acedb6df (patch) | |
tree | 444e59ece236e09dc153f665e42160aeb0208c24 /backend/escl/escl_reset.c | |
parent | bc8a517abd2e11e1435f4ef042cfcc8648b62ef7 (diff) | |
parent | bce41b3c37c2a68e7dab234ce0247755a61ceb40 (diff) |
Merge branch 'release/debian/1.0.31-1_experimental1' into masterdebian/1.0.31-1_experimental1
Diffstat (limited to 'backend/escl/escl_reset.c')
-rw-r--r-- | backend/escl/escl_reset.c | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/backend/escl/escl_reset.c b/backend/escl/escl_reset.c index 7722d89..64d779a 100644 --- a/backend/escl/escl_reset.c +++ b/backend/escl/escl_reset.c @@ -31,13 +31,22 @@ #include <curl/curl.h> +static size_t +write_callback(void __sane_unused__*str, + size_t __sane_unused__ size, + size_t nmemb, + void __sane_unused__ *userp) +{ + return nmemb; +} + /** - * \fn void escl_scanner(SANE_String_Const name, char *result) + * \fn void escl_scanner(const ESCL_Device *device, char *result) * \brief Function that resets the scanner after each scan, using curl. * This function is called in the 'sane_cancel' function. */ void -escl_scanner(SANE_String_Const name, char *result) +escl_scanner(const ESCL_Device *device, char *result) { CURL *curl_handle = NULL; const char *scan_jobs = "/eSCL/ScanJobs"; @@ -46,30 +55,25 @@ escl_scanner(SANE_String_Const name, char *result) int i = 0; long answer = 0; - if (name == NULL || result == NULL) + if (device == NULL || result == NULL) return; CURL_CALL: curl_handle = curl_easy_init(); if (curl_handle != NULL) { - strcpy(scan_cmd, name); - strcat(scan_cmd, scan_jobs); - strcat(scan_cmd, result); - strcat(scan_cmd, scanner_start); - curl_easy_setopt(curl_handle, CURLOPT_URL, scan_cmd); - DBG( 1, "Reset Job : %s.\n", scan_cmd); - if (strncmp(name, "https", 5) == 0) { - DBG( 1, "Ignoring safety certificates, use https\n"); - curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0L); - curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0L); - } + snprintf(scan_cmd, sizeof(scan_cmd), "%s%s%s", + scan_jobs, result, scanner_start); + escl_curl_url(curl_handle, device, scan_cmd); + curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_callback); if (curl_easy_perform(curl_handle) == CURLE_OK) { curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &answer); - if (i < 3 && answer == 503) { - curl_easy_cleanup(curl_handle); - i++; - goto CURL_CALL; - } + i++; + if (i >= 15) return; } curl_easy_cleanup(curl_handle); + if (SANE_STATUS_GOOD != escl_status(device, + PLATEN, + NULL, + NULL)) + goto CURL_CALL; } } |