summaryrefslogtreecommitdiff
path: root/backend/escl/escl_reset.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2025-06-09 14:27:29 +0200
committerJörg Frings-Fürst <debian@jff.email>2025-06-09 14:27:29 +0200
commit652efae78c00b812033ea162d76cd13bd40dcab6 (patch)
tree7c139f4d2a28061607cd7e2269693df993e5d60a /backend/escl/escl_reset.c
parentbfa2ae8e43fcbab696f272fffd164d0637e965c5 (diff)
New upstream version 1.4.0upstream/1.4.0upstream
Diffstat (limited to 'backend/escl/escl_reset.c')
-rw-r--r--backend/escl/escl_reset.c42
1 files changed, 36 insertions, 6 deletions
diff --git a/backend/escl/escl_reset.c b/backend/escl/escl_reset.c
index 95e3f2d..ad3080b 100644
--- a/backend/escl/escl_reset.c
+++ b/backend/escl/escl_reset.c
@@ -44,7 +44,32 @@ write_callback(void __sane_unused__*str,
* This function is called in the 'sane_cancel' function.
*/
void
-escl_scanner(const ESCL_Device *device, char *scanJob, char *result)
+escl_delete(const ESCL_Device *device, char *uri)
+{
+ CURL *curl_handle = NULL;
+ long answer = 0;
+
+ if (uri == NULL)
+ return;
+ curl_handle = curl_easy_init();
+ if (curl_handle != NULL) {
+ escl_curl_url(curl_handle, device, uri);
+ curl_easy_setopt(curl_handle, CURLOPT_CUSTOMREQUEST, "DELETE");
+ if (curl_easy_perform(curl_handle) == CURLE_OK) {
+ curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &answer);
+ return;
+ }
+ curl_easy_cleanup(curl_handle);
+ }
+}
+
+/**
+ * \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(const ESCL_Device *device, char *scanJob, char *result, SANE_Bool status)
{
CURL *curl_handle = NULL;
const char *scan_jobs = "/eSCL/";
@@ -70,10 +95,15 @@ CURL_CALL:
if (i >= 15) return;
}
curl_easy_cleanup(curl_handle);
- if (SANE_STATUS_GOOD != escl_status(device,
- PLATEN,
- NULL,
- NULL))
- goto CURL_CALL;
+ char* end = strrchr(scan_cmd, '/');
+ *end = 0;
+ escl_delete(device, scan_cmd);
+ if (status) {
+ if (SANE_STATUS_GOOD != escl_status(device,
+ PLATEN,
+ NULL,
+ NULL))
+ goto CURL_CALL;
+ }
}
}