summaryrefslogtreecommitdiff
path: root/lib/strerror.c
diff options
context:
space:
mode:
authorMark Salisbury <mark.salisbury@hp.com>2012-06-15 18:05:11 +0200
committerYang Tse <yangsita@gmail.com>2012-06-15 18:41:49 +0200
commit46480bb9a1569eaf156012f33e3e7e8c3de18f87 (patch)
tree28c6ee9e5b39119260f0691ecb765e771f7fed72 /lib/strerror.c
parent16c725dbc77b408d5b3c2b2d213063f7c2398c06 (diff)
downloadcurl-46480bb9a1569eaf156012f33e3e7e8c3de18f87.tar.gz
SSPI related code: Unicode support for WinCE
SSPI related code now compiles with ANSI and WCHAR versions of security methods (WinCE requires WCHAR versions of methods). Pulled UTF8 to WCHAR conversion methods out of idn_win32.c into their own file. curl_sasl.c - include curl_memory.h to use correct memory functions. getenv.c and telnet.c - WinCE compatibility fix With some committer adjustments
Diffstat (limited to 'lib/strerror.c')
-rw-r--r--lib/strerror.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/lib/strerror.c b/lib/strerror.c
index 84a900047..dd7d37565 100644
--- a/lib/strerror.c
+++ b/lib/strerror.c
@@ -635,7 +635,7 @@ const char *Curl_strerror(struct connectdata *conn, int err)
strncpy(buf, strerror(err), max);
else {
if(!get_winsock_error(err, buf, max) &&
- !FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err,
+ !FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err,
LANG_NEUTRAL, buf, (DWORD)max, NULL))
snprintf(buf, max, "Unknown error %d (%#x)", err, err);
}
@@ -788,7 +788,8 @@ const char *Curl_sspi_strerror (struct connectdata *conn, int err)
#ifndef CURL_DISABLE_VERBOSE_STRINGS
char txtbuf[80];
char msgbuf[sizeof(conn->syserr_buf)];
- char *str, *msg = NULL;
+ char *p, *str, *msg = NULL;
+ bool msg_formatted = FALSE;
int old_errno;
#endif
const char *txt;
@@ -1057,11 +1058,29 @@ const char *Curl_sspi_strerror (struct connectdata *conn, int err)
snprintf(txtbuf, sizeof(txtbuf), "%s (0x%04X%04X)",
txt, (err >> 16) & 0xffff, err & 0xffff);
txtbuf[sizeof(txtbuf)-1] = '\0';
- if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, err, LANG_NEUTRAL,
- msgbuf, sizeof(msgbuf)-1, NULL)) {
- char *p;
+
+#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)) {
+ wcstombs(msgbuf,wbuf,sizeof(msgbuf)-1);
+ msg_formatted = TRUE;
+ }
+ }
+#else
+ if(FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, err, LANG_NEUTRAL,
+ msgbuf, sizeof(msgbuf)-1, NULL)) {
+ msg_formatted = TRUE;
+ }
+#endif
+ if(msg_formatted) {
msgbuf[sizeof(msgbuf)-1] = '\0';
/* strip trailing '\r\n' or '\n' */
if((p = strrchr(msgbuf,'\n')) != NULL && (p - msgbuf) >= 2)