2 * Copyright (c) 2005-2008 Zmanda Inc. All Rights Reserved.
4 * This library is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 2.1 as
6 * published by the Free Software Foundation.
8 * This library is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
11 * License for more details.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this library; if not, write to the Free Software Foundation,
15 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17 * Contact information: Zmanda Inc., 465 S Mathlida Ave, Suite 300
18 * Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
25 foreach_fn(gpointer key_p, gpointer value_p, gpointer user_data_p)
28 char *value = value_p;
30 hv_store(hv, key, strlen(key), newSVpv(value, 0), 0);
34 g_hash_table_to_hashref(GHashTable *hash)
36 HV *hv = (HV *)sv_2mortal((SV *)newHV());
38 g_hash_table_foreach(hash, foreach_fn, hv);
40 return newRV((SV *)hv);
44 foreach_fn_gslist(gpointer key_p, gpointer value_p, gpointer user_data_p)
47 GSList *value_s = value_p;
52 for(value=value_s; value != NULL; value = value->next) {
53 av_push(list, newSVpv(value->data, 0));
56 hv_store(hv, key, strlen(key), newRV_noinc((SV*)list), 0);
60 g_hash_table_to_hashref_gslist(GHashTable *hash)
62 HV *hv = (HV *)sv_2mortal((SV *)newHV());
64 g_hash_table_foreach(hash, foreach_fn_gslist, hv);
66 return newRV((SV *)hv);
70 foreach_fn_property(gpointer key_p, gpointer value_p, gpointer user_data_p)
73 property_t *property = value_p;
77 HV *property_hv = newHV();
79 hv_store(property_hv, "append", strlen("append"), newSViv(property->append), 0);
80 hv_store(property_hv, "priority", strlen("priority"), newSViv(property->priority), 0);
81 for(value=property->values; value != NULL; value = value->next) {
82 av_push(list, newSVpv(value->data, 0));
84 hv_store(property_hv, "values", strlen("values"), newRV_noinc((SV*)list), 0);
86 hv_store(hv, key, strlen(key), newRV_noinc((SV*)property_hv), 0);
90 g_hash_table_to_hashref_property(GHashTable *hash)
92 HV *hv = (HV *)sv_2mortal((SV *)newHV());
94 g_hash_table_foreach(hash, foreach_fn_property, hv);
96 return newRV((SV *)hv);