summaryrefslogtreecommitdiffstats
path: root/ruby/ext
diff options
context:
space:
mode:
authorRichard Jones <rjones@trick.home.annexia.org>2009-06-22 07:49:50 +0100
committerRichard Jones <rjones@trick.home.annexia.org>2009-06-22 07:49:50 +0100
commit4211c7a258debd236017a19c70965bc1b3658edb (patch)
tree50372cfd72f49b84b753e2aa58c92dfc99b4586f /ruby/ext
parent57d2dfab18ad3d987d9273bb7c1f42e73e0bbcb2 (diff)
downloadlibguestfs-4211c7a258debd236017a19c70965bc1b3658edb.tar.gz
libguestfs-4211c7a258debd236017a19c70965bc1b3658edb.tar.xz
libguestfs-4211c7a258debd236017a19c70965bc1b3658edb.zip
Generated code for 'sh' and 'sh-lines' commands.
Diffstat (limited to 'ruby/ext')
-rw-r--r--ruby/ext/guestfs/_guestfs.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/ruby/ext/guestfs/_guestfs.c b/ruby/ext/guestfs/_guestfs.c
index 38256dc0..81e36910 100644
--- a/ruby/ext/guestfs/_guestfs.c
+++ b/ruby/ext/guestfs/_guestfs.c
@@ -4003,6 +4003,58 @@ static VALUE ruby_guestfs_ntfs_3g_probe (VALUE gv, VALUE rwv, VALUE devicev)
return INT2NUM (r);
}
+static VALUE ruby_guestfs_sh (VALUE gv, VALUE commandv)
+{
+ guestfs_h *g;
+ Data_Get_Struct (gv, guestfs_h, g);
+ if (!g)
+ rb_raise (rb_eArgError, "%s: used handle after closing it", "sh");
+
+ const char *command = StringValueCStr (commandv);
+ if (!command)
+ rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
+ "command", "sh");
+
+ char *r;
+
+ r = guestfs_sh (g, command);
+ if (r == NULL)
+ rb_raise (e_Error, "%s", guestfs_last_error (g));
+
+ VALUE rv = rb_str_new2 (r);
+ free (r);
+ return rv;
+}
+
+static VALUE ruby_guestfs_sh_lines (VALUE gv, VALUE commandv)
+{
+ guestfs_h *g;
+ Data_Get_Struct (gv, guestfs_h, g);
+ if (!g)
+ rb_raise (rb_eArgError, "%s: used handle after closing it", "sh_lines");
+
+ const char *command = StringValueCStr (commandv);
+ if (!command)
+ rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
+ "command", "sh_lines");
+
+ char **r;
+
+ r = guestfs_sh_lines (g, command);
+ if (r == NULL)
+ rb_raise (e_Error, "%s", guestfs_last_error (g));
+
+ int i, len = 0;
+ for (i = 0; r[i] != NULL; ++i) len++;
+ VALUE rv = rb_ary_new2 (len);
+ for (i = 0; r[i] != NULL; ++i) {
+ rb_ary_push (rv, rb_str_new2 (r[i]));
+ free (r[i]);
+ }
+ free (r);
+ return rv;
+}
+
/* Initialize the module. */
void Init__guestfs ()
{
@@ -4337,4 +4389,8 @@ void Init__guestfs ()
ruby_guestfs_sleep, 1);
rb_define_method (c_guestfs, "ntfs_3g_probe",
ruby_guestfs_ntfs_3g_probe, 2);
+ rb_define_method (c_guestfs, "sh",
+ ruby_guestfs_sh, 1);
+ rb_define_method (c_guestfs, "sh_lines",
+ ruby_guestfs_sh_lines, 1);
}