diff --git a/.gitignore b/.gitignore index 875b38d..c4c01b5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -sakisafecli *.o *.d +obj/ diff --git a/sakisafecli/config.c b/sakisafecli/config.c index a36ce7c..4e1cf10 100644 --- a/sakisafecli/config.c +++ b/sakisafecli/config.c @@ -1,6 +1,34 @@ #include #include +#include #include "options.h" +#include "config.h" + +void +print_config() +{ + puts("Current configuration:"); + printf("Server: %s\n",server); + if(socks_proxy_flag) + printf("Socks proxy url: %s",socks_proxy_url); + if(http_proxy_flag) + printf("HTTP proxy url: %s",http_proxy_url); + if(silent_flag) + puts("Silent: true"); + else + puts("Silent: false"); + if(ipv6_flag) + printf("Force IPv6: true\n"); + else + printf("Force IPv6: false\n"); + if(ipv4_flag) + printf("Force IPv4: true\n"); + else + printf("Force IPv4: false\n"); + + return; +} + void parse_config_file(FILE *config) { diff --git a/sakisafecli/config.h b/sakisafecli/config.h new file mode 100644 index 0000000..ede4bc2 --- /dev/null +++ b/sakisafecli/config.h @@ -0,0 +1,9 @@ +#include + +/* Parse the config file */ +void +parse_config_file(FILE *config); + +/* Print the current settings */ +void +print_config(); diff --git a/sakisafecli/funcs.c b/sakisafecli/funcs.c index 98b0d13..25b431d 100644 --- a/sakisafecli/funcs.c +++ b/sakisafecli/funcs.c @@ -50,3 +50,4 @@ progress(void *clientp, fflush(stdout); } + diff --git a/sakisafecli/funcs.h b/sakisafecli/funcs.h new file mode 100644 index 0000000..def8f15 --- /dev/null +++ b/sakisafecli/funcs.h @@ -0,0 +1,24 @@ +#pragma once +#include + +/* Function used from curl to write data to a buffer */ +size_t +write_data(void *buffer, size_t size, size_t nmemb, void *userp); + +/* Print usage message (when nothing is given to sakisafecli) */ +void +print_usage(); + +/* Print help message (-h) */ +void +print_help(); + +/* Function used to display progress when uploading a file */ + +void +progress( + void *clientp, double dltotal, double dlnow, double ultotal, double ulnow); + +/* Print config */ +void +print_config(); diff --git a/sakisafecli/sakisafecli.c b/sakisafecli/sakisafecli.c index 18b4550..7e13da9 100644 --- a/sakisafecli/sakisafecli.c +++ b/sakisafecli/sakisafecli.c @@ -9,6 +9,8 @@ #include #include "options.h" +#include "config.h" +#include "funcs.h" #include "sakisafecli.h" /* Config variables */ @@ -99,7 +101,7 @@ main(int argc, char **argv) int c = 0; while((c = getopt_long( - argc, argv, "46hT:p:P:Ss:x", long_options, &option_index)) != + argc, argv, "46hT:p:P:Ss:xC", long_options, &option_index)) != -1) { switch(c) { case 's': @@ -137,6 +139,9 @@ main(int argc, char **argv) print_usage(); return 0; break; + case 'C': + print_config(); + return 0; default: print_usage(); return 0; @@ -187,8 +192,8 @@ main(int argc, char **argv) */ curl_mimepart *file_data; file_data = curl_mime_addpart(mime); - char *filename = argv[argc]; - + char *filename = argv[optind]; + if(paste_flag) filename = "/dev/stdin";