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 | d29acea9c4da719fb0bad563447d17585168e06c (patch) | |
tree | dd2c17e5f27e5f69a6eb93b59bf68b02c1d89992 /bin | |
parent | Set Accept-Encoding in title (diff) | |
download | src-d29acea9c4da719fb0bad563447d17585168e06c.tar.gz src-d29acea9c4da719fb0bad563447d17585168e06c.zip |
Use curl error buffer
Diffstat (limited to 'bin')
-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 65270a6c..7f36d492 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] = ' '; } |