2001-03-04 05:09:23 -06:00
|
|
|
/********************************************************************
|
2005-11-01 21:32:36 -06:00
|
|
|
* sixtp-dom-parsers.c *
|
2001-03-04 05:09:23 -06:00
|
|
|
* Copyright 2001 Gnumatic, Inc. *
|
|
|
|
* *
|
|
|
|
* 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 *
|
2005-11-16 23:35:02 -06:00
|
|
|
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
|
|
|
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
2001-03-04 05:09:23 -06:00
|
|
|
* *
|
|
|
|
********************************************************************/
|
2021-04-20 13:03:23 -05:00
|
|
|
#include <glib.h>
|
|
|
|
|
2015-06-13 16:21:19 -05:00
|
|
|
extern "C"
|
|
|
|
{
|
2017-10-26 04:14:21 -05:00
|
|
|
#include <config.h>
|
2001-02-12 16:35:20 -06:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2015-06-14 16:52:25 -05:00
|
|
|
#include <gnc-engine.h>
|
2015-06-13 16:21:19 -05:00
|
|
|
}
|
2015-06-16 15:43:16 -05:00
|
|
|
|
2021-02-13 15:35:27 -06:00
|
|
|
#include "gnc-xml-helper.h"
|
2015-11-29 19:11:29 -06:00
|
|
|
#include "sixtp-utils.h"
|
|
|
|
#include "sixtp-dom-parsers.h"
|
2017-08-06 10:12:16 -05:00
|
|
|
#include <kvp-frame.hpp>
|
2015-06-16 15:43:16 -05:00
|
|
|
|
2005-11-01 21:32:36 -06:00
|
|
|
static QofLogModule log_module = GNC_MOD_IO;
|
2001-02-14 18:17:57 -06:00
|
|
|
|
2010-03-27 16:01:21 -05:00
|
|
|
GncGUID*
|
2016-03-12 16:04:40 -06:00
|
|
|
dom_tree_to_guid (xmlNodePtr node)
|
2001-02-12 16:35:20 -06:00
|
|
|
{
|
2009-12-29 14:12:48 -06:00
|
|
|
if (!node->properties)
|
2001-02-12 16:35:20 -06:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
if (strcmp ((char*) node->properties->name, "type") != 0)
|
2001-02-12 16:35:20 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
PERR ("Unknown attribute for id tag: %s",
|
|
|
|
node->properties->name ?
|
|
|
|
(char*) node->properties->name : "(null)");
|
2001-02-12 16:35:20 -06:00
|
|
|
return NULL;
|
|
|
|
}
|
2001-04-17 04:32:16 -05:00
|
|
|
|
2001-02-12 16:35:20 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
char* type;
|
2001-06-26 16:43:15 -05:00
|
|
|
|
2005-11-01 21:32:36 -06:00
|
|
|
type = (char*)xmlNodeGetContent (node->properties->xmlAttrPropertyValue);
|
2001-06-26 16:43:15 -05:00
|
|
|
|
2001-04-13 01:54:25 -05:00
|
|
|
/* handle new and guid the same for the moment */
|
2016-03-12 16:04:40 -06:00
|
|
|
if ((g_strcmp0 ("guid", type) == 0) || (g_strcmp0 ("new", type) == 0))
|
2001-02-12 16:35:20 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
auto gid = guid_new ();
|
|
|
|
char* guid_str;
|
2001-06-26 16:43:15 -05:00
|
|
|
|
2005-11-01 21:32:36 -06:00
|
|
|
guid_str = (char*)xmlNodeGetContent (node->xmlChildrenNode);
|
2016-03-12 16:04:40 -06:00
|
|
|
string_to_guid (guid_str, gid);
|
2001-06-26 16:43:15 -05:00
|
|
|
xmlFree (guid_str);
|
|
|
|
xmlFree (type);
|
2001-02-12 16:35:20 -06:00
|
|
|
return gid;
|
|
|
|
}
|
2009-12-29 14:12:48 -06:00
|
|
|
else
|
2001-02-12 16:35:20 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
PERR ("Unknown type %s for attribute type for tag %s",
|
|
|
|
type ? type : "(null)",
|
|
|
|
node->properties->name ?
|
|
|
|
(char*) node->properties->name : "(null)");
|
2001-06-26 16:43:15 -05:00
|
|
|
xmlFree (type);
|
2001-02-12 16:35:20 -06:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-13 19:28:11 -05:00
|
|
|
static KvpValue*
|
2016-03-12 16:04:40 -06:00
|
|
|
dom_tree_to_integer_kvp_value (xmlNodePtr node)
|
2001-02-22 01:29:05 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
gchar* text;
|
2001-02-22 01:29:05 -06:00
|
|
|
gint64 daint;
|
2014-09-17 16:31:16 -05:00
|
|
|
KvpValue* ret = NULL;
|
2009-12-29 14:12:48 -06:00
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
text = dom_tree_to_text (node);
|
2001-02-22 01:29:05 -06:00
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
if (string_to_gint64 (text, &daint))
|
2001-02-22 01:29:05 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
ret = new KvpValue {daint};
|
2001-02-22 01:29:05 -06:00
|
|
|
}
|
2016-03-12 16:04:40 -06:00
|
|
|
g_free (text);
|
2001-02-22 01:29:05 -06:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2016-03-12 16:04:40 -06:00
|
|
|
dom_tree_to_integer (xmlNodePtr node, gint64* daint)
|
2001-02-22 01:29:05 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
gchar* text;
|
2001-05-19 05:02:36 -05:00
|
|
|
gboolean ret;
|
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
text = dom_tree_to_text (node);
|
2001-02-22 01:29:05 -06:00
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
ret = string_to_gint64 (text, daint);
|
2001-05-19 05:02:36 -05:00
|
|
|
|
|
|
|
g_free (text);
|
|
|
|
|
|
|
|
return ret;
|
2001-02-22 01:29:05 -06:00
|
|
|
}
|
|
|
|
|
2005-11-01 21:32:36 -06:00
|
|
|
gboolean
|
2016-03-12 16:04:40 -06:00
|
|
|
dom_tree_to_guint16 (xmlNodePtr node, guint16* i)
|
2005-11-01 21:32:36 -06:00
|
|
|
{
|
|
|
|
gboolean ret;
|
|
|
|
guint j = 0;
|
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
ret = dom_tree_to_guint (node, &j);
|
2005-11-01 21:32:36 -06:00
|
|
|
*i = (guint16) j;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2016-03-12 16:04:40 -06:00
|
|
|
dom_tree_to_guint (xmlNodePtr node, guint* i)
|
2005-11-01 21:32:36 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
gchar* text, *endptr;
|
2005-11-01 21:32:36 -06:00
|
|
|
gboolean ret;
|
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
text = dom_tree_to_text (node);
|
2005-11-01 21:32:36 -06:00
|
|
|
/* In spite of the strange string_to_gint64 function, I'm just
|
|
|
|
going to use strtoul here until someone shows me the error of
|
|
|
|
my ways. -CAS */
|
2016-03-12 16:04:40 -06:00
|
|
|
*i = (guint) strtoul (text, &endptr, 0);
|
2005-11-01 21:32:36 -06:00
|
|
|
ret = (endptr != text);
|
2016-03-12 16:04:40 -06:00
|
|
|
g_free (text);
|
2005-11-01 21:32:36 -06:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-08-12 19:05:37 -05:00
|
|
|
gboolean
|
2016-03-12 16:04:40 -06:00
|
|
|
dom_tree_to_boolean (xmlNodePtr node, gboolean* b)
|
2009-08-12 19:05:37 -05:00
|
|
|
{
|
|
|
|
gchar* text;
|
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
text = dom_tree_to_text (node);
|
|
|
|
if (g_ascii_strncasecmp (text, "true", 4) == 0)
|
2009-12-29 14:12:48 -06:00
|
|
|
{
|
|
|
|
*b = TRUE;
|
2021-05-29 19:10:19 -05:00
|
|
|
g_free (text);
|
2009-12-29 14:12:48 -06:00
|
|
|
return TRUE;
|
|
|
|
}
|
2016-03-12 16:04:40 -06:00
|
|
|
else if (g_ascii_strncasecmp (text, "false", 5) == 0)
|
2009-12-29 14:12:48 -06:00
|
|
|
{
|
|
|
|
*b = FALSE;
|
2021-05-29 19:10:19 -05:00
|
|
|
g_free (text);
|
2009-12-29 14:12:48 -06:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*b = FALSE;
|
2021-05-29 19:10:19 -05:00
|
|
|
g_free (text);
|
2009-12-29 14:12:48 -06:00
|
|
|
return FALSE;
|
|
|
|
}
|
2009-08-12 19:05:37 -05:00
|
|
|
}
|
|
|
|
|
2015-06-13 19:28:11 -05:00
|
|
|
static KvpValue*
|
2016-03-12 16:04:40 -06:00
|
|
|
dom_tree_to_double_kvp_value (xmlNodePtr node)
|
2001-02-22 01:29:05 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
gchar* text;
|
2001-02-22 01:29:05 -06:00
|
|
|
double dadoub;
|
2016-03-12 16:04:40 -06:00
|
|
|
KvpValue* ret = NULL;
|
2001-02-22 01:29:05 -06:00
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
text = dom_tree_to_text (node);
|
2001-02-22 01:29:05 -06:00
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
if (string_to_double (text, &dadoub))
|
2001-02-22 01:29:05 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
ret = new KvpValue {dadoub};
|
2001-02-22 01:29:05 -06:00
|
|
|
}
|
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
g_free (text);
|
2009-12-29 14:12:48 -06:00
|
|
|
|
2001-02-22 01:29:05 -06:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-06-13 19:28:11 -05:00
|
|
|
static KvpValue*
|
2016-03-12 16:04:40 -06:00
|
|
|
dom_tree_to_numeric_kvp_value (xmlNodePtr node)
|
2001-02-22 01:29:05 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
gnc_numeric* danum;
|
|
|
|
KvpValue* ret = NULL;
|
2001-02-22 01:29:05 -06:00
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
danum = dom_tree_to_gnc_numeric (node);
|
2001-02-22 01:29:05 -06:00
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
if (danum)
|
2001-02-22 01:29:05 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
ret = new KvpValue {*danum};
|
2001-02-22 01:29:05 -06:00
|
|
|
}
|
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
g_free (danum);
|
2009-12-29 14:12:48 -06:00
|
|
|
|
2001-02-22 01:29:05 -06:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-06-13 19:28:11 -05:00
|
|
|
static KvpValue*
|
2016-03-12 16:04:40 -06:00
|
|
|
dom_tree_to_string_kvp_value (xmlNodePtr node)
|
2001-02-22 01:29:05 -06:00
|
|
|
{
|
2018-09-10 12:49:43 -05:00
|
|
|
const gchar* datext;
|
2016-03-12 16:04:40 -06:00
|
|
|
KvpValue* ret = NULL;
|
2001-02-22 01:29:05 -06:00
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
datext = dom_tree_to_text (node);
|
2009-12-29 14:12:48 -06:00
|
|
|
if (datext)
|
2001-02-22 01:29:05 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
ret = new KvpValue {datext};
|
2001-02-22 01:29:05 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-06-13 19:28:11 -05:00
|
|
|
static KvpValue*
|
2016-03-12 16:04:40 -06:00
|
|
|
dom_tree_to_guid_kvp_value (xmlNodePtr node)
|
2001-02-22 01:29:05 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
GncGUID* daguid;
|
|
|
|
KvpValue* ret = NULL;
|
2001-02-22 01:29:05 -06:00
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
daguid = dom_tree_to_guid (node);
|
2009-12-29 14:12:48 -06:00
|
|
|
if (daguid)
|
2001-02-22 01:29:05 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
ret = new KvpValue {daguid};
|
2001-02-22 01:29:05 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-06-13 19:28:11 -05:00
|
|
|
static KvpValue*
|
2017-12-29 12:52:45 -06:00
|
|
|
dom_tree_to_time64_kvp_value (xmlNodePtr node)
|
2001-11-21 03:49:02 -06:00
|
|
|
{
|
2018-08-02 15:29:47 -05:00
|
|
|
Time64 t{dom_tree_to_time64 (node)};
|
|
|
|
return new KvpValue {t};
|
2001-11-21 03:49:02 -06:00
|
|
|
}
|
|
|
|
|
2015-06-13 19:28:11 -05:00
|
|
|
static KvpValue*
|
2010-03-17 14:23:20 -05:00
|
|
|
dom_tree_to_gdate_kvp_value (xmlNodePtr node)
|
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
GDate* date;
|
|
|
|
KvpValue* ret = NULL;
|
2010-03-17 14:23:20 -05:00
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
date = dom_tree_to_gdate (node);
|
2010-03-17 14:23:20 -05:00
|
|
|
|
|
|
|
if (date)
|
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
ret = new KvpValue {*date};
|
2010-03-17 14:23:20 -05:00
|
|
|
}
|
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
g_free (date);
|
2010-03-17 14:23:20 -05:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2001-02-22 01:29:05 -06:00
|
|
|
gboolean
|
2016-03-12 16:04:40 -06:00
|
|
|
string_to_binary (const gchar* str, void** v, guint64* data_len)
|
2001-02-22 01:29:05 -06:00
|
|
|
{
|
2009-12-29 14:12:48 -06:00
|
|
|
guint64 str_len;
|
2016-03-12 16:04:40 -06:00
|
|
|
guchar* data;
|
2009-12-29 14:12:48 -06:00
|
|
|
unsigned int i, j;
|
2001-06-01 01:26:34 -05:00
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
g_return_val_if_fail (v != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (data_len != NULL, FALSE);
|
2001-06-01 01:26:34 -05:00
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
str_len = strlen (str);
|
2001-02-22 01:29:05 -06:00
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
/* Since no whitespace is allowed and hex encoding is 2 text chars
|
|
|
|
per binary char, the result must be half the input size and the
|
|
|
|
input size must be even. */
|
|
|
|
if ((str_len % 2) != 0)
|
2016-03-12 16:04:40 -06:00
|
|
|
return (FALSE);
|
2009-12-29 14:12:48 -06:00
|
|
|
*data_len = str_len / 2;
|
2016-03-12 16:04:40 -06:00
|
|
|
data = g_new0 (guchar, *data_len);
|
2001-02-22 01:29:05 -06:00
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
for (j = 0, i = 0; i < str_len; i += 2, j++)
|
|
|
|
{
|
|
|
|
gchar tmpstr[3];
|
|
|
|
long int converted;
|
2001-06-01 01:26:34 -05:00
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
tmpstr[0] = str[i];
|
|
|
|
tmpstr[1] = str[i + 1];
|
|
|
|
tmpstr[2] = '\0';
|
2001-02-22 01:29:05 -06:00
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
converted = strtol (tmpstr, NULL, 16);
|
2001-02-22 01:29:05 -06:00
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
data[j] = (unsigned char)converted;
|
|
|
|
}
|
2001-02-22 01:29:05 -06:00
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
*v = data;
|
2001-06-01 01:26:34 -05:00
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
return (TRUE);
|
2001-02-22 01:29:05 -06:00
|
|
|
}
|
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
static KvpValue* dom_tree_to_kvp_value (xmlNodePtr node);
|
2015-06-13 19:28:11 -05:00
|
|
|
//needed for test access as well as internal use.
|
2016-03-12 16:04:40 -06:00
|
|
|
KvpFrame* dom_tree_to_kvp_frame (xmlNodePtr node);
|
2015-06-13 19:28:11 -05:00
|
|
|
|
|
|
|
static KvpValue*
|
2016-03-12 16:04:40 -06:00
|
|
|
dom_tree_to_list_kvp_value (xmlNodePtr node)
|
2001-02-22 01:29:05 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
GList* list = NULL;
|
2001-02-22 01:29:05 -06:00
|
|
|
xmlNodePtr mark;
|
2016-03-12 16:04:40 -06:00
|
|
|
KvpValue* ret = NULL;
|
2001-02-22 01:29:05 -06:00
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
for (mark = node->xmlChildrenNode; mark; mark = mark->next)
|
2001-02-22 01:29:05 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
KvpValue* new_val;
|
2001-10-11 06:35:50 -05:00
|
|
|
|
2012-08-07 12:24:55 -05:00
|
|
|
if (g_strcmp0 ((char*)mark->name, "text") == 0)
|
2009-12-29 14:12:48 -06:00
|
|
|
continue;
|
2001-10-11 06:35:50 -05:00
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
new_val = dom_tree_to_kvp_value (mark);
|
2009-12-29 14:12:48 -06:00
|
|
|
if (new_val)
|
2001-02-22 01:29:05 -06:00
|
|
|
{
|
2021-05-29 19:10:49 -05:00
|
|
|
list = g_list_prepend (list, (gpointer)new_val);
|
2001-02-22 01:29:05 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-29 19:10:49 -05:00
|
|
|
list = g_list_reverse (list);
|
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
ret = new KvpValue {list};
|
2001-10-11 06:35:50 -05:00
|
|
|
|
2001-02-22 01:29:05 -06:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-06-13 19:28:11 -05:00
|
|
|
static KvpValue*
|
2016-03-12 16:04:40 -06:00
|
|
|
dom_tree_to_frame_kvp_value (xmlNodePtr node)
|
2001-02-22 01:29:05 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
KvpFrame* frame;
|
|
|
|
KvpValue* ret = NULL;
|
2001-02-22 01:29:05 -06:00
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
frame = dom_tree_to_kvp_frame (node);
|
2001-02-22 01:29:05 -06:00
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
if (frame)
|
2001-02-22 01:29:05 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
ret = new KvpValue {frame};
|
2001-02-22 01:29:05 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct kvp_val_converter
|
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
const gchar* tag;
|
|
|
|
KvpValue* (*converter) (xmlNodePtr node);
|
2001-02-22 01:29:05 -06:00
|
|
|
};
|
2018-08-03 16:00:07 -05:00
|
|
|
/* Note: The type attribute must remain 'timespec' to maintain compatibility.
|
|
|
|
*/
|
2001-02-22 01:29:05 -06:00
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
struct kvp_val_converter val_converters[] =
|
|
|
|
{
|
2001-02-22 01:29:05 -06:00
|
|
|
{ "integer", dom_tree_to_integer_kvp_value },
|
|
|
|
{ "double", dom_tree_to_double_kvp_value },
|
|
|
|
{ "numeric", dom_tree_to_numeric_kvp_value },
|
|
|
|
{ "string", dom_tree_to_string_kvp_value },
|
|
|
|
{ "guid", dom_tree_to_guid_kvp_value },
|
2017-12-29 12:52:45 -06:00
|
|
|
{ "timespec", dom_tree_to_time64_kvp_value },
|
2010-03-17 14:23:20 -05:00
|
|
|
{ "gdate", dom_tree_to_gdate_kvp_value },
|
2001-02-22 01:29:05 -06:00
|
|
|
{ "list", dom_tree_to_list_kvp_value },
|
|
|
|
{ "frame", dom_tree_to_frame_kvp_value },
|
|
|
|
{ 0, 0 },
|
|
|
|
};
|
2009-12-29 14:12:48 -06:00
|
|
|
|
2015-06-13 19:28:11 -05:00
|
|
|
static KvpValue*
|
2016-03-12 16:04:40 -06:00
|
|
|
dom_tree_to_kvp_value (xmlNodePtr node)
|
2001-02-22 01:29:05 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
xmlChar* xml_type;
|
|
|
|
gchar* type;
|
|
|
|
struct kvp_val_converter* mark;
|
|
|
|
KvpValue* ret = NULL;
|
2001-05-19 05:02:36 -05:00
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
xml_type = xmlGetProp (node, BAD_CAST "type");
|
2009-12-29 14:12:48 -06:00
|
|
|
if (xml_type)
|
2001-05-19 05:02:36 -05:00
|
|
|
{
|
2005-11-01 21:32:36 -06:00
|
|
|
type = g_strdup ((char*) xml_type);
|
2001-05-19 05:02:36 -05:00
|
|
|
xmlFree (xml_type);
|
|
|
|
}
|
|
|
|
else
|
2009-12-29 14:12:48 -06:00
|
|
|
type = NULL;
|
2001-02-22 01:29:05 -06:00
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
for (mark = val_converters; mark->tag; mark++)
|
2001-02-22 01:29:05 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
if (g_strcmp0 (type, mark->tag) == 0)
|
2001-02-22 01:29:05 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
ret = (mark->converter) (node);
|
2001-02-22 01:29:05 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
if (!mark->tag)
|
2001-02-22 01:29:05 -06:00
|
|
|
{
|
|
|
|
/* FIXME: deal with unknown type tag here */
|
|
|
|
}
|
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
g_free (type);
|
2009-12-29 14:12:48 -06:00
|
|
|
|
2001-02-22 01:29:05 -06:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-06-13 19:28:11 -05:00
|
|
|
static gboolean
|
2016-03-12 16:04:40 -06:00
|
|
|
dom_tree_to_kvp_frame_given (xmlNodePtr node, KvpFrame* frame)
|
2001-02-14 18:17:57 -06:00
|
|
|
{
|
2001-02-22 01:29:05 -06:00
|
|
|
xmlNodePtr mark;
|
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
g_return_val_if_fail (node, FALSE);
|
|
|
|
g_return_val_if_fail (frame, FALSE);
|
2001-02-22 01:29:05 -06:00
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
for (mark = node->xmlChildrenNode; mark; mark = mark->next)
|
2001-02-22 01:29:05 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
if (g_strcmp0 ((char*)mark->name, "slot") == 0)
|
2001-02-22 01:29:05 -06:00
|
|
|
{
|
|
|
|
xmlNodePtr mark2;
|
2016-03-12 16:04:40 -06:00
|
|
|
gchar* key = NULL;
|
|
|
|
KvpValue* val = NULL;
|
2001-02-22 01:29:05 -06:00
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
for (mark2 = mark->xmlChildrenNode; mark2; mark2 = mark2->next)
|
2001-02-22 01:29:05 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
if (g_strcmp0 ((char*)mark2->name, "slot:key") == 0)
|
2001-02-22 01:29:05 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
key = dom_tree_to_text (mark2);
|
2001-02-22 01:29:05 -06:00
|
|
|
}
|
2016-03-12 16:04:40 -06:00
|
|
|
else if (g_strcmp0 ((char*)mark2->name, "slot:value") == 0)
|
2001-02-22 01:29:05 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
val = dom_tree_to_kvp_value (mark2);
|
2001-02-22 01:29:05 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-12-29 14:12:48 -06:00
|
|
|
/* FIXME: should put some error here.
|
2001-10-11 06:35:50 -05:00
|
|
|
* But ignore text type! */
|
2001-02-22 01:29:05 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
if (key)
|
2001-02-22 01:29:05 -06:00
|
|
|
{
|
2009-12-29 14:12:48 -06:00
|
|
|
if (val)
|
2001-02-22 01:29:05 -06:00
|
|
|
{
|
2015-06-16 15:43:16 -05:00
|
|
|
//We're deleting the old KvpValue returned by replace_nc().
|
2017-11-06 13:51:25 -06:00
|
|
|
delete frame->set ({key}, val);
|
2001-02-22 01:29:05 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* FIXME: should put some error here */
|
|
|
|
}
|
2016-03-12 16:04:40 -06:00
|
|
|
g_free (key);
|
2001-02-22 01:29:05 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-02-14 18:17:57 -06:00
|
|
|
|
2001-07-11 19:13:21 -05:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-07 09:05:22 -05:00
|
|
|
KvpFrame*
|
2016-03-12 16:04:40 -06:00
|
|
|
dom_tree_to_kvp_frame (xmlNodePtr node)
|
2001-07-11 19:13:21 -05:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
g_return_val_if_fail (node, NULL);
|
2001-07-11 19:13:21 -05:00
|
|
|
|
2015-06-16 15:43:16 -05:00
|
|
|
auto ret = new KvpFrame;
|
2001-07-11 19:13:21 -05:00
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
if (dom_tree_to_kvp_frame_given (node, ret))
|
2001-07-11 19:13:21 -05:00
|
|
|
return ret;
|
|
|
|
|
2015-06-16 15:43:16 -05:00
|
|
|
delete ret;
|
2001-07-11 19:13:21 -05:00
|
|
|
return NULL;
|
2001-02-14 18:17:57 -06:00
|
|
|
}
|
|
|
|
|
2015-06-13 19:28:11 -05:00
|
|
|
gboolean
|
2016-03-12 16:04:40 -06:00
|
|
|
dom_tree_create_instance_slots (xmlNodePtr node, QofInstance* inst)
|
2015-06-13 19:28:11 -05:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
KvpFrame* frame = qof_instance_get_slots (inst);
|
|
|
|
return dom_tree_to_kvp_frame_given (node, frame);
|
2015-06-13 19:28:11 -05:00
|
|
|
}
|
2001-02-14 18:17:57 -06:00
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
gchar*
|
|
|
|
dom_tree_to_text (xmlNodePtr tree)
|
2001-02-14 18:17:57 -06:00
|
|
|
{
|
2009-12-29 14:12:48 -06:00
|
|
|
/* Expect *only* text and comment sibling nodes in the given tree --
|
|
|
|
which actually may only be a "list". i.e. if you're trying to
|
|
|
|
extract bar from <foo>bar</foo>, pass in <foo>->xmlChildrenNode
|
|
|
|
to this function. This expectation is different from the rest of
|
|
|
|
the dom_tree_to_* converters...
|
|
|
|
|
|
|
|
Ignores comment nodes and collapse text nodes into one string.
|
|
|
|
Returns NULL if expectations are unsatisfied.
|
|
|
|
*/
|
2016-03-12 16:04:40 -06:00
|
|
|
gchar* result;
|
|
|
|
gchar* temp;
|
2009-12-29 14:12:48 -06:00
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
g_return_val_if_fail (tree, NULL);
|
2009-12-29 14:12:48 -06:00
|
|
|
|
|
|
|
/* no nodes means it's an empty string text */
|
|
|
|
if (!tree->xmlChildrenNode)
|
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
DEBUG ("No children");
|
|
|
|
return g_strdup ("");
|
2009-12-29 14:12:48 -06:00
|
|
|
}
|
2001-06-17 Joshua Sled <jsled@asynchronous.org>
* src/engine/gnc-account-xml-v2.c (dom_tree_to_account): Added.
* src/engine/gnc-transaction-xml-v2.c (dom_tree_to_transaction):
Added.
* src/FileDialog.c: Added support for copying
scheduled-transaction-related GNCBook fields.
src/engine/
* src/engine/FreqSpec.{h,c}: Added.
* src/engine/SchedXaction.{h,c}: Added.
* src/engine/gnc-{freqspec,schedxaction}-xml-v2.c: Added
* src/engine/gnc-book.c: Added the template group [template
transaction belong to the template group] and the Scheduled
Trasnaction list.
* src/gnome/glade/sched_xact.glade: Added.
* src/gnome/dialog-nextrun.{h,c}: Added.
* src/gnome/dialog-scheduledxaction.{h,c}: Added.
* src/gnome/gnc-frequency.{h,c}: Added.
* src/SplitLedger.c, src/MultiLedger.c: Added support for a
Template Ledger.
* src/guile/gnc.gwp: Added wrapping for
dialog-{scheduledxactions,nextrun}-creation functions.
* src/register/splitreg.c: Added formula credit and debit cells,
and flags for template-register support.
* src/register/formulacell.h: Added.
* src/gnome/gnc-dateedit.h: Added explanatory comment from dave_p
in IRC.
* src/gnome/query-user.h: Added prototype of
gnc_verify_dialog_parented(...), so I could use it the SX UI
stuff.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4725 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-06-18 03:25:46 -05:00
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
temp = (char*)xmlNodeListGetString (NULL, tree->xmlChildrenNode, TRUE);
|
|
|
|
if (!temp)
|
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
DEBUG ("Null string");
|
2009-12-29 14:12:48 -06:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
DEBUG ("node string [%s]", (temp == NULL ? "(null)" : temp));
|
2009-12-29 14:12:48 -06:00
|
|
|
result = g_strdup (temp);
|
|
|
|
xmlFree (temp);
|
|
|
|
return result;
|
2001-02-14 18:17:57 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
gnc_numeric*
|
2016-03-12 16:04:40 -06:00
|
|
|
dom_tree_to_gnc_numeric (xmlNodePtr node)
|
2001-02-12 16:35:20 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
gchar* content = dom_tree_to_text (node);
|
2009-12-29 14:12:48 -06:00
|
|
|
if (!content)
|
2001-02-14 18:17:57 -06:00
|
|
|
return NULL;
|
|
|
|
|
2017-07-15 19:05:10 -05:00
|
|
|
gnc_numeric *ret = g_new (gnc_numeric, 1);
|
2001-02-14 18:17:57 -06:00
|
|
|
|
2017-07-15 19:05:10 -05:00
|
|
|
if (!string_to_gnc_numeric (content, ret))
|
|
|
|
*ret = gnc_numeric_zero ();
|
|
|
|
g_free (content);
|
|
|
|
return ret;
|
2001-02-14 18:17:57 -06:00
|
|
|
}
|
2001-02-12 16:35:20 -06:00
|
|
|
|
2001-02-14 18:17:57 -06:00
|
|
|
|
2017-12-29 12:52:45 -06:00
|
|
|
time64
|
|
|
|
dom_tree_to_time64 (xmlNodePtr node)
|
2001-02-12 16:35:20 -06:00
|
|
|
{
|
2009-12-29 14:12:48 -06:00
|
|
|
/* Turn something like this
|
|
|
|
|
|
|
|
<date-posted>
|
2018-08-03 16:00:07 -05:00
|
|
|
<ts:date>Mon, 05 Jun 2000 23:16:19 -0500</ts:date>
|
2009-12-29 14:12:48 -06:00
|
|
|
</date-posted>
|
|
|
|
|
2018-08-03 16:00:07 -05:00
|
|
|
into a time64, returning INT64_MAX that we're using to flag an erroneous
|
|
|
|
date if there's a problem. Only one ts:date element is permitted for any
|
|
|
|
date attribute.
|
|
|
|
*/
|
2009-12-29 14:12:48 -06:00
|
|
|
|
2018-04-28 05:16:52 -05:00
|
|
|
time64 ret {INT64_MAX};
|
2018-08-03 16:00:07 -05:00
|
|
|
gboolean seen = FALSE;
|
2009-12-29 14:12:48 -06:00
|
|
|
xmlNodePtr n;
|
|
|
|
|
|
|
|
for (n = node->xmlChildrenNode; n; n = n->next)
|
|
|
|
{
|
|
|
|
switch (n->type)
|
2001-02-14 18:17:57 -06:00
|
|
|
{
|
2009-12-29 14:12:48 -06:00
|
|
|
case XML_COMMENT_NODE:
|
|
|
|
case XML_TEXT_NODE:
|
|
|
|
break;
|
|
|
|
case XML_ELEMENT_NODE:
|
2016-03-12 16:04:40 -06:00
|
|
|
if (g_strcmp0 ("ts:date", (char*)n->name) == 0)
|
2009-12-29 14:12:48 -06:00
|
|
|
{
|
2018-08-03 16:00:07 -05:00
|
|
|
if (seen)
|
2009-12-29 14:12:48 -06:00
|
|
|
{
|
2018-08-03 15:52:47 -05:00
|
|
|
return INT64_MAX;
|
2009-12-29 14:12:48 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
gchar* content = dom_tree_to_text (n);
|
2009-12-29 14:12:48 -06:00
|
|
|
if (!content)
|
|
|
|
{
|
2018-08-03 15:52:47 -05:00
|
|
|
return INT64_MAX;
|
2009-12-29 14:12:48 -06:00
|
|
|
}
|
|
|
|
|
2018-08-03 15:52:47 -05:00
|
|
|
ret = gnc_iso8601_to_time64_gmt (content);
|
2016-03-12 16:04:40 -06:00
|
|
|
g_free (content);
|
2018-08-03 16:00:07 -05:00
|
|
|
seen = TRUE;
|
2009-12-29 14:12:48 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2016-03-12 16:04:40 -06:00
|
|
|
PERR ("unexpected sub-node.");
|
2018-08-03 16:00:07 -05:00
|
|
|
return INT64_MAX;
|
2009-12-29 14:12:48 -06:00
|
|
|
break;
|
2001-02-14 18:17:57 -06:00
|
|
|
}
|
2009-12-29 14:12:48 -06:00
|
|
|
}
|
|
|
|
|
2018-08-03 16:00:07 -05:00
|
|
|
if (!seen)
|
2009-12-29 14:12:48 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
PERR ("no ts:date node found.");
|
2018-08-03 16:00:07 -05:00
|
|
|
return INT64_MAX;
|
2009-12-29 14:12:48 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2001-02-12 16:35:20 -06:00
|
|
|
}
|
|
|
|
|
2001-06-17 Joshua Sled <jsled@asynchronous.org>
* src/engine/gnc-account-xml-v2.c (dom_tree_to_account): Added.
* src/engine/gnc-transaction-xml-v2.c (dom_tree_to_transaction):
Added.
* src/FileDialog.c: Added support for copying
scheduled-transaction-related GNCBook fields.
src/engine/
* src/engine/FreqSpec.{h,c}: Added.
* src/engine/SchedXaction.{h,c}: Added.
* src/engine/gnc-{freqspec,schedxaction}-xml-v2.c: Added
* src/engine/gnc-book.c: Added the template group [template
transaction belong to the template group] and the Scheduled
Trasnaction list.
* src/gnome/glade/sched_xact.glade: Added.
* src/gnome/dialog-nextrun.{h,c}: Added.
* src/gnome/dialog-scheduledxaction.{h,c}: Added.
* src/gnome/gnc-frequency.{h,c}: Added.
* src/SplitLedger.c, src/MultiLedger.c: Added support for a
Template Ledger.
* src/guile/gnc.gwp: Added wrapping for
dialog-{scheduledxactions,nextrun}-creation functions.
* src/register/splitreg.c: Added formula credit and debit cells,
and flags for template-register support.
* src/register/formulacell.h: Added.
* src/gnome/gnc-dateedit.h: Added explanatory comment from dave_p
in IRC.
* src/gnome/query-user.h: Added prototype of
gnc_verify_dialog_parented(...), so I could use it the SX UI
stuff.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4725 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-06-18 03:25:46 -05:00
|
|
|
GDate*
|
2016-03-12 16:04:40 -06:00
|
|
|
dom_tree_to_gdate (xmlNodePtr node)
|
2001-06-17 Joshua Sled <jsled@asynchronous.org>
* src/engine/gnc-account-xml-v2.c (dom_tree_to_account): Added.
* src/engine/gnc-transaction-xml-v2.c (dom_tree_to_transaction):
Added.
* src/FileDialog.c: Added support for copying
scheduled-transaction-related GNCBook fields.
src/engine/
* src/engine/FreqSpec.{h,c}: Added.
* src/engine/SchedXaction.{h,c}: Added.
* src/engine/gnc-{freqspec,schedxaction}-xml-v2.c: Added
* src/engine/gnc-book.c: Added the template group [template
transaction belong to the template group] and the Scheduled
Trasnaction list.
* src/gnome/glade/sched_xact.glade: Added.
* src/gnome/dialog-nextrun.{h,c}: Added.
* src/gnome/dialog-scheduledxaction.{h,c}: Added.
* src/gnome/gnc-frequency.{h,c}: Added.
* src/SplitLedger.c, src/MultiLedger.c: Added support for a
Template Ledger.
* src/guile/gnc.gwp: Added wrapping for
dialog-{scheduledxactions,nextrun}-creation functions.
* src/register/splitreg.c: Added formula credit and debit cells,
and flags for template-register support.
* src/register/formulacell.h: Added.
* src/gnome/gnc-dateedit.h: Added explanatory comment from dave_p
in IRC.
* src/gnome/query-user.h: Added prototype of
gnc_verify_dialog_parented(...), so I could use it the SX UI
stuff.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4725 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-06-18 03:25:46 -05:00
|
|
|
{
|
2009-12-29 14:12:48 -06:00
|
|
|
/* Turn something like this
|
2001-06-17 Joshua Sled <jsled@asynchronous.org>
* src/engine/gnc-account-xml-v2.c (dom_tree_to_account): Added.
* src/engine/gnc-transaction-xml-v2.c (dom_tree_to_transaction):
Added.
* src/FileDialog.c: Added support for copying
scheduled-transaction-related GNCBook fields.
src/engine/
* src/engine/FreqSpec.{h,c}: Added.
* src/engine/SchedXaction.{h,c}: Added.
* src/engine/gnc-{freqspec,schedxaction}-xml-v2.c: Added
* src/engine/gnc-book.c: Added the template group [template
transaction belong to the template group] and the Scheduled
Trasnaction list.
* src/gnome/glade/sched_xact.glade: Added.
* src/gnome/dialog-nextrun.{h,c}: Added.
* src/gnome/dialog-scheduledxaction.{h,c}: Added.
* src/gnome/gnc-frequency.{h,c}: Added.
* src/SplitLedger.c, src/MultiLedger.c: Added support for a
Template Ledger.
* src/guile/gnc.gwp: Added wrapping for
dialog-{scheduledxactions,nextrun}-creation functions.
* src/register/splitreg.c: Added formula credit and debit cells,
and flags for template-register support.
* src/register/formulacell.h: Added.
* src/gnome/gnc-dateedit.h: Added explanatory comment from dave_p
in IRC.
* src/gnome/query-user.h: Added prototype of
gnc_verify_dialog_parented(...), so I could use it the SX UI
stuff.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4725 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-06-18 03:25:46 -05:00
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
<sx:startdate>
|
|
|
|
<gdate>2001-04-03</gdate>
|
|
|
|
</sx:startdate>
|
2001-06-17 Joshua Sled <jsled@asynchronous.org>
* src/engine/gnc-account-xml-v2.c (dom_tree_to_account): Added.
* src/engine/gnc-transaction-xml-v2.c (dom_tree_to_transaction):
Added.
* src/FileDialog.c: Added support for copying
scheduled-transaction-related GNCBook fields.
src/engine/
* src/engine/FreqSpec.{h,c}: Added.
* src/engine/SchedXaction.{h,c}: Added.
* src/engine/gnc-{freqspec,schedxaction}-xml-v2.c: Added
* src/engine/gnc-book.c: Added the template group [template
transaction belong to the template group] and the Scheduled
Trasnaction list.
* src/gnome/glade/sched_xact.glade: Added.
* src/gnome/dialog-nextrun.{h,c}: Added.
* src/gnome/dialog-scheduledxaction.{h,c}: Added.
* src/gnome/gnc-frequency.{h,c}: Added.
* src/SplitLedger.c, src/MultiLedger.c: Added support for a
Template Ledger.
* src/guile/gnc.gwp: Added wrapping for
dialog-{scheduledxactions,nextrun}-creation functions.
* src/register/splitreg.c: Added formula credit and debit cells,
and flags for template-register support.
* src/register/formulacell.h: Added.
* src/gnome/gnc-dateedit.h: Added explanatory comment from dave_p
in IRC.
* src/gnome/query-user.h: Added prototype of
gnc_verify_dialog_parented(...), so I could use it the SX UI
stuff.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4725 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-06-18 03:25:46 -05:00
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
into a GDate. If the xml is invalid, returns NULL. */
|
2001-06-17 Joshua Sled <jsled@asynchronous.org>
* src/engine/gnc-account-xml-v2.c (dom_tree_to_account): Added.
* src/engine/gnc-transaction-xml-v2.c (dom_tree_to_transaction):
Added.
* src/FileDialog.c: Added support for copying
scheduled-transaction-related GNCBook fields.
src/engine/
* src/engine/FreqSpec.{h,c}: Added.
* src/engine/SchedXaction.{h,c}: Added.
* src/engine/gnc-{freqspec,schedxaction}-xml-v2.c: Added
* src/engine/gnc-book.c: Added the template group [template
transaction belong to the template group] and the Scheduled
Trasnaction list.
* src/gnome/glade/sched_xact.glade: Added.
* src/gnome/dialog-nextrun.{h,c}: Added.
* src/gnome/dialog-scheduledxaction.{h,c}: Added.
* src/gnome/gnc-frequency.{h,c}: Added.
* src/SplitLedger.c, src/MultiLedger.c: Added support for a
Template Ledger.
* src/guile/gnc.gwp: Added wrapping for
dialog-{scheduledxactions,nextrun}-creation functions.
* src/register/splitreg.c: Added formula credit and debit cells,
and flags for template-register support.
* src/register/formulacell.h: Added.
* src/gnome/gnc-dateedit.h: Added explanatory comment from dave_p
in IRC.
* src/gnome/query-user.h: Added prototype of
gnc_verify_dialog_parented(...), so I could use it the SX UI
stuff.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4725 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-06-18 03:25:46 -05:00
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
GDate* ret;
|
2009-12-29 14:12:48 -06:00
|
|
|
gboolean seen_date = FALSE;
|
|
|
|
xmlNodePtr n;
|
2001-06-17 Joshua Sled <jsled@asynchronous.org>
* src/engine/gnc-account-xml-v2.c (dom_tree_to_account): Added.
* src/engine/gnc-transaction-xml-v2.c (dom_tree_to_transaction):
Added.
* src/FileDialog.c: Added support for copying
scheduled-transaction-related GNCBook fields.
src/engine/
* src/engine/FreqSpec.{h,c}: Added.
* src/engine/SchedXaction.{h,c}: Added.
* src/engine/gnc-{freqspec,schedxaction}-xml-v2.c: Added
* src/engine/gnc-book.c: Added the template group [template
transaction belong to the template group] and the Scheduled
Trasnaction list.
* src/gnome/glade/sched_xact.glade: Added.
* src/gnome/dialog-nextrun.{h,c}: Added.
* src/gnome/dialog-scheduledxaction.{h,c}: Added.
* src/gnome/gnc-frequency.{h,c}: Added.
* src/SplitLedger.c, src/MultiLedger.c: Added support for a
Template Ledger.
* src/guile/gnc.gwp: Added wrapping for
dialog-{scheduledxactions,nextrun}-creation functions.
* src/register/splitreg.c: Added formula credit and debit cells,
and flags for template-register support.
* src/register/formulacell.h: Added.
* src/gnome/gnc-dateedit.h: Added explanatory comment from dave_p
in IRC.
* src/gnome/query-user.h: Added prototype of
gnc_verify_dialog_parented(...), so I could use it the SX UI
stuff.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4725 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-06-18 03:25:46 -05:00
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
/* creates an invalid date */
|
2016-03-12 16:04:40 -06:00
|
|
|
ret = g_date_new ();
|
2001-06-17 Joshua Sled <jsled@asynchronous.org>
* src/engine/gnc-account-xml-v2.c (dom_tree_to_account): Added.
* src/engine/gnc-transaction-xml-v2.c (dom_tree_to_transaction):
Added.
* src/FileDialog.c: Added support for copying
scheduled-transaction-related GNCBook fields.
src/engine/
* src/engine/FreqSpec.{h,c}: Added.
* src/engine/SchedXaction.{h,c}: Added.
* src/engine/gnc-{freqspec,schedxaction}-xml-v2.c: Added
* src/engine/gnc-book.c: Added the template group [template
transaction belong to the template group] and the Scheduled
Trasnaction list.
* src/gnome/glade/sched_xact.glade: Added.
* src/gnome/dialog-nextrun.{h,c}: Added.
* src/gnome/dialog-scheduledxaction.{h,c}: Added.
* src/gnome/gnc-frequency.{h,c}: Added.
* src/SplitLedger.c, src/MultiLedger.c: Added support for a
Template Ledger.
* src/guile/gnc.gwp: Added wrapping for
dialog-{scheduledxactions,nextrun}-creation functions.
* src/register/splitreg.c: Added formula credit and debit cells,
and flags for template-register support.
* src/register/formulacell.h: Added.
* src/gnome/gnc-dateedit.h: Added explanatory comment from dave_p
in IRC.
* src/gnome/query-user.h: Added prototype of
gnc_verify_dialog_parented(...), so I could use it the SX UI
stuff.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4725 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-06-18 03:25:46 -05:00
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
for (n = node->xmlChildrenNode; n; n = n->next)
|
|
|
|
{
|
|
|
|
switch (n->type)
|
|
|
|
{
|
|
|
|
case XML_COMMENT_NODE:
|
|
|
|
case XML_TEXT_NODE:
|
|
|
|
break;
|
|
|
|
case XML_ELEMENT_NODE:
|
2016-03-12 16:04:40 -06:00
|
|
|
if (g_strcmp0 ("gdate", (char*)n->name) == 0)
|
2009-12-29 14:12:48 -06:00
|
|
|
{
|
|
|
|
if (seen_date)
|
|
|
|
{
|
|
|
|
goto failure;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
gchar* content = dom_tree_to_text (n);
|
2009-12-29 14:12:48 -06:00
|
|
|
gint year, month, day;
|
|
|
|
if (!content)
|
|
|
|
{
|
|
|
|
goto failure;
|
|
|
|
}
|
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
if (sscanf (content, "%d-%d-%d", &year, &month, &day) != 3)
|
2009-12-29 14:12:48 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
g_free (content);
|
2009-12-29 14:12:48 -06:00
|
|
|
goto failure;
|
|
|
|
}
|
2016-03-12 16:04:40 -06:00
|
|
|
g_free (content);
|
2009-12-29 14:12:48 -06:00
|
|
|
seen_date = TRUE;
|
2016-03-12 16:04:40 -06:00
|
|
|
g_date_set_dmy (ret, day, static_cast<GDateMonth> (month),
|
|
|
|
year);
|
|
|
|
if (!g_date_valid (ret))
|
2009-12-29 14:12:48 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
PWARN ("invalid date");
|
2009-12-29 14:12:48 -06:00
|
|
|
goto failure;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2016-03-12 16:04:40 -06:00
|
|
|
PERR ("unexpected sub-node.");
|
2001-06-17 Joshua Sled <jsled@asynchronous.org>
* src/engine/gnc-account-xml-v2.c (dom_tree_to_account): Added.
* src/engine/gnc-transaction-xml-v2.c (dom_tree_to_transaction):
Added.
* src/FileDialog.c: Added support for copying
scheduled-transaction-related GNCBook fields.
src/engine/
* src/engine/FreqSpec.{h,c}: Added.
* src/engine/SchedXaction.{h,c}: Added.
* src/engine/gnc-{freqspec,schedxaction}-xml-v2.c: Added
* src/engine/gnc-book.c: Added the template group [template
transaction belong to the template group] and the Scheduled
Trasnaction list.
* src/gnome/glade/sched_xact.glade: Added.
* src/gnome/dialog-nextrun.{h,c}: Added.
* src/gnome/dialog-scheduledxaction.{h,c}: Added.
* src/gnome/gnc-frequency.{h,c}: Added.
* src/SplitLedger.c, src/MultiLedger.c: Added support for a
Template Ledger.
* src/guile/gnc.gwp: Added wrapping for
dialog-{scheduledxactions,nextrun}-creation functions.
* src/register/splitreg.c: Added formula credit and debit cells,
and flags for template-register support.
* src/register/formulacell.h: Added.
* src/gnome/gnc-dateedit.h: Added explanatory comment from dave_p
in IRC.
* src/gnome/query-user.h: Added prototype of
gnc_verify_dialog_parented(...), so I could use it the SX UI
stuff.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4725 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-06-18 03:25:46 -05:00
|
|
|
goto failure;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
if (!seen_date)
|
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
PWARN ("no gdate node found.");
|
2009-12-29 14:12:48 -06:00
|
|
|
goto failure;
|
|
|
|
}
|
2001-06-17 Joshua Sled <jsled@asynchronous.org>
* src/engine/gnc-account-xml-v2.c (dom_tree_to_account): Added.
* src/engine/gnc-transaction-xml-v2.c (dom_tree_to_transaction):
Added.
* src/FileDialog.c: Added support for copying
scheduled-transaction-related GNCBook fields.
src/engine/
* src/engine/FreqSpec.{h,c}: Added.
* src/engine/SchedXaction.{h,c}: Added.
* src/engine/gnc-{freqspec,schedxaction}-xml-v2.c: Added
* src/engine/gnc-book.c: Added the template group [template
transaction belong to the template group] and the Scheduled
Trasnaction list.
* src/gnome/glade/sched_xact.glade: Added.
* src/gnome/dialog-nextrun.{h,c}: Added.
* src/gnome/dialog-scheduledxaction.{h,c}: Added.
* src/gnome/gnc-frequency.{h,c}: Added.
* src/SplitLedger.c, src/MultiLedger.c: Added support for a
Template Ledger.
* src/guile/gnc.gwp: Added wrapping for
dialog-{scheduledxactions,nextrun}-creation functions.
* src/register/splitreg.c: Added formula credit and debit cells,
and flags for template-register support.
* src/register/formulacell.h: Added.
* src/gnome/gnc-dateedit.h: Added explanatory comment from dave_p
in IRC.
* src/gnome/query-user.h: Added prototype of
gnc_verify_dialog_parented(...), so I could use it the SX UI
stuff.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4725 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-06-18 03:25:46 -05:00
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
return ret;
|
2001-06-17 Joshua Sled <jsled@asynchronous.org>
* src/engine/gnc-account-xml-v2.c (dom_tree_to_account): Added.
* src/engine/gnc-transaction-xml-v2.c (dom_tree_to_transaction):
Added.
* src/FileDialog.c: Added support for copying
scheduled-transaction-related GNCBook fields.
src/engine/
* src/engine/FreqSpec.{h,c}: Added.
* src/engine/SchedXaction.{h,c}: Added.
* src/engine/gnc-{freqspec,schedxaction}-xml-v2.c: Added
* src/engine/gnc-book.c: Added the template group [template
transaction belong to the template group] and the Scheduled
Trasnaction list.
* src/gnome/glade/sched_xact.glade: Added.
* src/gnome/dialog-nextrun.{h,c}: Added.
* src/gnome/dialog-scheduledxaction.{h,c}: Added.
* src/gnome/gnc-frequency.{h,c}: Added.
* src/SplitLedger.c, src/MultiLedger.c: Added support for a
Template Ledger.
* src/guile/gnc.gwp: Added wrapping for
dialog-{scheduledxactions,nextrun}-creation functions.
* src/register/splitreg.c: Added formula credit and debit cells,
and flags for template-register support.
* src/register/formulacell.h: Added.
* src/gnome/gnc-dateedit.h: Added explanatory comment from dave_p
in IRC.
* src/gnome/query-user.h: Added prototype of
gnc_verify_dialog_parented(...), so I could use it the SX UI
stuff.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4725 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-06-18 03:25:46 -05:00
|
|
|
failure:
|
2016-03-12 16:04:40 -06:00
|
|
|
g_date_free (ret);
|
2009-12-29 14:12:48 -06:00
|
|
|
return NULL;
|
2001-06-17 Joshua Sled <jsled@asynchronous.org>
* src/engine/gnc-account-xml-v2.c (dom_tree_to_account): Added.
* src/engine/gnc-transaction-xml-v2.c (dom_tree_to_transaction):
Added.
* src/FileDialog.c: Added support for copying
scheduled-transaction-related GNCBook fields.
src/engine/
* src/engine/FreqSpec.{h,c}: Added.
* src/engine/SchedXaction.{h,c}: Added.
* src/engine/gnc-{freqspec,schedxaction}-xml-v2.c: Added
* src/engine/gnc-book.c: Added the template group [template
transaction belong to the template group] and the Scheduled
Trasnaction list.
* src/gnome/glade/sched_xact.glade: Added.
* src/gnome/dialog-nextrun.{h,c}: Added.
* src/gnome/dialog-scheduledxaction.{h,c}: Added.
* src/gnome/gnc-frequency.{h,c}: Added.
* src/SplitLedger.c, src/MultiLedger.c: Added support for a
Template Ledger.
* src/guile/gnc.gwp: Added wrapping for
dialog-{scheduledxactions,nextrun}-creation functions.
* src/register/splitreg.c: Added formula credit and debit cells,
and flags for template-register support.
* src/register/formulacell.h: Added.
* src/gnome/gnc-dateedit.h: Added explanatory comment from dave_p
in IRC.
* src/gnome/query-user.h: Added prototype of
gnc_verify_dialog_parented(...), so I could use it the SX UI
stuff.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4725 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-06-18 03:25:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
gnc_commodity*
|
|
|
|
dom_tree_to_commodity_ref_no_engine (xmlNodePtr node, QofBook* book)
|
2001-02-14 18:17:57 -06:00
|
|
|
{
|
2009-12-29 14:12:48 -06:00
|
|
|
/* Turn something like this
|
|
|
|
|
|
|
|
<currency>
|
|
|
|
<cmdty:space>NASDAQ</cmdty:space>
|
|
|
|
<cmdty:id>LNUX</cmdty:space>
|
|
|
|
</currency>
|
|
|
|
|
|
|
|
into a gnc_commodity*, returning NULL on failure. Both sub-nodes
|
|
|
|
are required, though for now, order is irrelevant. */
|
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
gnc_commodity* c = NULL;
|
|
|
|
gchar* space_str = NULL;
|
|
|
|
gchar* id_str = NULL;
|
2009-12-29 14:12:48 -06:00
|
|
|
xmlNodePtr n;
|
|
|
|
|
|
|
|
if (!node) return NULL;
|
|
|
|
if (!node->xmlChildrenNode) return NULL;
|
|
|
|
|
|
|
|
for (n = node->xmlChildrenNode; n; n = n->next)
|
|
|
|
{
|
|
|
|
switch (n->type)
|
|
|
|
{
|
|
|
|
case XML_COMMENT_NODE:
|
|
|
|
case XML_TEXT_NODE:
|
|
|
|
break;
|
|
|
|
case XML_ELEMENT_NODE:
|
2016-03-12 16:04:40 -06:00
|
|
|
if (g_strcmp0 ("cmdty:space", (char*)n->name) == 0)
|
2009-12-29 14:12:48 -06:00
|
|
|
{
|
|
|
|
if (space_str)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
gchar* content = dom_tree_to_text (n);
|
2009-12-29 14:12:48 -06:00
|
|
|
if (!content) return NULL;
|
|
|
|
space_str = content;
|
|
|
|
}
|
|
|
|
}
|
2016-03-12 16:04:40 -06:00
|
|
|
else if (g_strcmp0 ("cmdty:id", (char*)n->name) == 0)
|
2009-12-29 14:12:48 -06:00
|
|
|
{
|
|
|
|
if (id_str)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
gchar* content = dom_tree_to_text (n);
|
2009-12-29 14:12:48 -06:00
|
|
|
if (!content) return NULL;
|
|
|
|
id_str = content;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2016-03-12 16:04:40 -06:00
|
|
|
PERR ("unexpected sub-node.");
|
2009-12-29 14:12:48 -06:00
|
|
|
return NULL;
|
|
|
|
break;
|
2001-02-14 18:17:57 -06:00
|
|
|
}
|
2009-12-29 14:12:48 -06:00
|
|
|
}
|
2016-03-12 16:04:40 -06:00
|
|
|
if (! (space_str && id_str))
|
2009-12-29 14:12:48 -06:00
|
|
|
{
|
|
|
|
c = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
g_strstrip (space_str);
|
|
|
|
g_strstrip (id_str);
|
|
|
|
c = gnc_commodity_new (book, NULL, space_str, id_str, NULL, 0);
|
2009-12-29 14:12:48 -06:00
|
|
|
}
|
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
g_free (space_str);
|
|
|
|
g_free (id_str);
|
2009-12-29 14:12:48 -06:00
|
|
|
|
|
|
|
return c;
|
2001-02-14 18:17:57 -06:00
|
|
|
}
|
|
|
|
|
2001-02-15 02:40:33 -06:00
|
|
|
gnc_commodity*
|
2016-03-12 16:04:40 -06:00
|
|
|
dom_tree_to_commodity_ref (xmlNodePtr node, QofBook* book)
|
2001-02-15 02:40:33 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
gnc_commodity* daref;
|
|
|
|
gnc_commodity* ret;
|
|
|
|
gnc_commodity_table* table;
|
2001-10-03 05:07:45 -05:00
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
daref = dom_tree_to_commodity_ref_no_engine (node, book);
|
2001-10-03 05:07:45 -05:00
|
|
|
|
2003-09-01 10:08:26 -05:00
|
|
|
table = gnc_commodity_table_get_table (book);
|
2001-10-03 05:07:45 -05:00
|
|
|
|
|
|
|
g_return_val_if_fail (table != NULL, NULL);
|
|
|
|
|
|
|
|
ret = gnc_commodity_table_lookup (table,
|
2016-03-12 16:04:40 -06:00
|
|
|
gnc_commodity_get_namespace (daref),
|
|
|
|
gnc_commodity_get_mnemonic (daref));
|
2001-02-15 02:40:33 -06:00
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
gnc_commodity_destroy (daref);
|
2001-02-15 02:40:33 -06:00
|
|
|
|
2001-10-03 05:07:45 -05:00
|
|
|
g_return_val_if_fail (ret != NULL, NULL);
|
2001-02-15 02:40:33 -06:00
|
|
|
|
2001-10-03 05:07:45 -05:00
|
|
|
return ret;
|
2001-02-14 18:17:57 -06:00
|
|
|
}
|
2001-03-09 01:46:13 -06:00
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* generic parser */
|
|
|
|
|
2003-09-01 10:08:26 -05:00
|
|
|
static inline void
|
2016-03-12 16:04:40 -06:00
|
|
|
dom_tree_handlers_reset (struct dom_tree_handler* handlers)
|
2001-03-09 01:46:13 -06:00
|
|
|
{
|
2009-12-29 14:12:48 -06:00
|
|
|
for (; handlers->tag != NULL; handlers++)
|
2001-03-09 01:46:13 -06:00
|
|
|
{
|
|
|
|
handlers->gotten = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-01 10:08:26 -05:00
|
|
|
static inline gboolean
|
2016-03-12 16:04:40 -06:00
|
|
|
dom_tree_handlers_all_gotten_p (struct dom_tree_handler* handlers)
|
2001-03-09 01:46:13 -06:00
|
|
|
{
|
|
|
|
gboolean ret = TRUE;
|
2009-12-29 14:12:48 -06:00
|
|
|
for (; handlers->tag != NULL; handlers++)
|
2001-03-09 01:46:13 -06:00
|
|
|
{
|
2009-12-29 14:12:48 -06:00
|
|
|
if (handlers->required && ! handlers->gotten)
|
2001-03-09 01:46:13 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
PERR ("Not defined and it should be: %s",
|
|
|
|
handlers->tag ? handlers->tag : "(null)");
|
2001-03-09 01:46:13 -06:00
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2001-10-03 05:07:45 -05:00
|
|
|
|
2003-09-01 10:08:26 -05:00
|
|
|
static inline gboolean
|
2016-03-12 16:04:40 -06:00
|
|
|
gnc_xml_set_data (const gchar* tag, xmlNodePtr node, gpointer item,
|
|
|
|
struct dom_tree_handler* handlers)
|
2001-03-09 01:46:13 -06:00
|
|
|
{
|
2009-12-29 14:12:48 -06:00
|
|
|
for (; handlers->tag != NULL; handlers++)
|
2001-03-09 01:46:13 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
if (g_strcmp0 (tag, handlers->tag) == 0)
|
2001-03-09 01:46:13 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
(handlers->handler) (node, item);
|
2001-03-09 01:46:13 -06:00
|
|
|
handlers->gotten = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-10-03 05:07:45 -05:00
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
if (!handlers->tag)
|
2001-03-09 01:46:13 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
PERR ("Unhandled tag: %s",
|
|
|
|
tag ? tag : "(null)");
|
2001-03-09 01:46:13 -06:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2016-03-12 16:04:40 -06:00
|
|
|
dom_tree_generic_parse (xmlNodePtr node, struct dom_tree_handler* handlers,
|
|
|
|
gpointer data)
|
2001-03-09 01:46:13 -06:00
|
|
|
{
|
|
|
|
xmlNodePtr achild;
|
|
|
|
gboolean successful = TRUE;
|
2001-10-03 05:07:45 -05:00
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
dom_tree_handlers_reset (handlers);
|
2001-03-09 01:46:13 -06:00
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
for (achild = node->xmlChildrenNode; achild; achild = achild->next)
|
2001-03-09 01:46:13 -06:00
|
|
|
{
|
2001-10-11 06:35:50 -05:00
|
|
|
/* ignore stray text nodes */
|
2012-08-07 12:24:55 -05:00
|
|
|
if (g_strcmp0 ((char*)achild->name, "text") == 0)
|
2009-12-29 14:12:48 -06:00
|
|
|
continue;
|
2001-10-11 06:35:50 -05:00
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
if (!gnc_xml_set_data ((char*)achild->name, achild, data, handlers))
|
2001-03-09 01:46:13 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
PERR ("gnc_xml_set_data failed");
|
2001-03-09 01:46:13 -06:00
|
|
|
successful = FALSE;
|
2002-12-23 20:27:10 -06:00
|
|
|
continue;
|
2001-03-09 01:46:13 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-12 16:04:40 -06:00
|
|
|
if (!dom_tree_handlers_all_gotten_p (handlers))
|
2001-03-09 01:46:13 -06:00
|
|
|
{
|
2016-03-12 16:04:40 -06:00
|
|
|
PERR ("didn't find all of the expected tags in the input");
|
2001-03-09 01:46:13 -06:00
|
|
|
successful = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return successful;
|
|
|
|
}
|
2005-11-01 21:32:36 -06:00
|
|
|
|
2017-12-29 12:52:45 -06:00
|
|
|
gboolean
|
|
|
|
dom_tree_valid_time64 (time64 val, const xmlChar * name)
|
|
|
|
{
|
2018-04-28 05:16:52 -05:00
|
|
|
if (val != INT64_MAX)
|
2017-12-29 12:52:45 -06:00
|
|
|
return TRUE;
|
|
|
|
g_warning ("Invalid timestamp in data file. Look for a '%s' entry "
|
2018-05-04 12:04:52 -05:00
|
|
|
"with a year outside of the valid range: 1400..10000", name);
|
2017-12-29 12:52:45 -06:00
|
|
|
return FALSE;
|
|
|
|
}
|