/* * Copyright (C) 2013 Red Hat, Inc. * Authors: * Thomas Woerner * * 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, see . * */ #include "functions.h" gint g_list_str_equal(gconstpointer a, gconstpointer b) { if (a && b) return !g_str_equal(a, b); return -1; } gboolean g_list_contains_str(GList *list, const gchar *str) { if (list == NULL) return FALSE; return (g_list_find_custom(list, (gpointer) str, g_list_str_equal) != NULL); } void g_list_print(GList *list) { gint i; if (list == NULL) { g_print("NULL\n"); return; } g_print("["); for (i=0; i 0) g_print(", "); g_print("%s", (char *)g_list_nth_data(list, i)); } g_print("]\n"); } GList * g_list_remove_str(GList *list, const gchar *str) { GList *to_remove; if (list == NULL) return FALSE; to_remove = g_list_find_custom(list, (gpointer) str, g_list_str_equal); if (to_remove != NULL) return g_list_remove_link(list, to_remove); return list; }