mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
James LewisMoss's xml patch.
* src/test/test-xml-account.c (node_and_account_equal): fix mem leak. (test_add_account): new func. (test_generation): Actually test the node created and the parser. Everything looks good other than some sixtp oddness I don't understand yet. * src/engine/gnc-transaction-xml-v2.c (gnc_transaction_end_handler): same as below. * src/engine/gnc-commodity-xml-v2.c (gnc_commodity_end_handler): Use data struct from io-gncxml-v2.h * src/engine/gnc-account-xml-v2.c (account_currency_handler): Make not use engine commodity funcs to make this testable. Will have to have something to clean this up in production code. (account_security_handler): Same. (gnc_xml_set_account_data): Oops. Actually set that we have gotten this so the got all test succeeds. (gnc_account_end_handler): Start the main parsing setup by relying on data struct from io-gncxml-v2.h (gnc_account_end_handler): fix free to free the correct thing. Add some g_warning calls to make errors more apparent. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3720 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
6df78be645
commit
0221a10490
26
ChangeLog
26
ChangeLog
@ -1,3 +1,29 @@
|
|||||||
|
2001-02-28 James LewisMoss <jimdres@mindspring.com>
|
||||||
|
|
||||||
|
* src/test/test-xml-account.c (node_and_account_equal): fix mem
|
||||||
|
leak.
|
||||||
|
(test_add_account): new func.
|
||||||
|
(test_generation): Actually test the node created and the
|
||||||
|
parser. Everything looks good other than some sixtp oddness I
|
||||||
|
don't understand yet.
|
||||||
|
|
||||||
|
* src/engine/gnc-transaction-xml-v2.c
|
||||||
|
(gnc_transaction_end_handler): same as below.
|
||||||
|
|
||||||
|
* src/engine/gnc-commodity-xml-v2.c (gnc_commodity_end_handler):
|
||||||
|
Use data struct from io-gncxml-v2.h
|
||||||
|
|
||||||
|
* src/engine/gnc-account-xml-v2.c (account_currency_handler): Make
|
||||||
|
not use engine commodity funcs to make this testable. Will have
|
||||||
|
to have something to clean this up in production code.
|
||||||
|
(account_security_handler): Same.
|
||||||
|
(gnc_xml_set_account_data): Oops. Actually set that we have
|
||||||
|
gotten this so the got all test succeeds.
|
||||||
|
(gnc_account_end_handler): Start the main parsing setup by relying
|
||||||
|
on data struct from io-gncxml-v2.h
|
||||||
|
(gnc_account_end_handler): fix free to free the correct thing.
|
||||||
|
Add some g_warning calls to make errors more apparent.
|
||||||
|
|
||||||
2001-02-28 Dave Peticolas <dave@krondo.com>
|
2001-02-28 Dave Peticolas <dave@krondo.com>
|
||||||
|
|
||||||
* src/FileDialog.c: store the original (not comma-fied) version
|
* src/FileDialog.c: store the original (not comma-fied) version
|
||||||
|
@ -42,6 +42,7 @@ libgncengine_la_SOURCES = \
|
|||||||
io-gncbin-r.c \
|
io-gncbin-r.c \
|
||||||
io-gncxml-r.c \
|
io-gncxml-r.c \
|
||||||
io-gncxml-w.c \
|
io-gncxml-w.c \
|
||||||
|
io-gncxml-v2.c \
|
||||||
kvp_frame.c \
|
kvp_frame.c \
|
||||||
md5.c \
|
md5.c \
|
||||||
sixtp-dom-generators.c \
|
sixtp-dom-generators.c \
|
||||||
@ -90,6 +91,7 @@ noinst_HEADERS = \
|
|||||||
io-gncbin.h \
|
io-gncbin.h \
|
||||||
io-gncxml.h \
|
io-gncxml.h \
|
||||||
io-gncxml-p.h \
|
io-gncxml-p.h \
|
||||||
|
io-gncxml-v2.h \
|
||||||
kvp_frame.h \
|
kvp_frame.h \
|
||||||
md5.h \
|
md5.h \
|
||||||
sixtp-dom-generators.h \
|
sixtp-dom-generators.h \
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "sixtp-dom-generators.h"
|
#include "sixtp-dom-generators.h"
|
||||||
|
|
||||||
#include "gnc-xml.h"
|
#include "gnc-xml.h"
|
||||||
|
#include "io-gncxml-v2.h"
|
||||||
|
|
||||||
#include "sixtp-dom-parsers.h"
|
#include "sixtp-dom-parsers.h"
|
||||||
#include "AccountP.h"
|
#include "AccountP.h"
|
||||||
@ -122,10 +123,9 @@ account_currency_handler (xmlNodePtr node, Account* act)
|
|||||||
{
|
{
|
||||||
gnc_commodity *ref;
|
gnc_commodity *ref;
|
||||||
|
|
||||||
ref = dom_tree_to_commodity_ref(node);
|
ref = dom_tree_to_commodity_ref_no_engine(node);
|
||||||
xaccAccountSetCurrency(
|
xaccAccountSetCurrency(act, ref);
|
||||||
act, associate_commodity_ref_with_engine_commodity(ref));
|
|
||||||
gnc_commodity_destroy(ref);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,10 +133,9 @@ static gboolean
|
|||||||
account_security_handler (xmlNodePtr node, Account* act)
|
account_security_handler (xmlNodePtr node, Account* act)
|
||||||
{
|
{
|
||||||
gnc_commodity *ref;
|
gnc_commodity *ref;
|
||||||
ref = dom_tree_to_commodity_ref(node);
|
ref = dom_tree_to_commodity_ref_no_engine(node);
|
||||||
xaccAccountSetSecurity(
|
xaccAccountSetSecurity(act, ref);
|
||||||
act, associate_commodity_ref_with_engine_commodity(ref));
|
|
||||||
gnc_commodity_destroy(ref);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,6 +237,7 @@ all_required_gotten_p(struct dom_handlers *handler_ptr)
|
|||||||
{
|
{
|
||||||
if(handler_ptr->required && ! handler_ptr->gotten)
|
if(handler_ptr->required && ! handler_ptr->gotten)
|
||||||
{
|
{
|
||||||
|
g_warning("Not defined and it should be: %s", handler_ptr->tag);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
handler_ptr++;
|
handler_ptr++;
|
||||||
@ -254,6 +254,7 @@ gnc_xml_set_account_data(const gchar* tag, xmlNodePtr node, Account *acc,
|
|||||||
if(strcmp(tag, handler_ptr->tag) == 0)
|
if(strcmp(tag, handler_ptr->tag) == 0)
|
||||||
{
|
{
|
||||||
(handler_ptr->handler)(node, acc);
|
(handler_ptr->handler)(node, acc);
|
||||||
|
handler_ptr->gotten = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,13 +280,23 @@ gnc_account_end_handler(gpointer data_for_children,
|
|||||||
Account *acc;
|
Account *acc;
|
||||||
xmlNodePtr achild;
|
xmlNodePtr achild;
|
||||||
xmlNodePtr tree = (xmlNodePtr)data_for_children;
|
xmlNodePtr tree = (xmlNodePtr)data_for_children;
|
||||||
|
sixtp_gdv2 *gdata = (sixtp_gdv2*)global_data;
|
||||||
|
|
||||||
successful = TRUE;
|
successful = TRUE;
|
||||||
|
|
||||||
if(parent_data)
|
if(parent_data)
|
||||||
{
|
{
|
||||||
return successful;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* OK. For some messed up reason this is getting called again with a
|
||||||
|
NULL tag. So we ignore those cases */
|
||||||
|
if(!tag)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_return_val_if_fail(tree, FALSE);
|
||||||
|
|
||||||
acc = xaccMallocAccount();
|
acc = xaccMallocAccount();
|
||||||
g_return_val_if_fail(acc, FALSE);
|
g_return_val_if_fail(acc, FALSE);
|
||||||
@ -298,6 +309,7 @@ gnc_account_end_handler(gpointer data_for_children,
|
|||||||
if(!gnc_xml_set_account_data(achild->name, achild, acc,
|
if(!gnc_xml_set_account_data(achild->name, achild, acc,
|
||||||
account_handlers_v2))
|
account_handlers_v2))
|
||||||
{
|
{
|
||||||
|
g_warning("gnc_xml_set_account_data failed");
|
||||||
successful = FALSE;
|
successful = FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -307,6 +319,7 @@ gnc_account_end_handler(gpointer data_for_children,
|
|||||||
|
|
||||||
if(!all_required_gotten_p(account_handlers_v2))
|
if(!all_required_gotten_p(account_handlers_v2))
|
||||||
{
|
{
|
||||||
|
g_warning("all_required_gotten_p failed");
|
||||||
successful = FALSE;
|
successful = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,14 +329,10 @@ gnc_account_end_handler(gpointer data_for_children,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(!xaccAccountGetParent(acc))
|
gdata->addAccountFunc(global_data, acc);
|
||||||
{
|
|
||||||
/* FIXME: something like this */
|
|
||||||
/* xaccGroupInsertAccount(global_data, acc); */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
xmlFreeNode((xmlNodePtr) result);
|
xmlFreeNode(tree);
|
||||||
|
|
||||||
return successful;
|
return successful;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "gnc-xml.h"
|
#include "gnc-xml.h"
|
||||||
#include "gnc-engine-util.h"
|
#include "gnc-engine-util.h"
|
||||||
|
#include "io-gncxml-v2.h"
|
||||||
|
|
||||||
#include "sixtp-dom-parsers.h"
|
#include "sixtp-dom-parsers.h"
|
||||||
#include "AccountP.h"
|
#include "AccountP.h"
|
||||||
@ -127,6 +128,7 @@ gnc_commodity_end_handler(gpointer data_for_children,
|
|||||||
gnc_commodity *com;
|
gnc_commodity *com;
|
||||||
xmlNodePtr achild;
|
xmlNodePtr achild;
|
||||||
xmlNodePtr tree = (xmlNodePtr)data_for_children;
|
xmlNodePtr tree = (xmlNodePtr)data_for_children;
|
||||||
|
sixtp_gdv2 *globaldata = (sixtp_gdv2*)global_data;
|
||||||
|
|
||||||
if(parent_data)
|
if(parent_data)
|
||||||
{
|
{
|
||||||
@ -142,9 +144,13 @@ gnc_commodity_end_handler(gpointer data_for_children,
|
|||||||
|
|
||||||
if(!valid_commodity(com))
|
if(!valid_commodity(com))
|
||||||
{
|
{
|
||||||
|
gnc_commodity_destroy(com);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
globaldata->addCommodityFunc(globaldata, com);
|
||||||
|
|
||||||
|
gnc_commodity_destroy(com);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,9 +49,10 @@ gnc_transaction_end_handler(gpointer data_for_children,
|
|||||||
gpointer parent_data, gpointer global_data,
|
gpointer parent_data, gpointer global_data,
|
||||||
gpointer *result, const gchar *tag)
|
gpointer *result, const gchar *tag)
|
||||||
{
|
{
|
||||||
Transaction *com;
|
Transaction *tran;
|
||||||
xmlNodePtr achild;
|
xmlNodePtr achild;
|
||||||
xmlNodePtr tree = (xmlNodePtr)data_for_children;
|
xmlNodePtr tree = (xmlNodePtr)data_for_children;
|
||||||
|
sixtp_gdv2 *globaldata = (sixtp_gdv2*)global_data;
|
||||||
|
|
||||||
if(parent_data)
|
if(parent_data)
|
||||||
{
|
{
|
||||||
@ -63,6 +64,8 @@ gnc_transaction_end_handler(gpointer data_for_children,
|
|||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
globaldata->accTransactionFunc(globaldata, tran);
|
||||||
|
|
||||||
return TRUE
|
return TRUE
|
||||||
}
|
}
|
||||||
|
23
src/engine/io-gncxml-v2.c
Normal file
23
src/engine/io-gncxml-v2.c
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#include "io-gncxml-v2.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gnc_book_load_from_xml_file_v2(GNCBook *book)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gnc_book_write_to_xml_file_v2(GNCBook *book, const char *filename)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
gboolean gnc_is_xml_data_file_v2(const gchar *name)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
50
src/engine/io-gncxml-v2.h
Normal file
50
src/engine/io-gncxml-v2.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* io-gncxml.h -- api for new XML-based file format
|
||||||
|
*
|
||||||
|
* Initial code by James LewisMoss
|
||||||
|
*
|
||||||
|
* Copyright (c) 2001 Gnumatic Incorporated
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifndef __IO_GNCXML_V2_H__
|
||||||
|
#define __IO_GNCXML_V2_H__
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
#include "gnc-book.h"
|
||||||
|
#include "Account.h"
|
||||||
|
#include "Transaction.h"
|
||||||
|
#include "gnc-commodity.h"
|
||||||
|
|
||||||
|
struct sixtp_global_data_v2_struct
|
||||||
|
{
|
||||||
|
GNCBook *book;
|
||||||
|
gpointer data;
|
||||||
|
|
||||||
|
int value;
|
||||||
|
char *tag;
|
||||||
|
|
||||||
|
gboolean (*addAccountFunc)(struct sixtp_global_data_v2_struct *data,
|
||||||
|
Account *act);
|
||||||
|
gboolean (*addCommodityFunc)(struct sixtp_global_data_v2_struct *data,
|
||||||
|
gnc_commodity *com);
|
||||||
|
gboolean (*addTransactionFunc)(struct sixtp_global_data_v2_struct *data,
|
||||||
|
Transaction *act);
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct sixtp_global_data_v2_struct sixtp_gdv2;
|
||||||
|
|
||||||
|
/* read in an account group from a file */
|
||||||
|
gboolean gnc_book_load_from_xml_file_v2(GNCBook *book);
|
||||||
|
|
||||||
|
/* write all account info to a file */
|
||||||
|
gboolean gnc_book_write_to_xml_file_v2(GNCBook *book, const char *filename);
|
||||||
|
|
||||||
|
/* The is_gncxml_file() routine checks to see if the first few
|
||||||
|
* chars of the file look like gnc-xml data.
|
||||||
|
*/
|
||||||
|
gboolean gnc_is_xml_data_file_v2(const gchar *name);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __IO_GNCXML_V2_H__ */
|
Loading…
Reference in New Issue
Block a user