2 * Copyright (c) 2007,2008,2009 Zmanda, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published
6 * by the Free Software Foundation.
8 * This program 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 General Public License
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 * Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300
18 * Sunnyvale, CA 94085, 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);