MPD 0.17~git
|
00001 /* 00002 * Copyright (C) 2003-2011 The Music Player Daemon Project 00003 * http://www.musicpd.org 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License along 00016 * with this program; if not, write to the Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00018 */ 00019 00020 /* 00021 * Compatibility with older GLib versions. Some of this isn't 00022 * implemented properly, just "good enough" to allow users with older 00023 * operating systems to run MPD. 00024 */ 00025 00026 #ifndef MPD_GLIB_COMPAT_H 00027 #define MPD_GLIB_COMPAT_H 00028 00029 #include <glib.h> 00030 00031 #if !GLIB_CHECK_VERSION(2,14,0) 00032 00033 #define g_queue_clear(q) do { g_queue_free(q); q = g_queue_new(); } while (0) 00034 00035 static inline GSource * 00036 g_timeout_source_new_seconds(guint interval) 00037 { 00038 return g_timeout_source_new(interval * 1000); 00039 } 00040 00041 static inline guint 00042 g_timeout_add_seconds(guint interval, GSourceFunc function, gpointer data) 00043 { 00044 return g_timeout_add(interval * 1000, function, data); 00045 } 00046 00047 #endif /* !2.14 */ 00048 00049 #if !GLIB_CHECK_VERSION(2,16,0) 00050 00051 static inline void 00052 g_prefix_error(G_GNUC_UNUSED GError **error_r, 00053 G_GNUC_UNUSED const gchar *format, ...) 00054 { 00055 } 00056 00057 static inline void 00058 g_propagate_prefixed_error(GError **dest_r, GError *src, 00059 G_GNUC_UNUSED const gchar *format, ...) 00060 { 00061 g_propagate_error(dest_r, src); 00062 } 00063 00064 static inline char * 00065 g_uri_escape_string(const char *unescaped, 00066 G_GNUC_UNUSED const char *reserved_chars_allowed, 00067 G_GNUC_UNUSED gboolean allow_utf8) 00068 { 00069 return g_strdup(unescaped); 00070 } 00071 00072 #endif /* !2.16 */ 00073 00074 #if !GLIB_CHECK_VERSION(2,16,0) 00075 00076 #include <string.h> 00077 00078 static inline char * 00079 g_uri_parse_scheme(const char *uri) 00080 { 00081 const char *end = strstr(uri, "://"); 00082 if (end == NULL) 00083 return NULL; 00084 return g_strndup(uri, end - uri); 00085 } 00086 00087 #endif 00088 00089 #if !GLIB_CHECK_VERSION(2,18,0) 00090 00091 static inline void 00092 g_set_error_literal(GError **err, GQuark domain, gint code, 00093 const gchar *message) 00094 { 00095 g_set_error(err, domain, code, "%s", message); 00096 } 00097 00098 #endif 00099 00100 #endif