From 8d3d52109e22f1f13378bc1909071d35d7e13c42 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Tue, 10 Sep 2019 21:13:47 -0400 Subject: Use curl error buffer --- bin/title.c | 9 +++++---- 1 file 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] = ' '; } -- cgit 1.4.1