Tabs, makefile modification and no warnings

This commit is contained in:
qorg11 2021-03-10 09:49:56 +01:00
parent 3e27f25236
commit 018f0d64e4
No known key found for this signature in database
GPG Key ID: 343FC20A4ACA62B9
3 changed files with 32 additions and 40 deletions

View File

@ -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)

View File

@ -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 <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);
}

View File

@ -1,7 +1,7 @@
#include <stdlib.h>
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