10969
|
1
|
|
2 /*
|
|
3 Meanwhile - Unofficial Lotus Sametime Community Client Library
|
|
4 Copyright (C) 2004 Christopher (siege) O'Brien
|
|
5
|
|
6 This library is free software; you can redistribute it and/or
|
|
7 modify it under the terms of the GNU Library General Public
|
|
8 License as published by the Free Software Foundation; either
|
|
9 version 2 of the License, or (at your option) any later version.
|
|
10
|
|
11 This library is distributed in the hope that it will be useful,
|
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
14 Library General Public License for more details.
|
|
15
|
|
16 You should have received a copy of the GNU Library General Public
|
|
17 License along with this library; if not, write to the Free
|
|
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
19 */
|
|
20
|
|
21 #ifndef _MW_UTIL_H
|
|
22 #define _MW_UTIL_H
|
|
23
|
|
24
|
|
25 #include <glib.h>
|
|
26 #include <glib/ghash.h>
|
|
27 #include <glib/glist.h>
|
|
28
|
|
29
|
|
30 #define map_guint_new() \
|
|
31 g_hash_table_new(g_direct_hash, g_direct_equal)
|
|
32
|
|
33
|
|
34 #define map_guint_new_full(valfree) \
|
|
35 g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (valfree))
|
|
36
|
|
37
|
|
38 #define map_guint_insert(ht, key, val) \
|
|
39 g_hash_table_insert((ht), GUINT_TO_POINTER((guint)(key)), (val))
|
|
40
|
|
41
|
|
42 #define map_guint_replace(ht, key, val) \
|
|
43 g_hash_table_replace((ht), GUINT_TO_POINTER((guint)(key)), (val))
|
|
44
|
|
45
|
|
46 #define map_guint_lookup(ht, key) \
|
|
47 g_hash_table_lookup((ht), GUINT_TO_POINTER((guint)(key)))
|
|
48
|
|
49
|
|
50 #define map_guint_remove(ht, key) \
|
|
51 g_hash_table_remove((ht), GUINT_TO_POINTER((guint)(key)))
|
|
52
|
|
53
|
|
54 #define map_guint_steal(ht, key) \
|
|
55 g_hash_table_steal((ht), GUINT_TO_POINTER((guint)(key)))
|
|
56
|
|
57
|
|
58 GList *map_collect_keys(GHashTable *ht);
|
|
59
|
|
60
|
|
61 GList *map_collect_values(GHashTable *ht);
|
|
62
|
|
63
|
|
64 struct mw_datum {
|
|
65 gpointer data;
|
|
66 GDestroyNotify clear;
|
|
67 };
|
|
68
|
|
69
|
|
70 struct mw_datum *mw_datum_new(gpointer data, GDestroyNotify clear);
|
|
71
|
|
72
|
|
73 void mw_datum_set(struct mw_datum *d, gpointer data, GDestroyNotify clear);
|
|
74
|
|
75
|
|
76 gpointer mw_datum_get(struct mw_datum *d);
|
|
77
|
|
78
|
|
79 void mw_datum_clear(struct mw_datum *d);
|
|
80
|
|
81
|
|
82 void mw_datum_free(struct mw_datum *d);
|
|
83
|
|
84
|
|
85 #endif
|