/* GKrellM giFT plugin * Copyright (C) 2002, 2003 Tilman Sauerbeck * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * */ #include "common.h" #include "event_ids.h" static GHashTable *event_ids = NULL; EventID *gift_event_id_add (gint i, TransferDirection dir) { EventID *id = g_new0 (EventID, 1); id->num = i; id->dir = dir; if (!event_ids) event_ids = g_hash_table_new_full (NULL, NULL, NULL, g_free); g_hash_table_insert (event_ids, GINT_TO_POINTER (i), (gpointer) id); return id; } void gift_event_id_remove (EventID *id) { g_assert (event_ids); g_assert (id); g_hash_table_remove (event_ids, (gpointer) id); } EventID *gift_event_id_lookup (gint i) { if (event_ids) return g_hash_table_lookup (event_ids, GINT_TO_POINTER (i)); else return NULL; } void gift_event_id_destroy () { if (event_ids) { g_hash_table_destroy (event_ids); event_ids = NULL; } }