X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=ruby%2Fext%2Fguestfs%2F_guestfs.c;h=9971228f175cfc6192383887ef836a3a085ce584;hp=f73a3b78afff97b05315e01ec79e2fa725e6ee57;hb=0232e722826cfda0f6042da983f9eb871f24e946;hpb=bb07a7f858da5d07c57360e62c0ddfd24ce6be45 diff --git a/ruby/ext/guestfs/_guestfs.c b/ruby/ext/guestfs/_guestfs.c index f73a3b7..9971228 100644 --- a/ruby/ext/guestfs/_guestfs.c +++ b/ruby/ext/guestfs/_guestfs.c @@ -374,6 +374,40 @@ static VALUE ruby_guestfs_get_state (VALUE gv) return INT2NUM (r); } +static VALUE ruby_guestfs_set_busy (VALUE gv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "set_busy"); + + + int r; + + r = guestfs_set_busy (g); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + +static VALUE ruby_guestfs_set_ready (VALUE gv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "set_ready"); + + + int r; + + r = guestfs_set_ready (g); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + static VALUE ruby_guestfs_mount (VALUE gv, VALUE devicev, VALUE mountpointv) { guestfs_h *g; @@ -2032,6 +2066,133 @@ static VALUE ruby_guestfs_download (VALUE gv, VALUE remotefilenamev, VALUE filen return Qnil; } +static VALUE ruby_guestfs_checksum (VALUE gv, VALUE csumtypev, VALUE pathv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "checksum"); + + const char *csumtype = StringValueCStr (csumtypev); + if (!csumtype) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "csumtype", "checksum"); + const char *path = StringValueCStr (pathv); + if (!path) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "path", "checksum"); + + char *r; + + r = guestfs_checksum (g, csumtype, path); + 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_tar_in (VALUE gv, VALUE tarfilev, VALUE directoryv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "tar_in"); + + const char *tarfile = StringValueCStr (tarfilev); + if (!tarfile) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "tarfile", "tar_in"); + const char *directory = StringValueCStr (directoryv); + if (!directory) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "directory", "tar_in"); + + int r; + + r = guestfs_tar_in (g, tarfile, directory); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + +static VALUE ruby_guestfs_tar_out (VALUE gv, VALUE directoryv, VALUE tarfilev) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "tar_out"); + + const char *directory = StringValueCStr (directoryv); + if (!directory) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "directory", "tar_out"); + const char *tarfile = StringValueCStr (tarfilev); + if (!tarfile) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "tarfile", "tar_out"); + + int r; + + r = guestfs_tar_out (g, directory, tarfile); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + +static VALUE ruby_guestfs_tgz_in (VALUE gv, VALUE tarballv, VALUE directoryv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "tgz_in"); + + const char *tarball = StringValueCStr (tarballv); + if (!tarball) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "tarball", "tgz_in"); + const char *directory = StringValueCStr (directoryv); + if (!directory) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "directory", "tgz_in"); + + int r; + + r = guestfs_tgz_in (g, tarball, directory); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + +static VALUE ruby_guestfs_tgz_out (VALUE gv, VALUE directoryv, VALUE tarballv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "tgz_out"); + + const char *directory = StringValueCStr (directoryv); + if (!directory) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "directory", "tgz_out"); + const char *tarball = StringValueCStr (tarballv); + if (!tarball) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "tarball", "tgz_out"); + + int r; + + r = guestfs_tgz_out (g, directory, tarball); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + /* Initialize the module. */ void Init__guestfs () { @@ -2076,6 +2237,10 @@ void Init__guestfs () ruby_guestfs_is_busy, 0); rb_define_method (c_guestfs, "get_state", ruby_guestfs_get_state, 0); + rb_define_method (c_guestfs, "set_busy", + ruby_guestfs_set_busy, 0); + rb_define_method (c_guestfs, "set_ready", + ruby_guestfs_set_ready, 0); rb_define_method (c_guestfs, "mount", ruby_guestfs_mount, 2); rb_define_method (c_guestfs, "sync", @@ -2210,4 +2375,14 @@ void Init__guestfs () ruby_guestfs_upload, 2); rb_define_method (c_guestfs, "download", ruby_guestfs_download, 2); + rb_define_method (c_guestfs, "checksum", + ruby_guestfs_checksum, 2); + rb_define_method (c_guestfs, "tar_in", + ruby_guestfs_tar_in, 2); + rb_define_method (c_guestfs, "tar_out", + ruby_guestfs_tar_out, 2); + rb_define_method (c_guestfs, "tgz_in", + ruby_guestfs_tgz_in, 2); + rb_define_method (c_guestfs, "tgz_out", + ruby_guestfs_tgz_out, 2); }