Code

compatibility fixes for GLib 2.12
[ncmpc.git] / src / glib_compat.h
1 /*
2  * Copyright (C) 2003-2009 The Music Player Daemon Project
3  * http://www.musicpd.org
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
20 /*
21  * Compatibility with older GLib versions.  Some of this isn't
22  * implemented properly, just "good enough" to allow users with older
23  * operating systems to run MPD.
24  */
26 #ifndef MPD_GLIB_COMPAT_H
27 #define MPD_GLIB_COMPAT_H
29 #include <glib.h>
31 #if !GLIB_CHECK_VERSION(2,14,0)
33 #define g_queue_clear(q) do { g_queue_free(q); q = g_queue_new(); } while (0)
35 static inline guint
36 g_timeout_add_seconds(guint interval, GSourceFunc function, gpointer data)
37 {
38         return g_timeout_add(interval * 1000, function, data);
39 }
41 #endif /* !2.14 */
43 #if !GLIB_CHECK_VERSION(2,16,0)
45 static inline void
46 g_propagate_prefixed_error(GError **dest_r, GError *src,
47                            G_GNUC_UNUSED const gchar *format, ...)
48 {
49         g_propagate_error(dest_r, src);
50 }
52 static inline char *
53 g_uri_escape_string(const char *unescaped,
54                     G_GNUC_UNUSED const char *reserved_chars_allowed,
55                     G_GNUC_UNUSED gboolean allow_utf8)
56 {
57         return g_strdup(unescaped);
58 }
60 #endif /* !2.16 */
62 #endif