aboutsummaryrefslogtreecommitdiffstats
path: root/src/system/SocketError.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-09-04 23:36:30 +0200
committerMax Kellermann <max@duempel.org>2013-09-04 23:36:30 +0200
commitee9e238179677ad0168ead6edfe17f798dbf47dc (patch)
tree032c0f1593bc64f6745cd81cc124d9fc272a5010 /src/system/SocketError.cxx
parent29030b54c98b0aee65fbc10ebf7ba36bed98c02c (diff)
downloadmpd-ee9e238179677ad0168ead6edfe17f798dbf47dc.tar.gz
mpd-ee9e238179677ad0168ead6edfe17f798dbf47dc.tar.xz
mpd-ee9e238179677ad0168ead6edfe17f798dbf47dc.zip
system/SocketError: un-inline constructor
Reduces header dependencies.
Diffstat (limited to '')
-rw-r--r--src/system/SocketError.cxx22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/system/SocketError.cxx b/src/system/SocketError.cxx
index d3569c6f1..315a86e1f 100644
--- a/src/system/SocketError.cxx
+++ b/src/system/SocketError.cxx
@@ -21,4 +21,26 @@
#include "SocketError.hxx"
#include "util/Domain.hxx"
+#include <glib.h>
+
const Domain socket_domain("socket");
+
+#ifdef WIN32
+
+SocketErrorMessage::SocketErrorMessage(socket_error_t code)
+{
+ DWORD nbytes = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS |
+ FORMAT_MESSAGE_MAX_WIDTH_MASK,
+ NULL, code, 0,
+ (LPSTR)msg, sizeof(msg), NULL);
+ if (nbytes == 0)
+ strcpy(msg, "Unknown error");
+}
+
+#else
+
+SocketErrorMessage::SocketErrorMessage(socket_error_t code)
+ :msg(g_strerror(code)) {}
+
+#endif