libidav/resource.c

changeset 477
9a406db6729b
parent 475
52e4171d42ce
child 478
baa63fef5c5c
--- a/libidav/resource.c	Sun Sep 23 13:07:35 2018 +0200
+++ b/libidav/resource.c	Sun Oct 07 09:14:03 2018 +0200
@@ -764,6 +764,29 @@
     return r;
 }
 
+#if LIBCURL_VERSION_MAJOR >= 7 && LIBCURL_VERSION_MINOR >= 32
+static void set_progressfunc(DavResource *res) {
+    CURL *handle = res->session->handle;
+    curl_easy_setopt(handle, CURLOPT_XFERINFOFUNCTION, dav_session_get_progress);
+    curl_easy_setopt(handle, CURLOPT_XFERINFODATA, res);
+    curl_easy_setopt(handle, CURLOPT_NOPROGRESS, 0L);
+}
+
+static void unset_progressfunc(DavResource *res) {
+    CURL *handle = res->session->handle;
+    curl_easy_setopt(handle, CURLOPT_XFERINFOFUNCTION, NULL);
+    curl_easy_setopt(handle, CURLOPT_XFERINFODATA, NULL);
+    curl_easy_setopt(handle, CURLOPT_NOPROGRESS, 1L);
+}
+#else
+static void set_progressfunc(DavResource *res) {
+    
+}
+static void unset_progressfunc(DavResource *res) {
+    
+}
+#endif
+
 int dav_get_content(DavResource *res, void *stream, dav_write_func write_fnc) { 
     DavSession *sn = res->session;
     CURL *handle = sn->handle;
@@ -793,18 +816,14 @@
     curl_easy_setopt(handle, CURLOPT_WRITEDATA, stream);
     
     if(sn->get_progress) {
-        curl_easy_setopt(handle, CURLOPT_XFERINFOFUNCTION, dav_session_get_progress);
-        curl_easy_setopt(handle, CURLOPT_XFERINFODATA, res);
-        curl_easy_setopt(handle, CURLOPT_NOPROGRESS, 0L);
+        set_progressfunc(res);
     }
     
     long status = 0;
     CURLcode ret = dav_session_curl_perform(sn, &status);
     
     if(sn->get_progress) {
-        curl_easy_setopt(handle, CURLOPT_XFERINFOFUNCTION, NULL);
-        curl_easy_setopt(handle, CURLOPT_XFERINFODATA, NULL);
-        curl_easy_setopt(handle, CURLOPT_NOPROGRESS, 1L);
+        unset_progressfunc(res);
     }
     
     char *hash = NULL;

mercurial