# HG changeset patch # User Olaf Wintermann # Date 1538896443 -7200 # Node ID 9a406db6729b92a5119eb124f21a6dd8e47a52c9 # Parent b4e3453e2b4975fa3b0eac98b6a67679d3478c76 makes libidav compatible with libcurl < 7.32 diff -r b4e3453e2b49 -r 9a406db6729b libidav/resource.c --- 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;