From ee9e238179677ad0168ead6edfe17f798dbf47dc Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 4 Sep 2013 23:36:30 +0200 Subject: system/SocketError: un-inline constructor Reduces header dependencies. --- src/event/ServerSocket.cxx | 2 ++ src/system/SocketError.cxx | 22 ++++++++++++++++++++++ src/system/SocketError.hxx | 15 ++------------- 3 files changed, 26 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/event/ServerSocket.cxx b/src/event/ServerSocket.cxx index f0b02e34c..342acc04e 100644 --- a/src/event/ServerSocket.cxx +++ b/src/event/ServerSocket.cxx @@ -32,6 +32,8 @@ #include "util/Error.hxx" #include "util/Domain.hxx" +#include + #include #include #include 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 + 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 diff --git a/src/system/SocketError.hxx b/src/system/SocketError.hxx index c42e267dd..2b8332715 100644 --- a/src/system/SocketError.hxx +++ b/src/system/SocketError.hxx @@ -23,8 +23,6 @@ #include "gcc.h" #include "util/Error.hxx" -#include - #ifdef WIN32 #include typedef DWORD socket_error_t; @@ -97,18 +95,9 @@ class SocketErrorMessage { public: #ifdef WIN32 - explicit SocketErrorMessage(socket_error_t code=GetSocketError()) { - 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"); - } + explicit SocketErrorMessage(socket_error_t code=GetSocketError()); #else - explicit SocketErrorMessage(socket_error_t code=GetSocketError()) - :msg(g_strerror(code)) {} + explicit SocketErrorMessage(socket_error_t code=GetSocketError()); #endif operator const char *() const { -- cgit v1.2.3