[rrd-developers] Building rrdtool v1.3.8 on win32
Tobias Oetiker
tobi at oetiker.ch
Sat Jul 4 16:35:16 CEST 2009
Hi Barrie,
would the following patch work for you too:
Index: rrd_restore.c
===================================================================
--- rrd_restore.c (revision 1801)
+++ rrd_restore.c (working copy)
@@ -151,6 +151,36 @@
return (0);
} /* int get_ulong_from_node */
+static int get_long_long_from_node(
+ xmlDoc * doc,
+ xmlNode * node,
+ long long *value)
+{
+ long long temp;
+ char *str_ptr;
+ char *end_ptr;
+
+ str_ptr = (char *) xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
+ if (str_ptr == NULL) {
+ rrd_set_error("get_ulong_from_node: xmlNodeListGetString failed.");
+ return (-1);
+ }
+
+ end_ptr = NULL;
+ temp = strtoll(str_ptr, &end_ptr, 0);
+ xmlFree(str_ptr);
+
+ if (str_ptr == end_ptr) {
+ rrd_set_error("get_long_long_from_node: Cannot parse buffer as unsigned long long: %s",
+ str_ptr);
+ return (-1);
+ }
+
+ *value = temp;
+
+ return (0);
+} /* int get_ulong_from_node */
+
static int get_double_from_node(
xmlDoc * doc,
xmlNode * node,
@@ -918,8 +948,12 @@
status = get_ulong_from_node(doc, child,
&rrd->stat_head->pdp_step);
else if (xmlStrcmp(child->name, (const xmlChar *) "lastupdate") == 0)
- status = get_long_from_node(doc, child,
- &rrd->live_head->last_up);
+ if (sizeof(time_t) == sizeof(long)) {
+ status = get_long_from_node(doc, child, (long *)&rrd->live_head->last_up);
+ }
+ else if (sizeof(time_t) == sizeof(long long)) {
+ status = get_long_long_from_node(doc, child, (long long *)&rrd->live_head->last_up);
+ }
else if (xmlStrcmp(child->name, (const xmlChar *) "ds") == 0)
status = parse_tag_ds(doc, child, rrd);
else if (xmlStrcmp(child->name, (const xmlChar *) "rra") == 0)
Yesterday Barrie0482 wrote:
>
>
> Barrie0482 wrote:
> >
> >
> > I received the following error when I tried to build rrdlib.
> >
> > 1>------ Build started: Project: rrdlib, Configuration: Debug Win32 ------
> > 1>Compiling...
> > 1>rrd_restore.c
> > 1>..\src\rrd_restore.c(917) : error C2664: 'get_long_from_node' : cannot
> > convert parameter 3 from 'time_t *' to 'long *'
> > 1> Types pointed to are unrelated; conversion requires
> > reinterpret_cast, C-style cast or function-style
> > casthttp://oss.oetiker.ch/rrdtool/forum.en.html#nabble-td3169370%7Ca3169370
> > 1>Build log was saved at
> > "file://d:\projects\rrdtool\rrdtool-1.3.8\win32\Debug\BuildLog.htm"
> > 1>rrdlib - 1 error(s), 0 warning(s)
> > ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
> > ==========
> >
>
>
> OK, I have found a fix for this error. I have added the patch file below.
>
> --- D:\rrdtool\src\rrd_restore_orig.c
> +++ D:\rrdtool\src\rrd_restore.c
> @@ -48,6 +48,7 @@
> #define ARRAY_LENGTH(a) (sizeof (a) / sizeof ((a)[0]))
> static int opt_range_check = 0;
> static int opt_force_overwrite = 0;
> +long * timet2long;
>
> /*
> * Auxiliary functions
> @@ -897,12 +898,11 @@
> rrd->stat_head->version,
> sizeof (rrd->stat_head->version));
> else if (xmlStrcmp(child->name, (const xmlChar *) "step") == 0)
> - status = get_ulong_from_node(doc, child,
> - &rrd->stat_head->pdp_step);
> - else if (xmlStrcmp(child->name, (const xmlChar *) "lastupdate") ==
> 0)
> - status = get_long_from_node(doc, child,
> - &rrd->live_head->last_up);
> - else if (xmlStrcmp(child->name, (const xmlChar *) "ds") == 0)
> + status = get_ulong_from_node(doc, child,
> &rrd->stat_head->pdp_step);
> + else if (xmlStrcmp(child->name, (const xmlChar *) "lastupdate") ==
> 0) {
> + timet2long = (long *) & rrd->live_head->last_up;
> + status = get_long_from_node(doc, child, timet2long);
> + } else if (xmlStrcmp(child->name, (const xmlChar *) "ds") == 0)
> status = parse_tag_ds(doc, child, rrd);
> else if (xmlStrcmp(child->name, (const xmlChar *) "rra") == 0)
> status = parse_tag_rra(doc, child, rrd);
>
> I'm not sure if this is the best way to fix the problem I had, but it
> worked. I have been able to compile and run rrdtool v1.3.8 on Windows XP. I
> am going to do some testing and try to compile the ruby gem on this build.
>
> Cheers, Barrie
>
--
Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten, Switzerland
http://it.oetiker.ch tobi at oetiker.ch ++41 62 775 9902 / sb: -9900
More information about the rrd-developers
mailing list