2 * Supplementary captive utilities for libxml2
3 * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; exactly version 2 of June 1991 is required
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "captive/libxml.h" /* self */
23 #include <glib/gmessages.h>
24 #include <glib/ghook.h>
26 #include "captive/macros.h"
29 struct captive_libxml_string_drop_stack {
30 GHookList g_hook_list;
34 gint64 captive_libxml_sscanf_gint64(const gchar *gint64_string)
38 int gint64_string_len;
40 g_return_val_if_fail(gint64_string!=NULL,0);
42 errint=sscanf(gint64_string,"%" G_GINT64_FORMAT "%n",&r,&gint64_string_len);
43 g_assert(errint==1 || errint==2 /* %n */);
44 g_assert(gint64_string_len==(int)strlen(gint64_string));
50 static void captive_libxml_string_drop_hook_func(const xmlChar *xml_string /* data */)
52 g_return_if_fail(xml_string!=NULL);
54 xmlFree((xmlChar *)xml_string);
57 const xmlChar *captive_libxml_string_drop(struct captive_libxml_string_drop_stack **drop_stackp,const xmlChar *xml_string)
61 g_return_val_if_fail(drop_stackp!=NULL,NULL);
67 captive_new(*drop_stackp);
68 g_hook_list_init(&(*drop_stackp)->g_hook_list,sizeof(GHook));
71 g_hook=g_hook_alloc(&(*drop_stackp)->g_hook_list);
72 g_hook->func=(GHookFunc)captive_libxml_string_drop_hook_func;
73 g_hook->data=(xmlChar *)xml_string;
74 g_hook_append(&(*drop_stackp)->g_hook_list,g_hook);
80 void captive_libxml_string_drop_flush(struct captive_libxml_string_drop_stack **drop_stackp)
82 struct captive_libxml_string_drop_stack *drop_stack;
84 g_return_if_fail(drop_stackp!=NULL);
86 if (!(drop_stack=*drop_stackp))
90 g_hook_list_invoke(&drop_stack->g_hook_list,
91 FALSE); /* may_recurse */
92 g_hook_list_clear(&drop_stack->g_hook_list);