CURLOPT_ERRORBUFFER.3: Fix example, escape backslashes

This commit is contained in:
Jay Satiro 2015-06-17 02:49:14 -04:00
parent 52d83cb0c6
commit f72b30e6fb
1 changed files with 7 additions and 6 deletions

View File

@ -65,17 +65,18 @@ if(curl) {
/* perform the request */ /* perform the request */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* if the request did not complete correctly, show the error information. /* if the request did not complete correctly, show the error
if no detailed error information was written to errbuf show the more generic information. if no detailed error information was written to errbuf
information from curl_easy_strerror instead. show the more generic information from curl_easy_strerror instead.
*/ */
if(res != CURLE_OK) { if(res != CURLE_OK) {
size_t len = strlen(errbuf); size_t len = strlen(errbuf);
fprintf(stderr, "\nlibcurl: (%d) ", res); fprintf(stderr, "\\nlibcurl: (%d) ", res);
if(len) if(len)
fprintf(stderr, "%s%s", errbuf, ((errbuf[len - 1] != '\n') ? "\n" : "")); fprintf(stderr, "%s%s", errbuf,
((errbuf[len - 1] != '\\n') ? "\\n" : ""));
else else
fprintf(stderr, "%s\n", curl_easy_strerror(res)); fprintf(stderr, "%s\\n", curl_easy_strerror(res));
} }
} }
.fi .fi