From 33402f6f799b53ff6ae910f6e94977daa75cf27d Mon Sep 17 00:00:00 2001 From: Nick White Date: Tue, 13 May 2008 21:09:31 +0100 Subject: Added quiet option --- src/download.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'src/download.c') diff --git a/src/download.c b/src/download.c index b287655..7f2610a 100644 --- a/src/download.c +++ b/src/download.c @@ -38,8 +38,11 @@ int update_progress(void *data, double dltotal, double dlnow, int save_file(char *uri, char *filepath, char *filetitle, long resume_offset, struct config * options) /* Save the file *uri to *filepath */ { - printf("Downloading %s ",filetitle); - fflush(stdout); + if(!options->quiet) + { + printf("Downloading %s ",filetitle); + fflush(stdout); + } if(options->curl_handle) { FILE *file; @@ -71,9 +74,14 @@ int save_file(char *uri, char *filepath, char *filetitle, long resume_offset, st } } - curl_easy_setopt(options->curl_handle, CURLOPT_NOPROGRESS, 0); - curl_easy_setopt(options->curl_handle, CURLOPT_PROGRESSFUNCTION, update_progress); - curl_easy_setopt(options->curl_handle, CURLOPT_PROGRESSDATA, &resume_offset); + if(!options->quiet) + { + curl_easy_setopt(options->curl_handle, CURLOPT_NOPROGRESS, 0); + curl_easy_setopt(options->curl_handle, CURLOPT_PROGRESSFUNCTION, update_progress); + curl_easy_setopt(options->curl_handle, CURLOPT_PROGRESSDATA, &resume_offset); + } + else + curl_easy_setopt(options->curl_handle, CURLOPT_NOPROGRESS, 1); curl_easy_setopt(options->curl_handle, CURLOPT_RESUME_FROM, resume_offset); @@ -90,7 +98,8 @@ int save_file(char *uri, char *filepath, char *filetitle, long resume_offset, st fclose(file); - printf("\rDownloaded %s \n",filetitle); + if(!options->quiet) + printf("\rDownloaded %s \n",filetitle); } else { fprintf(stderr,"Error: curl failed to initialise.\n"); @@ -212,7 +221,10 @@ void downloadissue(struct config * options, iss * issue, int force) if(remotesize > 0 && localsize < remotesize) save_file(cur_section->uri, filepath, filename, localsize, options); else - printf("Skipping download of completed section %i\n", cur_section->number); + { + if(!options->quiet) + printf("Skipping download of completed section %i\n", cur_section->number); + } } } else -- cgit v1.2.3