mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Missed one.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3619 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
fa9cff9ce9
commit
fbb1a7a440
78
src/engine/sixtp-to-dom-parser.c
Normal file
78
src/engine/sixtp-to-dom-parser.c
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
#include "sixtp-parsers.h"
|
||||||
|
#include "sixtp-utils.h"
|
||||||
|
#include "sixtp.h"
|
||||||
|
|
||||||
|
static xmlNsPtr global_namespace;
|
||||||
|
|
||||||
|
static gboolean dom_start_handler(
|
||||||
|
GSList* sibling_data, gpointer parent_data, gpointer global_data,
|
||||||
|
gpointer *data_for_children, gpointer *result, const gchar *tag,
|
||||||
|
gchar **attrs)
|
||||||
|
{
|
||||||
|
xmlNodePtr thing;
|
||||||
|
gchar** atptr = attrs;
|
||||||
|
|
||||||
|
if(parent_data == NULL)
|
||||||
|
{
|
||||||
|
thing = xmlNewNode(global_namespace, tag);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
thing = xmlNewChild(parent_data, global_namespace, tag, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
while(*atptr != 0)
|
||||||
|
{
|
||||||
|
xmlSetProp(thing, atptr[0], atptr[1]);
|
||||||
|
atptr += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
*result = thing;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean dom_chars_handler(
|
||||||
|
GSList *sibling_data, gpointer parent_data, gpointer global_data,
|
||||||
|
gpointer *result, const char *text, int length)
|
||||||
|
{
|
||||||
|
xmlNodeSetContent((xmlNodePtr)result, text);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean dom_before_handler(
|
||||||
|
gpointer data_for_children, GSList* data_from_children,
|
||||||
|
GSList* sibling_data, gpointer parent_data, gpointer global_data,
|
||||||
|
gpointer *result, const gchar *tag, const gchar *child_tag)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
sixtp* sixtp_dom_parser_new(sixtp_end_handler ender)
|
||||||
|
{
|
||||||
|
sixtp *top_level;
|
||||||
|
|
||||||
|
g_return_val_if_fail(ender, NULL);
|
||||||
|
|
||||||
|
if(!(top_level =
|
||||||
|
sixtp_set_any(sixtp_new(), FALSE,
|
||||||
|
SIXTP_START_HANDLER_ID, dom_start_handler,
|
||||||
|
SIXTP_BEFORE_CHILD_HANDLER_ID, dom_before_handler,
|
||||||
|
SIXTP_CHARACTERS_HANDLER_ID, dom_chars_handler,
|
||||||
|
SIXTP_END_HANDLER_ID, ender,
|
||||||
|
SIXTP_NO_MORE_HANDLERS)))
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!sixtp_add_sub_parser(top_level, SIXTP_MAGIC_CATCHER, top_level))
|
||||||
|
{
|
||||||
|
sixtp_destroy(top_level);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return top_level;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user