diff options
author | June McEnroe <june@causal.agency> | 2019-09-10 21:13:47 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2019-09-10 21:13:47 -0400 |
commit | 8d3d52109e22f1f13378bc1909071d35d7e13c42 (patch) | |
tree | 7e4cafed0f69802fd7b205c5de570f58a8e59bdc | |
parent | Set Accept-Encoding in title (diff) | |
download | src-8d3d52109e22f1f13378bc1909071d35d7e13c42.tar.gz src-8d3d52109e22f1f13378bc1909071d35d7e13c42.zip |
Use curl error buffer
Diffstat (limited to '')
-rw-r--r-- | bin/title.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/bin/title.c b/bin/title.c index b9cf4a49..57ae8ebe 100644 --- a/bin/title.c +++ b/bin/title.c @@ -165,10 +165,13 @@ 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); + if (optind < argc) { code = fetchTitle(argv[optind]); if (!code) return EX_OK; - errx(EX_DATAERR, "curl_easy_perform: %s", curl_easy_strerror(code)); + errx(EX_DATAERR, "curl_easy_perform: %s", error); } char *buf = NULL; @@ -183,9 +186,7 @@ int main(int argc, char *argv[]) { const char *url = &ptr[match.rm_so]; if (!exclude || regexec(&excludeRegex, url, 0, NULL, 0)) { code = fetchTitle(url); - if (code) { - warnx("curl_easy_perform: %s", curl_easy_strerror(code)); - } + if (code) warnx("curl_easy_perform: %s", error); } ptr[match.rm_eo] = ' '; } |