From 3c03246af4041d4f09c1839b26962e5b0e308590 Mon Sep 17 00:00:00 2001 From: qorg11 Date: Sun, 14 Feb 2021 00:48:22 +0100 Subject: [PATCH] Added a more user friendly progress bar (in bytes so kinda to do) but it shows the % at least. --- clainsafecli/clainsafecli.c | 18 +++++++++++++++++- clainsafecli/clainsafecli.h | 8 ++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/clainsafecli/clainsafecli.c b/clainsafecli/clainsafecli.c index 20e0715..8fa5d03 100644 --- a/clainsafecli/clainsafecli.c +++ b/clainsafecli/clainsafecli.c @@ -124,10 +124,12 @@ main(int argc, char **argv) */ curl_easy_setopt(easy_handle,CURLOPT_NOPROGRESS,silent_flag); + curl_easy_setopt(easy_handle,CURLOPT_PROGRESSFUNCTION,progress); + curl_easy_setopt(easy_handle,CURLOPT_HTTPPOST,post); curl_easy_perform(easy_handle); - + if(!silent_flag) puts(""); puts(buffer); curl_formfree(post); @@ -179,3 +181,17 @@ print_help() "--help: print this message\n"); return; } + +void +progress(void *clientp, + double dltotal, + double dlnow, + double ultotal, + double ulnow) +{ + printf("\r%0.f uploaded of %0.f (%0.f%%)",ulnow,ultotal, + ulnow*100/ultotal); + fflush(stdout); + + +} diff --git a/clainsafecli/clainsafecli.h b/clainsafecli/clainsafecli.h index d92b70c..682c145 100644 --- a/clainsafecli/clainsafecli.h +++ b/clainsafecli/clainsafecli.h @@ -12,3 +12,11 @@ store_link(const char *path, const char *buf); void print_help(); + +void +progress(void *clientp, + double dltotal, + double dlnow, + double ultotal, + double ulnow); +