From 018f0d64e427ab6385cf49d662cca317a845ab16 Mon Sep 17 00:00:00 2001 From: qorg11 Date: Wed, 10 Mar 2021 09:49:56 +0100 Subject: [PATCH] Tabs, makefile modification and no warnings --- clainsafecli/Makefile | 2 +- clainsafecli/clainsafecli.c | 68 ++++++++++++++++--------------------- clainsafecli/clainsafecli.h | 2 +- 3 files changed, 32 insertions(+), 40 deletions(-) diff --git a/clainsafecli/Makefile b/clainsafecli/Makefile index 0d619db..e27307d 100644 --- a/clainsafecli/Makefile +++ b/clainsafecli/Makefile @@ -3,7 +3,7 @@ TARGET = clainsafecli OBJS = clainsafecli.o CC = cc -CFLAGS = -MD -Wall -Wextra -O2 -march=native -lcurl +CFLAGS = -MD -std=c11 -Wall -Wextra -O2 -march=native -lcurl $(TARGET): clainsafecli.o $(CC) $(CFLAGS) $(OBJS) -o $(TARGET) diff --git a/clainsafecli/clainsafecli.c b/clainsafecli/clainsafecli.c index 8c7aa24..1197669 100644 --- a/clainsafecli/clainsafecli.c +++ b/clainsafecli/clainsafecli.c @@ -53,7 +53,7 @@ main(int argc, char **argv) int c = 0; while((c = getopt_long(argc,argv, "46htiSs:", - long_options,&option_index)) != -1) { + long_options,&option_index)) != -1) { switch(c) { case 's': server = optarg; @@ -107,24 +107,24 @@ main(int argc, char **argv) } else if(tor_flag) { curl_easy_setopt(easy_handle,CURLOPT_PROXY,tor_proxy_url); curl_easy_setopt(easy_handle,CURLOPT_PROXYTYPE, - CURLPROXY_SOCKS5_HOSTNAME); + CURLPROXY_SOCKS5_HOSTNAME); } else if(i2p_flag) { curl_easy_setopt(easy_handle,CURLOPT_PROXY,i2p_proxy_url); curl_easy_setopt(easy_handle,CURLOPT_PROXYTYPE, - CURLPROXY_HTTP); + CURLPROXY_HTTP); } /* Which address to use */ if(ipv6_flag) curl_easy_setopt(easy_handle,CURLOPT_IPRESOLVE, - CURL_IPRESOLVE_V6); + CURL_IPRESOLVE_V6); else if(ipv4_flag) curl_easy_setopt(easy_handle,CURLOPT_IPRESOLVE, - CURL_IPRESOLVE_V4); + CURL_IPRESOLVE_V4); else curl_easy_setopt(easy_handle,CURLOPT_IPRESOLVE, - CURL_IPRESOLVE_WHATEVER); + CURL_IPRESOLVE_WHATEVER); /* Form parameters */ @@ -135,21 +135,14 @@ main(int argc, char **argv) */ curl_formadd(&post,&last, - CURLFORM_COPYNAME,"file", - CURLFORM_FILE,argv[optind], - CURLFORM_END); + CURLFORM_COPYNAME,"file", + CURLFORM_FILE,argv[optind], + CURLFORM_END); /* Actual file content */ curl_formadd(&post,&last, - CURLFORM_COPYNAME,"file", - CURLFORM_COPYCONTENTS,argv[optind], - CURLFORM_END); - - /* Progress bar - * - * TODO: Use a custom progress bar rather than - * default curl progress bar - * - */ + CURLFORM_COPYNAME,"file", + CURLFORM_COPYCONTENTS,argv[optind], + CURLFORM_END); curl_easy_setopt(easy_handle,CURLOPT_NOPROGRESS,silent_flag); curl_easy_setopt(easy_handle,CURLOPT_PROGRESSFUNCTION,progress); @@ -174,9 +167,9 @@ main(int argc, char **argv) return 0; } -static size_t +size_t write_data(void *buffer, size_t size, size_t nmemb, - void *userp) + void *userp) { memcpy(userp, buffer, nmemb*size); return 0; @@ -195,7 +188,7 @@ store_link(const char *path, const char *buf) FILE *fp = fopen(path,"a+"); if(fp == NULL) { fprintf(stderr,"Error opening file %i: %s\n",errno, - strerror(errno)); + strerror(errno)); return -1; } fwrite(buf,strlen(buf),1,fp); @@ -207,28 +200,27 @@ void print_help() { printf("--server : specifies the lainsafe server\n%s\n%s\n%s\n%s\n%s\%s", - "--tor: uses tor.", - "--i2p: uses i2p.", - "-6|--ipv6: uses IPv6 only.", - "-4|--ipv6: uses IPv4 only.", - "--silent: doesn't print progress.", - "--help: print this message.\n"); + "--tor: uses tor.", + "--i2p: uses i2p.", + "-6|--ipv6: uses IPv6 only.", + "-4|--ipv6: uses IPv4 only.", + "--silent: doesn't print progress.", + "--help: print this message.\n"); return; } void progress(void *clientp, - double dltotal, - double dlnow, - double ultotal, - double ulnow) + double dltotal, + double dlnow, + double ultotal, + double ulnow) { - clientp = NULL; - dltotal = 0; - dlnow = 0; + /* So I don't get a warning */ + clientp++; + dltotal += 1; + dlnow += 1; printf("\r%0.f uploaded of %0.f (%0.f%%)",ulnow,ultotal, - ulnow*100/ultotal); + ulnow*100/ultotal); fflush(stdout); - - } diff --git a/clainsafecli/clainsafecli.h b/clainsafecli/clainsafecli.h index 682c145..8944f7c 100644 --- a/clainsafecli/clainsafecli.h +++ b/clainsafecli/clainsafecli.h @@ -1,7 +1,7 @@ #include size_t -static write_data(void *buffer, size_t size, size_t nmemb, +write_data(void *buffer, size_t size, size_t nmemb, void *userp); void