Files
gnucash/src/engine/gnc-account-xml-v2.c

358 lines
9.9 KiB
C
Raw Normal View History

/********************************************************************\
* gnc-account-xml-v2.c -- account xml i/o implementation *
* *
* Copyright (C) 2001 James LewisMoss <dres@debian.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, contact: *
* *
* Free Software Foundation Voice: +1-617-542-5942 *
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
* Boston, MA 02111-1307, USA gnu@gnu.org *
* *
\********************************************************************/
#include "config.h"
#include <glib.h>
#include <string.h>
#include "gnc-xml-helper.h"
#include "sixtp.h"
#include "sixtp-utils.h"
#include "sixtp-parsers.h"
#include "sixtp-utils.h"
#include "sixtp-dom-parsers.h"
#include "sixtp-dom-generators.h"
#include "gnc-xml.h"
#include "io-gncxml-gen.h"
#include "sixtp-dom-parsers.h"
#include "AccountP.h"
#include "Account.h"
#include "Group.h"
const gchar *account_version_string = "2.0.0";
/* ids */
#define gnc_account_string "gnc:account"
#define act_name_string "act:name"
#define act_id_string "act:id"
#define act_type_string "act:type"
#define act_currency_string "act:currency"
#define act_currency_scu_string "act:currency-scu"
#define act_code_string "act:code"
#define act_description_string "act:description"
#define act_security_string "act:security"
#define act_security_scu_string "act:security-scu"
#define act_slots_string "act:slots"
#define act_parent_string "act:parent"
xmlNodePtr
gnc_account_dom_tree_create(Account *act)
{
xmlNodePtr ret;
ret = xmlNewNode(NULL, gnc_account_string);
xmlSetProp(ret, "version", account_version_string);
James LewisMoss's patch. * src/engine/io-gncxml-v2.c (gnc_counter_end_handler): complete func. (print_counter_data): new func. (gnc_book_load_from_xml_file_v2): call above func at end of parse. * src/engine/sixtp-dom-parsers.c (string_to_integer): move here from gnc-commodity-xml-v2.c * src/engine/io-gncxml-v2.c (gnc_book_write_to_xml_file_v2): add transaction number output. * src/engine/Group.c (xaccGroupForEachTransaction): actually make this work. (xaccGroupVisitUnvisitedTransactions): actually make this work. Don't get accounts from group. We already are looking at all of them by xaccGroupGetSubAccounts. (xaccGroupVisitUnvisitedTransactions_thunk): new func for xaccAccountForEachTransaction call. * src/test/test-string-converters.c (test_string_converters): add func to test some more difficult strings (including xml special characters) * src/engine/gnc-account-xml-v2.c (gnc_account_dom_tree_create): convert to use text_to_dom_tree. * src/engine/gnc-commodity-xml-v2.c (gnc_commodity_dom_tree_create): convert to use text_to_dom_tree. * src/engine/gnc-book.c (gnc_book_count_transactions): new func. * src/engine/io-gncxml-v2.c: (write_account_group)new func. extract out stuff from write_accounts. Forgot to traverse down accounts so a bunch of the accounts weren't being written. (write_accounts): now just call the write_account_group func. (gnc_book_write_to_xml_file_v2): use xaccGroupNumSubAccounts to get the number of accounts. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3774 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-13 21:05:09 +00:00
xmlAddChild(ret, text_to_dom_tree(act_name_string, xaccAccountGetName(act)));
xmlAddChild(ret, guid_to_dom_tree(act_id_string, xaccAccountGetGUID(act)));
James LewisMoss's patch. * src/engine/io-gncxml-v2.c (gnc_counter_end_handler): complete func. (print_counter_data): new func. (gnc_book_load_from_xml_file_v2): call above func at end of parse. * src/engine/sixtp-dom-parsers.c (string_to_integer): move here from gnc-commodity-xml-v2.c * src/engine/io-gncxml-v2.c (gnc_book_write_to_xml_file_v2): add transaction number output. * src/engine/Group.c (xaccGroupForEachTransaction): actually make this work. (xaccGroupVisitUnvisitedTransactions): actually make this work. Don't get accounts from group. We already are looking at all of them by xaccGroupGetSubAccounts. (xaccGroupVisitUnvisitedTransactions_thunk): new func for xaccAccountForEachTransaction call. * src/test/test-string-converters.c (test_string_converters): add func to test some more difficult strings (including xml special characters) * src/engine/gnc-account-xml-v2.c (gnc_account_dom_tree_create): convert to use text_to_dom_tree. * src/engine/gnc-commodity-xml-v2.c (gnc_commodity_dom_tree_create): convert to use text_to_dom_tree. * src/engine/gnc-book.c (gnc_book_count_transactions): new func. * src/engine/io-gncxml-v2.c: (write_account_group)new func. extract out stuff from write_accounts. Forgot to traverse down accounts so a bunch of the accounts weren't being written. (write_accounts): now just call the write_account_group func. (gnc_book_write_to_xml_file_v2): use xaccGroupNumSubAccounts to get the number of accounts. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3774 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-13 21:05:09 +00:00
xmlAddChild(ret, text_to_dom_tree(
act_type_string,
xaccAccountTypeEnumAsString(xaccAccountGetType(act))));
xmlAddChild(ret, commodity_ref_to_dom_tree(act_currency_string,
xaccAccountGetCurrency(act)));
xmlAddChild(ret, int_to_dom_tree(act_currency_scu_string,
xaccAccountGetCurrencySCU(act)));
James LewisMoss's patch. * src/gnome/window-main.c (gnc_ui_xml_v2_cb): new func. (gnc_ui_account_heirarchy_cb): new empty func. (gnc_main_create_menus): add devel menu. * src/engine/io-gncxml-v2.h (struct _load_counter_struct): add counters stuff. * src/engine/io-gncxml-v2.c: mostly complete everything. Writing only partially tested. Reading not tested at all. * src/engine/gnc-xml.h: add pricedb declarations. * src/engine/gnc-transaction-xml-v2.c (split_to_dom_tree): check for NULL return from kvp_frame_to_dom_tree and don't add if we get it. (gnc_transaction_dom_tree_create): same. * src/engine/gnc-commodity.c (gnc_commodity_table_get_size): add func. * src/engine/gnc-account-xml-v2.c (gnc_account_dom_tree_create): check for NULL return from kvp_frame_to_dom_tree and don't do anything if we get it. * src/gnome/gnc-http.c (gnc_http_start_post): cast data to char* (it's const char*) (compile warning) * src/gnome/gnc-html.c: put const on char *ptr (compile warning) * src/doc/xml/io-gncxml-version2.dtd: reorder commodity and prices. Add count data defs. * src/engine/sixtp-dom-generators.c (timespec_to_dom_tree): Only write nanoseconds if > 0. (kvp_frame_to_dom_tree): don't return an xmlNodePtr if the frame is null or contains no data. * src/engine/gnc-commodity-xml-v2.c (gnc_commodity_dom_tree_create): check to see if xcode is > 0 * src/engine/gnc-account-xml-v2.c (gnc_account_dom_tree_create): check for description and code strlen > 0 * src/engine/gnc-pricedb-xml-v1.c (pricedb_v2_end_handler): make this func work in the v2 manner with a callback in the global data. (gnc_pricedb_sixtp_parser_create): change to work in the v2 manner with an end handler that does the final link of the data into the book. (pricedb_after_child_handler): add upping the counter for prices loaded. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3772 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-13 06:20:03 +00:00
if(xaccAccountGetCode(act) &&
strlen(xaccAccountGetCode(act)) > 0)
{
James LewisMoss's patch. * src/engine/io-gncxml-v2.c (gnc_counter_end_handler): complete func. (print_counter_data): new func. (gnc_book_load_from_xml_file_v2): call above func at end of parse. * src/engine/sixtp-dom-parsers.c (string_to_integer): move here from gnc-commodity-xml-v2.c * src/engine/io-gncxml-v2.c (gnc_book_write_to_xml_file_v2): add transaction number output. * src/engine/Group.c (xaccGroupForEachTransaction): actually make this work. (xaccGroupVisitUnvisitedTransactions): actually make this work. Don't get accounts from group. We already are looking at all of them by xaccGroupGetSubAccounts. (xaccGroupVisitUnvisitedTransactions_thunk): new func for xaccAccountForEachTransaction call. * src/test/test-string-converters.c (test_string_converters): add func to test some more difficult strings (including xml special characters) * src/engine/gnc-account-xml-v2.c (gnc_account_dom_tree_create): convert to use text_to_dom_tree. * src/engine/gnc-commodity-xml-v2.c (gnc_commodity_dom_tree_create): convert to use text_to_dom_tree. * src/engine/gnc-book.c (gnc_book_count_transactions): new func. * src/engine/io-gncxml-v2.c: (write_account_group)new func. extract out stuff from write_accounts. Forgot to traverse down accounts so a bunch of the accounts weren't being written. (write_accounts): now just call the write_account_group func. (gnc_book_write_to_xml_file_v2): use xaccGroupNumSubAccounts to get the number of accounts. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3774 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-13 21:05:09 +00:00
xmlAddChild(ret, text_to_dom_tree(act_code_string,
xaccAccountGetCode(act)));
}
James LewisMoss's patch. * src/gnome/window-main.c (gnc_ui_xml_v2_cb): new func. (gnc_ui_account_heirarchy_cb): new empty func. (gnc_main_create_menus): add devel menu. * src/engine/io-gncxml-v2.h (struct _load_counter_struct): add counters stuff. * src/engine/io-gncxml-v2.c: mostly complete everything. Writing only partially tested. Reading not tested at all. * src/engine/gnc-xml.h: add pricedb declarations. * src/engine/gnc-transaction-xml-v2.c (split_to_dom_tree): check for NULL return from kvp_frame_to_dom_tree and don't add if we get it. (gnc_transaction_dom_tree_create): same. * src/engine/gnc-commodity.c (gnc_commodity_table_get_size): add func. * src/engine/gnc-account-xml-v2.c (gnc_account_dom_tree_create): check for NULL return from kvp_frame_to_dom_tree and don't do anything if we get it. * src/gnome/gnc-http.c (gnc_http_start_post): cast data to char* (it's const char*) (compile warning) * src/gnome/gnc-html.c: put const on char *ptr (compile warning) * src/doc/xml/io-gncxml-version2.dtd: reorder commodity and prices. Add count data defs. * src/engine/sixtp-dom-generators.c (timespec_to_dom_tree): Only write nanoseconds if > 0. (kvp_frame_to_dom_tree): don't return an xmlNodePtr if the frame is null or contains no data. * src/engine/gnc-commodity-xml-v2.c (gnc_commodity_dom_tree_create): check to see if xcode is > 0 * src/engine/gnc-account-xml-v2.c (gnc_account_dom_tree_create): check for description and code strlen > 0 * src/engine/gnc-pricedb-xml-v1.c (pricedb_v2_end_handler): make this func work in the v2 manner with a callback in the global data. (gnc_pricedb_sixtp_parser_create): change to work in the v2 manner with an end handler that does the final link of the data into the book. (pricedb_after_child_handler): add upping the counter for prices loaded. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3772 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-13 06:20:03 +00:00
if(xaccAccountGetDescription(act) &&
strlen(xaccAccountGetDescription(act)) > 0)
{
James LewisMoss's patch. * src/engine/io-gncxml-v2.c (gnc_counter_end_handler): complete func. (print_counter_data): new func. (gnc_book_load_from_xml_file_v2): call above func at end of parse. * src/engine/sixtp-dom-parsers.c (string_to_integer): move here from gnc-commodity-xml-v2.c * src/engine/io-gncxml-v2.c (gnc_book_write_to_xml_file_v2): add transaction number output. * src/engine/Group.c (xaccGroupForEachTransaction): actually make this work. (xaccGroupVisitUnvisitedTransactions): actually make this work. Don't get accounts from group. We already are looking at all of them by xaccGroupGetSubAccounts. (xaccGroupVisitUnvisitedTransactions_thunk): new func for xaccAccountForEachTransaction call. * src/test/test-string-converters.c (test_string_converters): add func to test some more difficult strings (including xml special characters) * src/engine/gnc-account-xml-v2.c (gnc_account_dom_tree_create): convert to use text_to_dom_tree. * src/engine/gnc-commodity-xml-v2.c (gnc_commodity_dom_tree_create): convert to use text_to_dom_tree. * src/engine/gnc-book.c (gnc_book_count_transactions): new func. * src/engine/io-gncxml-v2.c: (write_account_group)new func. extract out stuff from write_accounts. Forgot to traverse down accounts so a bunch of the accounts weren't being written. (write_accounts): now just call the write_account_group func. (gnc_book_write_to_xml_file_v2): use xaccGroupNumSubAccounts to get the number of accounts. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3774 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-13 21:05:09 +00:00
xmlAddChild(ret, text_to_dom_tree(act_description_string,
xaccAccountGetDescription(act)));
}
if(xaccAccountGetSecurity(act))
{
xmlAddChild(ret, commodity_ref_to_dom_tree(act_security_string,
xaccAccountGetSecurity(act)));
xmlAddChild(ret, int_to_dom_tree(act_security_scu_string,
xaccAccountGetCommoditySCU(act)));
}
if(xaccAccountGetSlots(act))
{
James LewisMoss's patch. * src/gnome/window-main.c (gnc_ui_xml_v2_cb): new func. (gnc_ui_account_heirarchy_cb): new empty func. (gnc_main_create_menus): add devel menu. * src/engine/io-gncxml-v2.h (struct _load_counter_struct): add counters stuff. * src/engine/io-gncxml-v2.c: mostly complete everything. Writing only partially tested. Reading not tested at all. * src/engine/gnc-xml.h: add pricedb declarations. * src/engine/gnc-transaction-xml-v2.c (split_to_dom_tree): check for NULL return from kvp_frame_to_dom_tree and don't add if we get it. (gnc_transaction_dom_tree_create): same. * src/engine/gnc-commodity.c (gnc_commodity_table_get_size): add func. * src/engine/gnc-account-xml-v2.c (gnc_account_dom_tree_create): check for NULL return from kvp_frame_to_dom_tree and don't do anything if we get it. * src/gnome/gnc-http.c (gnc_http_start_post): cast data to char* (it's const char*) (compile warning) * src/gnome/gnc-html.c: put const on char *ptr (compile warning) * src/doc/xml/io-gncxml-version2.dtd: reorder commodity and prices. Add count data defs. * src/engine/sixtp-dom-generators.c (timespec_to_dom_tree): Only write nanoseconds if > 0. (kvp_frame_to_dom_tree): don't return an xmlNodePtr if the frame is null or contains no data. * src/engine/gnc-commodity-xml-v2.c (gnc_commodity_dom_tree_create): check to see if xcode is > 0 * src/engine/gnc-account-xml-v2.c (gnc_account_dom_tree_create): check for description and code strlen > 0 * src/engine/gnc-pricedb-xml-v1.c (pricedb_v2_end_handler): make this func work in the v2 manner with a callback in the global data. (gnc_pricedb_sixtp_parser_create): change to work in the v2 manner with an end handler that does the final link of the data into the book. (pricedb_after_child_handler): add upping the counter for prices loaded. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3772 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-13 06:20:03 +00:00
xmlNodePtr kvpnode = kvp_frame_to_dom_tree(act_slots_string,
xaccAccountGetSlots(act));
if(kvpnode)
{
xmlAddChild(ret, kvpnode);
}
}
if(xaccAccountGetParentAccount(act))
{
xmlAddChild(ret, guid_to_dom_tree(
act_parent_string,
xaccAccountGetGUID(xaccAccountGetParentAccount(act))));
}
return ret;
}
/***********************************************************************/
James LewisMoss's patch. * src/test/test-stuff.c (failure): don't print num if == -1. (success): same. (get_random_account): move here from test-xml-account.c (get_random_split): move here from test-xml-transaction.c (get_random_transaction): same. (success_args): New func. (success): Simplified version (failure_args): new func. (failure): Simplified version. * src/engine/io-gncbin-r.c: same as below. * src/engine/TransLog.c (xaccTransWriteLog): same as below. * src/engine/Group.c (xaccGroupMergeAccounts): same as below. * src/engine/Backend.c (xaccTransactionGetBackend): Convert to not use the split's acc part directly, but only to access through funcs * src/engine/sixtp-dom-parsers.c (dom_tree_generic_parse): Add generic parser. * src/engine/gnc-account-xml-v2.c (gnc_account_end_handler): use generic parser extracted from here and used here and gnc-transaction-iml-v2.c * src/engine/Transaction.c (xaccInitSplit): Add a split->acc_guid field that is set to the account's guid. This way an Account is not required to exist yet when loading the split. Later when xaccSplitGetAccount is called the account is looked up, cached and returned. Make sure everything accesses ->acc through the helper function. * src/engine/AccountP.h: same as below. * src/engine/Account.c (xaccAccountSetGUID): mark guid argument const since it doesn't keep a pointer to it. * src/doc/xml/transactions-v2.dtd: change guid -> id. * src/engine/Transaction.c (get_denom_internal): New helper func. (get_currency_denom): use func. (get_security_denom): use func. * src/engine/sixtp.c: (sixtp_sax_end_handler, sixtp_sax_characters_handler, sixtp_sax_start_handler): don't use g_return_if_fail to test pdata->parsing_ok so we don't see the million CRITICAL warnings. We'll print an error at the end anyway. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3762 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-09 07:46:13 +00:00
static gboolean
James LewisMoss's patch. * src/test/test-stuff.c (failure): don't print num if == -1. (success): same. (get_random_account): move here from test-xml-account.c (get_random_split): move here from test-xml-transaction.c (get_random_transaction): same. (success_args): New func. (success): Simplified version (failure_args): new func. (failure): Simplified version. * src/engine/io-gncbin-r.c: same as below. * src/engine/TransLog.c (xaccTransWriteLog): same as below. * src/engine/Group.c (xaccGroupMergeAccounts): same as below. * src/engine/Backend.c (xaccTransactionGetBackend): Convert to not use the split's acc part directly, but only to access through funcs * src/engine/sixtp-dom-parsers.c (dom_tree_generic_parse): Add generic parser. * src/engine/gnc-account-xml-v2.c (gnc_account_end_handler): use generic parser extracted from here and used here and gnc-transaction-iml-v2.c * src/engine/Transaction.c (xaccInitSplit): Add a split->acc_guid field that is set to the account's guid. This way an Account is not required to exist yet when loading the split. Later when xaccSplitGetAccount is called the account is looked up, cached and returned. Make sure everything accesses ->acc through the helper function. * src/engine/AccountP.h: same as below. * src/engine/Account.c (xaccAccountSetGUID): mark guid argument const since it doesn't keep a pointer to it. * src/doc/xml/transactions-v2.dtd: change guid -> id. * src/engine/Transaction.c (get_denom_internal): New helper func. (get_currency_denom): use func. (get_security_denom): use func. * src/engine/sixtp.c: (sixtp_sax_end_handler, sixtp_sax_characters_handler, sixtp_sax_start_handler): don't use g_return_if_fail to test pdata->parsing_ok so we don't see the million CRITICAL warnings. We'll print an error at the end anyway. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3762 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-09 07:46:13 +00:00
set_string(xmlNodePtr node, Account* act,
void (*func)(Account *act, const gchar *txt))
{
James LewisMoss's patch. * src/test/test-stuff.c (failure): don't print num if == -1. (success): same. (get_random_account): move here from test-xml-account.c (get_random_split): move here from test-xml-transaction.c (get_random_transaction): same. (success_args): New func. (success): Simplified version (failure_args): new func. (failure): Simplified version. * src/engine/io-gncbin-r.c: same as below. * src/engine/TransLog.c (xaccTransWriteLog): same as below. * src/engine/Group.c (xaccGroupMergeAccounts): same as below. * src/engine/Backend.c (xaccTransactionGetBackend): Convert to not use the split's acc part directly, but only to access through funcs * src/engine/sixtp-dom-parsers.c (dom_tree_generic_parse): Add generic parser. * src/engine/gnc-account-xml-v2.c (gnc_account_end_handler): use generic parser extracted from here and used here and gnc-transaction-iml-v2.c * src/engine/Transaction.c (xaccInitSplit): Add a split->acc_guid field that is set to the account's guid. This way an Account is not required to exist yet when loading the split. Later when xaccSplitGetAccount is called the account is looked up, cached and returned. Make sure everything accesses ->acc through the helper function. * src/engine/AccountP.h: same as below. * src/engine/Account.c (xaccAccountSetGUID): mark guid argument const since it doesn't keep a pointer to it. * src/doc/xml/transactions-v2.dtd: change guid -> id. * src/engine/Transaction.c (get_denom_internal): New helper func. (get_currency_denom): use func. (get_security_denom): use func. * src/engine/sixtp.c: (sixtp_sax_end_handler, sixtp_sax_characters_handler, sixtp_sax_start_handler): don't use g_return_if_fail to test pdata->parsing_ok so we don't see the million CRITICAL warnings. We'll print an error at the end anyway. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3762 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-09 07:46:13 +00:00
gchar* txt = dom_tree_to_text(node);
g_return_val_if_fail(txt, FALSE);
James LewisMoss's patch. * src/test/test-stuff.c (failure): don't print num if == -1. (success): same. (get_random_account): move here from test-xml-account.c (get_random_split): move here from test-xml-transaction.c (get_random_transaction): same. (success_args): New func. (success): Simplified version (failure_args): new func. (failure): Simplified version. * src/engine/io-gncbin-r.c: same as below. * src/engine/TransLog.c (xaccTransWriteLog): same as below. * src/engine/Group.c (xaccGroupMergeAccounts): same as below. * src/engine/Backend.c (xaccTransactionGetBackend): Convert to not use the split's acc part directly, but only to access through funcs * src/engine/sixtp-dom-parsers.c (dom_tree_generic_parse): Add generic parser. * src/engine/gnc-account-xml-v2.c (gnc_account_end_handler): use generic parser extracted from here and used here and gnc-transaction-iml-v2.c * src/engine/Transaction.c (xaccInitSplit): Add a split->acc_guid field that is set to the account's guid. This way an Account is not required to exist yet when loading the split. Later when xaccSplitGetAccount is called the account is looked up, cached and returned. Make sure everything accesses ->acc through the helper function. * src/engine/AccountP.h: same as below. * src/engine/Account.c (xaccAccountSetGUID): mark guid argument const since it doesn't keep a pointer to it. * src/doc/xml/transactions-v2.dtd: change guid -> id. * src/engine/Transaction.c (get_denom_internal): New helper func. (get_currency_denom): use func. (get_security_denom): use func. * src/engine/sixtp.c: (sixtp_sax_end_handler, sixtp_sax_characters_handler, sixtp_sax_start_handler): don't use g_return_if_fail to test pdata->parsing_ok so we don't see the million CRITICAL warnings. We'll print an error at the end anyway. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3762 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-09 07:46:13 +00:00
func(act, txt);
g_free(txt);
return TRUE;
}
static gboolean
James LewisMoss's patch. * src/test/test-stuff.c (failure): don't print num if == -1. (success): same. (get_random_account): move here from test-xml-account.c (get_random_split): move here from test-xml-transaction.c (get_random_transaction): same. (success_args): New func. (success): Simplified version (failure_args): new func. (failure): Simplified version. * src/engine/io-gncbin-r.c: same as below. * src/engine/TransLog.c (xaccTransWriteLog): same as below. * src/engine/Group.c (xaccGroupMergeAccounts): same as below. * src/engine/Backend.c (xaccTransactionGetBackend): Convert to not use the split's acc part directly, but only to access through funcs * src/engine/sixtp-dom-parsers.c (dom_tree_generic_parse): Add generic parser. * src/engine/gnc-account-xml-v2.c (gnc_account_end_handler): use generic parser extracted from here and used here and gnc-transaction-iml-v2.c * src/engine/Transaction.c (xaccInitSplit): Add a split->acc_guid field that is set to the account's guid. This way an Account is not required to exist yet when loading the split. Later when xaccSplitGetAccount is called the account is looked up, cached and returned. Make sure everything accesses ->acc through the helper function. * src/engine/AccountP.h: same as below. * src/engine/Account.c (xaccAccountSetGUID): mark guid argument const since it doesn't keep a pointer to it. * src/doc/xml/transactions-v2.dtd: change guid -> id. * src/engine/Transaction.c (get_denom_internal): New helper func. (get_currency_denom): use func. (get_security_denom): use func. * src/engine/sixtp.c: (sixtp_sax_end_handler, sixtp_sax_characters_handler, sixtp_sax_start_handler): don't use g_return_if_fail to test pdata->parsing_ok so we don't see the million CRITICAL warnings. We'll print an error at the end anyway. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3762 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-09 07:46:13 +00:00
account_name_handler (xmlNodePtr node, gpointer act)
{
return set_string(node, (Account*)act, xaccAccountSetName);
}
static gboolean
account_id_handler (xmlNodePtr node, gpointer act)
{
GUID *guid;
guid = dom_tree_to_guid(node);
James LewisMoss's patch. * src/test/test-stuff.c (failure): don't print num if == -1. (success): same. (get_random_account): move here from test-xml-account.c (get_random_split): move here from test-xml-transaction.c (get_random_transaction): same. (success_args): New func. (success): Simplified version (failure_args): new func. (failure): Simplified version. * src/engine/io-gncbin-r.c: same as below. * src/engine/TransLog.c (xaccTransWriteLog): same as below. * src/engine/Group.c (xaccGroupMergeAccounts): same as below. * src/engine/Backend.c (xaccTransactionGetBackend): Convert to not use the split's acc part directly, but only to access through funcs * src/engine/sixtp-dom-parsers.c (dom_tree_generic_parse): Add generic parser. * src/engine/gnc-account-xml-v2.c (gnc_account_end_handler): use generic parser extracted from here and used here and gnc-transaction-iml-v2.c * src/engine/Transaction.c (xaccInitSplit): Add a split->acc_guid field that is set to the account's guid. This way an Account is not required to exist yet when loading the split. Later when xaccSplitGetAccount is called the account is looked up, cached and returned. Make sure everything accesses ->acc through the helper function. * src/engine/AccountP.h: same as below. * src/engine/Account.c (xaccAccountSetGUID): mark guid argument const since it doesn't keep a pointer to it. * src/doc/xml/transactions-v2.dtd: change guid -> id. * src/engine/Transaction.c (get_denom_internal): New helper func. (get_currency_denom): use func. (get_security_denom): use func. * src/engine/sixtp.c: (sixtp_sax_end_handler, sixtp_sax_characters_handler, sixtp_sax_start_handler): don't use g_return_if_fail to test pdata->parsing_ok so we don't see the million CRITICAL warnings. We'll print an error at the end anyway. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3762 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-09 07:46:13 +00:00
xaccAccountSetGUID((Account*)act, guid);
g_free(guid);
return TRUE;
}
static gboolean
James LewisMoss's patch. * src/test/test-stuff.c (failure): don't print num if == -1. (success): same. (get_random_account): move here from test-xml-account.c (get_random_split): move here from test-xml-transaction.c (get_random_transaction): same. (success_args): New func. (success): Simplified version (failure_args): new func. (failure): Simplified version. * src/engine/io-gncbin-r.c: same as below. * src/engine/TransLog.c (xaccTransWriteLog): same as below. * src/engine/Group.c (xaccGroupMergeAccounts): same as below. * src/engine/Backend.c (xaccTransactionGetBackend): Convert to not use the split's acc part directly, but only to access through funcs * src/engine/sixtp-dom-parsers.c (dom_tree_generic_parse): Add generic parser. * src/engine/gnc-account-xml-v2.c (gnc_account_end_handler): use generic parser extracted from here and used here and gnc-transaction-iml-v2.c * src/engine/Transaction.c (xaccInitSplit): Add a split->acc_guid field that is set to the account's guid. This way an Account is not required to exist yet when loading the split. Later when xaccSplitGetAccount is called the account is looked up, cached and returned. Make sure everything accesses ->acc through the helper function. * src/engine/AccountP.h: same as below. * src/engine/Account.c (xaccAccountSetGUID): mark guid argument const since it doesn't keep a pointer to it. * src/doc/xml/transactions-v2.dtd: change guid -> id. * src/engine/Transaction.c (get_denom_internal): New helper func. (get_currency_denom): use func. (get_security_denom): use func. * src/engine/sixtp.c: (sixtp_sax_end_handler, sixtp_sax_characters_handler, sixtp_sax_start_handler): don't use g_return_if_fail to test pdata->parsing_ok so we don't see the million CRITICAL warnings. We'll print an error at the end anyway. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3762 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-09 07:46:13 +00:00
account_type_handler (xmlNodePtr node, gpointer act)
{
int type;
char *string;
string = xmlNodeGetContent (node->xmlChildrenNode);
xaccAccountStringToType(string, &type);
xmlFree (string);
James LewisMoss's patch. * src/test/test-stuff.c (failure): don't print num if == -1. (success): same. (get_random_account): move here from test-xml-account.c (get_random_split): move here from test-xml-transaction.c (get_random_transaction): same. (success_args): New func. (success): Simplified version (failure_args): new func. (failure): Simplified version. * src/engine/io-gncbin-r.c: same as below. * src/engine/TransLog.c (xaccTransWriteLog): same as below. * src/engine/Group.c (xaccGroupMergeAccounts): same as below. * src/engine/Backend.c (xaccTransactionGetBackend): Convert to not use the split's acc part directly, but only to access through funcs * src/engine/sixtp-dom-parsers.c (dom_tree_generic_parse): Add generic parser. * src/engine/gnc-account-xml-v2.c (gnc_account_end_handler): use generic parser extracted from here and used here and gnc-transaction-iml-v2.c * src/engine/Transaction.c (xaccInitSplit): Add a split->acc_guid field that is set to the account's guid. This way an Account is not required to exist yet when loading the split. Later when xaccSplitGetAccount is called the account is looked up, cached and returned. Make sure everything accesses ->acc through the helper function. * src/engine/AccountP.h: same as below. * src/engine/Account.c (xaccAccountSetGUID): mark guid argument const since it doesn't keep a pointer to it. * src/doc/xml/transactions-v2.dtd: change guid -> id. * src/engine/Transaction.c (get_denom_internal): New helper func. (get_currency_denom): use func. (get_security_denom): use func. * src/engine/sixtp.c: (sixtp_sax_end_handler, sixtp_sax_characters_handler, sixtp_sax_start_handler): don't use g_return_if_fail to test pdata->parsing_ok so we don't see the million CRITICAL warnings. We'll print an error at the end anyway. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3762 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-09 07:46:13 +00:00
xaccAccountSetType((Account*)act, type);
return TRUE;
}
static gboolean
James LewisMoss's patch. * src/test/test-stuff.c (failure): don't print num if == -1. (success): same. (get_random_account): move here from test-xml-account.c (get_random_split): move here from test-xml-transaction.c (get_random_transaction): same. (success_args): New func. (success): Simplified version (failure_args): new func. (failure): Simplified version. * src/engine/io-gncbin-r.c: same as below. * src/engine/TransLog.c (xaccTransWriteLog): same as below. * src/engine/Group.c (xaccGroupMergeAccounts): same as below. * src/engine/Backend.c (xaccTransactionGetBackend): Convert to not use the split's acc part directly, but only to access through funcs * src/engine/sixtp-dom-parsers.c (dom_tree_generic_parse): Add generic parser. * src/engine/gnc-account-xml-v2.c (gnc_account_end_handler): use generic parser extracted from here and used here and gnc-transaction-iml-v2.c * src/engine/Transaction.c (xaccInitSplit): Add a split->acc_guid field that is set to the account's guid. This way an Account is not required to exist yet when loading the split. Later when xaccSplitGetAccount is called the account is looked up, cached and returned. Make sure everything accesses ->acc through the helper function. * src/engine/AccountP.h: same as below. * src/engine/Account.c (xaccAccountSetGUID): mark guid argument const since it doesn't keep a pointer to it. * src/doc/xml/transactions-v2.dtd: change guid -> id. * src/engine/Transaction.c (get_denom_internal): New helper func. (get_currency_denom): use func. (get_security_denom): use func. * src/engine/sixtp.c: (sixtp_sax_end_handler, sixtp_sax_characters_handler, sixtp_sax_start_handler): don't use g_return_if_fail to test pdata->parsing_ok so we don't see the million CRITICAL warnings. We'll print an error at the end anyway. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3762 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-09 07:46:13 +00:00
account_currency_handler (xmlNodePtr node, gpointer act)
{
gnc_commodity *ref;
ref = dom_tree_to_commodity_ref_no_engine(node);
James LewisMoss's patch. * src/test/test-stuff.c (failure): don't print num if == -1. (success): same. (get_random_account): move here from test-xml-account.c (get_random_split): move here from test-xml-transaction.c (get_random_transaction): same. (success_args): New func. (success): Simplified version (failure_args): new func. (failure): Simplified version. * src/engine/io-gncbin-r.c: same as below. * src/engine/TransLog.c (xaccTransWriteLog): same as below. * src/engine/Group.c (xaccGroupMergeAccounts): same as below. * src/engine/Backend.c (xaccTransactionGetBackend): Convert to not use the split's acc part directly, but only to access through funcs * src/engine/sixtp-dom-parsers.c (dom_tree_generic_parse): Add generic parser. * src/engine/gnc-account-xml-v2.c (gnc_account_end_handler): use generic parser extracted from here and used here and gnc-transaction-iml-v2.c * src/engine/Transaction.c (xaccInitSplit): Add a split->acc_guid field that is set to the account's guid. This way an Account is not required to exist yet when loading the split. Later when xaccSplitGetAccount is called the account is looked up, cached and returned. Make sure everything accesses ->acc through the helper function. * src/engine/AccountP.h: same as below. * src/engine/Account.c (xaccAccountSetGUID): mark guid argument const since it doesn't keep a pointer to it. * src/doc/xml/transactions-v2.dtd: change guid -> id. * src/engine/Transaction.c (get_denom_internal): New helper func. (get_currency_denom): use func. (get_security_denom): use func. * src/engine/sixtp.c: (sixtp_sax_end_handler, sixtp_sax_characters_handler, sixtp_sax_start_handler): don't use g_return_if_fail to test pdata->parsing_ok so we don't see the million CRITICAL warnings. We'll print an error at the end anyway. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3762 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-09 07:46:13 +00:00
xaccAccountSetCurrency((Account*)act, ref);
return TRUE;
}
static gboolean
account_currency_scu_handler (xmlNodePtr node, gpointer act)
{
gint64 val;
dom_tree_to_integer(node, &val);
xaccAccountSetCurrencySCU((Account*)act, val);
return TRUE;
}
static gboolean
James LewisMoss's patch. * src/test/test-stuff.c (failure): don't print num if == -1. (success): same. (get_random_account): move here from test-xml-account.c (get_random_split): move here from test-xml-transaction.c (get_random_transaction): same. (success_args): New func. (success): Simplified version (failure_args): new func. (failure): Simplified version. * src/engine/io-gncbin-r.c: same as below. * src/engine/TransLog.c (xaccTransWriteLog): same as below. * src/engine/Group.c (xaccGroupMergeAccounts): same as below. * src/engine/Backend.c (xaccTransactionGetBackend): Convert to not use the split's acc part directly, but only to access through funcs * src/engine/sixtp-dom-parsers.c (dom_tree_generic_parse): Add generic parser. * src/engine/gnc-account-xml-v2.c (gnc_account_end_handler): use generic parser extracted from here and used here and gnc-transaction-iml-v2.c * src/engine/Transaction.c (xaccInitSplit): Add a split->acc_guid field that is set to the account's guid. This way an Account is not required to exist yet when loading the split. Later when xaccSplitGetAccount is called the account is looked up, cached and returned. Make sure everything accesses ->acc through the helper function. * src/engine/AccountP.h: same as below. * src/engine/Account.c (xaccAccountSetGUID): mark guid argument const since it doesn't keep a pointer to it. * src/doc/xml/transactions-v2.dtd: change guid -> id. * src/engine/Transaction.c (get_denom_internal): New helper func. (get_currency_denom): use func. (get_security_denom): use func. * src/engine/sixtp.c: (sixtp_sax_end_handler, sixtp_sax_characters_handler, sixtp_sax_start_handler): don't use g_return_if_fail to test pdata->parsing_ok so we don't see the million CRITICAL warnings. We'll print an error at the end anyway. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3762 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-09 07:46:13 +00:00
account_security_handler (xmlNodePtr node, gpointer act)
{
gnc_commodity *ref;
ref = dom_tree_to_commodity_ref_no_engine(node);
James LewisMoss's patch. * src/test/test-stuff.c (failure): don't print num if == -1. (success): same. (get_random_account): move here from test-xml-account.c (get_random_split): move here from test-xml-transaction.c (get_random_transaction): same. (success_args): New func. (success): Simplified version (failure_args): new func. (failure): Simplified version. * src/engine/io-gncbin-r.c: same as below. * src/engine/TransLog.c (xaccTransWriteLog): same as below. * src/engine/Group.c (xaccGroupMergeAccounts): same as below. * src/engine/Backend.c (xaccTransactionGetBackend): Convert to not use the split's acc part directly, but only to access through funcs * src/engine/sixtp-dom-parsers.c (dom_tree_generic_parse): Add generic parser. * src/engine/gnc-account-xml-v2.c (gnc_account_end_handler): use generic parser extracted from here and used here and gnc-transaction-iml-v2.c * src/engine/Transaction.c (xaccInitSplit): Add a split->acc_guid field that is set to the account's guid. This way an Account is not required to exist yet when loading the split. Later when xaccSplitGetAccount is called the account is looked up, cached and returned. Make sure everything accesses ->acc through the helper function. * src/engine/AccountP.h: same as below. * src/engine/Account.c (xaccAccountSetGUID): mark guid argument const since it doesn't keep a pointer to it. * src/doc/xml/transactions-v2.dtd: change guid -> id. * src/engine/Transaction.c (get_denom_internal): New helper func. (get_currency_denom): use func. (get_security_denom): use func. * src/engine/sixtp.c: (sixtp_sax_end_handler, sixtp_sax_characters_handler, sixtp_sax_start_handler): don't use g_return_if_fail to test pdata->parsing_ok so we don't see the million CRITICAL warnings. We'll print an error at the end anyway. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3762 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-09 07:46:13 +00:00
xaccAccountSetSecurity((Account*)act, ref);
return TRUE;
}
static gboolean
account_security_scu_handler (xmlNodePtr node, gpointer act)
{
gint64 val;
dom_tree_to_integer(node, &val);
xaccAccountSetCommoditySCU((Account*)act, val);
return TRUE;
}
static gboolean
James LewisMoss's patch. * src/test/test-stuff.c (failure): don't print num if == -1. (success): same. (get_random_account): move here from test-xml-account.c (get_random_split): move here from test-xml-transaction.c (get_random_transaction): same. (success_args): New func. (success): Simplified version (failure_args): new func. (failure): Simplified version. * src/engine/io-gncbin-r.c: same as below. * src/engine/TransLog.c (xaccTransWriteLog): same as below. * src/engine/Group.c (xaccGroupMergeAccounts): same as below. * src/engine/Backend.c (xaccTransactionGetBackend): Convert to not use the split's acc part directly, but only to access through funcs * src/engine/sixtp-dom-parsers.c (dom_tree_generic_parse): Add generic parser. * src/engine/gnc-account-xml-v2.c (gnc_account_end_handler): use generic parser extracted from here and used here and gnc-transaction-iml-v2.c * src/engine/Transaction.c (xaccInitSplit): Add a split->acc_guid field that is set to the account's guid. This way an Account is not required to exist yet when loading the split. Later when xaccSplitGetAccount is called the account is looked up, cached and returned. Make sure everything accesses ->acc through the helper function. * src/engine/AccountP.h: same as below. * src/engine/Account.c (xaccAccountSetGUID): mark guid argument const since it doesn't keep a pointer to it. * src/doc/xml/transactions-v2.dtd: change guid -> id. * src/engine/Transaction.c (get_denom_internal): New helper func. (get_currency_denom): use func. (get_security_denom): use func. * src/engine/sixtp.c: (sixtp_sax_end_handler, sixtp_sax_characters_handler, sixtp_sax_start_handler): don't use g_return_if_fail to test pdata->parsing_ok so we don't see the million CRITICAL warnings. We'll print an error at the end anyway. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3762 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-09 07:46:13 +00:00
account_slots_handler (xmlNodePtr node, gpointer act)
{
kvp_frame *frm = dom_tree_to_kvp_frame(node);
g_return_val_if_fail(frm, FALSE);
James LewisMoss's patch. * src/test/test-stuff.c (failure): don't print num if == -1. (success): same. (get_random_account): move here from test-xml-account.c (get_random_split): move here from test-xml-transaction.c (get_random_transaction): same. (success_args): New func. (success): Simplified version (failure_args): new func. (failure): Simplified version. * src/engine/io-gncbin-r.c: same as below. * src/engine/TransLog.c (xaccTransWriteLog): same as below. * src/engine/Group.c (xaccGroupMergeAccounts): same as below. * src/engine/Backend.c (xaccTransactionGetBackend): Convert to not use the split's acc part directly, but only to access through funcs * src/engine/sixtp-dom-parsers.c (dom_tree_generic_parse): Add generic parser. * src/engine/gnc-account-xml-v2.c (gnc_account_end_handler): use generic parser extracted from here and used here and gnc-transaction-iml-v2.c * src/engine/Transaction.c (xaccInitSplit): Add a split->acc_guid field that is set to the account's guid. This way an Account is not required to exist yet when loading the split. Later when xaccSplitGetAccount is called the account is looked up, cached and returned. Make sure everything accesses ->acc through the helper function. * src/engine/AccountP.h: same as below. * src/engine/Account.c (xaccAccountSetGUID): mark guid argument const since it doesn't keep a pointer to it. * src/doc/xml/transactions-v2.dtd: change guid -> id. * src/engine/Transaction.c (get_denom_internal): New helper func. (get_currency_denom): use func. (get_security_denom): use func. * src/engine/sixtp.c: (sixtp_sax_end_handler, sixtp_sax_characters_handler, sixtp_sax_start_handler): don't use g_return_if_fail to test pdata->parsing_ok so we don't see the million CRITICAL warnings. We'll print an error at the end anyway. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3762 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-09 07:46:13 +00:00
xaccAccountSetSlots_nc((Account*)act, frm);
return TRUE;
}
static gboolean
James LewisMoss's patch. * src/test/test-stuff.c (failure): don't print num if == -1. (success): same. (get_random_account): move here from test-xml-account.c (get_random_split): move here from test-xml-transaction.c (get_random_transaction): same. (success_args): New func. (success): Simplified version (failure_args): new func. (failure): Simplified version. * src/engine/io-gncbin-r.c: same as below. * src/engine/TransLog.c (xaccTransWriteLog): same as below. * src/engine/Group.c (xaccGroupMergeAccounts): same as below. * src/engine/Backend.c (xaccTransactionGetBackend): Convert to not use the split's acc part directly, but only to access through funcs * src/engine/sixtp-dom-parsers.c (dom_tree_generic_parse): Add generic parser. * src/engine/gnc-account-xml-v2.c (gnc_account_end_handler): use generic parser extracted from here and used here and gnc-transaction-iml-v2.c * src/engine/Transaction.c (xaccInitSplit): Add a split->acc_guid field that is set to the account's guid. This way an Account is not required to exist yet when loading the split. Later when xaccSplitGetAccount is called the account is looked up, cached and returned. Make sure everything accesses ->acc through the helper function. * src/engine/AccountP.h: same as below. * src/engine/Account.c (xaccAccountSetGUID): mark guid argument const since it doesn't keep a pointer to it. * src/doc/xml/transactions-v2.dtd: change guid -> id. * src/engine/Transaction.c (get_denom_internal): New helper func. (get_currency_denom): use func. (get_security_denom): use func. * src/engine/sixtp.c: (sixtp_sax_end_handler, sixtp_sax_characters_handler, sixtp_sax_start_handler): don't use g_return_if_fail to test pdata->parsing_ok so we don't see the million CRITICAL warnings. We'll print an error at the end anyway. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3762 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-09 07:46:13 +00:00
account_parent_handler (xmlNodePtr node, gpointer act)
{
Account *parent;
GUID *gid;
gid = dom_tree_to_guid(node);
g_return_val_if_fail(gid, FALSE);
parent = xaccAccountLookup(gid);
if (!parent)
{
g_free (gid);
g_return_val_if_fail(parent, FALSE);
}
James LewisMoss's patch. * src/test/test-stuff.c (failure): don't print num if == -1. (success): same. (get_random_account): move here from test-xml-account.c (get_random_split): move here from test-xml-transaction.c (get_random_transaction): same. (success_args): New func. (success): Simplified version (failure_args): new func. (failure): Simplified version. * src/engine/io-gncbin-r.c: same as below. * src/engine/TransLog.c (xaccTransWriteLog): same as below. * src/engine/Group.c (xaccGroupMergeAccounts): same as below. * src/engine/Backend.c (xaccTransactionGetBackend): Convert to not use the split's acc part directly, but only to access through funcs * src/engine/sixtp-dom-parsers.c (dom_tree_generic_parse): Add generic parser. * src/engine/gnc-account-xml-v2.c (gnc_account_end_handler): use generic parser extracted from here and used here and gnc-transaction-iml-v2.c * src/engine/Transaction.c (xaccInitSplit): Add a split->acc_guid field that is set to the account's guid. This way an Account is not required to exist yet when loading the split. Later when xaccSplitGetAccount is called the account is looked up, cached and returned. Make sure everything accesses ->acc through the helper function. * src/engine/AccountP.h: same as below. * src/engine/Account.c (xaccAccountSetGUID): mark guid argument const since it doesn't keep a pointer to it. * src/doc/xml/transactions-v2.dtd: change guid -> id. * src/engine/Transaction.c (get_denom_internal): New helper func. (get_currency_denom): use func. (get_security_denom): use func. * src/engine/sixtp.c: (sixtp_sax_end_handler, sixtp_sax_characters_handler, sixtp_sax_start_handler): don't use g_return_if_fail to test pdata->parsing_ok so we don't see the million CRITICAL warnings. We'll print an error at the end anyway. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3762 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-09 07:46:13 +00:00
xaccAccountInsertSubAccount(parent, (Account*)act);
g_free (gid);
return TRUE;
}
static gboolean
James LewisMoss's patch. * src/test/test-stuff.c (failure): don't print num if == -1. (success): same. (get_random_account): move here from test-xml-account.c (get_random_split): move here from test-xml-transaction.c (get_random_transaction): same. (success_args): New func. (success): Simplified version (failure_args): new func. (failure): Simplified version. * src/engine/io-gncbin-r.c: same as below. * src/engine/TransLog.c (xaccTransWriteLog): same as below. * src/engine/Group.c (xaccGroupMergeAccounts): same as below. * src/engine/Backend.c (xaccTransactionGetBackend): Convert to not use the split's acc part directly, but only to access through funcs * src/engine/sixtp-dom-parsers.c (dom_tree_generic_parse): Add generic parser. * src/engine/gnc-account-xml-v2.c (gnc_account_end_handler): use generic parser extracted from here and used here and gnc-transaction-iml-v2.c * src/engine/Transaction.c (xaccInitSplit): Add a split->acc_guid field that is set to the account's guid. This way an Account is not required to exist yet when loading the split. Later when xaccSplitGetAccount is called the account is looked up, cached and returned. Make sure everything accesses ->acc through the helper function. * src/engine/AccountP.h: same as below. * src/engine/Account.c (xaccAccountSetGUID): mark guid argument const since it doesn't keep a pointer to it. * src/doc/xml/transactions-v2.dtd: change guid -> id. * src/engine/Transaction.c (get_denom_internal): New helper func. (get_currency_denom): use func. (get_security_denom): use func. * src/engine/sixtp.c: (sixtp_sax_end_handler, sixtp_sax_characters_handler, sixtp_sax_start_handler): don't use g_return_if_fail to test pdata->parsing_ok so we don't see the million CRITICAL warnings. We'll print an error at the end anyway. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3762 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-09 07:46:13 +00:00
account_code_handler(xmlNodePtr node, gpointer act)
{
James LewisMoss's patch. * src/test/test-stuff.c (failure): don't print num if == -1. (success): same. (get_random_account): move here from test-xml-account.c (get_random_split): move here from test-xml-transaction.c (get_random_transaction): same. (success_args): New func. (success): Simplified version (failure_args): new func. (failure): Simplified version. * src/engine/io-gncbin-r.c: same as below. * src/engine/TransLog.c (xaccTransWriteLog): same as below. * src/engine/Group.c (xaccGroupMergeAccounts): same as below. * src/engine/Backend.c (xaccTransactionGetBackend): Convert to not use the split's acc part directly, but only to access through funcs * src/engine/sixtp-dom-parsers.c (dom_tree_generic_parse): Add generic parser. * src/engine/gnc-account-xml-v2.c (gnc_account_end_handler): use generic parser extracted from here and used here and gnc-transaction-iml-v2.c * src/engine/Transaction.c (xaccInitSplit): Add a split->acc_guid field that is set to the account's guid. This way an Account is not required to exist yet when loading the split. Later when xaccSplitGetAccount is called the account is looked up, cached and returned. Make sure everything accesses ->acc through the helper function. * src/engine/AccountP.h: same as below. * src/engine/Account.c (xaccAccountSetGUID): mark guid argument const since it doesn't keep a pointer to it. * src/doc/xml/transactions-v2.dtd: change guid -> id. * src/engine/Transaction.c (get_denom_internal): New helper func. (get_currency_denom): use func. (get_security_denom): use func. * src/engine/sixtp.c: (sixtp_sax_end_handler, sixtp_sax_characters_handler, sixtp_sax_start_handler): don't use g_return_if_fail to test pdata->parsing_ok so we don't see the million CRITICAL warnings. We'll print an error at the end anyway. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3762 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-09 07:46:13 +00:00
return set_string(node, (Account*)act, xaccAccountSetCode);
}
static gboolean
James LewisMoss's patch. * src/test/test-stuff.c (failure): don't print num if == -1. (success): same. (get_random_account): move here from test-xml-account.c (get_random_split): move here from test-xml-transaction.c (get_random_transaction): same. (success_args): New func. (success): Simplified version (failure_args): new func. (failure): Simplified version. * src/engine/io-gncbin-r.c: same as below. * src/engine/TransLog.c (xaccTransWriteLog): same as below. * src/engine/Group.c (xaccGroupMergeAccounts): same as below. * src/engine/Backend.c (xaccTransactionGetBackend): Convert to not use the split's acc part directly, but only to access through funcs * src/engine/sixtp-dom-parsers.c (dom_tree_generic_parse): Add generic parser. * src/engine/gnc-account-xml-v2.c (gnc_account_end_handler): use generic parser extracted from here and used here and gnc-transaction-iml-v2.c * src/engine/Transaction.c (xaccInitSplit): Add a split->acc_guid field that is set to the account's guid. This way an Account is not required to exist yet when loading the split. Later when xaccSplitGetAccount is called the account is looked up, cached and returned. Make sure everything accesses ->acc through the helper function. * src/engine/AccountP.h: same as below. * src/engine/Account.c (xaccAccountSetGUID): mark guid argument const since it doesn't keep a pointer to it. * src/doc/xml/transactions-v2.dtd: change guid -> id. * src/engine/Transaction.c (get_denom_internal): New helper func. (get_currency_denom): use func. (get_security_denom): use func. * src/engine/sixtp.c: (sixtp_sax_end_handler, sixtp_sax_characters_handler, sixtp_sax_start_handler): don't use g_return_if_fail to test pdata->parsing_ok so we don't see the million CRITICAL warnings. We'll print an error at the end anyway. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3762 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-09 07:46:13 +00:00
account_description_handler(xmlNodePtr node, gpointer act)
{
James LewisMoss's patch. * src/test/test-stuff.c (failure): don't print num if == -1. (success): same. (get_random_account): move here from test-xml-account.c (get_random_split): move here from test-xml-transaction.c (get_random_transaction): same. (success_args): New func. (success): Simplified version (failure_args): new func. (failure): Simplified version. * src/engine/io-gncbin-r.c: same as below. * src/engine/TransLog.c (xaccTransWriteLog): same as below. * src/engine/Group.c (xaccGroupMergeAccounts): same as below. * src/engine/Backend.c (xaccTransactionGetBackend): Convert to not use the split's acc part directly, but only to access through funcs * src/engine/sixtp-dom-parsers.c (dom_tree_generic_parse): Add generic parser. * src/engine/gnc-account-xml-v2.c (gnc_account_end_handler): use generic parser extracted from here and used here and gnc-transaction-iml-v2.c * src/engine/Transaction.c (xaccInitSplit): Add a split->acc_guid field that is set to the account's guid. This way an Account is not required to exist yet when loading the split. Later when xaccSplitGetAccount is called the account is looked up, cached and returned. Make sure everything accesses ->acc through the helper function. * src/engine/AccountP.h: same as below. * src/engine/Account.c (xaccAccountSetGUID): mark guid argument const since it doesn't keep a pointer to it. * src/doc/xml/transactions-v2.dtd: change guid -> id. * src/engine/Transaction.c (get_denom_internal): New helper func. (get_currency_denom): use func. (get_security_denom): use func. * src/engine/sixtp.c: (sixtp_sax_end_handler, sixtp_sax_characters_handler, sixtp_sax_start_handler): don't use g_return_if_fail to test pdata->parsing_ok so we don't see the million CRITICAL warnings. We'll print an error at the end anyway. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3762 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-09 07:46:13 +00:00
return set_string(node, (Account*)act, xaccAccountSetDescription);
}
James LewisMoss's patch. * src/test/test-stuff.c (failure): don't print num if == -1. (success): same. (get_random_account): move here from test-xml-account.c (get_random_split): move here from test-xml-transaction.c (get_random_transaction): same. (success_args): New func. (success): Simplified version (failure_args): new func. (failure): Simplified version. * src/engine/io-gncbin-r.c: same as below. * src/engine/TransLog.c (xaccTransWriteLog): same as below. * src/engine/Group.c (xaccGroupMergeAccounts): same as below. * src/engine/Backend.c (xaccTransactionGetBackend): Convert to not use the split's acc part directly, but only to access through funcs * src/engine/sixtp-dom-parsers.c (dom_tree_generic_parse): Add generic parser. * src/engine/gnc-account-xml-v2.c (gnc_account_end_handler): use generic parser extracted from here and used here and gnc-transaction-iml-v2.c * src/engine/Transaction.c (xaccInitSplit): Add a split->acc_guid field that is set to the account's guid. This way an Account is not required to exist yet when loading the split. Later when xaccSplitGetAccount is called the account is looked up, cached and returned. Make sure everything accesses ->acc through the helper function. * src/engine/AccountP.h: same as below. * src/engine/Account.c (xaccAccountSetGUID): mark guid argument const since it doesn't keep a pointer to it. * src/doc/xml/transactions-v2.dtd: change guid -> id. * src/engine/Transaction.c (get_denom_internal): New helper func. (get_currency_denom): use func. (get_security_denom): use func. * src/engine/sixtp.c: (sixtp_sax_end_handler, sixtp_sax_characters_handler, sixtp_sax_start_handler): don't use g_return_if_fail to test pdata->parsing_ok so we don't see the million CRITICAL warnings. We'll print an error at the end anyway. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3762 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-09 07:46:13 +00:00
static struct dom_tree_handler account_handlers_v2[] = {
{ act_name_string, account_name_handler, 1, 0 },
{ act_id_string, account_id_handler, 1, 0 },
{ act_type_string, account_type_handler, 1, 0 },
{ act_currency_string, account_currency_handler, 1, 0 },
{ act_currency_scu_string, account_currency_scu_handler, 0, 0 },
{ act_code_string, account_code_handler, 0, 0 },
{ act_description_string, account_description_handler, 0, 0},
{ act_security_string, account_security_handler, 0, 0 },
{ act_security_scu_string, account_security_scu_handler, 0, 0 },
{ act_slots_string, account_slots_handler, 0, 0 },
{ act_parent_string, account_parent_handler, 0, 0 },
{ NULL, 0, 0, 0 }
};
static gboolean
gnc_account_end_handler(gpointer data_for_children,
GSList* data_from_children, GSList* sibling_data,
gpointer parent_data, gpointer global_data,
gpointer *result, const gchar *tag)
{
int successful;
Account *acc;
xmlNodePtr achild;
xmlNodePtr tree = (xmlNodePtr)data_for_children;
gxpf_data *gdata = (gxpf_data*)global_data;
successful = TRUE;
if(parent_data)
{
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();
g_return_val_if_fail(acc, FALSE);
xaccAccountBeginEdit(acc);
James LewisMoss's patch. * src/test/test-stuff.c (failure): don't print num if == -1. (success): same. (get_random_account): move here from test-xml-account.c (get_random_split): move here from test-xml-transaction.c (get_random_transaction): same. (success_args): New func. (success): Simplified version (failure_args): new func. (failure): Simplified version. * src/engine/io-gncbin-r.c: same as below. * src/engine/TransLog.c (xaccTransWriteLog): same as below. * src/engine/Group.c (xaccGroupMergeAccounts): same as below. * src/engine/Backend.c (xaccTransactionGetBackend): Convert to not use the split's acc part directly, but only to access through funcs * src/engine/sixtp-dom-parsers.c (dom_tree_generic_parse): Add generic parser. * src/engine/gnc-account-xml-v2.c (gnc_account_end_handler): use generic parser extracted from here and used here and gnc-transaction-iml-v2.c * src/engine/Transaction.c (xaccInitSplit): Add a split->acc_guid field that is set to the account's guid. This way an Account is not required to exist yet when loading the split. Later when xaccSplitGetAccount is called the account is looked up, cached and returned. Make sure everything accesses ->acc through the helper function. * src/engine/AccountP.h: same as below. * src/engine/Account.c (xaccAccountSetGUID): mark guid argument const since it doesn't keep a pointer to it. * src/doc/xml/transactions-v2.dtd: change guid -> id. * src/engine/Transaction.c (get_denom_internal): New helper func. (get_currency_denom): use func. (get_security_denom): use func. * src/engine/sixtp.c: (sixtp_sax_end_handler, sixtp_sax_characters_handler, sixtp_sax_start_handler): don't use g_return_if_fail to test pdata->parsing_ok so we don't see the million CRITICAL warnings. We'll print an error at the end anyway. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3762 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-09 07:46:13 +00:00
successful = dom_tree_generic_parse(tree, account_handlers_v2, acc);
xaccAccountCommitEdit(acc);
if(!successful)
{
xaccFreeAccount(acc);
}
else
{
gdata->cb(tag, gdata->data, acc);
/*
* Now return the account to the "edit" state. At the end of reading
* all the transactions, we will Commit. This replaces #splits
* rebalances with #accounts rebalances at the end. A BIG win!
*/
xaccAccountBeginEdit(acc);
}
xmlFreeNode(tree);
return successful;
}
Account*
dom_tree_to_account( xmlNodePtr node )
{
Account *accToRet;
gboolean successful;
accToRet = xaccMallocAccount();
successful = dom_tree_generic_parse( node, account_handlers_v2, accToRet );
xaccAccountCommitEdit( accToRet );
if ( !successful ) {
xaccFreeAccount( accToRet );
accToRet = NULL;
}
// jsled_FIXME? See note above.
xaccAccountBeginEdit( accToRet );
return accToRet;
}
sixtp*
gnc_account_sixtp_parser_create(void)
{
return sixtp_dom_parser_new(gnc_account_end_handler, NULL, NULL);
}