From 84eaad4e8248ea2ed97ac26cb013dc34fe117110 Mon Sep 17 00:00:00 2001 From: Toni Gundogdu Date: Sun, 27 Nov 2011 23:23:52 +0200 Subject: [PATCH] Add --feature, depr. --no-* --- src/quvi/cmdline.ggo | 16 +++++++-------- src/quvi/quvi.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 62 insertions(+), 11 deletions(-) diff --git a/src/quvi/cmdline.ggo b/src/quvi/cmdline.ggo index 6a8de30..20fd5b7 100644 --- a/src/quvi/cmdline.ggo +++ b/src/quvi/cmdline.ggo @@ -31,12 +31,10 @@ option "exec" string typestr="arg" optional -option "no-resolve" - r "Do not resolve redirections" - optional -option "no-verify" - n "Do not verify media URL" - optional +option "feature" e "Enable (or disable) feature" optional + enum typestr="value" multiple + values="resolve","-resolve","verify","-verify", + "proxy","-proxy" option "query-formats" F "Query available formats to URL" @@ -56,9 +54,6 @@ option "proxy" - "Use HTTP proxy arg (e.g. http://addr:port)" string typestr="arg" optional -option "no-proxy" - - "Disable use of HTTP proxy" - optional option "connect-timeout" - "Seconds connecting allowed to take" int typestr="arg" @@ -74,3 +69,6 @@ option "category-rtmp" - "Category RTMP website scripts" optional option "xml" - "Print details in XML" optional option "quiet" q "Turn off output to stderr" optional option "verbose-libcurl" - "Turn on libcurl verbose mode" optional +option "no-resolve" r "Do not resolve redirections" optional +option "no-verify" n "Do not verify media URL" optional +option "no-proxy" - "Disable use of HTTP proxy" optional diff --git a/src/quvi/quvi.c b/src/quvi/quvi.c index 40ba12e..d84668f 100644 --- a/src/quvi/quvi.c +++ b/src/quvi/quvi.c @@ -653,8 +653,28 @@ static void depr_verbosity(const char *o) spew_qe("warning: %s: deprecated, use --verbosity instead\n", o); } +static void depr_feat(const char *o) +{ + spew_e("warning: %s: deprecated, use --feature instead\n", o); +} + +static int enabled(enum enum_feature on) +{ + const enum enum_feature off = on+1; + int i,r=1; + for (i=0; ifeature_given; ++i) + { + if (opts->feature_arg[i] == on) + r = 1; + else if (opts->feature_arg[i] == on+1) + r = 0; + } + return (r); +} + static void init_quvi() { + int resolve, verify, proxy; QUVIcategory categories; QUVIcode rc; @@ -668,8 +688,26 @@ static void init_quvi() /* Set quvi options. */ quvi_setopt(quvi, QUVIOPT_FORMAT, opts->format_arg); - quvi_setopt(quvi, QUVIOPT_NORESOLVE, opts->no_resolve_given); - quvi_setopt(quvi, QUVIOPT_NOVERIFY, opts->no_verify_given); + + resolve = enabled(feature_arg_resolve); + verify = enabled(feature_arg_verify); + + /* Deprecated. */ + + if (opts->no_resolve_given) + { + depr_feat("--no-resolve"); + resolve = 0; + } + + if (opts->no_verify_given) + { + depr_feat("--no-verify"); + verify = 0; + } + + quvi_setopt(quvi, QUVIOPT_NORESOLVE, resolve == 0); + quvi_setopt(quvi, QUVIOPT_NOVERIFY, verify == 0); /* Category. */ @@ -723,7 +761,22 @@ static void init_quvi() curl_easy_setopt(curl, CURLOPT_USERAGENT, opts->agent_arg); curl_easy_setopt(curl, CURLOPT_PROXY, opts->proxy_arg); + proxy = enabled(feature_arg_proxy); + + /* Deprecated. */ if (opts->no_proxy_given == 1) + { + depr_feat("--no-proxy"); + proxy = 0; + } + +#ifdef _1 + printf("resolve=%d, verify=%d, proxy=%d\n", resolve, verify, proxy); +#endif + + /* -- */ + + if (proxy == 0) curl_easy_setopt(curl, CURLOPT_PROXY, ""); if (opts->verbose_libcurl_given) -- 2.11.4.GIT