rename ntmake.pl to ntmake.PL so that it does not get installed
[rrdtool.git] / bindings / ruby / main.c
index d2a7ace..551203b 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <unistd.h>
 #include <ruby.h>
+#include <math.h>
 #include "../../src/rrd_tool.h"
 
 typedef struct string_arr_t {
@@ -19,6 +20,11 @@ typedef int (
     int argc,
     char **argv);
 
+typedef rrd_info_t *(
+    *RRDINFOFUNC) (
+    int argc,
+    char **argv);
+
 #define RRD_CHECK_ERROR  \
     if (rrd_test_error()) \
       rb_raise(rb_eRRDError, rrd_get_error()); \
@@ -142,7 +148,7 @@ VALUE rb_rrd_update(
 /* Calls Returning Data via the Info Interface */
 
 VALUE rb_rrd_infocall(
-    RRDFUNC func,
+    RRDINFOFUNC func,
     VALUE args)
 {
     string_arr a;
@@ -173,9 +179,12 @@ VALUE rb_rrd_infocall(
         case RD_I_STR:
             rb_hash_aset(result, key, rb_str_new2(data->value.u_str));
             break;
+        case RD_I_INT:
+            rb_hash_aset(result, key, INT2FIX(data->value.u_int));
+            break;
         case RD_I_BLO:
             rb_hash_aset(result, key,
-                         rb_str_new(data->value.u_blo.ptr,
+                         rb_str_new((char *)data->value.u_blo.ptr,
                                     data->value.u_blo.size));
             break;
         }
@@ -300,7 +309,7 @@ VALUE rb_rrd_last(
     string_arr_delete(a);
 
     RRD_CHECK_ERROR
-        return rb_funcall(rb_cTime, rb_intern("at"), 1, INT2FIX(last));
+        return rb_funcall(rb_cTime, rb_intern("at"), 1, UINT2NUM(last));
 }
 
 void Init_RRD(