diff options
Diffstat (limited to '')
-rw-r--r-- | bin/man1/title.1 | 7 | ||||
-rw-r--r-- | bin/title.c | 33 |
2 files changed, 23 insertions, 17 deletions
diff --git a/bin/man1/title.1 b/bin/man1/title.1 index 9eb27cb1..43ecc5e2 100644 --- a/bin/man1/title.1 +++ b/bin/man1/title.1 @@ -1,4 +1,4 @@ -.Dd September 7, 2019 +.Dd September 10, 2019 .Dt TITLE 1 .Os . @@ -8,6 +8,7 @@ . .Sh SYNOPSIS .Nm +.Op Fl v .Op Fl x Ar pattern .Op Ar url . @@ -33,6 +34,10 @@ Exclude URLs matching which is a modern regular expression. See .Xr re_format 7 . +.It Fl v +Enable +.Xr libcurl 3 +verbose output. .El . .Sh EXAMPLES diff --git a/bin/title.c b/bin/title.c index 57ae8ebe..affc3ceb 100644 --- a/bin/title.c +++ b/bin/title.c @@ -137,26 +137,15 @@ int main(int argc, char *argv[]) { setlocale(LC_CTYPE, ""); setlinebuf(stdout); - bool exclude = false; - regex_t excludeRegex; - - int opt; - while (0 < (opt = getopt(argc, argv, "x:"))) { - switch (opt) { - break; case 'x': { - exclude = true; - excludeRegex = regex(optarg, REG_NOSUB); - } - break; default: return EX_USAGE; - } - } - CURLcode code = curl_global_init(CURL_GLOBAL_ALL); if (code) errx(EX_OSERR, "curl_global_init: %s", curl_easy_strerror(code)); curl = curl_easy_init(); if (!curl) errx(EX_SOFTWARE, "curl_easy_init"); + static char error[CURL_ERROR_SIZE]; + curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error); + curl_easy_setopt(curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); curl_easy_setopt(curl, CURLOPT_USERAGENT, "title/1.0"); curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, ""); @@ -165,8 +154,20 @@ int main(int argc, char *argv[]) { curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, handleBody); - static char error[CURL_ERROR_SIZE]; - curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error); + bool exclude = false; + regex_t excludeRegex; + + int opt; + while (0 < (opt = getopt(argc, argv, "x:v"))) { + switch (opt) { + break; case 'x': { + exclude = true; + excludeRegex = regex(optarg, REG_NOSUB); + } + break; case 'v': curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + break; default: return EX_USAGE; + } + } if (optind < argc) { code = fetchTitle(argv[optind]); |