diff options
author | Curl Upstream <curl-library@cool.haxx.se> | 2020-12-09 06:38:24 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-12-09 16:45:09 (GMT) |
commit | 5aacc593a961fe9ee1427c03d18fba8947a9e33d (patch) | |
tree | 1eb7234820ce18ece5ae773015217f8135c9c08e /lib/strerror.c | |
parent | 7ceb56989f8ab3a4e1b1f2c48c9a0f382b85ec04 (diff) | |
download | CMake-5aacc593a961fe9ee1427c03d18fba8947a9e33d.zip CMake-5aacc593a961fe9ee1427c03d18fba8947a9e33d.tar.gz CMake-5aacc593a961fe9ee1427c03d18fba8947a9e33d.tar.bz2 |
curl 2020-12-09 (e0528597)
Code extracted from:
https://github.com/curl/curl.git
at commit e052859759b34d0e05ce0f17244873e5cd7b457b (curl-7_74_0).
Diffstat (limited to 'lib/strerror.c')
-rw-r--r-- | lib/strerror.c | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/lib/strerror.c b/lib/strerror.c index 015e588..9b2fc26 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -9,7 +9,7 @@ * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms - * are also available at https://curl.haxx.se/docs/copyright.html. + * are also available at https://curl.se/docs/copyright.html. * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is @@ -320,6 +320,9 @@ curl_easy_strerror(CURLcode error) case CURLE_QUIC_CONNECT_ERROR: return "QUIC connection error"; + case CURLE_PROXY: + return "proxy handshake error"; + /* error codes not used by current libcurl */ case CURLE_OBSOLETE20: case CURLE_OBSOLETE24: @@ -652,34 +655,27 @@ static const char * get_winapi_error(int err, char *buf, size_t buflen) { char *p; + wchar_t wbuf[256]; if(!buflen) return NULL; *buf = '\0'; - -#ifdef _WIN32_WCE - { - wchar_t wbuf[256]; - wbuf[0] = L'\0'; - - if(FormatMessage((FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS), NULL, err, - LANG_NEUTRAL, wbuf, sizeof(wbuf)/sizeof(wchar_t), NULL)) { - size_t written = wcstombs(buf, wbuf, buflen - 1); - if(written != (size_t)-1) - buf[written] = '\0'; - else - *buf = '\0'; - } - } -#else - if(!FormatMessageA((FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS), NULL, err, - LANG_NEUTRAL, buf, (DWORD)buflen, NULL)) { - *buf = '\0'; + *wbuf = L'\0'; + + /* We return the local codepage version of the error string because if it is + output to the user's terminal it will likely be with functions which + expect the local codepage (eg fprintf, failf, infof). + FormatMessageW -> wcstombs is used for Windows CE compatibility. */ + if(FormatMessageW((FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS), NULL, err, + LANG_NEUTRAL, wbuf, sizeof(wbuf)/sizeof(wchar_t), NULL)) { + size_t written = wcstombs(buf, wbuf, buflen - 1); + if(written != (size_t)-1) + buf[written] = '\0'; + else + *buf = '\0'; } -#endif /* Truncate multiple lines */ p = strchr(buf, '\n'); @@ -785,7 +781,7 @@ const char *Curl_strerror(int err, char *buf, size_t buflen) } #else { - char *msg = strerror(err); + const char *msg = strerror(err); if(msg) strncpy(buf, msg, max); else |