From: Felix Fietkau Date: Sun, 4 May 2014 12:11:40 +0000 (+0200) Subject: example: change -C to --no-check-certificate to match wget X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuclient.git;a=commitdiff_plain;h=fd6ab91eeb0ccddaf1e295a77912f684c8a00336;hp=bd38e778dc28dbf3e5f0a249689fad2b2c6b7243 example: change -C to --no-check-certificate to match wget Signed-off-by: Felix Fietkau --- diff --git a/uclient-example.c b/uclient-example.c index e0e9015..69ba79a 100644 --- a/uclient-example.c +++ b/uclient-example.c @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -148,6 +149,13 @@ static int no_ssl(const char *progname) return 1; } +enum { + L_NO_CHECK_CERTIFICATE, +}; + +static const struct option longopts[] = { + [L_NO_CHECK_CERTIFICATE] = { "no-check-certificate", no_argument } +}; int main(int argc, char **argv) { @@ -155,18 +163,24 @@ int main(int argc, char **argv) struct uclient *cl; bool verify = true; int ch; + int longopt_idx = 0; init_ustream_ssl(); - while ((ch = getopt(argc, argv, "Cc:")) != -1) { + while ((ch = getopt_long(argc, argv, "c:", longopts, &longopt_idx)) != -1) { switch(ch) { + case 0: + switch (longopt_idx) { + case L_NO_CHECK_CERTIFICATE: + verify = false; + break; + default: + return usage(progname); + } case 'c': if (ssl_ctx) ssl_ops->context_add_ca_crt_file(ssl_ctx, optarg); break; - case 'C': - verify = false; - break; default: return usage(progname); }