From d29acea9c4da719fb0bad563447d17585168e06c Mon Sep 17 00:00:00 2001 From: June 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(-) (limited to 'bin') 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] = ' '; } -- cgit 1.4.1