system/SocketError, ...: use strerror() instead of g_strerror()

Avoid GLib.
This commit is contained in:
Max Kellermann 2013-12-15 18:30:25 +01:00
parent a10a4ad900
commit 777844ae0c
4 changed files with 14 additions and 9 deletions

View File

@ -24,9 +24,8 @@
#include "util/Error.hxx" #include "util/Error.hxx"
#include "Log.hxx" #include "Log.hxx"
#include <glib.h>
#include <assert.h> #include <assert.h>
#include <string.h>
#include <errno.h> #include <errno.h>
CommandResult CommandResult
@ -38,7 +37,7 @@ print_playlist_result(Client &client, PlaylistResult result)
case PlaylistResult::ERRNO: case PlaylistResult::ERRNO:
command_error(client, ACK_ERROR_SYSTEM, "%s", command_error(client, ACK_ERROR_SYSTEM, "%s",
g_strerror(errno)); strerror(errno));
return CommandResult::ERROR; return CommandResult::ERROR;
case PlaylistResult::DENIED: case PlaylistResult::DENIED:
@ -115,7 +114,7 @@ print_error(Client &client, const Error &error)
} }
} else if (error.IsDomain(errno_domain)) { } else if (error.IsDomain(errno_domain)) {
command_error(client, ACK_ERROR_SYSTEM, "%s", command_error(client, ACK_ERROR_SYSTEM, "%s",
g_strerror(error.GetCode())); strerror(error.GetCode()));
return CommandResult::ERROR; return CommandResult::ERROR;
} }

View File

@ -23,12 +23,15 @@
#include "util/Domain.hxx" #include "util/Domain.hxx"
#include "LogV.hxx" #include "LogV.hxx"
#ifdef WIN32
#include <glib.h> #include <glib.h>
#endif
#include <unistd.h> #include <unistd.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#ifdef WIN32 #ifdef WIN32
#include <windows.h> #include <windows.h>
@ -88,7 +91,7 @@ FatalSystemError(const char *msg)
#ifdef WIN32 #ifdef WIN32
system_error = g_win32_error_message(GetLastError()); system_error = g_win32_error_message(GetLastError());
#else #else
system_error = g_strerror(errno); system_error = strerror(errno);
#endif #endif
FormatError(fatal_error_domain, "%s: %s", msg, system_error); FormatError(fatal_error_domain, "%s: %s", msg, system_error);

View File

@ -21,7 +21,7 @@
#include "SocketError.hxx" #include "SocketError.hxx"
#include "util/Domain.hxx" #include "util/Domain.hxx"
#include <glib.h> #include <string.h>
const Domain socket_domain("socket"); const Domain socket_domain("socket");
@ -41,6 +41,6 @@ SocketErrorMessage::SocketErrorMessage(socket_error_t code)
#else #else
SocketErrorMessage::SocketErrorMessage(socket_error_t code) SocketErrorMessage::SocketErrorMessage(socket_error_t code)
:msg(g_strerror(code)) {} :msg(strerror(code)) {}
#endif #endif

View File

@ -21,11 +21,14 @@
#include "Error.hxx" #include "Error.hxx"
#include "Domain.hxx" #include "Domain.hxx"
#ifdef WIN32
#include <glib.h> #include <glib.h>
#endif
#include <errno.h> #include <errno.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
const Domain errno_domain("errno"); const Domain errno_domain("errno");
@ -70,7 +73,7 @@ Error::FormatPrefix(const char *fmt, ...)
void void
Error::SetErrno(int e) Error::SetErrno(int e)
{ {
Set(errno_domain, e, g_strerror(e)); Set(errno_domain, e, strerror(e));
} }
void void
@ -82,7 +85,7 @@ Error::SetErrno()
void void
Error::SetErrno(int e, const char *prefix) Error::SetErrno(int e, const char *prefix)
{ {
Format(errno_domain, e, "%s: %s", prefix, g_strerror(e)); Format(errno_domain, e, "%s: %s", prefix, strerror(e));
} }
void void