Tabs, makefile modification and no warnings
This commit is contained in:
parent
3e27f25236
commit
018f0d64e4
3 changed files with 32 additions and 40 deletions
|
@ -3,7 +3,7 @@
|
||||||
TARGET = clainsafecli
|
TARGET = clainsafecli
|
||||||
OBJS = clainsafecli.o
|
OBJS = clainsafecli.o
|
||||||
CC = cc
|
CC = cc
|
||||||
CFLAGS = -MD -Wall -Wextra -O2 -march=native -lcurl
|
CFLAGS = -MD -std=c11 -Wall -Wextra -O2 -march=native -lcurl
|
||||||
|
|
||||||
$(TARGET): clainsafecli.o
|
$(TARGET): clainsafecli.o
|
||||||
$(CC) $(CFLAGS) $(OBJS) -o $(TARGET)
|
$(CC) $(CFLAGS) $(OBJS) -o $(TARGET)
|
||||||
|
|
|
@ -53,7 +53,7 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
int c = 0;
|
int c = 0;
|
||||||
while((c = getopt_long(argc,argv, "46htiSs:",
|
while((c = getopt_long(argc,argv, "46htiSs:",
|
||||||
long_options,&option_index)) != -1) {
|
long_options,&option_index)) != -1) {
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case 's':
|
case 's':
|
||||||
server = optarg;
|
server = optarg;
|
||||||
|
@ -107,24 +107,24 @@ main(int argc, char **argv)
|
||||||
} else if(tor_flag) {
|
} else if(tor_flag) {
|
||||||
curl_easy_setopt(easy_handle,CURLOPT_PROXY,tor_proxy_url);
|
curl_easy_setopt(easy_handle,CURLOPT_PROXY,tor_proxy_url);
|
||||||
curl_easy_setopt(easy_handle,CURLOPT_PROXYTYPE,
|
curl_easy_setopt(easy_handle,CURLOPT_PROXYTYPE,
|
||||||
CURLPROXY_SOCKS5_HOSTNAME);
|
CURLPROXY_SOCKS5_HOSTNAME);
|
||||||
} else if(i2p_flag) {
|
} else if(i2p_flag) {
|
||||||
curl_easy_setopt(easy_handle,CURLOPT_PROXY,i2p_proxy_url);
|
curl_easy_setopt(easy_handle,CURLOPT_PROXY,i2p_proxy_url);
|
||||||
curl_easy_setopt(easy_handle,CURLOPT_PROXYTYPE,
|
curl_easy_setopt(easy_handle,CURLOPT_PROXYTYPE,
|
||||||
CURLPROXY_HTTP);
|
CURLPROXY_HTTP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Which address to use */
|
/* Which address to use */
|
||||||
|
|
||||||
if(ipv6_flag)
|
if(ipv6_flag)
|
||||||
curl_easy_setopt(easy_handle,CURLOPT_IPRESOLVE,
|
curl_easy_setopt(easy_handle,CURLOPT_IPRESOLVE,
|
||||||
CURL_IPRESOLVE_V6);
|
CURL_IPRESOLVE_V6);
|
||||||
else if(ipv4_flag)
|
else if(ipv4_flag)
|
||||||
curl_easy_setopt(easy_handle,CURLOPT_IPRESOLVE,
|
curl_easy_setopt(easy_handle,CURLOPT_IPRESOLVE,
|
||||||
CURL_IPRESOLVE_V4);
|
CURL_IPRESOLVE_V4);
|
||||||
else
|
else
|
||||||
curl_easy_setopt(easy_handle,CURLOPT_IPRESOLVE,
|
curl_easy_setopt(easy_handle,CURLOPT_IPRESOLVE,
|
||||||
CURL_IPRESOLVE_WHATEVER);
|
CURL_IPRESOLVE_WHATEVER);
|
||||||
|
|
||||||
/* Form parameters */
|
/* Form parameters */
|
||||||
|
|
||||||
|
@ -135,21 +135,14 @@ main(int argc, char **argv)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
curl_formadd(&post,&last,
|
curl_formadd(&post,&last,
|
||||||
CURLFORM_COPYNAME,"file",
|
CURLFORM_COPYNAME,"file",
|
||||||
CURLFORM_FILE,argv[optind],
|
CURLFORM_FILE,argv[optind],
|
||||||
CURLFORM_END);
|
CURLFORM_END);
|
||||||
/* Actual file content */
|
/* Actual file content */
|
||||||
curl_formadd(&post,&last,
|
curl_formadd(&post,&last,
|
||||||
CURLFORM_COPYNAME,"file",
|
CURLFORM_COPYNAME,"file",
|
||||||
CURLFORM_COPYCONTENTS,argv[optind],
|
CURLFORM_COPYCONTENTS,argv[optind],
|
||||||
CURLFORM_END);
|
CURLFORM_END);
|
||||||
|
|
||||||
/* Progress bar
|
|
||||||
*
|
|
||||||
* TODO: Use a custom progress bar rather than
|
|
||||||
* default curl progress bar
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
curl_easy_setopt(easy_handle,CURLOPT_NOPROGRESS,silent_flag);
|
curl_easy_setopt(easy_handle,CURLOPT_NOPROGRESS,silent_flag);
|
||||||
curl_easy_setopt(easy_handle,CURLOPT_PROGRESSFUNCTION,progress);
|
curl_easy_setopt(easy_handle,CURLOPT_PROGRESSFUNCTION,progress);
|
||||||
|
@ -174,9 +167,9 @@ main(int argc, char **argv)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t
|
size_t
|
||||||
write_data(void *buffer, size_t size, size_t nmemb,
|
write_data(void *buffer, size_t size, size_t nmemb,
|
||||||
void *userp)
|
void *userp)
|
||||||
{
|
{
|
||||||
memcpy(userp, buffer, nmemb*size);
|
memcpy(userp, buffer, nmemb*size);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -195,7 +188,7 @@ store_link(const char *path, const char *buf)
|
||||||
FILE *fp = fopen(path,"a+");
|
FILE *fp = fopen(path,"a+");
|
||||||
if(fp == NULL) {
|
if(fp == NULL) {
|
||||||
fprintf(stderr,"Error opening file %i: %s\n",errno,
|
fprintf(stderr,"Error opening file %i: %s\n",errno,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fwrite(buf,strlen(buf),1,fp);
|
fwrite(buf,strlen(buf),1,fp);
|
||||||
|
@ -207,28 +200,27 @@ void
|
||||||
print_help()
|
print_help()
|
||||||
{
|
{
|
||||||
printf("--server <server>: specifies the lainsafe server\n%s\n%s\n%s\n%s\n%s\%s",
|
printf("--server <server>: specifies the lainsafe server\n%s\n%s\n%s\n%s\n%s\%s",
|
||||||
"--tor: uses tor.",
|
"--tor: uses tor.",
|
||||||
"--i2p: uses i2p.",
|
"--i2p: uses i2p.",
|
||||||
"-6|--ipv6: uses IPv6 only.",
|
"-6|--ipv6: uses IPv6 only.",
|
||||||
"-4|--ipv6: uses IPv4 only.",
|
"-4|--ipv6: uses IPv4 only.",
|
||||||
"--silent: doesn't print progress.",
|
"--silent: doesn't print progress.",
|
||||||
"--help: print this message.\n");
|
"--help: print this message.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
progress(void *clientp,
|
progress(void *clientp,
|
||||||
double dltotal,
|
double dltotal,
|
||||||
double dlnow,
|
double dlnow,
|
||||||
double ultotal,
|
double ultotal,
|
||||||
double ulnow)
|
double ulnow)
|
||||||
{
|
{
|
||||||
clientp = NULL;
|
/* So I don't get a warning */
|
||||||
dltotal = 0;
|
clientp++;
|
||||||
dlnow = 0;
|
dltotal += 1;
|
||||||
|
dlnow += 1;
|
||||||
printf("\r%0.f uploaded of %0.f (%0.f%%)",ulnow,ultotal,
|
printf("\r%0.f uploaded of %0.f (%0.f%%)",ulnow,ultotal,
|
||||||
ulnow*100/ultotal);
|
ulnow*100/ultotal);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
size_t
|
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 *userp);
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Add table
Reference in a new issue