meanwhile 1.0.2
|
00001 00002 /* 00003 Meanwhile - Unofficial Lotus Sametime Community Client Library 00004 Copyright (C) 2004 Christopher (siege) O'Brien 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public 00017 License along with this library; if not, write to the Free 00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 */ 00020 00021 #ifndef _MW_UTIL_H 00022 #define _MW_UTIL_H 00023 00024 00025 #include <glib.h> 00026 #include <glib/ghash.h> 00027 #include <glib/glist.h> 00028 00029 00030 #define map_guint_new() \ 00031 g_hash_table_new(g_direct_hash, g_direct_equal) 00032 00033 00034 #define map_guint_new_full(valfree) \ 00035 g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (valfree)) 00036 00037 00038 #define map_guint_insert(ht, key, val) \ 00039 g_hash_table_insert((ht), GUINT_TO_POINTER((guint)(key)), (val)) 00040 00041 00042 #define map_guint_replace(ht, key, val) \ 00043 g_hash_table_replace((ht), GUINT_TO_POINTER((guint)(key)), (val)) 00044 00045 00046 #define map_guint_lookup(ht, key) \ 00047 g_hash_table_lookup((ht), GUINT_TO_POINTER((guint)(key))) 00048 00049 00050 #define map_guint_remove(ht, key) \ 00051 g_hash_table_remove((ht), GUINT_TO_POINTER((guint)(key))) 00052 00053 00054 #define map_guint_steal(ht, key) \ 00055 g_hash_table_steal((ht), GUINT_TO_POINTER((guint)(key))) 00056 00057 00058 GList *map_collect_keys(GHashTable *ht); 00059 00060 00061 GList *map_collect_values(GHashTable *ht); 00062 00063 00064 struct mw_datum { 00065 gpointer data; 00066 GDestroyNotify clear; 00067 }; 00068 00069 00070 struct mw_datum *mw_datum_new(gpointer data, GDestroyNotify clear); 00071 00072 00073 void mw_datum_set(struct mw_datum *d, gpointer data, GDestroyNotify clear); 00074 00075 00076 gpointer mw_datum_get(struct mw_datum *d); 00077 00078 00079 void mw_datum_clear(struct mw_datum *d); 00080 00081 00082 void mw_datum_free(struct mw_datum *d); 00083 00084 00085 #endif