#include "extconf.h"
+/* For Ruby < 1.9 */
+#ifndef RARRAY_LEN
+#define RARRAY_LEN(r) (RARRAY((r))->len)
+#endif
+
static VALUE m_guestfs; /* guestfs module */
static VALUE c_guestfs; /* guestfs_h handle */
static VALUE e_Error; /* used for all errors */
return rv;
}
+static VALUE ruby_guestfs_ping_daemon (VALUE gv)
+{
+ guestfs_h *g;
+ Data_Get_Struct (gv, guestfs_h, g);
+ if (!g)
+ rb_raise (rb_eArgError, "%s: used handle after closing it", "ping_daemon");
+
+
+ int r;
+
+ r = guestfs_ping_daemon (g);
+ if (r == -1)
+ rb_raise (e_Error, "%s", guestfs_last_error (g));
+
+ return Qnil;
+}
+
+static VALUE ruby_guestfs_equal (VALUE gv, VALUE file1v, VALUE file2v)
+{
+ guestfs_h *g;
+ Data_Get_Struct (gv, guestfs_h, g);
+ if (!g)
+ rb_raise (rb_eArgError, "%s: used handle after closing it", "equal");
+
+ const char *file1 = StringValueCStr (file1v);
+ if (!file1)
+ rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
+ "file1", "equal");
+ const char *file2 = StringValueCStr (file2v);
+ if (!file2)
+ rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
+ "file2", "equal");
+
+ int r;
+
+ r = guestfs_equal (g, file1, file2);
+ if (r == -1)
+ rb_raise (e_Error, "%s", guestfs_last_error (g));
+
+ return INT2NUM (r);
+}
+
/* Initialize the module. */
void Init__guestfs ()
{
ruby_guestfs_drop_caches, 1);
rb_define_method (c_guestfs, "dmesg",
ruby_guestfs_dmesg, 0);
+ rb_define_method (c_guestfs, "ping_daemon",
+ ruby_guestfs_ping_daemon, 0);
+ rb_define_method (c_guestfs, "equal",
+ ruby_guestfs_equal, 2);
}