summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitri Papadopoulos <dimitri_at@users.sf.net>2006-04-14 16:40:30 +0000
committerDimitri Papadopoulos <dimitri_at@users.sf.net>2006-04-14 16:40:30 +0000
commit538146072aa20eda09fabd762d4eb7e7d00269af (patch)
tree492d6430d433e8168261ee8fd7392f6796e37c9d
parent285ae543e289049ef47b73a3845d63e5188507c8 (diff)
downloadcygnal-538146072aa20eda09fabd762d4eb7e7d00269af.tar.gz
cygnal-538146072aa20eda09fabd762d4eb7e7d00269af.tar.bz2
cygnal-538146072aa20eda09fabd762d4eb7e7d00269af.zip
* include/ws2tcpip.h (gai_strerror{AW}): Implement as inline function.
-rw-r--r--winsup/w32api/ChangeLog4
-rw-r--r--winsup/w32api/include/ws2tcpip.h37
2 files changed, 30 insertions, 11 deletions
diff --git a/winsup/w32api/ChangeLog b/winsup/w32api/ChangeLog
index 8e2b9ebe3..4ff0d1c2e 100644
--- a/winsup/w32api/ChangeLog
+++ b/winsup/w32api/ChangeLog
@@ -1,5 +1,9 @@
2006-04-14 Dimitri Papadopoulos <papadopo@users.sourceforge.net>
+ * include/ws2tcpip.h (gai_strerror{AW}): Implement as inline function.
+
+2006-04-14 Dimitri Papadopoulos <papadopo@users.sourceforge.net>
+
* include/wsahelp.h (system_header): Add pragma.
* include/ws2spi.h (system_header): Add pragma.
* include/rasdlg.h (system_header): Add pragma.
diff --git a/winsup/w32api/include/ws2tcpip.h b/winsup/w32api/include/ws2tcpip.h
index 8251f9862..6ae0ea50d 100644
--- a/winsup/w32api/include/ws2tcpip.h
+++ b/winsup/w32api/include/ws2tcpip.h
@@ -304,17 +304,33 @@ int WSAAPI getnameinfo(const struct sockaddr*,socklen_t,char*,DWORD,
/* FIXME: Need WS protocol-independent API helpers. */
#endif
-#if 0
-/* These are not exported from any known w32api library. Are they
- implemented as macros or inline finctions? */
-char* WSAAPI gai_strerrorA(int);
-WCHAR* WSAAPI gai_strerrorW(int);
+static __inline char*
+gai_strerrorA(int ecode)
+{
+ static char message[1024+1];
+ DWORD dwFlags = FORMAT_MESSAGE_FROM_SYSTEM
+ | FORMAT_MESSAGE_IGNORE_INSERTS
+ | FORMAT_MESSAGE_MAX_WIDTH_MASK;
+ DWORD dwLanguageId = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);
+ FormatMessageA(dwFlags, NULL, ecode, dwLanguageId, (LPSTR)message, 1024, NULL);
+ return message;
+}
+static __inline WCHAR*
+gai_strerrorW(int ecode)
+{
+ static WCHAR message[1024+1];
+ DWORD dwFlags = FORMAT_MESSAGE_FROM_SYSTEM
+ | FORMAT_MESSAGE_IGNORE_INSERTS
+ | FORMAT_MESSAGE_MAX_WIDTH_MASK;
+ DWORD dwLanguageId = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);
+ FormatMessageW(dwFlags, NULL, ecode, dwLanguageId, (LPWSTR)message, 1024, NULL);
+ return message;
+}
#ifdef UNICODE
-#define gai_strerror gai_strerrorW
+#define gai_strerror gai_strerrorW
#else
-#define gai_strerror gai_strerrorA
-#endif /* UNICODE */
-#endif /* 0 */
+#define gai_strerror gai_strerrorA
+#endif
/* Some older IPv4/IPv6 compatibility stuff */
@@ -360,5 +376,4 @@ typedef struct _OLD_INTERFACE_INFO {
#ifdef __cplusplus
}
#endif
-
-#endif /* _WS2TCPIP_H */
+#endif