Sun, 07 Oct 2018 09:14:03 +0200
makes libidav compatible with libcurl < 7.32
libidav/resource.c | file | annotate | diff | comparison | revisions |
--- 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;