diff options
author | Max Kellermann <max@duempel.org> | 2013-12-15 12:32:15 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-12-15 18:43:12 +0100 |
commit | d5dfe7d457b559bd9c53d65d0315c55611cc6a79 (patch) | |
tree | 42825c13cc44e4fe1272d14f9dc26f03ce0ef596 /src | |
parent | 0db0b4e302f82165b763da7717059911a85c370f (diff) | |
download | mpd-d5dfe7d457b559bd9c53d65d0315c55611cc6a79.tar.gz mpd-d5dfe7d457b559bd9c53d65d0315c55611cc6a79.tar.xz mpd-d5dfe7d457b559bd9c53d65d0315c55611cc6a79.zip |
configure.ac: add option "--disable-glib"
Allows building without GLib. This fails to compile currently,
because GLib is still used in the MPD core.
Diffstat (limited to 'src')
-rw-r--r-- | src/LogBackend.cxx | 14 | ||||
-rw-r--r-- | src/LogInit.cxx | 7 | ||||
-rw-r--r-- | src/Main.cxx | 8 | ||||
-rw-r--r-- | src/event/SignalMonitor.cxx | 1 | ||||
-rw-r--r-- | src/system/FatalError.cxx | 6 | ||||
-rw-r--r-- | src/system/FatalError.hxx | 2 |
6 files changed, 35 insertions, 3 deletions
diff --git a/src/LogBackend.cxx b/src/LogBackend.cxx index a5c0a691f..bddf8db16 100644 --- a/src/LogBackend.cxx +++ b/src/LogBackend.cxx @@ -23,18 +23,24 @@ #include "util/Domain.hxx" #include "util/CharUtil.hxx" +#ifdef HAVE_GLIB #include <glib.h> +#endif #include <assert.h> #include <stdio.h> #include <string.h> +#include <time.h> #ifdef HAVE_SYSLOG #include <syslog.h> #endif static LogLevel log_threshold = LogLevel::INFO; + +#ifdef HAVE_GLIB static const char *log_charset; +#endif static bool enable_timestamp; @@ -48,12 +54,16 @@ SetLogThreshold(LogLevel _threshold) log_threshold = _threshold; } +#ifdef HAVE_GLIB + void SetLogCharset(const char *_charset) { log_charset = _charset; } +#endif + void EnableLogTimestamp() { @@ -142,6 +152,7 @@ LogFinishSysLog() static void FileLog(const Domain &domain, const char *message) { +#ifdef HAVE_GLIB char *converted; if (log_charset != nullptr) { @@ -153,13 +164,16 @@ FileLog(const Domain &domain, const char *message) message = converted; } else converted = nullptr; +#endif fprintf(stderr, "%s%s: %.*s\n", enable_timestamp ? log_date() : "", domain.GetName(), chomp_length(message), message); +#ifdef HAVE_GLIB g_free(converted); +#endif } void diff --git a/src/LogInit.cxx b/src/LogInit.cxx index 42d86951f..bd858a32c 100644 --- a/src/LogInit.cxx +++ b/src/LogInit.cxx @@ -31,13 +31,16 @@ #include "util/Domain.hxx" #include "system/FatalError.hxx" +#ifdef HAVE_GLIB +#include <glib.h> +#endif + #include <assert.h> #include <string.h> #include <fcntl.h> #include <stdio.h> #include <time.h> #include <unistd.h> -#include <glib.h> #define LOG_LEVEL_SECURE LogLevel::INFO @@ -110,9 +113,11 @@ log_init(bool verbose, bool use_stdout, Error &error) { const struct config_param *param; +#ifdef HAVE_GLIB const char *charset; g_get_charset(&charset); SetLogCharset(charset); +#endif if (verbose) SetLogThreshold(LogLevel::DEBUG); diff --git a/src/Main.cxx b/src/Main.cxx index 2d25297c9..da8458340 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -79,7 +79,9 @@ #include "ArchiveList.hxx" #endif +#ifdef HAVE_GLIB #include <glib.h> +#endif #include <stdlib.h> @@ -92,6 +94,8 @@ #include <ws2tcpip.h> #endif +#include <limits.h> + static constexpr unsigned DEFAULT_BUFFER_SIZE = 4096; static constexpr unsigned DEFAULT_BUFFER_BEFORE_PLAY = 10; @@ -359,12 +363,14 @@ int mpd_main(int argc, char *argv[]) setlocale(LC_CTYPE,""); #endif +#ifdef HAVE_GLIB g_set_application_name("Music Player Daemon"); #if !GLIB_CHECK_VERSION(2,32,0) /* enable GLib's thread safety code */ g_thread_init(nullptr); #endif +#endif winsock_init(); io_thread_init(); @@ -473,7 +479,7 @@ int mpd_main(int argc, char *argv[]) } if (!glue_state_file_init(error)) { - g_printerr("%s\n", error.GetMessage()); + LogError(error); return EXIT_FAILURE; } diff --git a/src/event/SignalMonitor.cxx b/src/event/SignalMonitor.cxx index 0d96fb138..bb75f49a3 100644 --- a/src/event/SignalMonitor.cxx +++ b/src/event/SignalMonitor.cxx @@ -40,6 +40,7 @@ #include <algorithm> #include <assert.h> +#include <signal.h> class SignalMonitor final : private SocketMonitor { #ifdef USE_SIGNALFD diff --git a/src/system/FatalError.cxx b/src/system/FatalError.cxx index 11a0944df..b54a677f2 100644 --- a/src/system/FatalError.cxx +++ b/src/system/FatalError.cxx @@ -23,7 +23,7 @@ #include "util/Domain.hxx" #include "LogV.hxx" -#ifdef WIN32 +#ifdef HAVE_GLIB #include <glib.h> #endif @@ -78,12 +78,16 @@ FatalError(const char *msg, const Error &error) FormatFatalError("%s: %s", msg, error.GetMessage()); } +#ifdef HAVE_GLIB + void FatalError(const char *msg, GError *error) { FormatFatalError("%s: %s", msg, error->message); } +#endif + void FatalSystemError(const char *msg) { diff --git a/src/system/FatalError.hxx b/src/system/FatalError.hxx index 2845359ef..4ef290714 100644 --- a/src/system/FatalError.hxx +++ b/src/system/FatalError.hxx @@ -45,9 +45,11 @@ gcc_noreturn void FatalError(const char *msg, const Error &error); +#ifdef HAVE_GLIB gcc_noreturn void FatalError(const char *msg, GError *error); +#endif /** * Call this after a system call has failed that is not supposed to |