|
Packit |
16808d |
|
|
Packit |
16808d |
/*
|
|
Packit |
16808d |
Meanwhile - Unofficial Lotus Sametime Community Client Library
|
|
Packit |
16808d |
Copyright (C) 2004 Christopher (siege) O'Brien
|
|
Packit |
16808d |
|
|
Packit |
16808d |
This library is free software; you can redistribute it and/or
|
|
Packit |
16808d |
modify it under the terms of the GNU Library General Public
|
|
Packit |
16808d |
License as published by the Free Software Foundation; either
|
|
Packit |
16808d |
version 2 of the License, or (at your option) any later version.
|
|
Packit |
16808d |
|
|
Packit |
16808d |
This library is distributed in the hope that it will be useful,
|
|
Packit |
16808d |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
16808d |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
16808d |
Library General Public License for more details.
|
|
Packit |
16808d |
|
|
Packit |
16808d |
You should have received a copy of the GNU Library General Public
|
|
Packit |
16808d |
License along with this library; if not, write to the Free
|
|
Packit |
16808d |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
Packit |
16808d |
*/
|
|
Packit |
16808d |
|
|
Packit |
16808d |
#include "mw_util.h"
|
|
Packit |
16808d |
|
|
Packit |
16808d |
|
|
Packit |
16808d |
static void collect_keys(gpointer key, gpointer val, gpointer data) {
|
|
Packit |
16808d |
GList **list = data;
|
|
Packit |
16808d |
*list = g_list_append(*list, key);
|
|
Packit |
16808d |
}
|
|
Packit |
16808d |
|
|
Packit |
16808d |
|
|
Packit |
16808d |
GList *map_collect_keys(GHashTable *ht) {
|
|
Packit |
16808d |
GList *ret = NULL;
|
|
Packit |
16808d |
g_hash_table_foreach(ht, collect_keys, &ret;;
|
|
Packit |
16808d |
return ret;
|
|
Packit |
16808d |
}
|
|
Packit |
16808d |
|
|
Packit |
16808d |
|
|
Packit |
16808d |
static void collect_values(gpointer key, gpointer val, gpointer data) {
|
|
Packit |
16808d |
GList **list = data;
|
|
Packit |
16808d |
*list = g_list_append(*list, val);
|
|
Packit |
16808d |
}
|
|
Packit |
16808d |
|
|
Packit |
16808d |
|
|
Packit |
16808d |
GList *map_collect_values(GHashTable *ht) {
|
|
Packit |
16808d |
GList *ret = NULL;
|
|
Packit |
16808d |
g_hash_table_foreach(ht, collect_values, &ret;;
|
|
Packit |
16808d |
return ret;
|
|
Packit |
16808d |
}
|
|
Packit |
16808d |
|
|
Packit |
16808d |
|
|
Packit |
16808d |
struct mw_datum *mw_datum_new(gpointer data, GDestroyNotify clear) {
|
|
Packit |
16808d |
struct mw_datum *d = g_new(struct mw_datum, 1);
|
|
Packit |
16808d |
mw_datum_set(d, data, clear);
|
|
Packit |
16808d |
return d;
|
|
Packit |
16808d |
}
|
|
Packit |
16808d |
|
|
Packit |
16808d |
|
|
Packit |
16808d |
void mw_datum_set(struct mw_datum *d, gpointer data, GDestroyNotify clear) {
|
|
Packit |
16808d |
d->data = data;
|
|
Packit |
16808d |
d->clear = clear;
|
|
Packit |
16808d |
}
|
|
Packit |
16808d |
|
|
Packit |
16808d |
|
|
Packit |
16808d |
gpointer mw_datum_get(struct mw_datum *d) {
|
|
Packit |
16808d |
return d->data;
|
|
Packit |
16808d |
}
|
|
Packit |
16808d |
|
|
Packit |
16808d |
|
|
Packit |
16808d |
void mw_datum_clear(struct mw_datum *d) {
|
|
Packit |
16808d |
if(d->clear) {
|
|
Packit |
16808d |
d->clear(d->data);
|
|
Packit |
16808d |
d->clear = NULL;
|
|
Packit |
16808d |
}
|
|
Packit |
16808d |
d->data = NULL;
|
|
Packit |
16808d |
}
|
|
Packit |
16808d |
|
|
Packit |
16808d |
|
|
Packit |
16808d |
void mw_datum_free(struct mw_datum *d) {
|
|
Packit |
16808d |
mw_datum_clear(d);
|
|
Packit |
16808d |
g_free(d);
|
|
Packit |
16808d |
}
|