grim/purple-plugin-pack
* Purple Plugin Pack - GLib Compatibility Header * This code borrowed from GLib (http://www.gtk.org/) for backward * compatibility with ancient versions of GLib. * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA #if !GLIB_CHECK_VERSION(2,2,0) g_str_has_suffix (const gchar *str, const gchar *suffix) g_return_val_if_fail (str != NULL, FALSE); g_return_val_if_fail (suffix != NULL, FALSE); suffix_len = strlen (suffix); if (str_len < suffix_len) return strcmp (str + str_len - suffix_len, suffix) == 0; g_str_has_prefix (const gchar *str, const gchar *prefix) g_return_val_if_fail (str != NULL, FALSE); g_return_val_if_fail (prefix != NULL, FALSE); prefix_len = strlen (prefix); if (str_len < prefix_len) return strncmp (str, prefix, prefix_len) == 0; /* this check is backwards now because we need to do stuff both if the builder * has 2.4.0 and if the builder doesn't have 2.4.0 */ #if GLIB_CHECK_VERSION(2,4,0) # include <glib/gi18n-lib.h> # define _(String) dgettext (GETTEXT_PACKAGE, String) # define Q_(String) g_strip_context ((String), dgettext (GETTEXT_PACKAGE, String)) # define N_(String) gettext_noop (String) # define N_(String) (String) g_strsplit_set (const gchar *string, const gchar *delimiters, gint max_tokens) gboolean delim_table[256]; g_return_val_if_fail (string != NULL, NULL); g_return_val_if_fail (delimiters != NULL, NULL); result = g_new (char *, 1); memset (delim_table, FALSE, sizeof (delim_table)); for (s = delimiters; *s != '\0'; ++s) delim_table[*(guchar *)s] = TRUE; if (delim_table[*(guchar *)s] && n_tokens + 1 < max_tokens) token = g_strndup (current, s - current); tokens = g_slist_prepend (tokens, token); token = g_strndup (current, s - current); tokens = g_slist_prepend (tokens, token); result = g_new (gchar *, n_tokens + 1); for (list = tokens; list != NULL; list = list->next) result[--n_tokens] = list->data; #if !GLIB_CHECK_VERSION(2,6,0) g_strv_length (gchar **str_array) g_return_val_if_fail (str_array != NULL, 0);