# HG changeset patch # User Olaf Wintermann # Date 1538896443 -7200 # Node ID 7bb47ddc1b5edb075e275533c420e39d518af964 # Parent 4996f8953c3a3ef379da90d353b8d82d8a6d5b98 makes libidav compatible with libcurl < 7.32 diff -r 4996f8953c3a -r 7bb47ddc1b5e libidav/resource.c --- a/libidav/resource.c Thu Sep 06 12:51:02 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;