* RRDtool 1.3.2 Copyright by Tobi Oetiker, 1997-2009
*****************************************************************************
* rrd_restore.c Contains logic to parse XML input and create an RRD file
- * initial libxml2 version of rrd_restore (c) by Florian octo Forster
+ * This file:
+ * Copyright (C) 2008 Florian octo Forster (original libxml2 code)
+ * Copyright (C) 2008,2009 Tobias Oetiker
*****************************************************************************
* $Id$
*************************************************************************** */
#include <string.h>
#include <libxml/parser.h>
#include <libxml/xmlreader.h>
-
+#include <locale.h>
#ifndef WIN32
# include <unistd.h> /* for off_t */
return -1;
} /* get_xml_ulong */
+#ifndef TIME_T_IS_LONG
static int get_xml_llong(
xmlTextReaderPtr reader,
long long *value)
return -1;
} /* get_xml_llong */
+#endif
+
static int get_xml_double(
xmlTextReaderPtr reader,
double *value)
}
errno = 0;
temp = strtod((char *)text,NULL);
- xmlFree(text);
if (errno>0){
rrd_set_error("ling %d: get_xml_double from '%s' %s",
xmlTextReaderGetParserLineNumber(reader),
text,rrd_strerror(errno));
+ xmlFree(text);
return -1;
}
+ xmlFree(text);
*value = temp;
return 0;
}
status = get_xml_ulong(reader,
&rrd->stat_head->pdp_step);
else if (xmlStrcasecmp(element, (const xmlChar *) "lastupdate") == 0) {
+#ifdef TIME_T_IS_LONG
+ status = get_xml_long(reader, &rrd->live_head->last_up);
+#else
+#ifdef TIME_T_IS_LONG_LONG
+ status = get_xml_llong(reader, &rrd->live_head->last_up);
+#else
if (sizeof(time_t) == sizeof(long)) {
status = get_xml_long(reader,
(long *)&rrd->live_head->last_up);
status = get_xml_llong(reader,
(long long *)&rrd->live_head->last_up);
}
+#endif
+#endif
}
else if (xmlStrcasecmp(element, (const xmlChar *) "ds") == 0){
xmlFree(element);
char **argv)
{
rrd_t *rrd;
-
+ char *old_locale;
/* init rrd clean */
optind = 0;
opterr = 0; /* initialize getopt */
return (-1);
}
+ old_locale = setlocale(LC_NUMERIC, "C");
+
rrd = parse_file(argv[optind]);
+
+ setlocale(LC_NUMERIC, old_locale);
+
if (rrd == NULL)
return (-1);