From 190a6b04c4f12ee20e7ae86cc3f280c63c2503f6 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Tue, 17 Jul 2012 16:21:18 +0200 Subject: Limit when downloading should show progress and when not --- src/download.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/download.c') diff --git a/src/download.c b/src/download.c index 603342a..849088e 100644 --- a/src/download.c +++ b/src/download.c @@ -101,7 +101,7 @@ int download_progress(void *clientp, double dltotal, double dlnow, double ultota return 0; } -int download_to_file(const char* url, const char* filename) +int download_to_file(const char* url, const char* filename, int enable_progress) { int res = 0; curl_global_init(CURL_GLOBAL_ALL); @@ -124,7 +124,10 @@ int download_to_file(const char* url, const char* filename) curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, (curl_write_callback)&fwrite); curl_easy_setopt(handle, CURLOPT_WRITEDATA, f); - curl_easy_setopt(handle, CURLOPT_PROGRESSFUNCTION, (curl_progress_callback)&download_progress); + + if (enable_progress > 0) + curl_easy_setopt(handle, CURLOPT_PROGRESSFUNCTION, (curl_progress_callback)&download_progress); + curl_easy_setopt(handle, CURLOPT_NOPROGRESS, 0); curl_easy_setopt(handle, CURLOPT_USERAGENT, "InetURL/1.0"); curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, 1); -- cgit v1.1-32-gdbae