[rrd-developers] Building rrdtool v1.3.8 on win32

Tobias Oetiker tobi at oetiker.ch
Mon Jul 6 12:04:28 CEST 2009


Hi Barrie,

just to be sure, here is the latest version of the patch ...

--- rrd_restore.c       (revision 1801)
+++ rrd_restore.c       (working copy)
@@ -151,6 +151,46 @@
     return (0);
 }                       /* int get_ulong_from_node */

+
+#ifdef WIN32
+/* Gross Hack Alert */
+#if _MSC_VER < 1300
+#define strtoll(p, e, b) ((*(e) = (char*)(p) + (((b) == 10) ? strspn((p), "0123456789") : 0)), _atoi64(p))
+#else
+#define strtoll(p, e, b) _strtoi64(p, e, b)
+#endif
+#endif
+
+static int get_llong_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_llong_from_node: xmlNodeListGetString failed.");
+        return (-1);
+    }
+
+    end_ptr = NULL;
+    temp = strtoll(str_ptr, &end_ptr, 10);
+    xmlFree(str_ptr);
+
+    if (str_ptr == end_ptr) {
+        rrd_set_error("get_llong_from_node: Cannot parse buffer as unsigned long long: %s",
+                      str_ptr);
+        return (-1);
+    }
+
+    *value = temp;
+
+    return (0);
+}                       /* int get_llong_from_node */
+
 static int get_double_from_node(
     xmlDoc * doc,
     xmlNode * node,
@@ -917,9 +957,19 @@
         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 *) "lastupdate") == 0) {
+            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_llong_from_node(doc, child, (long long *)&rrd->live_head->last_up);
+                    }
+                    else {
+                       rrd_set_error("can't convert to time_t ...", child->name);
+                       status = -1;
+                    }
+            }
+        }
         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)


cheers
tobi

Today Barrie wrote:

> Hi Tobi,
>
> I was wrong in my last mail. It actually looks like rrd_restore is now not
> working. I must have been testing with the wrong binaries.
>
> I am going to clean up my project area and make sure I have my information
> correct.
>
> Sorry about the wrong information.
>
> Cheers, Barrie
>
>
> Tobias Oetiker wrote:
> > Tomorrow Barrie wrote:
> >
> >
> > > Hi Tobi,
> > >
> > > The errors occur on both the rrd created bt rrd_create and rrd_restore.
> > >
> > > rrdtool.exe info test.rrd
> > > ERROR: 'test.rrd' is too small (should be 5676 bytes)
> > >
> > > rrdtool.exe info new.rrd
> > > ERROR: 'new.rrd' is too small (should be 5676 bytes)
> > >
> >
> > ok so it is at least consistant ...
> > cheers
> > tobi
> >
> >
> > > Cheers, Barrie
> > >
> > > Tobias Oetiker wrote:
> > >
> > > > do the errors only occure on the rrds created by rrd_restore ? this
> > > > would indicate that there is still a problem with rrd_restore on
> > > > windows ...
> > > >
> > > >
> > >
> >
> >   ------------------------------------------------------------------------
> >
> >
> > No virus found in this incoming message.
> > Checked by AVG - www.avg.com Version: 8.5.375 / Virus Database:
> > 270.13.5/2219 - Release Date: 07/05/09 05:53:00
> >
> >
>
>

-- 
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