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:53 +0200
committerJörg Frings-Fürst <debian@jff.email>2025-06-09 14:27:53 +0200
commit115d2beab18fae48374bb3dc8603a0c48df58ce1 (patch)
tree7e1920e7f69782aec0d4813963c3601d62a757c1 /backend/escl/escl_reset.c
parenta0fd2a8557d28ec8e7bbf881f78daf7e8e8fbd6b (diff)
parent1f3f1e7d112f051f22fe7fc82739b483cef09b2a (diff)
Merge branch 'feature/upstream' into developdevelop
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;
+ }
}
}