From c41fe04a652437c920acb0e820762c53bf44a139 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 28 May 2009 16:23:04 +0100 Subject: [PATCH] Add the test0* functions, used to test language bindings. --- capitests/tests.c | 31 +- java/com/redhat/et/libguestfs/GuestFS.java | 270 ++++++++ java/com_redhat_et_libguestfs_GuestFS.c | 950 +++++++++++++++++++++++++++++ ocaml/guestfs.ml | 27 + ocaml/guestfs.mli | 81 +++ ocaml/guestfs_c_actions.c | 653 ++++++++++++++++++++ perl/Guestfs.xs | 565 +++++++++++++++++ perl/t/006-pod-coverage.t | 2 +- python/guestfs-py.c | 695 +++++++++++++++++++++ python/guestfs.py | 81 +++ ruby/ext/guestfs/_guestfs.c | 831 +++++++++++++++++++++++++ src/Makefile.am | 1 + src/generator.ml | 500 +++++++++++---- src/guestfs-actions.h | 27 + src/guestfs-bindtests.c | 307 ++++++++++ 15 files changed, 4905 insertions(+), 116 deletions(-) create mode 100644 src/guestfs-bindtests.c diff --git a/capitests/tests.c b/capitests/tests.c index 5d94598..c0c3597 100644 --- a/capitests/tests.c +++ b/capitests/tests.c @@ -62,6 +62,33 @@ static void print_table (char * const * const argv) static void no_test_warnings (void) { + fprintf (stderr, "warning: \"guestfs_test0\" has no tests\n"); + fprintf (stderr, "warning: \"guestfs_test0rint\" has no tests\n"); + fprintf (stderr, "warning: \"guestfs_test0rinterr\" has no tests\n"); + fprintf (stderr, "warning: \"guestfs_test0rint64\" has no tests\n"); + fprintf (stderr, "warning: \"guestfs_test0rint64err\" has no tests\n"); + fprintf (stderr, "warning: \"guestfs_test0rbool\" has no tests\n"); + fprintf (stderr, "warning: \"guestfs_test0rboolerr\" has no tests\n"); + fprintf (stderr, "warning: \"guestfs_test0rconststring\" has no tests\n"); + fprintf (stderr, "warning: \"guestfs_test0rconststringerr\" has no tests\n"); + fprintf (stderr, "warning: \"guestfs_test0rstring\" has no tests\n"); + fprintf (stderr, "warning: \"guestfs_test0rstringerr\" has no tests\n"); + fprintf (stderr, "warning: \"guestfs_test0rstringlist\" has no tests\n"); + fprintf (stderr, "warning: \"guestfs_test0rstringlisterr\" has no tests\n"); + fprintf (stderr, "warning: \"guestfs_test0rintbool\" has no tests\n"); + fprintf (stderr, "warning: \"guestfs_test0rintboolerr\" has no tests\n"); + fprintf (stderr, "warning: \"guestfs_test0rpvlist\" has no tests\n"); + fprintf (stderr, "warning: \"guestfs_test0rpvlisterr\" has no tests\n"); + fprintf (stderr, "warning: \"guestfs_test0rvglist\" has no tests\n"); + fprintf (stderr, "warning: \"guestfs_test0rvglisterr\" has no tests\n"); + fprintf (stderr, "warning: \"guestfs_test0rlvlist\" has no tests\n"); + fprintf (stderr, "warning: \"guestfs_test0rlvlisterr\" has no tests\n"); + fprintf (stderr, "warning: \"guestfs_test0rstat\" has no tests\n"); + fprintf (stderr, "warning: \"guestfs_test0rstaterr\" has no tests\n"); + fprintf (stderr, "warning: \"guestfs_test0rstatvfs\" has no tests\n"); + fprintf (stderr, "warning: \"guestfs_test0rstatvfserr\" has no tests\n"); + fprintf (stderr, "warning: \"guestfs_test0rhashtable\" has no tests\n"); + fprintf (stderr, "warning: \"guestfs_test0rhashtableerr\" has no tests\n"); fprintf (stderr, "warning: \"guestfs_launch\" has no tests\n"); fprintf (stderr, "warning: \"guestfs_wait_ready\" has no tests\n"); fprintf (stderr, "warning: \"guestfs_kill_subprocess\" has no tests\n"); @@ -4762,7 +4789,7 @@ static int test_tgz_in_0 (void) char directory[] = "/"; int r; suppress_error = 0; - r = guestfs_tgz_in (g, "images/helloworld.tar.gz", directory); + r = guestfs_tgz_in (g, "../images/helloworld.tar.gz", directory); if (r == -1) return -1; } @@ -4864,7 +4891,7 @@ static int test_tar_in_0 (void) char directory[] = "/"; int r; suppress_error = 0; - r = guestfs_tar_in (g, "images/helloworld.tar", directory); + r = guestfs_tar_in (g, "../images/helloworld.tar", directory); if (r == -1) return -1; } diff --git a/java/com/redhat/et/libguestfs/GuestFS.java b/java/com/redhat/et/libguestfs/GuestFS.java index c7fcc11..d340b8c 100644 --- a/java/com/redhat/et/libguestfs/GuestFS.java +++ b/java/com/redhat/et/libguestfs/GuestFS.java @@ -81,6 +81,276 @@ public class GuestFS { close (); } +public void test0 (String str, String optstr, String[] strlist, boolean b, int integer, String filein, String fileout) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0: handle is closed"); + _test0 (g, str, optstr, strlist, b, integer, filein, fileout); + } + private native void _test0 (long g, String str, String optstr, String[] strlist, boolean b, int integer, String filein, String fileout) + throws LibGuestFSException; + +public int test0rint (String val) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rint: handle is closed"); + return _test0rint (g, val); + } + private native int _test0rint (long g, String val) + throws LibGuestFSException; + +public int test0rinterr () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rinterr: handle is closed"); + return _test0rinterr (g); + } + private native int _test0rinterr (long g) + throws LibGuestFSException; + +public long test0rint64 (String val) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rint64: handle is closed"); + return _test0rint64 (g, val); + } + private native long _test0rint64 (long g, String val) + throws LibGuestFSException; + +public long test0rint64err () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rint64err: handle is closed"); + return _test0rint64err (g); + } + private native long _test0rint64err (long g) + throws LibGuestFSException; + +public boolean test0rbool (String val) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rbool: handle is closed"); + return _test0rbool (g, val); + } + private native boolean _test0rbool (long g, String val) + throws LibGuestFSException; + +public boolean test0rboolerr () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rboolerr: handle is closed"); + return _test0rboolerr (g); + } + private native boolean _test0rboolerr (long g) + throws LibGuestFSException; + +public String test0rconststring (String val) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rconststring: handle is closed"); + return _test0rconststring (g, val); + } + private native String _test0rconststring (long g, String val) + throws LibGuestFSException; + +public String test0rconststringerr () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rconststringerr: handle is closed"); + return _test0rconststringerr (g); + } + private native String _test0rconststringerr (long g) + throws LibGuestFSException; + +public String test0rstring (String val) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rstring: handle is closed"); + return _test0rstring (g, val); + } + private native String _test0rstring (long g, String val) + throws LibGuestFSException; + +public String test0rstringerr () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rstringerr: handle is closed"); + return _test0rstringerr (g); + } + private native String _test0rstringerr (long g) + throws LibGuestFSException; + +public String[] test0rstringlist (String val) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rstringlist: handle is closed"); + return _test0rstringlist (g, val); + } + private native String[] _test0rstringlist (long g, String val) + throws LibGuestFSException; + +public String[] test0rstringlisterr () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rstringlisterr: handle is closed"); + return _test0rstringlisterr (g); + } + private native String[] _test0rstringlisterr (long g) + throws LibGuestFSException; + +public IntBool test0rintbool (String val) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rintbool: handle is closed"); + return _test0rintbool (g, val); + } + private native IntBool _test0rintbool (long g, String val) + throws LibGuestFSException; + +public IntBool test0rintboolerr () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rintboolerr: handle is closed"); + return _test0rintboolerr (g); + } + private native IntBool _test0rintboolerr (long g) + throws LibGuestFSException; + +public PV[] test0rpvlist (String val) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rpvlist: handle is closed"); + return _test0rpvlist (g, val); + } + private native PV[] _test0rpvlist (long g, String val) + throws LibGuestFSException; + +public PV[] test0rpvlisterr () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rpvlisterr: handle is closed"); + return _test0rpvlisterr (g); + } + private native PV[] _test0rpvlisterr (long g) + throws LibGuestFSException; + +public VG[] test0rvglist (String val) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rvglist: handle is closed"); + return _test0rvglist (g, val); + } + private native VG[] _test0rvglist (long g, String val) + throws LibGuestFSException; + +public VG[] test0rvglisterr () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rvglisterr: handle is closed"); + return _test0rvglisterr (g); + } + private native VG[] _test0rvglisterr (long g) + throws LibGuestFSException; + +public LV[] test0rlvlist (String val) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rlvlist: handle is closed"); + return _test0rlvlist (g, val); + } + private native LV[] _test0rlvlist (long g, String val) + throws LibGuestFSException; + +public LV[] test0rlvlisterr () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rlvlisterr: handle is closed"); + return _test0rlvlisterr (g); + } + private native LV[] _test0rlvlisterr (long g) + throws LibGuestFSException; + +public Stat test0rstat (String val) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rstat: handle is closed"); + return _test0rstat (g, val); + } + private native Stat _test0rstat (long g, String val) + throws LibGuestFSException; + +public Stat test0rstaterr () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rstaterr: handle is closed"); + return _test0rstaterr (g); + } + private native Stat _test0rstaterr (long g) + throws LibGuestFSException; + +public StatVFS test0rstatvfs (String val) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rstatvfs: handle is closed"); + return _test0rstatvfs (g, val); + } + private native StatVFS _test0rstatvfs (long g, String val) + throws LibGuestFSException; + +public StatVFS test0rstatvfserr () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rstatvfserr: handle is closed"); + return _test0rstatvfserr (g); + } + private native StatVFS _test0rstatvfserr (long g) + throws LibGuestFSException; + +public HashMap test0rhashtable (String val) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rhashtable: handle is closed"); + return _test0rhashtable (g, val); + } + private native HashMap _test0rhashtable (long g, String val) + throws LibGuestFSException; + +public HashMap test0rhashtableerr () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rhashtableerr: handle is closed"); + return _test0rhashtableerr (g); + } + private native HashMap _test0rhashtableerr (long g) + throws LibGuestFSException; + /** * launch the qemu subprocess *

diff --git a/java/com_redhat_et_libguestfs_GuestFS.c b/java/com_redhat_et_libguestfs_GuestFS.c index dea916e..37683bf 100644 --- a/java/com_redhat_et_libguestfs_GuestFS.c +++ b/java/com_redhat_et_libguestfs_GuestFS.c @@ -62,6 +62,956 @@ Java_com_redhat_et_libguestfs_GuestFS__1close } JNIEXPORT void JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1test0 + (JNIEnv *env, jobject obj, jlong jg, jstring jstr, jstring joptstr, jobjectArray jstrlist, jboolean jb, jint jinteger, jstring jfilein, jstring jfileout) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + int r; + const char *str; + const char *optstr; + int strlist_len; + const char **strlist; + int b; + int integer; + const char *filein; + const char *fileout; + int i; + + str = (*env)->GetStringUTFChars (env, jstr, NULL); + optstr = (*env)->GetStringUTFChars (env, joptstr, NULL); + strlist_len = (*env)->GetArrayLength (env, jstrlist); + strlist = guestfs_safe_malloc (g, sizeof (char *) * (strlist_len+1)); + for (i = 0; i < strlist_len; ++i) { + jobject o = (*env)->GetObjectArrayElement (env, jstrlist, i); + strlist[i] = (*env)->GetStringUTFChars (env, o, NULL); + } + strlist[strlist_len] = NULL; + b = jb; + integer = jinteger; + filein = (*env)->GetStringUTFChars (env, jfilein, NULL); + fileout = (*env)->GetStringUTFChars (env, jfileout, NULL); + r = guestfs_test0 (g, str, optstr, strlist, b, integer, filein, fileout); + (*env)->ReleaseStringUTFChars (env, jstr, str); + (*env)->ReleaseStringUTFChars (env, joptstr, optstr); + for (i = 0; i < strlist_len; ++i) { + jobject o = (*env)->GetObjectArrayElement (env, jstrlist, i); + (*env)->ReleaseStringUTFChars (env, o, strlist[i]); + } + free (strlist); + (*env)->ReleaseStringUTFChars (env, jfilein, filein); + (*env)->ReleaseStringUTFChars (env, jfileout, fileout); + if (r == -1) { + throw_exception (env, guestfs_last_error (g)); + return ; + } +} + +JNIEXPORT jint JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1test0rint + (JNIEnv *env, jobject obj, jlong jg, jstring jval) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + int r; + const char *val; + + val = (*env)->GetStringUTFChars (env, jval, NULL); + r = guestfs_test0rint (g, val); + (*env)->ReleaseStringUTFChars (env, jval, val); + if (r == -1) { + throw_exception (env, guestfs_last_error (g)); + return 0; + } + return (jint) r; +} + +JNIEXPORT jint JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1test0rinterr + (JNIEnv *env, jobject obj, jlong jg) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + int r; + + r = guestfs_test0rinterr (g); + if (r == -1) { + throw_exception (env, guestfs_last_error (g)); + return 0; + } + return (jint) r; +} + +JNIEXPORT jlong JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1test0rint64 + (JNIEnv *env, jobject obj, jlong jg, jstring jval) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + int64_t r; + const char *val; + + val = (*env)->GetStringUTFChars (env, jval, NULL); + r = guestfs_test0rint64 (g, val); + (*env)->ReleaseStringUTFChars (env, jval, val); + if (r == -1) { + throw_exception (env, guestfs_last_error (g)); + return 0; + } + return (jlong) r; +} + +JNIEXPORT jlong JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1test0rint64err + (JNIEnv *env, jobject obj, jlong jg) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + int64_t r; + + r = guestfs_test0rint64err (g); + if (r == -1) { + throw_exception (env, guestfs_last_error (g)); + return 0; + } + return (jlong) r; +} + +JNIEXPORT jboolean JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1test0rbool + (JNIEnv *env, jobject obj, jlong jg, jstring jval) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + int r; + const char *val; + + val = (*env)->GetStringUTFChars (env, jval, NULL); + r = guestfs_test0rbool (g, val); + (*env)->ReleaseStringUTFChars (env, jval, val); + if (r == -1) { + throw_exception (env, guestfs_last_error (g)); + return 0; + } + return (jboolean) r; +} + +JNIEXPORT jboolean JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1test0rboolerr + (JNIEnv *env, jobject obj, jlong jg) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + int r; + + r = guestfs_test0rboolerr (g); + if (r == -1) { + throw_exception (env, guestfs_last_error (g)); + return 0; + } + return (jboolean) r; +} + +JNIEXPORT jstring JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1test0rconststring + (JNIEnv *env, jobject obj, jlong jg, jstring jval) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + const char *r; + const char *val; + + val = (*env)->GetStringUTFChars (env, jval, NULL); + r = guestfs_test0rconststring (g, val); + (*env)->ReleaseStringUTFChars (env, jval, val); + if (r == NULL) { + throw_exception (env, guestfs_last_error (g)); + return NULL; + } + return (*env)->NewStringUTF (env, r); +} + +JNIEXPORT jstring JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1test0rconststringerr + (JNIEnv *env, jobject obj, jlong jg) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + const char *r; + + r = guestfs_test0rconststringerr (g); + if (r == NULL) { + throw_exception (env, guestfs_last_error (g)); + return NULL; + } + return (*env)->NewStringUTF (env, r); +} + +JNIEXPORT jstring JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1test0rstring + (JNIEnv *env, jobject obj, jlong jg, jstring jval) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + jstring jr; + char *r; + const char *val; + + val = (*env)->GetStringUTFChars (env, jval, NULL); + r = guestfs_test0rstring (g, val); + (*env)->ReleaseStringUTFChars (env, jval, val); + if (r == NULL) { + throw_exception (env, guestfs_last_error (g)); + return NULL; + } + jr = (*env)->NewStringUTF (env, r); + free (r); + return jr; +} + +JNIEXPORT jstring JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1test0rstringerr + (JNIEnv *env, jobject obj, jlong jg) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + jstring jr; + char *r; + + r = guestfs_test0rstringerr (g); + if (r == NULL) { + throw_exception (env, guestfs_last_error (g)); + return NULL; + } + jr = (*env)->NewStringUTF (env, r); + free (r); + return jr; +} + +JNIEXPORT jobjectArray JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1test0rstringlist + (JNIEnv *env, jobject obj, jlong jg, jstring jval) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + jobjectArray jr; + int r_len; + jclass cl; + jstring jstr; + char **r; + const char *val; + int i; + + val = (*env)->GetStringUTFChars (env, jval, NULL); + r = guestfs_test0rstringlist (g, val); + (*env)->ReleaseStringUTFChars (env, jval, val); + if (r == NULL) { + throw_exception (env, guestfs_last_error (g)); + return NULL; + } + for (r_len = 0; r[r_len] != NULL; ++r_len) ; + cl = (*env)->FindClass (env, "java/lang/String"); + jstr = (*env)->NewStringUTF (env, ""); + jr = (*env)->NewObjectArray (env, r_len, cl, jstr); + for (i = 0; i < r_len; ++i) { + jstr = (*env)->NewStringUTF (env, r[i]); + (*env)->SetObjectArrayElement (env, jr, i, jstr); + free (r[i]); + } + free (r); + return jr; +} + +JNIEXPORT jobjectArray JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1test0rstringlisterr + (JNIEnv *env, jobject obj, jlong jg) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + jobjectArray jr; + int r_len; + jclass cl; + jstring jstr; + char **r; + int i; + + r = guestfs_test0rstringlisterr (g); + if (r == NULL) { + throw_exception (env, guestfs_last_error (g)); + return NULL; + } + for (r_len = 0; r[r_len] != NULL; ++r_len) ; + cl = (*env)->FindClass (env, "java/lang/String"); + jstr = (*env)->NewStringUTF (env, ""); + jr = (*env)->NewObjectArray (env, r_len, cl, jstr); + for (i = 0; i < r_len; ++i) { + jstr = (*env)->NewStringUTF (env, r[i]); + (*env)->SetObjectArrayElement (env, jr, i, jstr); + free (r[i]); + } + free (r); + return jr; +} + +JNIEXPORT jobject JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1test0rintbool + (JNIEnv *env, jobject obj, jlong jg, jstring jval) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + jobject jr; + jclass cl; + jfieldID fl; + struct guestfs_int_bool *r; + const char *val; + + val = (*env)->GetStringUTFChars (env, jval, NULL); + r = guestfs_test0rintbool (g, val); + (*env)->ReleaseStringUTFChars (env, jval, val); + if (r == NULL) { + throw_exception (env, guestfs_last_error (g)); + return NULL; + } + cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/IntBool"); + jr = (*env)->AllocObject (env, cl); + fl = (*env)->GetFieldID (env, cl, "i", "I"); + (*env)->SetIntField (env, jr, fl, r->i); + fl = (*env)->GetFieldID (env, cl, "i", "Z"); + (*env)->SetBooleanField (env, jr, fl, r->b); + guestfs_free_int_bool (r); + return jr; +} + +JNIEXPORT jobject JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1test0rintboolerr + (JNIEnv *env, jobject obj, jlong jg) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + jobject jr; + jclass cl; + jfieldID fl; + struct guestfs_int_bool *r; + + r = guestfs_test0rintboolerr (g); + if (r == NULL) { + throw_exception (env, guestfs_last_error (g)); + return NULL; + } + cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/IntBool"); + jr = (*env)->AllocObject (env, cl); + fl = (*env)->GetFieldID (env, cl, "i", "I"); + (*env)->SetIntField (env, jr, fl, r->i); + fl = (*env)->GetFieldID (env, cl, "i", "Z"); + (*env)->SetBooleanField (env, jr, fl, r->b); + guestfs_free_int_bool (r); + return jr; +} + +JNIEXPORT jobjectArray JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1test0rpvlist + (JNIEnv *env, jobject obj, jlong jg, jstring jval) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + jobjectArray jr; + jclass cl; + jfieldID fl; + jobject jfl; + struct guestfs_lvm_pv_list *r; + const char *val; + int i; + + val = (*env)->GetStringUTFChars (env, jval, NULL); + r = guestfs_test0rpvlist (g, val); + (*env)->ReleaseStringUTFChars (env, jval, val); + if (r == NULL) { + throw_exception (env, guestfs_last_error (g)); + return NULL; + } + cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/PV"); + jr = (*env)->NewObjectArray (env, r->len, cl, NULL); + for (i = 0; i < r->len; ++i) { + jfl = (*env)->AllocObject (env, cl); + fl = (*env)->GetFieldID (env, cl, "pv_name", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].pv_name)); + { + char s[33]; + memcpy (s, r->val[i].pv_uuid, 32); + s[32] = 0; + fl = (*env)->GetFieldID (env, cl, "pv_uuid", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, s)); + } + fl = (*env)->GetFieldID (env, cl, "pv_fmt", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].pv_fmt)); + fl = (*env)->GetFieldID (env, cl, "pv_size", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].pv_size); + fl = (*env)->GetFieldID (env, cl, "dev_size", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].dev_size); + fl = (*env)->GetFieldID (env, cl, "pv_free", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].pv_free); + fl = (*env)->GetFieldID (env, cl, "pv_used", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].pv_used); + fl = (*env)->GetFieldID (env, cl, "pv_attr", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].pv_attr)); + fl = (*env)->GetFieldID (env, cl, "pv_pe_count", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].pv_pe_count); + fl = (*env)->GetFieldID (env, cl, "pv_pe_alloc_count", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].pv_pe_alloc_count); + fl = (*env)->GetFieldID (env, cl, "pv_tags", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].pv_tags)); + fl = (*env)->GetFieldID (env, cl, "pe_start", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].pe_start); + fl = (*env)->GetFieldID (env, cl, "pv_mda_count", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].pv_mda_count); + fl = (*env)->GetFieldID (env, cl, "pv_mda_free", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].pv_mda_free); + (*env)->SetObjectArrayElement (env, jfl, i, jfl); + } + guestfs_free_lvm_pv_list (r); + return jr; +} + +JNIEXPORT jobjectArray JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1test0rpvlisterr + (JNIEnv *env, jobject obj, jlong jg) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + jobjectArray jr; + jclass cl; + jfieldID fl; + jobject jfl; + struct guestfs_lvm_pv_list *r; + int i; + + r = guestfs_test0rpvlisterr (g); + if (r == NULL) { + throw_exception (env, guestfs_last_error (g)); + return NULL; + } + cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/PV"); + jr = (*env)->NewObjectArray (env, r->len, cl, NULL); + for (i = 0; i < r->len; ++i) { + jfl = (*env)->AllocObject (env, cl); + fl = (*env)->GetFieldID (env, cl, "pv_name", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].pv_name)); + { + char s[33]; + memcpy (s, r->val[i].pv_uuid, 32); + s[32] = 0; + fl = (*env)->GetFieldID (env, cl, "pv_uuid", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, s)); + } + fl = (*env)->GetFieldID (env, cl, "pv_fmt", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].pv_fmt)); + fl = (*env)->GetFieldID (env, cl, "pv_size", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].pv_size); + fl = (*env)->GetFieldID (env, cl, "dev_size", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].dev_size); + fl = (*env)->GetFieldID (env, cl, "pv_free", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].pv_free); + fl = (*env)->GetFieldID (env, cl, "pv_used", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].pv_used); + fl = (*env)->GetFieldID (env, cl, "pv_attr", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].pv_attr)); + fl = (*env)->GetFieldID (env, cl, "pv_pe_count", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].pv_pe_count); + fl = (*env)->GetFieldID (env, cl, "pv_pe_alloc_count", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].pv_pe_alloc_count); + fl = (*env)->GetFieldID (env, cl, "pv_tags", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].pv_tags)); + fl = (*env)->GetFieldID (env, cl, "pe_start", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].pe_start); + fl = (*env)->GetFieldID (env, cl, "pv_mda_count", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].pv_mda_count); + fl = (*env)->GetFieldID (env, cl, "pv_mda_free", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].pv_mda_free); + (*env)->SetObjectArrayElement (env, jfl, i, jfl); + } + guestfs_free_lvm_pv_list (r); + return jr; +} + +JNIEXPORT jobjectArray JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1test0rvglist + (JNIEnv *env, jobject obj, jlong jg, jstring jval) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + jobjectArray jr; + jclass cl; + jfieldID fl; + jobject jfl; + struct guestfs_lvm_vg_list *r; + const char *val; + int i; + + val = (*env)->GetStringUTFChars (env, jval, NULL); + r = guestfs_test0rvglist (g, val); + (*env)->ReleaseStringUTFChars (env, jval, val); + if (r == NULL) { + throw_exception (env, guestfs_last_error (g)); + return NULL; + } + cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/VG"); + jr = (*env)->NewObjectArray (env, r->len, cl, NULL); + for (i = 0; i < r->len; ++i) { + jfl = (*env)->AllocObject (env, cl); + fl = (*env)->GetFieldID (env, cl, "vg_name", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].vg_name)); + { + char s[33]; + memcpy (s, r->val[i].vg_uuid, 32); + s[32] = 0; + fl = (*env)->GetFieldID (env, cl, "vg_uuid", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, s)); + } + fl = (*env)->GetFieldID (env, cl, "vg_fmt", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].vg_fmt)); + fl = (*env)->GetFieldID (env, cl, "vg_attr", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].vg_attr)); + fl = (*env)->GetFieldID (env, cl, "vg_size", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].vg_size); + fl = (*env)->GetFieldID (env, cl, "vg_free", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].vg_free); + fl = (*env)->GetFieldID (env, cl, "vg_sysid", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].vg_sysid)); + fl = (*env)->GetFieldID (env, cl, "vg_extent_size", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].vg_extent_size); + fl = (*env)->GetFieldID (env, cl, "vg_extent_count", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].vg_extent_count); + fl = (*env)->GetFieldID (env, cl, "vg_free_count", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].vg_free_count); + fl = (*env)->GetFieldID (env, cl, "max_lv", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].max_lv); + fl = (*env)->GetFieldID (env, cl, "max_pv", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].max_pv); + fl = (*env)->GetFieldID (env, cl, "pv_count", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].pv_count); + fl = (*env)->GetFieldID (env, cl, "lv_count", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].lv_count); + fl = (*env)->GetFieldID (env, cl, "snap_count", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].snap_count); + fl = (*env)->GetFieldID (env, cl, "vg_seqno", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].vg_seqno); + fl = (*env)->GetFieldID (env, cl, "vg_tags", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].vg_tags)); + fl = (*env)->GetFieldID (env, cl, "vg_mda_count", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].vg_mda_count); + fl = (*env)->GetFieldID (env, cl, "vg_mda_free", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].vg_mda_free); + (*env)->SetObjectArrayElement (env, jfl, i, jfl); + } + guestfs_free_lvm_vg_list (r); + return jr; +} + +JNIEXPORT jobjectArray JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1test0rvglisterr + (JNIEnv *env, jobject obj, jlong jg) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + jobjectArray jr; + jclass cl; + jfieldID fl; + jobject jfl; + struct guestfs_lvm_vg_list *r; + int i; + + r = guestfs_test0rvglisterr (g); + if (r == NULL) { + throw_exception (env, guestfs_last_error (g)); + return NULL; + } + cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/VG"); + jr = (*env)->NewObjectArray (env, r->len, cl, NULL); + for (i = 0; i < r->len; ++i) { + jfl = (*env)->AllocObject (env, cl); + fl = (*env)->GetFieldID (env, cl, "vg_name", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].vg_name)); + { + char s[33]; + memcpy (s, r->val[i].vg_uuid, 32); + s[32] = 0; + fl = (*env)->GetFieldID (env, cl, "vg_uuid", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, s)); + } + fl = (*env)->GetFieldID (env, cl, "vg_fmt", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].vg_fmt)); + fl = (*env)->GetFieldID (env, cl, "vg_attr", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].vg_attr)); + fl = (*env)->GetFieldID (env, cl, "vg_size", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].vg_size); + fl = (*env)->GetFieldID (env, cl, "vg_free", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].vg_free); + fl = (*env)->GetFieldID (env, cl, "vg_sysid", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].vg_sysid)); + fl = (*env)->GetFieldID (env, cl, "vg_extent_size", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].vg_extent_size); + fl = (*env)->GetFieldID (env, cl, "vg_extent_count", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].vg_extent_count); + fl = (*env)->GetFieldID (env, cl, "vg_free_count", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].vg_free_count); + fl = (*env)->GetFieldID (env, cl, "max_lv", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].max_lv); + fl = (*env)->GetFieldID (env, cl, "max_pv", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].max_pv); + fl = (*env)->GetFieldID (env, cl, "pv_count", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].pv_count); + fl = (*env)->GetFieldID (env, cl, "lv_count", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].lv_count); + fl = (*env)->GetFieldID (env, cl, "snap_count", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].snap_count); + fl = (*env)->GetFieldID (env, cl, "vg_seqno", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].vg_seqno); + fl = (*env)->GetFieldID (env, cl, "vg_tags", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].vg_tags)); + fl = (*env)->GetFieldID (env, cl, "vg_mda_count", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].vg_mda_count); + fl = (*env)->GetFieldID (env, cl, "vg_mda_free", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].vg_mda_free); + (*env)->SetObjectArrayElement (env, jfl, i, jfl); + } + guestfs_free_lvm_vg_list (r); + return jr; +} + +JNIEXPORT jobjectArray JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1test0rlvlist + (JNIEnv *env, jobject obj, jlong jg, jstring jval) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + jobjectArray jr; + jclass cl; + jfieldID fl; + jobject jfl; + struct guestfs_lvm_lv_list *r; + const char *val; + int i; + + val = (*env)->GetStringUTFChars (env, jval, NULL); + r = guestfs_test0rlvlist (g, val); + (*env)->ReleaseStringUTFChars (env, jval, val); + if (r == NULL) { + throw_exception (env, guestfs_last_error (g)); + return NULL; + } + cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/LV"); + jr = (*env)->NewObjectArray (env, r->len, cl, NULL); + for (i = 0; i < r->len; ++i) { + jfl = (*env)->AllocObject (env, cl); + fl = (*env)->GetFieldID (env, cl, "lv_name", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].lv_name)); + { + char s[33]; + memcpy (s, r->val[i].lv_uuid, 32); + s[32] = 0; + fl = (*env)->GetFieldID (env, cl, "lv_uuid", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, s)); + } + fl = (*env)->GetFieldID (env, cl, "lv_attr", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].lv_attr)); + fl = (*env)->GetFieldID (env, cl, "lv_major", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].lv_major); + fl = (*env)->GetFieldID (env, cl, "lv_minor", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].lv_minor); + fl = (*env)->GetFieldID (env, cl, "lv_kernel_major", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].lv_kernel_major); + fl = (*env)->GetFieldID (env, cl, "lv_kernel_minor", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].lv_kernel_minor); + fl = (*env)->GetFieldID (env, cl, "lv_size", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].lv_size); + fl = (*env)->GetFieldID (env, cl, "seg_count", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].seg_count); + fl = (*env)->GetFieldID (env, cl, "origin", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].origin)); + fl = (*env)->GetFieldID (env, cl, "snap_percent", "F"); + (*env)->SetFloatField (env, jfl, fl, r->val[i].snap_percent); + fl = (*env)->GetFieldID (env, cl, "copy_percent", "F"); + (*env)->SetFloatField (env, jfl, fl, r->val[i].copy_percent); + fl = (*env)->GetFieldID (env, cl, "move_pv", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].move_pv)); + fl = (*env)->GetFieldID (env, cl, "lv_tags", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].lv_tags)); + fl = (*env)->GetFieldID (env, cl, "mirror_log", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].mirror_log)); + fl = (*env)->GetFieldID (env, cl, "modules", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].modules)); + (*env)->SetObjectArrayElement (env, jfl, i, jfl); + } + guestfs_free_lvm_lv_list (r); + return jr; +} + +JNIEXPORT jobjectArray JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1test0rlvlisterr + (JNIEnv *env, jobject obj, jlong jg) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + jobjectArray jr; + jclass cl; + jfieldID fl; + jobject jfl; + struct guestfs_lvm_lv_list *r; + int i; + + r = guestfs_test0rlvlisterr (g); + if (r == NULL) { + throw_exception (env, guestfs_last_error (g)); + return NULL; + } + cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/LV"); + jr = (*env)->NewObjectArray (env, r->len, cl, NULL); + for (i = 0; i < r->len; ++i) { + jfl = (*env)->AllocObject (env, cl); + fl = (*env)->GetFieldID (env, cl, "lv_name", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].lv_name)); + { + char s[33]; + memcpy (s, r->val[i].lv_uuid, 32); + s[32] = 0; + fl = (*env)->GetFieldID (env, cl, "lv_uuid", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, s)); + } + fl = (*env)->GetFieldID (env, cl, "lv_attr", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].lv_attr)); + fl = (*env)->GetFieldID (env, cl, "lv_major", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].lv_major); + fl = (*env)->GetFieldID (env, cl, "lv_minor", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].lv_minor); + fl = (*env)->GetFieldID (env, cl, "lv_kernel_major", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].lv_kernel_major); + fl = (*env)->GetFieldID (env, cl, "lv_kernel_minor", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].lv_kernel_minor); + fl = (*env)->GetFieldID (env, cl, "lv_size", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].lv_size); + fl = (*env)->GetFieldID (env, cl, "seg_count", "J"); + (*env)->SetLongField (env, jfl, fl, r->val[i].seg_count); + fl = (*env)->GetFieldID (env, cl, "origin", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].origin)); + fl = (*env)->GetFieldID (env, cl, "snap_percent", "F"); + (*env)->SetFloatField (env, jfl, fl, r->val[i].snap_percent); + fl = (*env)->GetFieldID (env, cl, "copy_percent", "F"); + (*env)->SetFloatField (env, jfl, fl, r->val[i].copy_percent); + fl = (*env)->GetFieldID (env, cl, "move_pv", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].move_pv)); + fl = (*env)->GetFieldID (env, cl, "lv_tags", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].lv_tags)); + fl = (*env)->GetFieldID (env, cl, "mirror_log", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].mirror_log)); + fl = (*env)->GetFieldID (env, cl, "modules", "Ljava/lang/String;"); + (*env)->SetObjectField (env, jfl, fl, (*env)->NewStringUTF (env, r->val[i].modules)); + (*env)->SetObjectArrayElement (env, jfl, i, jfl); + } + guestfs_free_lvm_lv_list (r); + return jr; +} + +JNIEXPORT jobject JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1test0rstat + (JNIEnv *env, jobject obj, jlong jg, jstring jval) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + jobject jr; + jclass cl; + jfieldID fl; + struct guestfs_stat *r; + const char *val; + + val = (*env)->GetStringUTFChars (env, jval, NULL); + r = guestfs_test0rstat (g, val); + (*env)->ReleaseStringUTFChars (env, jval, val); + if (r == NULL) { + throw_exception (env, guestfs_last_error (g)); + return NULL; + } + cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/Stat"); + jr = (*env)->AllocObject (env, cl); + fl = (*env)->GetFieldID (env, cl, "dev", "J"); + (*env)->SetLongField (env, jr, fl, r->dev); + fl = (*env)->GetFieldID (env, cl, "ino", "J"); + (*env)->SetLongField (env, jr, fl, r->ino); + fl = (*env)->GetFieldID (env, cl, "mode", "J"); + (*env)->SetLongField (env, jr, fl, r->mode); + fl = (*env)->GetFieldID (env, cl, "nlink", "J"); + (*env)->SetLongField (env, jr, fl, r->nlink); + fl = (*env)->GetFieldID (env, cl, "uid", "J"); + (*env)->SetLongField (env, jr, fl, r->uid); + fl = (*env)->GetFieldID (env, cl, "gid", "J"); + (*env)->SetLongField (env, jr, fl, r->gid); + fl = (*env)->GetFieldID (env, cl, "rdev", "J"); + (*env)->SetLongField (env, jr, fl, r->rdev); + fl = (*env)->GetFieldID (env, cl, "size", "J"); + (*env)->SetLongField (env, jr, fl, r->size); + fl = (*env)->GetFieldID (env, cl, "blksize", "J"); + (*env)->SetLongField (env, jr, fl, r->blksize); + fl = (*env)->GetFieldID (env, cl, "blocks", "J"); + (*env)->SetLongField (env, jr, fl, r->blocks); + fl = (*env)->GetFieldID (env, cl, "atime", "J"); + (*env)->SetLongField (env, jr, fl, r->atime); + fl = (*env)->GetFieldID (env, cl, "mtime", "J"); + (*env)->SetLongField (env, jr, fl, r->mtime); + fl = (*env)->GetFieldID (env, cl, "ctime", "J"); + (*env)->SetLongField (env, jr, fl, r->ctime); + free (r); + return jr; +} + +JNIEXPORT jobject JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1test0rstaterr + (JNIEnv *env, jobject obj, jlong jg) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + jobject jr; + jclass cl; + jfieldID fl; + struct guestfs_stat *r; + + r = guestfs_test0rstaterr (g); + if (r == NULL) { + throw_exception (env, guestfs_last_error (g)); + return NULL; + } + cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/Stat"); + jr = (*env)->AllocObject (env, cl); + fl = (*env)->GetFieldID (env, cl, "dev", "J"); + (*env)->SetLongField (env, jr, fl, r->dev); + fl = (*env)->GetFieldID (env, cl, "ino", "J"); + (*env)->SetLongField (env, jr, fl, r->ino); + fl = (*env)->GetFieldID (env, cl, "mode", "J"); + (*env)->SetLongField (env, jr, fl, r->mode); + fl = (*env)->GetFieldID (env, cl, "nlink", "J"); + (*env)->SetLongField (env, jr, fl, r->nlink); + fl = (*env)->GetFieldID (env, cl, "uid", "J"); + (*env)->SetLongField (env, jr, fl, r->uid); + fl = (*env)->GetFieldID (env, cl, "gid", "J"); + (*env)->SetLongField (env, jr, fl, r->gid); + fl = (*env)->GetFieldID (env, cl, "rdev", "J"); + (*env)->SetLongField (env, jr, fl, r->rdev); + fl = (*env)->GetFieldID (env, cl, "size", "J"); + (*env)->SetLongField (env, jr, fl, r->size); + fl = (*env)->GetFieldID (env, cl, "blksize", "J"); + (*env)->SetLongField (env, jr, fl, r->blksize); + fl = (*env)->GetFieldID (env, cl, "blocks", "J"); + (*env)->SetLongField (env, jr, fl, r->blocks); + fl = (*env)->GetFieldID (env, cl, "atime", "J"); + (*env)->SetLongField (env, jr, fl, r->atime); + fl = (*env)->GetFieldID (env, cl, "mtime", "J"); + (*env)->SetLongField (env, jr, fl, r->mtime); + fl = (*env)->GetFieldID (env, cl, "ctime", "J"); + (*env)->SetLongField (env, jr, fl, r->ctime); + free (r); + return jr; +} + +JNIEXPORT jobject JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1test0rstatvfs + (JNIEnv *env, jobject obj, jlong jg, jstring jval) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + jobject jr; + jclass cl; + jfieldID fl; + struct guestfs_statvfs *r; + const char *val; + + val = (*env)->GetStringUTFChars (env, jval, NULL); + r = guestfs_test0rstatvfs (g, val); + (*env)->ReleaseStringUTFChars (env, jval, val); + if (r == NULL) { + throw_exception (env, guestfs_last_error (g)); + return NULL; + } + cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/StatVFS"); + jr = (*env)->AllocObject (env, cl); + fl = (*env)->GetFieldID (env, cl, "bsize", "J"); + (*env)->SetLongField (env, jr, fl, r->bsize); + fl = (*env)->GetFieldID (env, cl, "frsize", "J"); + (*env)->SetLongField (env, jr, fl, r->frsize); + fl = (*env)->GetFieldID (env, cl, "blocks", "J"); + (*env)->SetLongField (env, jr, fl, r->blocks); + fl = (*env)->GetFieldID (env, cl, "bfree", "J"); + (*env)->SetLongField (env, jr, fl, r->bfree); + fl = (*env)->GetFieldID (env, cl, "bavail", "J"); + (*env)->SetLongField (env, jr, fl, r->bavail); + fl = (*env)->GetFieldID (env, cl, "files", "J"); + (*env)->SetLongField (env, jr, fl, r->files); + fl = (*env)->GetFieldID (env, cl, "ffree", "J"); + (*env)->SetLongField (env, jr, fl, r->ffree); + fl = (*env)->GetFieldID (env, cl, "favail", "J"); + (*env)->SetLongField (env, jr, fl, r->favail); + fl = (*env)->GetFieldID (env, cl, "fsid", "J"); + (*env)->SetLongField (env, jr, fl, r->fsid); + fl = (*env)->GetFieldID (env, cl, "flag", "J"); + (*env)->SetLongField (env, jr, fl, r->flag); + fl = (*env)->GetFieldID (env, cl, "namemax", "J"); + (*env)->SetLongField (env, jr, fl, r->namemax); + free (r); + return jr; +} + +JNIEXPORT jobject JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1test0rstatvfserr + (JNIEnv *env, jobject obj, jlong jg) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + jobject jr; + jclass cl; + jfieldID fl; + struct guestfs_statvfs *r; + + r = guestfs_test0rstatvfserr (g); + if (r == NULL) { + throw_exception (env, guestfs_last_error (g)); + return NULL; + } + cl = (*env)->FindClass (env, "com/redhat/et/libguestfs/StatVFS"); + jr = (*env)->AllocObject (env, cl); + fl = (*env)->GetFieldID (env, cl, "bsize", "J"); + (*env)->SetLongField (env, jr, fl, r->bsize); + fl = (*env)->GetFieldID (env, cl, "frsize", "J"); + (*env)->SetLongField (env, jr, fl, r->frsize); + fl = (*env)->GetFieldID (env, cl, "blocks", "J"); + (*env)->SetLongField (env, jr, fl, r->blocks); + fl = (*env)->GetFieldID (env, cl, "bfree", "J"); + (*env)->SetLongField (env, jr, fl, r->bfree); + fl = (*env)->GetFieldID (env, cl, "bavail", "J"); + (*env)->SetLongField (env, jr, fl, r->bavail); + fl = (*env)->GetFieldID (env, cl, "files", "J"); + (*env)->SetLongField (env, jr, fl, r->files); + fl = (*env)->GetFieldID (env, cl, "ffree", "J"); + (*env)->SetLongField (env, jr, fl, r->ffree); + fl = (*env)->GetFieldID (env, cl, "favail", "J"); + (*env)->SetLongField (env, jr, fl, r->favail); + fl = (*env)->GetFieldID (env, cl, "fsid", "J"); + (*env)->SetLongField (env, jr, fl, r->fsid); + fl = (*env)->GetFieldID (env, cl, "flag", "J"); + (*env)->SetLongField (env, jr, fl, r->flag); + fl = (*env)->GetFieldID (env, cl, "namemax", "J"); + (*env)->SetLongField (env, jr, fl, r->namemax); + free (r); + return jr; +} + +JNIEXPORT jobject JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1test0rhashtable + (JNIEnv *env, jobject obj, jlong jg, jstring jval) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + char **r; + const char *val; + + val = (*env)->GetStringUTFChars (env, jval, NULL); + r = guestfs_test0rhashtable (g, val); + (*env)->ReleaseStringUTFChars (env, jval, val); + if (r == NULL) { + throw_exception (env, guestfs_last_error (g)); + return NULL; + } + throw_exception (env, "test0rhashtable: internal error: please let us know how to make a Java HashMap from JNI bindings!"); + return NULL; +} + +JNIEXPORT jobject JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1test0rhashtableerr + (JNIEnv *env, jobject obj, jlong jg) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + char **r; + + r = guestfs_test0rhashtableerr (g); + if (r == NULL) { + throw_exception (env, guestfs_last_error (g)); + return NULL; + } + throw_exception (env, "test0rhashtableerr: internal error: please let us know how to make a Java HashMap from JNI bindings!"); + return NULL; +} + +JNIEXPORT void JNICALL Java_com_redhat_et_libguestfs_GuestFS__1launch (JNIEnv *env, jobject obj, jlong jg) { diff --git a/ocaml/guestfs.ml b/ocaml/guestfs.ml index 48dae20..d218b3e 100644 --- a/ocaml/guestfs.ml +++ b/ocaml/guestfs.ml @@ -115,6 +115,33 @@ type statvfs = { namemax : int64; } +external test0 : t -> string -> string option -> string array -> bool -> int -> string -> string -> unit = "ocaml_guestfs_test0_byte" "ocaml_guestfs_test0" +external test0rint : t -> string -> int = "ocaml_guestfs_test0rint" +external test0rinterr : t -> int = "ocaml_guestfs_test0rinterr" +external test0rint64 : t -> string -> int64 = "ocaml_guestfs_test0rint64" +external test0rint64err : t -> int64 = "ocaml_guestfs_test0rint64err" +external test0rbool : t -> string -> bool = "ocaml_guestfs_test0rbool" +external test0rboolerr : t -> bool = "ocaml_guestfs_test0rboolerr" +external test0rconststring : t -> string -> string = "ocaml_guestfs_test0rconststring" +external test0rconststringerr : t -> string = "ocaml_guestfs_test0rconststringerr" +external test0rstring : t -> string -> string = "ocaml_guestfs_test0rstring" +external test0rstringerr : t -> string = "ocaml_guestfs_test0rstringerr" +external test0rstringlist : t -> string -> string array = "ocaml_guestfs_test0rstringlist" +external test0rstringlisterr : t -> string array = "ocaml_guestfs_test0rstringlisterr" +external test0rintbool : t -> string -> int * bool = "ocaml_guestfs_test0rintbool" +external test0rintboolerr : t -> int * bool = "ocaml_guestfs_test0rintboolerr" +external test0rpvlist : t -> string -> lvm_pv array = "ocaml_guestfs_test0rpvlist" +external test0rpvlisterr : t -> lvm_pv array = "ocaml_guestfs_test0rpvlisterr" +external test0rvglist : t -> string -> lvm_vg array = "ocaml_guestfs_test0rvglist" +external test0rvglisterr : t -> lvm_vg array = "ocaml_guestfs_test0rvglisterr" +external test0rlvlist : t -> string -> lvm_lv array = "ocaml_guestfs_test0rlvlist" +external test0rlvlisterr : t -> lvm_lv array = "ocaml_guestfs_test0rlvlisterr" +external test0rstat : t -> string -> stat = "ocaml_guestfs_test0rstat" +external test0rstaterr : t -> stat = "ocaml_guestfs_test0rstaterr" +external test0rstatvfs : t -> string -> statvfs = "ocaml_guestfs_test0rstatvfs" +external test0rstatvfserr : t -> statvfs = "ocaml_guestfs_test0rstatvfserr" +external test0rhashtable : t -> string -> (string * string) list = "ocaml_guestfs_test0rhashtable" +external test0rhashtableerr : t -> (string * string) list = "ocaml_guestfs_test0rhashtableerr" external launch : t -> unit = "ocaml_guestfs_launch" external wait_ready : t -> unit = "ocaml_guestfs_wait_ready" external kill_subprocess : t -> unit = "ocaml_guestfs_kill_subprocess" diff --git a/ocaml/guestfs.mli b/ocaml/guestfs.mli index e115a79..564f163 100644 --- a/ocaml/guestfs.mli +++ b/ocaml/guestfs.mli @@ -124,6 +124,87 @@ type statvfs = { namemax : int64; } +val test0 : t -> string -> string option -> string array -> bool -> int -> string -> string -> unit +(** internal test function - do not use *) + +val test0rint : t -> string -> int +(** internal test function - do not use *) + +val test0rinterr : t -> int +(** internal test function - do not use *) + +val test0rint64 : t -> string -> int64 +(** internal test function - do not use *) + +val test0rint64err : t -> int64 +(** internal test function - do not use *) + +val test0rbool : t -> string -> bool +(** internal test function - do not use *) + +val test0rboolerr : t -> bool +(** internal test function - do not use *) + +val test0rconststring : t -> string -> string +(** internal test function - do not use *) + +val test0rconststringerr : t -> string +(** internal test function - do not use *) + +val test0rstring : t -> string -> string +(** internal test function - do not use *) + +val test0rstringerr : t -> string +(** internal test function - do not use *) + +val test0rstringlist : t -> string -> string array +(** internal test function - do not use *) + +val test0rstringlisterr : t -> string array +(** internal test function - do not use *) + +val test0rintbool : t -> string -> int * bool +(** internal test function - do not use *) + +val test0rintboolerr : t -> int * bool +(** internal test function - do not use *) + +val test0rpvlist : t -> string -> lvm_pv array +(** internal test function - do not use *) + +val test0rpvlisterr : t -> lvm_pv array +(** internal test function - do not use *) + +val test0rvglist : t -> string -> lvm_vg array +(** internal test function - do not use *) + +val test0rvglisterr : t -> lvm_vg array +(** internal test function - do not use *) + +val test0rlvlist : t -> string -> lvm_lv array +(** internal test function - do not use *) + +val test0rlvlisterr : t -> lvm_lv array +(** internal test function - do not use *) + +val test0rstat : t -> string -> stat +(** internal test function - do not use *) + +val test0rstaterr : t -> stat +(** internal test function - do not use *) + +val test0rstatvfs : t -> string -> statvfs +(** internal test function - do not use *) + +val test0rstatvfserr : t -> statvfs +(** internal test function - do not use *) + +val test0rhashtable : t -> string -> (string * string) list +(** internal test function - do not use *) + +val test0rhashtableerr : t -> (string * string) list +(** internal test function - do not use *) + val launch : t -> unit (** launch the qemu subprocess *) diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c index 795a0f3..74c25d9 100644 --- a/ocaml/guestfs_c_actions.c +++ b/ocaml/guestfs_c_actions.c @@ -329,6 +329,659 @@ copy_statvfs (const struct guestfs_statvfs *statvfs) } CAMLprim value +ocaml_guestfs_test0 (value gv, value strv, value optstrv, value strlistv, value bv, value integerv, value fileinv, value fileoutv) +{ + CAMLparam5 (gv, strv, optstrv, strlistv, bv); + CAMLxparam3 (integerv, fileinv, fileoutv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("test0: used handle after closing it"); + + const char *str = String_val (strv); + const char *optstr = + optstrv != Val_int (0) ? String_val (Field (optstrv, 0)) : NULL; + char **strlist = ocaml_guestfs_strings_val (g, strlistv); + int b = Bool_val (bv); + int integer = Int_val (integerv); + const char *filein = String_val (fileinv); + const char *fileout = String_val (fileoutv); + int r; + + caml_enter_blocking_section (); + r = guestfs_test0 (g, str, optstr, strlist, b, integer, filein, fileout); + caml_leave_blocking_section (); + ocaml_guestfs_free_strings (strlist); + if (r == -1) + ocaml_guestfs_raise_error (g, "test0"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_test0_byte (value *argv, int argn) +{ + return ocaml_guestfs_test0 (argv[0], argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]); +} + +CAMLprim value +ocaml_guestfs_test0rint (value gv, value valv) +{ + CAMLparam2 (gv, valv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("test0rint: used handle after closing it"); + + const char *val = String_val (valv); + int r; + + caml_enter_blocking_section (); + r = guestfs_test0rint (g, val); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "test0rint"); + + rv = Val_int (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_test0rinterr (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("test0rinterr: used handle after closing it"); + + int r; + + caml_enter_blocking_section (); + r = guestfs_test0rinterr (g); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "test0rinterr"); + + rv = Val_int (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_test0rint64 (value gv, value valv) +{ + CAMLparam2 (gv, valv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("test0rint64: used handle after closing it"); + + const char *val = String_val (valv); + int64_t r; + + caml_enter_blocking_section (); + r = guestfs_test0rint64 (g, val); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "test0rint64"); + + rv = caml_copy_int64 (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_test0rint64err (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("test0rint64err: used handle after closing it"); + + int64_t r; + + caml_enter_blocking_section (); + r = guestfs_test0rint64err (g); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "test0rint64err"); + + rv = caml_copy_int64 (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_test0rbool (value gv, value valv) +{ + CAMLparam2 (gv, valv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("test0rbool: used handle after closing it"); + + const char *val = String_val (valv); + int r; + + caml_enter_blocking_section (); + r = guestfs_test0rbool (g, val); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "test0rbool"); + + rv = Val_bool (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_test0rboolerr (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("test0rboolerr: used handle after closing it"); + + int r; + + caml_enter_blocking_section (); + r = guestfs_test0rboolerr (g); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "test0rboolerr"); + + rv = Val_bool (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_test0rconststring (value gv, value valv) +{ + CAMLparam2 (gv, valv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("test0rconststring: used handle after closing it"); + + const char *val = String_val (valv); + const char *r; + + caml_enter_blocking_section (); + r = guestfs_test0rconststring (g, val); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "test0rconststring"); + + rv = caml_copy_string (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_test0rconststringerr (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("test0rconststringerr: used handle after closing it"); + + const char *r; + + caml_enter_blocking_section (); + r = guestfs_test0rconststringerr (g); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "test0rconststringerr"); + + rv = caml_copy_string (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_test0rstring (value gv, value valv) +{ + CAMLparam2 (gv, valv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("test0rstring: used handle after closing it"); + + const char *val = String_val (valv); + char *r; + + caml_enter_blocking_section (); + r = guestfs_test0rstring (g, val); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "test0rstring"); + + rv = caml_copy_string (r); + free (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_test0rstringerr (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("test0rstringerr: used handle after closing it"); + + char *r; + + caml_enter_blocking_section (); + r = guestfs_test0rstringerr (g); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "test0rstringerr"); + + rv = caml_copy_string (r); + free (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_test0rstringlist (value gv, value valv) +{ + CAMLparam2 (gv, valv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("test0rstringlist: used handle after closing it"); + + const char *val = String_val (valv); + int i; + char **r; + + caml_enter_blocking_section (); + r = guestfs_test0rstringlist (g, val); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "test0rstringlist"); + + rv = caml_copy_string_array ((const char **) r); + for (i = 0; r[i] != NULL; ++i) free (r[i]); + free (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_test0rstringlisterr (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("test0rstringlisterr: used handle after closing it"); + + int i; + char **r; + + caml_enter_blocking_section (); + r = guestfs_test0rstringlisterr (g); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "test0rstringlisterr"); + + rv = caml_copy_string_array ((const char **) r); + for (i = 0; r[i] != NULL; ++i) free (r[i]); + free (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_test0rintbool (value gv, value valv) +{ + CAMLparam2 (gv, valv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("test0rintbool: used handle after closing it"); + + const char *val = String_val (valv); + struct guestfs_int_bool *r; + + caml_enter_blocking_section (); + r = guestfs_test0rintbool (g, val); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "test0rintbool"); + + rv = caml_alloc (2, 0); + Store_field (rv, 0, Val_int (r->i)); + Store_field (rv, 1, Val_bool (r->b)); + guestfs_free_int_bool (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_test0rintboolerr (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("test0rintboolerr: used handle after closing it"); + + struct guestfs_int_bool *r; + + caml_enter_blocking_section (); + r = guestfs_test0rintboolerr (g); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "test0rintboolerr"); + + rv = caml_alloc (2, 0); + Store_field (rv, 0, Val_int (r->i)); + Store_field (rv, 1, Val_bool (r->b)); + guestfs_free_int_bool (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_test0rpvlist (value gv, value valv) +{ + CAMLparam2 (gv, valv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("test0rpvlist: used handle after closing it"); + + const char *val = String_val (valv); + struct guestfs_lvm_pv_list *r; + + caml_enter_blocking_section (); + r = guestfs_test0rpvlist (g, val); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "test0rpvlist"); + + rv = copy_lvm_pv_list (r); + guestfs_free_lvm_pv_list (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_test0rpvlisterr (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("test0rpvlisterr: used handle after closing it"); + + struct guestfs_lvm_pv_list *r; + + caml_enter_blocking_section (); + r = guestfs_test0rpvlisterr (g); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "test0rpvlisterr"); + + rv = copy_lvm_pv_list (r); + guestfs_free_lvm_pv_list (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_test0rvglist (value gv, value valv) +{ + CAMLparam2 (gv, valv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("test0rvglist: used handle after closing it"); + + const char *val = String_val (valv); + struct guestfs_lvm_vg_list *r; + + caml_enter_blocking_section (); + r = guestfs_test0rvglist (g, val); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "test0rvglist"); + + rv = copy_lvm_vg_list (r); + guestfs_free_lvm_vg_list (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_test0rvglisterr (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("test0rvglisterr: used handle after closing it"); + + struct guestfs_lvm_vg_list *r; + + caml_enter_blocking_section (); + r = guestfs_test0rvglisterr (g); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "test0rvglisterr"); + + rv = copy_lvm_vg_list (r); + guestfs_free_lvm_vg_list (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_test0rlvlist (value gv, value valv) +{ + CAMLparam2 (gv, valv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("test0rlvlist: used handle after closing it"); + + const char *val = String_val (valv); + struct guestfs_lvm_lv_list *r; + + caml_enter_blocking_section (); + r = guestfs_test0rlvlist (g, val); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "test0rlvlist"); + + rv = copy_lvm_lv_list (r); + guestfs_free_lvm_lv_list (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_test0rlvlisterr (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("test0rlvlisterr: used handle after closing it"); + + struct guestfs_lvm_lv_list *r; + + caml_enter_blocking_section (); + r = guestfs_test0rlvlisterr (g); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "test0rlvlisterr"); + + rv = copy_lvm_lv_list (r); + guestfs_free_lvm_lv_list (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_test0rstat (value gv, value valv) +{ + CAMLparam2 (gv, valv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("test0rstat: used handle after closing it"); + + const char *val = String_val (valv); + struct guestfs_stat *r; + + caml_enter_blocking_section (); + r = guestfs_test0rstat (g, val); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "test0rstat"); + + rv = copy_stat (r); + free (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_test0rstaterr (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("test0rstaterr: used handle after closing it"); + + struct guestfs_stat *r; + + caml_enter_blocking_section (); + r = guestfs_test0rstaterr (g); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "test0rstaterr"); + + rv = copy_stat (r); + free (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_test0rstatvfs (value gv, value valv) +{ + CAMLparam2 (gv, valv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("test0rstatvfs: used handle after closing it"); + + const char *val = String_val (valv); + struct guestfs_statvfs *r; + + caml_enter_blocking_section (); + r = guestfs_test0rstatvfs (g, val); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "test0rstatvfs"); + + rv = copy_statvfs (r); + free (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_test0rstatvfserr (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("test0rstatvfserr: used handle after closing it"); + + struct guestfs_statvfs *r; + + caml_enter_blocking_section (); + r = guestfs_test0rstatvfserr (g); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "test0rstatvfserr"); + + rv = copy_statvfs (r); + free (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_test0rhashtable (value gv, value valv) +{ + CAMLparam2 (gv, valv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("test0rhashtable: used handle after closing it"); + + const char *val = String_val (valv); + int i; + char **r; + + caml_enter_blocking_section (); + r = guestfs_test0rhashtable (g, val); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "test0rhashtable"); + + rv = copy_table (r); + for (i = 0; r[i] != NULL; ++i) free (r[i]); + free (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_test0rhashtableerr (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("test0rhashtableerr: used handle after closing it"); + + int i; + char **r; + + caml_enter_blocking_section (); + r = guestfs_test0rhashtableerr (g); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "test0rhashtableerr"); + + rv = copy_table (r); + for (i = 0; r[i] != NULL; ++i) free (r[i]); + free (r); + CAMLreturn (rv); +} + +CAMLprim value ocaml_guestfs_launch (value gv) { CAMLparam1 (gv); diff --git a/perl/Guestfs.xs b/perl/Guestfs.xs index 66eeb29..fcf62f7 100644 --- a/perl/Guestfs.xs +++ b/perl/Guestfs.xs @@ -107,6 +107,571 @@ DESTROY (g) guestfs_close (g); void +test0 (g, str, optstr, strlist, b, integer, filein, fileout) + guestfs_h *g; + char *str; + char *optstr; + char **strlist; + int b; + int integer; + char *filein; + char *fileout; +PREINIT: + int r; + PPCODE: + r = guestfs_test0 (g, str, optstr, strlist, b, integer, filein, fileout); + free (strlist); + if (r == -1) + croak ("test0: %s", guestfs_last_error (g)); + +SV * +test0rint (g, val) + guestfs_h *g; + char *val; +PREINIT: + int valout; + CODE: + valout = guestfs_test0rint (g, val); + if (valout == -1) + croak ("test0rint: %s", guestfs_last_error (g)); + RETVAL = newSViv (valout); + OUTPUT: + RETVAL + +SV * +test0rinterr (g) + guestfs_h *g; +PREINIT: + int valout; + CODE: + valout = guestfs_test0rinterr (g); + if (valout == -1) + croak ("test0rinterr: %s", guestfs_last_error (g)); + RETVAL = newSViv (valout); + OUTPUT: + RETVAL + +SV * +test0rint64 (g, val) + guestfs_h *g; + char *val; +PREINIT: + int64_t valout; + CODE: + valout = guestfs_test0rint64 (g, val); + if (valout == -1) + croak ("test0rint64: %s", guestfs_last_error (g)); + RETVAL = my_newSVll (valout); + OUTPUT: + RETVAL + +SV * +test0rint64err (g) + guestfs_h *g; +PREINIT: + int64_t valout; + CODE: + valout = guestfs_test0rint64err (g); + if (valout == -1) + croak ("test0rint64err: %s", guestfs_last_error (g)); + RETVAL = my_newSVll (valout); + OUTPUT: + RETVAL + +SV * +test0rbool (g, val) + guestfs_h *g; + char *val; +PREINIT: + int valout; + CODE: + valout = guestfs_test0rbool (g, val); + if (valout == -1) + croak ("test0rbool: %s", guestfs_last_error (g)); + RETVAL = newSViv (valout); + OUTPUT: + RETVAL + +SV * +test0rboolerr (g) + guestfs_h *g; +PREINIT: + int valout; + CODE: + valout = guestfs_test0rboolerr (g); + if (valout == -1) + croak ("test0rboolerr: %s", guestfs_last_error (g)); + RETVAL = newSViv (valout); + OUTPUT: + RETVAL + +SV * +test0rconststring (g, val) + guestfs_h *g; + char *val; +PREINIT: + const char *valout; + CODE: + valout = guestfs_test0rconststring (g, val); + if (valout == NULL) + croak ("test0rconststring: %s", guestfs_last_error (g)); + RETVAL = newSVpv (valout, 0); + OUTPUT: + RETVAL + +SV * +test0rconststringerr (g) + guestfs_h *g; +PREINIT: + const char *valout; + CODE: + valout = guestfs_test0rconststringerr (g); + if (valout == NULL) + croak ("test0rconststringerr: %s", guestfs_last_error (g)); + RETVAL = newSVpv (valout, 0); + OUTPUT: + RETVAL + +SV * +test0rstring (g, val) + guestfs_h *g; + char *val; +PREINIT: + char *valout; + CODE: + valout = guestfs_test0rstring (g, val); + if (valout == NULL) + croak ("test0rstring: %s", guestfs_last_error (g)); + RETVAL = newSVpv (valout, 0); + free (valout); + OUTPUT: + RETVAL + +SV * +test0rstringerr (g) + guestfs_h *g; +PREINIT: + char *valout; + CODE: + valout = guestfs_test0rstringerr (g); + if (valout == NULL) + croak ("test0rstringerr: %s", guestfs_last_error (g)); + RETVAL = newSVpv (valout, 0); + free (valout); + OUTPUT: + RETVAL + +void +test0rstringlist (g, val) + guestfs_h *g; + char *val; +PREINIT: + char **valout; + int i, n; + PPCODE: + valout = guestfs_test0rstringlist (g, val); + if (valout == NULL) + croak ("test0rstringlist: %s", guestfs_last_error (g)); + for (n = 0; valout[n] != NULL; ++n) /**/; + EXTEND (SP, n); + for (i = 0; i < n; ++i) { + PUSHs (sv_2mortal (newSVpv (valout[i], 0))); + free (valout[i]); + } + free (valout); + +void +test0rstringlisterr (g) + guestfs_h *g; +PREINIT: + char **valout; + int i, n; + PPCODE: + valout = guestfs_test0rstringlisterr (g); + if (valout == NULL) + croak ("test0rstringlisterr: %s", guestfs_last_error (g)); + for (n = 0; valout[n] != NULL; ++n) /**/; + EXTEND (SP, n); + for (i = 0; i < n; ++i) { + PUSHs (sv_2mortal (newSVpv (valout[i], 0))); + free (valout[i]); + } + free (valout); + +void +test0rintbool (g, val) + guestfs_h *g; + char *val; +PREINIT: + struct guestfs_int_bool *r; + PPCODE: + r = guestfs_test0rintbool (g, val); + if (r == NULL) + croak ("test0rintbool: %s", guestfs_last_error (g)); + EXTEND (SP, 2); + PUSHs (sv_2mortal (newSViv (r->i))); + PUSHs (sv_2mortal (newSViv (r->b))); + guestfs_free_int_bool (r); + +void +test0rintboolerr (g) + guestfs_h *g; +PREINIT: + struct guestfs_int_bool *r; + PPCODE: + r = guestfs_test0rintboolerr (g); + if (r == NULL) + croak ("test0rintboolerr: %s", guestfs_last_error (g)); + EXTEND (SP, 2); + PUSHs (sv_2mortal (newSViv (r->i))); + PUSHs (sv_2mortal (newSViv (r->b))); + guestfs_free_int_bool (r); + +void +test0rpvlist (g, val) + guestfs_h *g; + char *val; +PREINIT: + struct guestfs_lvm_pv_list *valout; + int i; + HV *hv; + PPCODE: + valout = guestfs_test0rpvlist (g, val); + if (valout == NULL) + croak ("test0rpvlist: %s", guestfs_last_error (g)); + EXTEND (SP, valout->len); + for (i = 0; i < valout->len; ++i) { + hv = newHV (); + (void) hv_store (hv, "pv_name", 7, newSVpv (valout->val[i].pv_name, 0), 0); + (void) hv_store (hv, "pv_uuid", 7, newSVpv (valout->val[i].pv_uuid, 32), 0); + (void) hv_store (hv, "pv_fmt", 6, newSVpv (valout->val[i].pv_fmt, 0), 0); + (void) hv_store (hv, "pv_size", 7, my_newSVull (valout->val[i].pv_size), 0); + (void) hv_store (hv, "dev_size", 8, my_newSVull (valout->val[i].dev_size), 0); + (void) hv_store (hv, "pv_free", 7, my_newSVull (valout->val[i].pv_free), 0); + (void) hv_store (hv, "pv_used", 7, my_newSVull (valout->val[i].pv_used), 0); + (void) hv_store (hv, "pv_attr", 7, newSVpv (valout->val[i].pv_attr, 0), 0); + (void) hv_store (hv, "pv_pe_count", 11, my_newSVll (valout->val[i].pv_pe_count), 0); + (void) hv_store (hv, "pv_pe_alloc_count", 17, my_newSVll (valout->val[i].pv_pe_alloc_count), 0); + (void) hv_store (hv, "pv_tags", 7, newSVpv (valout->val[i].pv_tags, 0), 0); + (void) hv_store (hv, "pe_start", 8, my_newSVull (valout->val[i].pe_start), 0); + (void) hv_store (hv, "pv_mda_count", 12, my_newSVll (valout->val[i].pv_mda_count), 0); + (void) hv_store (hv, "pv_mda_free", 11, my_newSVull (valout->val[i].pv_mda_free), 0); + PUSHs (sv_2mortal ((SV *) hv)); + } + guestfs_free_lvm_pv_list (valout); + +void +test0rpvlisterr (g) + guestfs_h *g; +PREINIT: + struct guestfs_lvm_pv_list *valout; + int i; + HV *hv; + PPCODE: + valout = guestfs_test0rpvlisterr (g); + if (valout == NULL) + croak ("test0rpvlisterr: %s", guestfs_last_error (g)); + EXTEND (SP, valout->len); + for (i = 0; i < valout->len; ++i) { + hv = newHV (); + (void) hv_store (hv, "pv_name", 7, newSVpv (valout->val[i].pv_name, 0), 0); + (void) hv_store (hv, "pv_uuid", 7, newSVpv (valout->val[i].pv_uuid, 32), 0); + (void) hv_store (hv, "pv_fmt", 6, newSVpv (valout->val[i].pv_fmt, 0), 0); + (void) hv_store (hv, "pv_size", 7, my_newSVull (valout->val[i].pv_size), 0); + (void) hv_store (hv, "dev_size", 8, my_newSVull (valout->val[i].dev_size), 0); + (void) hv_store (hv, "pv_free", 7, my_newSVull (valout->val[i].pv_free), 0); + (void) hv_store (hv, "pv_used", 7, my_newSVull (valout->val[i].pv_used), 0); + (void) hv_store (hv, "pv_attr", 7, newSVpv (valout->val[i].pv_attr, 0), 0); + (void) hv_store (hv, "pv_pe_count", 11, my_newSVll (valout->val[i].pv_pe_count), 0); + (void) hv_store (hv, "pv_pe_alloc_count", 17, my_newSVll (valout->val[i].pv_pe_alloc_count), 0); + (void) hv_store (hv, "pv_tags", 7, newSVpv (valout->val[i].pv_tags, 0), 0); + (void) hv_store (hv, "pe_start", 8, my_newSVull (valout->val[i].pe_start), 0); + (void) hv_store (hv, "pv_mda_count", 12, my_newSVll (valout->val[i].pv_mda_count), 0); + (void) hv_store (hv, "pv_mda_free", 11, my_newSVull (valout->val[i].pv_mda_free), 0); + PUSHs (sv_2mortal ((SV *) hv)); + } + guestfs_free_lvm_pv_list (valout); + +void +test0rvglist (g, val) + guestfs_h *g; + char *val; +PREINIT: + struct guestfs_lvm_vg_list *valout; + int i; + HV *hv; + PPCODE: + valout = guestfs_test0rvglist (g, val); + if (valout == NULL) + croak ("test0rvglist: %s", guestfs_last_error (g)); + EXTEND (SP, valout->len); + for (i = 0; i < valout->len; ++i) { + hv = newHV (); + (void) hv_store (hv, "vg_name", 7, newSVpv (valout->val[i].vg_name, 0), 0); + (void) hv_store (hv, "vg_uuid", 7, newSVpv (valout->val[i].vg_uuid, 32), 0); + (void) hv_store (hv, "vg_fmt", 6, newSVpv (valout->val[i].vg_fmt, 0), 0); + (void) hv_store (hv, "vg_attr", 7, newSVpv (valout->val[i].vg_attr, 0), 0); + (void) hv_store (hv, "vg_size", 7, my_newSVull (valout->val[i].vg_size), 0); + (void) hv_store (hv, "vg_free", 7, my_newSVull (valout->val[i].vg_free), 0); + (void) hv_store (hv, "vg_sysid", 8, newSVpv (valout->val[i].vg_sysid, 0), 0); + (void) hv_store (hv, "vg_extent_size", 14, my_newSVull (valout->val[i].vg_extent_size), 0); + (void) hv_store (hv, "vg_extent_count", 15, my_newSVll (valout->val[i].vg_extent_count), 0); + (void) hv_store (hv, "vg_free_count", 13, my_newSVll (valout->val[i].vg_free_count), 0); + (void) hv_store (hv, "max_lv", 6, my_newSVll (valout->val[i].max_lv), 0); + (void) hv_store (hv, "max_pv", 6, my_newSVll (valout->val[i].max_pv), 0); + (void) hv_store (hv, "pv_count", 8, my_newSVll (valout->val[i].pv_count), 0); + (void) hv_store (hv, "lv_count", 8, my_newSVll (valout->val[i].lv_count), 0); + (void) hv_store (hv, "snap_count", 10, my_newSVll (valout->val[i].snap_count), 0); + (void) hv_store (hv, "vg_seqno", 8, my_newSVll (valout->val[i].vg_seqno), 0); + (void) hv_store (hv, "vg_tags", 7, newSVpv (valout->val[i].vg_tags, 0), 0); + (void) hv_store (hv, "vg_mda_count", 12, my_newSVll (valout->val[i].vg_mda_count), 0); + (void) hv_store (hv, "vg_mda_free", 11, my_newSVull (valout->val[i].vg_mda_free), 0); + PUSHs (sv_2mortal ((SV *) hv)); + } + guestfs_free_lvm_vg_list (valout); + +void +test0rvglisterr (g) + guestfs_h *g; +PREINIT: + struct guestfs_lvm_vg_list *valout; + int i; + HV *hv; + PPCODE: + valout = guestfs_test0rvglisterr (g); + if (valout == NULL) + croak ("test0rvglisterr: %s", guestfs_last_error (g)); + EXTEND (SP, valout->len); + for (i = 0; i < valout->len; ++i) { + hv = newHV (); + (void) hv_store (hv, "vg_name", 7, newSVpv (valout->val[i].vg_name, 0), 0); + (void) hv_store (hv, "vg_uuid", 7, newSVpv (valout->val[i].vg_uuid, 32), 0); + (void) hv_store (hv, "vg_fmt", 6, newSVpv (valout->val[i].vg_fmt, 0), 0); + (void) hv_store (hv, "vg_attr", 7, newSVpv (valout->val[i].vg_attr, 0), 0); + (void) hv_store (hv, "vg_size", 7, my_newSVull (valout->val[i].vg_size), 0); + (void) hv_store (hv, "vg_free", 7, my_newSVull (valout->val[i].vg_free), 0); + (void) hv_store (hv, "vg_sysid", 8, newSVpv (valout->val[i].vg_sysid, 0), 0); + (void) hv_store (hv, "vg_extent_size", 14, my_newSVull (valout->val[i].vg_extent_size), 0); + (void) hv_store (hv, "vg_extent_count", 15, my_newSVll (valout->val[i].vg_extent_count), 0); + (void) hv_store (hv, "vg_free_count", 13, my_newSVll (valout->val[i].vg_free_count), 0); + (void) hv_store (hv, "max_lv", 6, my_newSVll (valout->val[i].max_lv), 0); + (void) hv_store (hv, "max_pv", 6, my_newSVll (valout->val[i].max_pv), 0); + (void) hv_store (hv, "pv_count", 8, my_newSVll (valout->val[i].pv_count), 0); + (void) hv_store (hv, "lv_count", 8, my_newSVll (valout->val[i].lv_count), 0); + (void) hv_store (hv, "snap_count", 10, my_newSVll (valout->val[i].snap_count), 0); + (void) hv_store (hv, "vg_seqno", 8, my_newSVll (valout->val[i].vg_seqno), 0); + (void) hv_store (hv, "vg_tags", 7, newSVpv (valout->val[i].vg_tags, 0), 0); + (void) hv_store (hv, "vg_mda_count", 12, my_newSVll (valout->val[i].vg_mda_count), 0); + (void) hv_store (hv, "vg_mda_free", 11, my_newSVull (valout->val[i].vg_mda_free), 0); + PUSHs (sv_2mortal ((SV *) hv)); + } + guestfs_free_lvm_vg_list (valout); + +void +test0rlvlist (g, val) + guestfs_h *g; + char *val; +PREINIT: + struct guestfs_lvm_lv_list *valout; + int i; + HV *hv; + PPCODE: + valout = guestfs_test0rlvlist (g, val); + if (valout == NULL) + croak ("test0rlvlist: %s", guestfs_last_error (g)); + EXTEND (SP, valout->len); + for (i = 0; i < valout->len; ++i) { + hv = newHV (); + (void) hv_store (hv, "lv_name", 7, newSVpv (valout->val[i].lv_name, 0), 0); + (void) hv_store (hv, "lv_uuid", 7, newSVpv (valout->val[i].lv_uuid, 32), 0); + (void) hv_store (hv, "lv_attr", 7, newSVpv (valout->val[i].lv_attr, 0), 0); + (void) hv_store (hv, "lv_major", 8, my_newSVll (valout->val[i].lv_major), 0); + (void) hv_store (hv, "lv_minor", 8, my_newSVll (valout->val[i].lv_minor), 0); + (void) hv_store (hv, "lv_kernel_major", 15, my_newSVll (valout->val[i].lv_kernel_major), 0); + (void) hv_store (hv, "lv_kernel_minor", 15, my_newSVll (valout->val[i].lv_kernel_minor), 0); + (void) hv_store (hv, "lv_size", 7, my_newSVull (valout->val[i].lv_size), 0); + (void) hv_store (hv, "seg_count", 9, my_newSVll (valout->val[i].seg_count), 0); + (void) hv_store (hv, "origin", 6, newSVpv (valout->val[i].origin, 0), 0); + (void) hv_store (hv, "snap_percent", 12, newSVnv (valout->val[i].snap_percent), 0); + (void) hv_store (hv, "copy_percent", 12, newSVnv (valout->val[i].copy_percent), 0); + (void) hv_store (hv, "move_pv", 7, newSVpv (valout->val[i].move_pv, 0), 0); + (void) hv_store (hv, "lv_tags", 7, newSVpv (valout->val[i].lv_tags, 0), 0); + (void) hv_store (hv, "mirror_log", 10, newSVpv (valout->val[i].mirror_log, 0), 0); + (void) hv_store (hv, "modules", 7, newSVpv (valout->val[i].modules, 0), 0); + PUSHs (sv_2mortal ((SV *) hv)); + } + guestfs_free_lvm_lv_list (valout); + +void +test0rlvlisterr (g) + guestfs_h *g; +PREINIT: + struct guestfs_lvm_lv_list *valout; + int i; + HV *hv; + PPCODE: + valout = guestfs_test0rlvlisterr (g); + if (valout == NULL) + croak ("test0rlvlisterr: %s", guestfs_last_error (g)); + EXTEND (SP, valout->len); + for (i = 0; i < valout->len; ++i) { + hv = newHV (); + (void) hv_store (hv, "lv_name", 7, newSVpv (valout->val[i].lv_name, 0), 0); + (void) hv_store (hv, "lv_uuid", 7, newSVpv (valout->val[i].lv_uuid, 32), 0); + (void) hv_store (hv, "lv_attr", 7, newSVpv (valout->val[i].lv_attr, 0), 0); + (void) hv_store (hv, "lv_major", 8, my_newSVll (valout->val[i].lv_major), 0); + (void) hv_store (hv, "lv_minor", 8, my_newSVll (valout->val[i].lv_minor), 0); + (void) hv_store (hv, "lv_kernel_major", 15, my_newSVll (valout->val[i].lv_kernel_major), 0); + (void) hv_store (hv, "lv_kernel_minor", 15, my_newSVll (valout->val[i].lv_kernel_minor), 0); + (void) hv_store (hv, "lv_size", 7, my_newSVull (valout->val[i].lv_size), 0); + (void) hv_store (hv, "seg_count", 9, my_newSVll (valout->val[i].seg_count), 0); + (void) hv_store (hv, "origin", 6, newSVpv (valout->val[i].origin, 0), 0); + (void) hv_store (hv, "snap_percent", 12, newSVnv (valout->val[i].snap_percent), 0); + (void) hv_store (hv, "copy_percent", 12, newSVnv (valout->val[i].copy_percent), 0); + (void) hv_store (hv, "move_pv", 7, newSVpv (valout->val[i].move_pv, 0), 0); + (void) hv_store (hv, "lv_tags", 7, newSVpv (valout->val[i].lv_tags, 0), 0); + (void) hv_store (hv, "mirror_log", 10, newSVpv (valout->val[i].mirror_log, 0), 0); + (void) hv_store (hv, "modules", 7, newSVpv (valout->val[i].modules, 0), 0); + PUSHs (sv_2mortal ((SV *) hv)); + } + guestfs_free_lvm_lv_list (valout); + +void +test0rstat (g, val) + guestfs_h *g; + char *val; +PREINIT: + struct guestfs_stat *valout; + PPCODE: + valout = guestfs_test0rstat (g, val); + if (valout == NULL) + croak ("test0rstat: %s", guestfs_last_error (g)); + EXTEND (SP, 13); + PUSHs (sv_2mortal (my_newSVll (valout->dev))); + PUSHs (sv_2mortal (my_newSVll (valout->ino))); + PUSHs (sv_2mortal (my_newSVll (valout->mode))); + PUSHs (sv_2mortal (my_newSVll (valout->nlink))); + PUSHs (sv_2mortal (my_newSVll (valout->uid))); + PUSHs (sv_2mortal (my_newSVll (valout->gid))); + PUSHs (sv_2mortal (my_newSVll (valout->rdev))); + PUSHs (sv_2mortal (my_newSVll (valout->size))); + PUSHs (sv_2mortal (my_newSVll (valout->blksize))); + PUSHs (sv_2mortal (my_newSVll (valout->blocks))); + PUSHs (sv_2mortal (my_newSVll (valout->atime))); + PUSHs (sv_2mortal (my_newSVll (valout->mtime))); + PUSHs (sv_2mortal (my_newSVll (valout->ctime))); + free (valout); + +void +test0rstaterr (g) + guestfs_h *g; +PREINIT: + struct guestfs_stat *valout; + PPCODE: + valout = guestfs_test0rstaterr (g); + if (valout == NULL) + croak ("test0rstaterr: %s", guestfs_last_error (g)); + EXTEND (SP, 13); + PUSHs (sv_2mortal (my_newSVll (valout->dev))); + PUSHs (sv_2mortal (my_newSVll (valout->ino))); + PUSHs (sv_2mortal (my_newSVll (valout->mode))); + PUSHs (sv_2mortal (my_newSVll (valout->nlink))); + PUSHs (sv_2mortal (my_newSVll (valout->uid))); + PUSHs (sv_2mortal (my_newSVll (valout->gid))); + PUSHs (sv_2mortal (my_newSVll (valout->rdev))); + PUSHs (sv_2mortal (my_newSVll (valout->size))); + PUSHs (sv_2mortal (my_newSVll (valout->blksize))); + PUSHs (sv_2mortal (my_newSVll (valout->blocks))); + PUSHs (sv_2mortal (my_newSVll (valout->atime))); + PUSHs (sv_2mortal (my_newSVll (valout->mtime))); + PUSHs (sv_2mortal (my_newSVll (valout->ctime))); + free (valout); + +void +test0rstatvfs (g, val) + guestfs_h *g; + char *val; +PREINIT: + struct guestfs_statvfs *valout; + PPCODE: + valout = guestfs_test0rstatvfs (g, val); + if (valout == NULL) + croak ("test0rstatvfs: %s", guestfs_last_error (g)); + EXTEND (SP, 11); + PUSHs (sv_2mortal (my_newSVll (valout->bsize))); + PUSHs (sv_2mortal (my_newSVll (valout->frsize))); + PUSHs (sv_2mortal (my_newSVll (valout->blocks))); + PUSHs (sv_2mortal (my_newSVll (valout->bfree))); + PUSHs (sv_2mortal (my_newSVll (valout->bavail))); + PUSHs (sv_2mortal (my_newSVll (valout->files))); + PUSHs (sv_2mortal (my_newSVll (valout->ffree))); + PUSHs (sv_2mortal (my_newSVll (valout->favail))); + PUSHs (sv_2mortal (my_newSVll (valout->fsid))); + PUSHs (sv_2mortal (my_newSVll (valout->flag))); + PUSHs (sv_2mortal (my_newSVll (valout->namemax))); + free (valout); + +void +test0rstatvfserr (g) + guestfs_h *g; +PREINIT: + struct guestfs_statvfs *valout; + PPCODE: + valout = guestfs_test0rstatvfserr (g); + if (valout == NULL) + croak ("test0rstatvfserr: %s", guestfs_last_error (g)); + EXTEND (SP, 11); + PUSHs (sv_2mortal (my_newSVll (valout->bsize))); + PUSHs (sv_2mortal (my_newSVll (valout->frsize))); + PUSHs (sv_2mortal (my_newSVll (valout->blocks))); + PUSHs (sv_2mortal (my_newSVll (valout->bfree))); + PUSHs (sv_2mortal (my_newSVll (valout->bavail))); + PUSHs (sv_2mortal (my_newSVll (valout->files))); + PUSHs (sv_2mortal (my_newSVll (valout->ffree))); + PUSHs (sv_2mortal (my_newSVll (valout->favail))); + PUSHs (sv_2mortal (my_newSVll (valout->fsid))); + PUSHs (sv_2mortal (my_newSVll (valout->flag))); + PUSHs (sv_2mortal (my_newSVll (valout->namemax))); + free (valout); + +void +test0rhashtable (g, val) + guestfs_h *g; + char *val; +PREINIT: + char **valout; + int i, n; + PPCODE: + valout = guestfs_test0rhashtable (g, val); + if (valout == NULL) + croak ("test0rhashtable: %s", guestfs_last_error (g)); + for (n = 0; valout[n] != NULL; ++n) /**/; + EXTEND (SP, n); + for (i = 0; i < n; ++i) { + PUSHs (sv_2mortal (newSVpv (valout[i], 0))); + free (valout[i]); + } + free (valout); + +void +test0rhashtableerr (g) + guestfs_h *g; +PREINIT: + char **valout; + int i, n; + PPCODE: + valout = guestfs_test0rhashtableerr (g); + if (valout == NULL) + croak ("test0rhashtableerr: %s", guestfs_last_error (g)); + for (n = 0; valout[n] != NULL; ++n) /**/; + EXTEND (SP, n); + for (i = 0; i < n; ++i) { + PUSHs (sv_2mortal (newSVpv (valout[i], 0))); + free (valout[i]); + } + free (valout); + +void launch (g) guestfs_h *g; PREINIT: diff --git a/perl/t/006-pod-coverage.t b/perl/t/006-pod-coverage.t index fd1c405..c648b34 100644 --- a/perl/t/006-pod-coverage.t +++ b/perl/t/006-pod-coverage.t @@ -21,4 +21,4 @@ use warnings; eval "use Test::Pod::Coverage 1.00"; plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD" if $@; -all_pod_coverage_ok (); +all_pod_coverage_ok ({also_private => [ qr/^test0.*/ ]}); diff --git a/python/guestfs-py.c b/python/guestfs-py.c index 4461462..6ac3bd9 100644 --- a/python/guestfs-py.c +++ b/python/guestfs-py.c @@ -389,6 +389,674 @@ put_statvfs (struct guestfs_statvfs *statvfs) }; static PyObject * +py_guestfs_test0 (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + int r; + const char *str; + const char *optstr; + PyObject *py_strlist; + const char **strlist; + int b; + int integer; + const char *filein; + const char *fileout; + + if (!PyArg_ParseTuple (args, (char *) "OszOiiss:guestfs_test0", + &py_g, &str, &optstr, &py_strlist, &b, &integer, &filein, &fileout)) + return NULL; + g = get_handle (py_g); + strlist = get_string_list (py_strlist); + if (!strlist) return NULL; + + r = guestfs_test0 (g, str, optstr, strlist, b, integer, filein, fileout); + free (strlist); + if (r == -1) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + Py_INCREF (Py_None); + py_r = Py_None; + return py_r; +} + +static PyObject * +py_guestfs_test0rint (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + int r; + const char *val; + + if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_test0rint", + &py_g, &val)) + return NULL; + g = get_handle (py_g); + + r = guestfs_test0rint (g, val); + if (r == -1) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = PyInt_FromLong ((long) r); + return py_r; +} + +static PyObject * +py_guestfs_test0rinterr (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + int r; + + if (!PyArg_ParseTuple (args, (char *) "O:guestfs_test0rinterr", + &py_g)) + return NULL; + g = get_handle (py_g); + + r = guestfs_test0rinterr (g); + if (r == -1) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = PyInt_FromLong ((long) r); + return py_r; +} + +static PyObject * +py_guestfs_test0rint64 (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + int64_t r; + const char *val; + + if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_test0rint64", + &py_g, &val)) + return NULL; + g = get_handle (py_g); + + r = guestfs_test0rint64 (g, val); + if (r == -1) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = PyLong_FromLongLong (r); + return py_r; +} + +static PyObject * +py_guestfs_test0rint64err (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + int64_t r; + + if (!PyArg_ParseTuple (args, (char *) "O:guestfs_test0rint64err", + &py_g)) + return NULL; + g = get_handle (py_g); + + r = guestfs_test0rint64err (g); + if (r == -1) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = PyLong_FromLongLong (r); + return py_r; +} + +static PyObject * +py_guestfs_test0rbool (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + int r; + const char *val; + + if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_test0rbool", + &py_g, &val)) + return NULL; + g = get_handle (py_g); + + r = guestfs_test0rbool (g, val); + if (r == -1) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = PyInt_FromLong ((long) r); + return py_r; +} + +static PyObject * +py_guestfs_test0rboolerr (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + int r; + + if (!PyArg_ParseTuple (args, (char *) "O:guestfs_test0rboolerr", + &py_g)) + return NULL; + g = get_handle (py_g); + + r = guestfs_test0rboolerr (g); + if (r == -1) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = PyInt_FromLong ((long) r); + return py_r; +} + +static PyObject * +py_guestfs_test0rconststring (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + const char *r; + const char *val; + + if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_test0rconststring", + &py_g, &val)) + return NULL; + g = get_handle (py_g); + + r = guestfs_test0rconststring (g, val); + if (r == NULL) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = PyString_FromString (r); + return py_r; +} + +static PyObject * +py_guestfs_test0rconststringerr (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + const char *r; + + if (!PyArg_ParseTuple (args, (char *) "O:guestfs_test0rconststringerr", + &py_g)) + return NULL; + g = get_handle (py_g); + + r = guestfs_test0rconststringerr (g); + if (r == NULL) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = PyString_FromString (r); + return py_r; +} + +static PyObject * +py_guestfs_test0rstring (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + char *r; + const char *val; + + if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_test0rstring", + &py_g, &val)) + return NULL; + g = get_handle (py_g); + + r = guestfs_test0rstring (g, val); + if (r == NULL) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = PyString_FromString (r); + free (r); + return py_r; +} + +static PyObject * +py_guestfs_test0rstringerr (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + char *r; + + if (!PyArg_ParseTuple (args, (char *) "O:guestfs_test0rstringerr", + &py_g)) + return NULL; + g = get_handle (py_g); + + r = guestfs_test0rstringerr (g); + if (r == NULL) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = PyString_FromString (r); + free (r); + return py_r; +} + +static PyObject * +py_guestfs_test0rstringlist (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + char **r; + const char *val; + + if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_test0rstringlist", + &py_g, &val)) + return NULL; + g = get_handle (py_g); + + r = guestfs_test0rstringlist (g, val); + if (r == NULL) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = put_string_list (r); + free_strings (r); + return py_r; +} + +static PyObject * +py_guestfs_test0rstringlisterr (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + char **r; + + if (!PyArg_ParseTuple (args, (char *) "O:guestfs_test0rstringlisterr", + &py_g)) + return NULL; + g = get_handle (py_g); + + r = guestfs_test0rstringlisterr (g); + if (r == NULL) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = put_string_list (r); + free_strings (r); + return py_r; +} + +static PyObject * +py_guestfs_test0rintbool (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + struct guestfs_int_bool *r; + const char *val; + + if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_test0rintbool", + &py_g, &val)) + return NULL; + g = get_handle (py_g); + + r = guestfs_test0rintbool (g, val); + if (r == NULL) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = PyTuple_New (2); + PyTuple_SetItem (py_r, 0, PyInt_FromLong ((long) r->i)); + PyTuple_SetItem (py_r, 1, PyInt_FromLong ((long) r->b)); + guestfs_free_int_bool (r); + return py_r; +} + +static PyObject * +py_guestfs_test0rintboolerr (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + struct guestfs_int_bool *r; + + if (!PyArg_ParseTuple (args, (char *) "O:guestfs_test0rintboolerr", + &py_g)) + return NULL; + g = get_handle (py_g); + + r = guestfs_test0rintboolerr (g); + if (r == NULL) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = PyTuple_New (2); + PyTuple_SetItem (py_r, 0, PyInt_FromLong ((long) r->i)); + PyTuple_SetItem (py_r, 1, PyInt_FromLong ((long) r->b)); + guestfs_free_int_bool (r); + return py_r; +} + +static PyObject * +py_guestfs_test0rpvlist (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + struct guestfs_lvm_pv_list *r; + const char *val; + + if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_test0rpvlist", + &py_g, &val)) + return NULL; + g = get_handle (py_g); + + r = guestfs_test0rpvlist (g, val); + if (r == NULL) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = put_lvm_pv_list (r); + guestfs_free_lvm_pv_list (r); + return py_r; +} + +static PyObject * +py_guestfs_test0rpvlisterr (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + struct guestfs_lvm_pv_list *r; + + if (!PyArg_ParseTuple (args, (char *) "O:guestfs_test0rpvlisterr", + &py_g)) + return NULL; + g = get_handle (py_g); + + r = guestfs_test0rpvlisterr (g); + if (r == NULL) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = put_lvm_pv_list (r); + guestfs_free_lvm_pv_list (r); + return py_r; +} + +static PyObject * +py_guestfs_test0rvglist (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + struct guestfs_lvm_vg_list *r; + const char *val; + + if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_test0rvglist", + &py_g, &val)) + return NULL; + g = get_handle (py_g); + + r = guestfs_test0rvglist (g, val); + if (r == NULL) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = put_lvm_vg_list (r); + guestfs_free_lvm_vg_list (r); + return py_r; +} + +static PyObject * +py_guestfs_test0rvglisterr (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + struct guestfs_lvm_vg_list *r; + + if (!PyArg_ParseTuple (args, (char *) "O:guestfs_test0rvglisterr", + &py_g)) + return NULL; + g = get_handle (py_g); + + r = guestfs_test0rvglisterr (g); + if (r == NULL) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = put_lvm_vg_list (r); + guestfs_free_lvm_vg_list (r); + return py_r; +} + +static PyObject * +py_guestfs_test0rlvlist (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + struct guestfs_lvm_lv_list *r; + const char *val; + + if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_test0rlvlist", + &py_g, &val)) + return NULL; + g = get_handle (py_g); + + r = guestfs_test0rlvlist (g, val); + if (r == NULL) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = put_lvm_lv_list (r); + guestfs_free_lvm_lv_list (r); + return py_r; +} + +static PyObject * +py_guestfs_test0rlvlisterr (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + struct guestfs_lvm_lv_list *r; + + if (!PyArg_ParseTuple (args, (char *) "O:guestfs_test0rlvlisterr", + &py_g)) + return NULL; + g = get_handle (py_g); + + r = guestfs_test0rlvlisterr (g); + if (r == NULL) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = put_lvm_lv_list (r); + guestfs_free_lvm_lv_list (r); + return py_r; +} + +static PyObject * +py_guestfs_test0rstat (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + struct guestfs_stat *r; + const char *val; + + if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_test0rstat", + &py_g, &val)) + return NULL; + g = get_handle (py_g); + + r = guestfs_test0rstat (g, val); + if (r == NULL) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = put_stat (r); + free (r); + return py_r; +} + +static PyObject * +py_guestfs_test0rstaterr (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + struct guestfs_stat *r; + + if (!PyArg_ParseTuple (args, (char *) "O:guestfs_test0rstaterr", + &py_g)) + return NULL; + g = get_handle (py_g); + + r = guestfs_test0rstaterr (g); + if (r == NULL) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = put_stat (r); + free (r); + return py_r; +} + +static PyObject * +py_guestfs_test0rstatvfs (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + struct guestfs_statvfs *r; + const char *val; + + if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_test0rstatvfs", + &py_g, &val)) + return NULL; + g = get_handle (py_g); + + r = guestfs_test0rstatvfs (g, val); + if (r == NULL) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = put_statvfs (r); + free (r); + return py_r; +} + +static PyObject * +py_guestfs_test0rstatvfserr (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + struct guestfs_statvfs *r; + + if (!PyArg_ParseTuple (args, (char *) "O:guestfs_test0rstatvfserr", + &py_g)) + return NULL; + g = get_handle (py_g); + + r = guestfs_test0rstatvfserr (g); + if (r == NULL) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = put_statvfs (r); + free (r); + return py_r; +} + +static PyObject * +py_guestfs_test0rhashtable (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + char **r; + const char *val; + + if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_test0rhashtable", + &py_g, &val)) + return NULL; + g = get_handle (py_g); + + r = guestfs_test0rhashtable (g, val); + if (r == NULL) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = put_table (r); + free_strings (r); + return py_r; +} + +static PyObject * +py_guestfs_test0rhashtableerr (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + char **r; + + if (!PyArg_ParseTuple (args, (char *) "O:guestfs_test0rhashtableerr", + &py_g)) + return NULL; + g = get_handle (py_g); + + r = guestfs_test0rhashtableerr (g); + if (r == NULL) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = put_table (r); + free_strings (r); + return py_r; +} + +static PyObject * py_guestfs_launch (PyObject *self, PyObject *args) { PyObject *py_g; @@ -3716,6 +4384,33 @@ py_guestfs_e2fsck_f (PyObject *self, PyObject *args) static PyMethodDef methods[] = { { (char *) "create", py_guestfs_create, METH_VARARGS, NULL }, { (char *) "close", py_guestfs_close, METH_VARARGS, NULL }, + { (char *) "test0", py_guestfs_test0, METH_VARARGS, NULL }, + { (char *) "test0rint", py_guestfs_test0rint, METH_VARARGS, NULL }, + { (char *) "test0rinterr", py_guestfs_test0rinterr, METH_VARARGS, NULL }, + { (char *) "test0rint64", py_guestfs_test0rint64, METH_VARARGS, NULL }, + { (char *) "test0rint64err", py_guestfs_test0rint64err, METH_VARARGS, NULL }, + { (char *) "test0rbool", py_guestfs_test0rbool, METH_VARARGS, NULL }, + { (char *) "test0rboolerr", py_guestfs_test0rboolerr, METH_VARARGS, NULL }, + { (char *) "test0rconststring", py_guestfs_test0rconststring, METH_VARARGS, NULL }, + { (char *) "test0rconststringerr", py_guestfs_test0rconststringerr, METH_VARARGS, NULL }, + { (char *) "test0rstring", py_guestfs_test0rstring, METH_VARARGS, NULL }, + { (char *) "test0rstringerr", py_guestfs_test0rstringerr, METH_VARARGS, NULL }, + { (char *) "test0rstringlist", py_guestfs_test0rstringlist, METH_VARARGS, NULL }, + { (char *) "test0rstringlisterr", py_guestfs_test0rstringlisterr, METH_VARARGS, NULL }, + { (char *) "test0rintbool", py_guestfs_test0rintbool, METH_VARARGS, NULL }, + { (char *) "test0rintboolerr", py_guestfs_test0rintboolerr, METH_VARARGS, NULL }, + { (char *) "test0rpvlist", py_guestfs_test0rpvlist, METH_VARARGS, NULL }, + { (char *) "test0rpvlisterr", py_guestfs_test0rpvlisterr, METH_VARARGS, NULL }, + { (char *) "test0rvglist", py_guestfs_test0rvglist, METH_VARARGS, NULL }, + { (char *) "test0rvglisterr", py_guestfs_test0rvglisterr, METH_VARARGS, NULL }, + { (char *) "test0rlvlist", py_guestfs_test0rlvlist, METH_VARARGS, NULL }, + { (char *) "test0rlvlisterr", py_guestfs_test0rlvlisterr, METH_VARARGS, NULL }, + { (char *) "test0rstat", py_guestfs_test0rstat, METH_VARARGS, NULL }, + { (char *) "test0rstaterr", py_guestfs_test0rstaterr, METH_VARARGS, NULL }, + { (char *) "test0rstatvfs", py_guestfs_test0rstatvfs, METH_VARARGS, NULL }, + { (char *) "test0rstatvfserr", py_guestfs_test0rstatvfserr, METH_VARARGS, NULL }, + { (char *) "test0rhashtable", py_guestfs_test0rhashtable, METH_VARARGS, NULL }, + { (char *) "test0rhashtableerr", py_guestfs_test0rhashtableerr, METH_VARARGS, NULL }, { (char *) "launch", py_guestfs_launch, METH_VARARGS, NULL }, { (char *) "wait_ready", py_guestfs_wait_ready, METH_VARARGS, NULL }, { (char *) "kill_subprocess", py_guestfs_kill_subprocess, METH_VARARGS, NULL }, diff --git a/python/guestfs.py b/python/guestfs.py index a82c8cb..4f32ae7 100644 --- a/python/guestfs.py +++ b/python/guestfs.py @@ -78,6 +78,87 @@ class GuestFS: def __del__ (self): libguestfsmod.close (self._o) + def test0 (self, str, optstr, strlist, b, integer, filein, fileout): + return libguestfsmod.test0 (self._o, str, optstr, strlist, b, integer, filein, fileout) + + def test0rint (self, val): + return libguestfsmod.test0rint (self._o, val) + + def test0rinterr (self): + return libguestfsmod.test0rinterr (self._o) + + def test0rint64 (self, val): + return libguestfsmod.test0rint64 (self._o, val) + + def test0rint64err (self): + return libguestfsmod.test0rint64err (self._o) + + def test0rbool (self, val): + return libguestfsmod.test0rbool (self._o, val) + + def test0rboolerr (self): + return libguestfsmod.test0rboolerr (self._o) + + def test0rconststring (self, val): + return libguestfsmod.test0rconststring (self._o, val) + + def test0rconststringerr (self): + return libguestfsmod.test0rconststringerr (self._o) + + def test0rstring (self, val): + return libguestfsmod.test0rstring (self._o, val) + + def test0rstringerr (self): + return libguestfsmod.test0rstringerr (self._o) + + def test0rstringlist (self, val): + return libguestfsmod.test0rstringlist (self._o, val) + + def test0rstringlisterr (self): + return libguestfsmod.test0rstringlisterr (self._o) + + def test0rintbool (self, val): + return libguestfsmod.test0rintbool (self._o, val) + + def test0rintboolerr (self): + return libguestfsmod.test0rintboolerr (self._o) + + def test0rpvlist (self, val): + return libguestfsmod.test0rpvlist (self._o, val) + + def test0rpvlisterr (self): + return libguestfsmod.test0rpvlisterr (self._o) + + def test0rvglist (self, val): + return libguestfsmod.test0rvglist (self._o, val) + + def test0rvglisterr (self): + return libguestfsmod.test0rvglisterr (self._o) + + def test0rlvlist (self, val): + return libguestfsmod.test0rlvlist (self._o, val) + + def test0rlvlisterr (self): + return libguestfsmod.test0rlvlisterr (self._o) + + def test0rstat (self, val): + return libguestfsmod.test0rstat (self._o, val) + + def test0rstaterr (self): + return libguestfsmod.test0rstaterr (self._o) + + def test0rstatvfs (self, val): + return libguestfsmod.test0rstatvfs (self._o, val) + + def test0rstatvfserr (self): + return libguestfsmod.test0rstatvfserr (self._o) + + def test0rhashtable (self, val): + return libguestfsmod.test0rhashtable (self._o, val) + + def test0rhashtableerr (self): + return libguestfsmod.test0rhashtableerr (self._o) + def launch (self): u"""Internally libguestfs is implemented by running a virtual machine using qemu(1). diff --git a/ruby/ext/guestfs/_guestfs.c b/ruby/ext/guestfs/_guestfs.c index 8b554bb..58f7532 100644 --- a/ruby/ext/guestfs/_guestfs.c +++ b/ruby/ext/guestfs/_guestfs.c @@ -71,6 +71,783 @@ static VALUE ruby_guestfs_close (VALUE gv) return Qnil; } +static VALUE ruby_guestfs_test0 (VALUE gv, VALUE strv, VALUE optstrv, VALUE strlistv, VALUE bv, VALUE integerv, VALUE fileinv, VALUE fileoutv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "test0"); + + const char *str = StringValueCStr (strv); + if (!str) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "str", "test0"); + const char *optstr = StringValueCStr (optstrv); + char **strlist; { + int i, len; + len = RARRAY_LEN (strlistv); + strlist = guestfs_safe_malloc (g, sizeof (char *) * (len+1)); + for (i = 0; i < len; ++i) { + VALUE v = rb_ary_entry (strlistv, i); + strlist[i] = StringValueCStr (v); + } + strlist[len] = NULL; + } + int b = NUM2INT (bv); + int integer = NUM2INT (integerv); + const char *filein = StringValueCStr (fileinv); + if (!filein) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "filein", "test0"); + const char *fileout = StringValueCStr (fileoutv); + if (!fileout) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "fileout", "test0"); + + int r; + + r = guestfs_test0 (g, str, optstr, strlist, b, integer, filein, fileout); + free (strlist); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + +static VALUE ruby_guestfs_test0rint (VALUE gv, VALUE valv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rint"); + + const char *val = StringValueCStr (valv); + if (!val) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "val", "test0rint"); + + int r; + + r = guestfs_test0rint (g, val); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return INT2NUM (r); +} + +static VALUE ruby_guestfs_test0rinterr (VALUE gv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rinterr"); + + + int r; + + r = guestfs_test0rinterr (g); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return INT2NUM (r); +} + +static VALUE ruby_guestfs_test0rint64 (VALUE gv, VALUE valv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rint64"); + + const char *val = StringValueCStr (valv); + if (!val) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "val", "test0rint64"); + + int64_t r; + + r = guestfs_test0rint64 (g, val); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return ULL2NUM (r); +} + +static VALUE ruby_guestfs_test0rint64err (VALUE gv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rint64err"); + + + int64_t r; + + r = guestfs_test0rint64err (g); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return ULL2NUM (r); +} + +static VALUE ruby_guestfs_test0rbool (VALUE gv, VALUE valv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rbool"); + + const char *val = StringValueCStr (valv); + if (!val) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "val", "test0rbool"); + + int r; + + r = guestfs_test0rbool (g, val); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return INT2NUM (r); +} + +static VALUE ruby_guestfs_test0rboolerr (VALUE gv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rboolerr"); + + + int r; + + r = guestfs_test0rboolerr (g); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return INT2NUM (r); +} + +static VALUE ruby_guestfs_test0rconststring (VALUE gv, VALUE valv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rconststring"); + + const char *val = StringValueCStr (valv); + if (!val) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "val", "test0rconststring"); + + const char *r; + + r = guestfs_test0rconststring (g, val); + if (r == NULL) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return rb_str_new2 (r); +} + +static VALUE ruby_guestfs_test0rconststringerr (VALUE gv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rconststringerr"); + + + const char *r; + + r = guestfs_test0rconststringerr (g); + if (r == NULL) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return rb_str_new2 (r); +} + +static VALUE ruby_guestfs_test0rstring (VALUE gv, VALUE valv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rstring"); + + const char *val = StringValueCStr (valv); + if (!val) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "val", "test0rstring"); + + char *r; + + r = guestfs_test0rstring (g, val); + 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_test0rstringerr (VALUE gv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rstringerr"); + + + char *r; + + r = guestfs_test0rstringerr (g); + 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_test0rstringlist (VALUE gv, VALUE valv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rstringlist"); + + const char *val = StringValueCStr (valv); + if (!val) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "val", "test0rstringlist"); + + char **r; + + r = guestfs_test0rstringlist (g, val); + 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; +} + +static VALUE ruby_guestfs_test0rstringlisterr (VALUE gv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rstringlisterr"); + + + char **r; + + r = guestfs_test0rstringlisterr (g); + 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; +} + +static VALUE ruby_guestfs_test0rintbool (VALUE gv, VALUE valv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rintbool"); + + const char *val = StringValueCStr (valv); + if (!val) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "val", "test0rintbool"); + + struct guestfs_int_bool *r; + + r = guestfs_test0rintbool (g, val); + if (r == NULL) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + VALUE rv = rb_ary_new2 (2); + rb_ary_push (rv, INT2NUM (r->i)); + rb_ary_push (rv, INT2NUM (r->b)); + guestfs_free_int_bool (r); + return rv; +} + +static VALUE ruby_guestfs_test0rintboolerr (VALUE gv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rintboolerr"); + + + struct guestfs_int_bool *r; + + r = guestfs_test0rintboolerr (g); + if (r == NULL) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + VALUE rv = rb_ary_new2 (2); + rb_ary_push (rv, INT2NUM (r->i)); + rb_ary_push (rv, INT2NUM (r->b)); + guestfs_free_int_bool (r); + return rv; +} + +static VALUE ruby_guestfs_test0rpvlist (VALUE gv, VALUE valv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rpvlist"); + + const char *val = StringValueCStr (valv); + if (!val) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "val", "test0rpvlist"); + + struct guestfs_lvm_pv_list *r; + + r = guestfs_test0rpvlist (g, val); + if (r == NULL) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + VALUE rv = rb_ary_new2 (r->len); + int i; + for (i = 0; i < r->len; ++i) { + VALUE hv = rb_hash_new (); + rb_hash_aset (rv, rb_str_new2 ("pv_name"), rb_str_new2 (r->val[i].pv_name)); + rb_hash_aset (rv, rb_str_new2 ("pv_uuid"), rb_str_new (r->val[i].pv_uuid, 32)); + rb_hash_aset (rv, rb_str_new2 ("pv_fmt"), rb_str_new2 (r->val[i].pv_fmt)); + rb_hash_aset (rv, rb_str_new2 ("pv_size"), ULL2NUM (r->val[i].pv_size)); + rb_hash_aset (rv, rb_str_new2 ("dev_size"), ULL2NUM (r->val[i].dev_size)); + rb_hash_aset (rv, rb_str_new2 ("pv_free"), ULL2NUM (r->val[i].pv_free)); + rb_hash_aset (rv, rb_str_new2 ("pv_used"), ULL2NUM (r->val[i].pv_used)); + rb_hash_aset (rv, rb_str_new2 ("pv_attr"), rb_str_new2 (r->val[i].pv_attr)); + rb_hash_aset (rv, rb_str_new2 ("pv_pe_count"), ULL2NUM (r->val[i].pv_pe_count)); + rb_hash_aset (rv, rb_str_new2 ("pv_pe_alloc_count"), ULL2NUM (r->val[i].pv_pe_alloc_count)); + rb_hash_aset (rv, rb_str_new2 ("pv_tags"), rb_str_new2 (r->val[i].pv_tags)); + rb_hash_aset (rv, rb_str_new2 ("pe_start"), ULL2NUM (r->val[i].pe_start)); + rb_hash_aset (rv, rb_str_new2 ("pv_mda_count"), ULL2NUM (r->val[i].pv_mda_count)); + rb_hash_aset (rv, rb_str_new2 ("pv_mda_free"), ULL2NUM (r->val[i].pv_mda_free)); + rb_ary_push (rv, hv); + } + guestfs_free_lvm_pv_list (r); + return rv; +} + +static VALUE ruby_guestfs_test0rpvlisterr (VALUE gv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rpvlisterr"); + + + struct guestfs_lvm_pv_list *r; + + r = guestfs_test0rpvlisterr (g); + if (r == NULL) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + VALUE rv = rb_ary_new2 (r->len); + int i; + for (i = 0; i < r->len; ++i) { + VALUE hv = rb_hash_new (); + rb_hash_aset (rv, rb_str_new2 ("pv_name"), rb_str_new2 (r->val[i].pv_name)); + rb_hash_aset (rv, rb_str_new2 ("pv_uuid"), rb_str_new (r->val[i].pv_uuid, 32)); + rb_hash_aset (rv, rb_str_new2 ("pv_fmt"), rb_str_new2 (r->val[i].pv_fmt)); + rb_hash_aset (rv, rb_str_new2 ("pv_size"), ULL2NUM (r->val[i].pv_size)); + rb_hash_aset (rv, rb_str_new2 ("dev_size"), ULL2NUM (r->val[i].dev_size)); + rb_hash_aset (rv, rb_str_new2 ("pv_free"), ULL2NUM (r->val[i].pv_free)); + rb_hash_aset (rv, rb_str_new2 ("pv_used"), ULL2NUM (r->val[i].pv_used)); + rb_hash_aset (rv, rb_str_new2 ("pv_attr"), rb_str_new2 (r->val[i].pv_attr)); + rb_hash_aset (rv, rb_str_new2 ("pv_pe_count"), ULL2NUM (r->val[i].pv_pe_count)); + rb_hash_aset (rv, rb_str_new2 ("pv_pe_alloc_count"), ULL2NUM (r->val[i].pv_pe_alloc_count)); + rb_hash_aset (rv, rb_str_new2 ("pv_tags"), rb_str_new2 (r->val[i].pv_tags)); + rb_hash_aset (rv, rb_str_new2 ("pe_start"), ULL2NUM (r->val[i].pe_start)); + rb_hash_aset (rv, rb_str_new2 ("pv_mda_count"), ULL2NUM (r->val[i].pv_mda_count)); + rb_hash_aset (rv, rb_str_new2 ("pv_mda_free"), ULL2NUM (r->val[i].pv_mda_free)); + rb_ary_push (rv, hv); + } + guestfs_free_lvm_pv_list (r); + return rv; +} + +static VALUE ruby_guestfs_test0rvglist (VALUE gv, VALUE valv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rvglist"); + + const char *val = StringValueCStr (valv); + if (!val) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "val", "test0rvglist"); + + struct guestfs_lvm_vg_list *r; + + r = guestfs_test0rvglist (g, val); + if (r == NULL) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + VALUE rv = rb_ary_new2 (r->len); + int i; + for (i = 0; i < r->len; ++i) { + VALUE hv = rb_hash_new (); + rb_hash_aset (rv, rb_str_new2 ("vg_name"), rb_str_new2 (r->val[i].vg_name)); + rb_hash_aset (rv, rb_str_new2 ("vg_uuid"), rb_str_new (r->val[i].vg_uuid, 32)); + rb_hash_aset (rv, rb_str_new2 ("vg_fmt"), rb_str_new2 (r->val[i].vg_fmt)); + rb_hash_aset (rv, rb_str_new2 ("vg_attr"), rb_str_new2 (r->val[i].vg_attr)); + rb_hash_aset (rv, rb_str_new2 ("vg_size"), ULL2NUM (r->val[i].vg_size)); + rb_hash_aset (rv, rb_str_new2 ("vg_free"), ULL2NUM (r->val[i].vg_free)); + rb_hash_aset (rv, rb_str_new2 ("vg_sysid"), rb_str_new2 (r->val[i].vg_sysid)); + rb_hash_aset (rv, rb_str_new2 ("vg_extent_size"), ULL2NUM (r->val[i].vg_extent_size)); + rb_hash_aset (rv, rb_str_new2 ("vg_extent_count"), ULL2NUM (r->val[i].vg_extent_count)); + rb_hash_aset (rv, rb_str_new2 ("vg_free_count"), ULL2NUM (r->val[i].vg_free_count)); + rb_hash_aset (rv, rb_str_new2 ("max_lv"), ULL2NUM (r->val[i].max_lv)); + rb_hash_aset (rv, rb_str_new2 ("max_pv"), ULL2NUM (r->val[i].max_pv)); + rb_hash_aset (rv, rb_str_new2 ("pv_count"), ULL2NUM (r->val[i].pv_count)); + rb_hash_aset (rv, rb_str_new2 ("lv_count"), ULL2NUM (r->val[i].lv_count)); + rb_hash_aset (rv, rb_str_new2 ("snap_count"), ULL2NUM (r->val[i].snap_count)); + rb_hash_aset (rv, rb_str_new2 ("vg_seqno"), ULL2NUM (r->val[i].vg_seqno)); + rb_hash_aset (rv, rb_str_new2 ("vg_tags"), rb_str_new2 (r->val[i].vg_tags)); + rb_hash_aset (rv, rb_str_new2 ("vg_mda_count"), ULL2NUM (r->val[i].vg_mda_count)); + rb_hash_aset (rv, rb_str_new2 ("vg_mda_free"), ULL2NUM (r->val[i].vg_mda_free)); + rb_ary_push (rv, hv); + } + guestfs_free_lvm_vg_list (r); + return rv; +} + +static VALUE ruby_guestfs_test0rvglisterr (VALUE gv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rvglisterr"); + + + struct guestfs_lvm_vg_list *r; + + r = guestfs_test0rvglisterr (g); + if (r == NULL) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + VALUE rv = rb_ary_new2 (r->len); + int i; + for (i = 0; i < r->len; ++i) { + VALUE hv = rb_hash_new (); + rb_hash_aset (rv, rb_str_new2 ("vg_name"), rb_str_new2 (r->val[i].vg_name)); + rb_hash_aset (rv, rb_str_new2 ("vg_uuid"), rb_str_new (r->val[i].vg_uuid, 32)); + rb_hash_aset (rv, rb_str_new2 ("vg_fmt"), rb_str_new2 (r->val[i].vg_fmt)); + rb_hash_aset (rv, rb_str_new2 ("vg_attr"), rb_str_new2 (r->val[i].vg_attr)); + rb_hash_aset (rv, rb_str_new2 ("vg_size"), ULL2NUM (r->val[i].vg_size)); + rb_hash_aset (rv, rb_str_new2 ("vg_free"), ULL2NUM (r->val[i].vg_free)); + rb_hash_aset (rv, rb_str_new2 ("vg_sysid"), rb_str_new2 (r->val[i].vg_sysid)); + rb_hash_aset (rv, rb_str_new2 ("vg_extent_size"), ULL2NUM (r->val[i].vg_extent_size)); + rb_hash_aset (rv, rb_str_new2 ("vg_extent_count"), ULL2NUM (r->val[i].vg_extent_count)); + rb_hash_aset (rv, rb_str_new2 ("vg_free_count"), ULL2NUM (r->val[i].vg_free_count)); + rb_hash_aset (rv, rb_str_new2 ("max_lv"), ULL2NUM (r->val[i].max_lv)); + rb_hash_aset (rv, rb_str_new2 ("max_pv"), ULL2NUM (r->val[i].max_pv)); + rb_hash_aset (rv, rb_str_new2 ("pv_count"), ULL2NUM (r->val[i].pv_count)); + rb_hash_aset (rv, rb_str_new2 ("lv_count"), ULL2NUM (r->val[i].lv_count)); + rb_hash_aset (rv, rb_str_new2 ("snap_count"), ULL2NUM (r->val[i].snap_count)); + rb_hash_aset (rv, rb_str_new2 ("vg_seqno"), ULL2NUM (r->val[i].vg_seqno)); + rb_hash_aset (rv, rb_str_new2 ("vg_tags"), rb_str_new2 (r->val[i].vg_tags)); + rb_hash_aset (rv, rb_str_new2 ("vg_mda_count"), ULL2NUM (r->val[i].vg_mda_count)); + rb_hash_aset (rv, rb_str_new2 ("vg_mda_free"), ULL2NUM (r->val[i].vg_mda_free)); + rb_ary_push (rv, hv); + } + guestfs_free_lvm_vg_list (r); + return rv; +} + +static VALUE ruby_guestfs_test0rlvlist (VALUE gv, VALUE valv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rlvlist"); + + const char *val = StringValueCStr (valv); + if (!val) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "val", "test0rlvlist"); + + struct guestfs_lvm_lv_list *r; + + r = guestfs_test0rlvlist (g, val); + if (r == NULL) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + VALUE rv = rb_ary_new2 (r->len); + int i; + for (i = 0; i < r->len; ++i) { + VALUE hv = rb_hash_new (); + rb_hash_aset (rv, rb_str_new2 ("lv_name"), rb_str_new2 (r->val[i].lv_name)); + rb_hash_aset (rv, rb_str_new2 ("lv_uuid"), rb_str_new (r->val[i].lv_uuid, 32)); + rb_hash_aset (rv, rb_str_new2 ("lv_attr"), rb_str_new2 (r->val[i].lv_attr)); + rb_hash_aset (rv, rb_str_new2 ("lv_major"), ULL2NUM (r->val[i].lv_major)); + rb_hash_aset (rv, rb_str_new2 ("lv_minor"), ULL2NUM (r->val[i].lv_minor)); + rb_hash_aset (rv, rb_str_new2 ("lv_kernel_major"), ULL2NUM (r->val[i].lv_kernel_major)); + rb_hash_aset (rv, rb_str_new2 ("lv_kernel_minor"), ULL2NUM (r->val[i].lv_kernel_minor)); + rb_hash_aset (rv, rb_str_new2 ("lv_size"), ULL2NUM (r->val[i].lv_size)); + rb_hash_aset (rv, rb_str_new2 ("seg_count"), ULL2NUM (r->val[i].seg_count)); + rb_hash_aset (rv, rb_str_new2 ("origin"), rb_str_new2 (r->val[i].origin)); + rb_hash_aset (rv, rb_str_new2 ("snap_percent"), rb_dbl2big (r->val[i].snap_percent)); + rb_hash_aset (rv, rb_str_new2 ("copy_percent"), rb_dbl2big (r->val[i].copy_percent)); + rb_hash_aset (rv, rb_str_new2 ("move_pv"), rb_str_new2 (r->val[i].move_pv)); + rb_hash_aset (rv, rb_str_new2 ("lv_tags"), rb_str_new2 (r->val[i].lv_tags)); + rb_hash_aset (rv, rb_str_new2 ("mirror_log"), rb_str_new2 (r->val[i].mirror_log)); + rb_hash_aset (rv, rb_str_new2 ("modules"), rb_str_new2 (r->val[i].modules)); + rb_ary_push (rv, hv); + } + guestfs_free_lvm_lv_list (r); + return rv; +} + +static VALUE ruby_guestfs_test0rlvlisterr (VALUE gv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rlvlisterr"); + + + struct guestfs_lvm_lv_list *r; + + r = guestfs_test0rlvlisterr (g); + if (r == NULL) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + VALUE rv = rb_ary_new2 (r->len); + int i; + for (i = 0; i < r->len; ++i) { + VALUE hv = rb_hash_new (); + rb_hash_aset (rv, rb_str_new2 ("lv_name"), rb_str_new2 (r->val[i].lv_name)); + rb_hash_aset (rv, rb_str_new2 ("lv_uuid"), rb_str_new (r->val[i].lv_uuid, 32)); + rb_hash_aset (rv, rb_str_new2 ("lv_attr"), rb_str_new2 (r->val[i].lv_attr)); + rb_hash_aset (rv, rb_str_new2 ("lv_major"), ULL2NUM (r->val[i].lv_major)); + rb_hash_aset (rv, rb_str_new2 ("lv_minor"), ULL2NUM (r->val[i].lv_minor)); + rb_hash_aset (rv, rb_str_new2 ("lv_kernel_major"), ULL2NUM (r->val[i].lv_kernel_major)); + rb_hash_aset (rv, rb_str_new2 ("lv_kernel_minor"), ULL2NUM (r->val[i].lv_kernel_minor)); + rb_hash_aset (rv, rb_str_new2 ("lv_size"), ULL2NUM (r->val[i].lv_size)); + rb_hash_aset (rv, rb_str_new2 ("seg_count"), ULL2NUM (r->val[i].seg_count)); + rb_hash_aset (rv, rb_str_new2 ("origin"), rb_str_new2 (r->val[i].origin)); + rb_hash_aset (rv, rb_str_new2 ("snap_percent"), rb_dbl2big (r->val[i].snap_percent)); + rb_hash_aset (rv, rb_str_new2 ("copy_percent"), rb_dbl2big (r->val[i].copy_percent)); + rb_hash_aset (rv, rb_str_new2 ("move_pv"), rb_str_new2 (r->val[i].move_pv)); + rb_hash_aset (rv, rb_str_new2 ("lv_tags"), rb_str_new2 (r->val[i].lv_tags)); + rb_hash_aset (rv, rb_str_new2 ("mirror_log"), rb_str_new2 (r->val[i].mirror_log)); + rb_hash_aset (rv, rb_str_new2 ("modules"), rb_str_new2 (r->val[i].modules)); + rb_ary_push (rv, hv); + } + guestfs_free_lvm_lv_list (r); + return rv; +} + +static VALUE ruby_guestfs_test0rstat (VALUE gv, VALUE valv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rstat"); + + const char *val = StringValueCStr (valv); + if (!val) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "val", "test0rstat"); + + struct guestfs_stat *r; + + r = guestfs_test0rstat (g, val); + if (r == NULL) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + VALUE rv = rb_hash_new (); + rb_hash_aset (rv, rb_str_new2 ("dev"), ULL2NUM (r->dev)); + rb_hash_aset (rv, rb_str_new2 ("ino"), ULL2NUM (r->ino)); + rb_hash_aset (rv, rb_str_new2 ("mode"), ULL2NUM (r->mode)); + rb_hash_aset (rv, rb_str_new2 ("nlink"), ULL2NUM (r->nlink)); + rb_hash_aset (rv, rb_str_new2 ("uid"), ULL2NUM (r->uid)); + rb_hash_aset (rv, rb_str_new2 ("gid"), ULL2NUM (r->gid)); + rb_hash_aset (rv, rb_str_new2 ("rdev"), ULL2NUM (r->rdev)); + rb_hash_aset (rv, rb_str_new2 ("size"), ULL2NUM (r->size)); + rb_hash_aset (rv, rb_str_new2 ("blksize"), ULL2NUM (r->blksize)); + rb_hash_aset (rv, rb_str_new2 ("blocks"), ULL2NUM (r->blocks)); + rb_hash_aset (rv, rb_str_new2 ("atime"), ULL2NUM (r->atime)); + rb_hash_aset (rv, rb_str_new2 ("mtime"), ULL2NUM (r->mtime)); + rb_hash_aset (rv, rb_str_new2 ("ctime"), ULL2NUM (r->ctime)); + free (r); + return rv; +} + +static VALUE ruby_guestfs_test0rstaterr (VALUE gv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rstaterr"); + + + struct guestfs_stat *r; + + r = guestfs_test0rstaterr (g); + if (r == NULL) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + VALUE rv = rb_hash_new (); + rb_hash_aset (rv, rb_str_new2 ("dev"), ULL2NUM (r->dev)); + rb_hash_aset (rv, rb_str_new2 ("ino"), ULL2NUM (r->ino)); + rb_hash_aset (rv, rb_str_new2 ("mode"), ULL2NUM (r->mode)); + rb_hash_aset (rv, rb_str_new2 ("nlink"), ULL2NUM (r->nlink)); + rb_hash_aset (rv, rb_str_new2 ("uid"), ULL2NUM (r->uid)); + rb_hash_aset (rv, rb_str_new2 ("gid"), ULL2NUM (r->gid)); + rb_hash_aset (rv, rb_str_new2 ("rdev"), ULL2NUM (r->rdev)); + rb_hash_aset (rv, rb_str_new2 ("size"), ULL2NUM (r->size)); + rb_hash_aset (rv, rb_str_new2 ("blksize"), ULL2NUM (r->blksize)); + rb_hash_aset (rv, rb_str_new2 ("blocks"), ULL2NUM (r->blocks)); + rb_hash_aset (rv, rb_str_new2 ("atime"), ULL2NUM (r->atime)); + rb_hash_aset (rv, rb_str_new2 ("mtime"), ULL2NUM (r->mtime)); + rb_hash_aset (rv, rb_str_new2 ("ctime"), ULL2NUM (r->ctime)); + free (r); + return rv; +} + +static VALUE ruby_guestfs_test0rstatvfs (VALUE gv, VALUE valv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rstatvfs"); + + const char *val = StringValueCStr (valv); + if (!val) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "val", "test0rstatvfs"); + + struct guestfs_statvfs *r; + + r = guestfs_test0rstatvfs (g, val); + if (r == NULL) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + VALUE rv = rb_hash_new (); + rb_hash_aset (rv, rb_str_new2 ("bsize"), ULL2NUM (r->bsize)); + rb_hash_aset (rv, rb_str_new2 ("frsize"), ULL2NUM (r->frsize)); + rb_hash_aset (rv, rb_str_new2 ("blocks"), ULL2NUM (r->blocks)); + rb_hash_aset (rv, rb_str_new2 ("bfree"), ULL2NUM (r->bfree)); + rb_hash_aset (rv, rb_str_new2 ("bavail"), ULL2NUM (r->bavail)); + rb_hash_aset (rv, rb_str_new2 ("files"), ULL2NUM (r->files)); + rb_hash_aset (rv, rb_str_new2 ("ffree"), ULL2NUM (r->ffree)); + rb_hash_aset (rv, rb_str_new2 ("favail"), ULL2NUM (r->favail)); + rb_hash_aset (rv, rb_str_new2 ("fsid"), ULL2NUM (r->fsid)); + rb_hash_aset (rv, rb_str_new2 ("flag"), ULL2NUM (r->flag)); + rb_hash_aset (rv, rb_str_new2 ("namemax"), ULL2NUM (r->namemax)); + free (r); + return rv; +} + +static VALUE ruby_guestfs_test0rstatvfserr (VALUE gv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rstatvfserr"); + + + struct guestfs_statvfs *r; + + r = guestfs_test0rstatvfserr (g); + if (r == NULL) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + VALUE rv = rb_hash_new (); + rb_hash_aset (rv, rb_str_new2 ("bsize"), ULL2NUM (r->bsize)); + rb_hash_aset (rv, rb_str_new2 ("frsize"), ULL2NUM (r->frsize)); + rb_hash_aset (rv, rb_str_new2 ("blocks"), ULL2NUM (r->blocks)); + rb_hash_aset (rv, rb_str_new2 ("bfree"), ULL2NUM (r->bfree)); + rb_hash_aset (rv, rb_str_new2 ("bavail"), ULL2NUM (r->bavail)); + rb_hash_aset (rv, rb_str_new2 ("files"), ULL2NUM (r->files)); + rb_hash_aset (rv, rb_str_new2 ("ffree"), ULL2NUM (r->ffree)); + rb_hash_aset (rv, rb_str_new2 ("favail"), ULL2NUM (r->favail)); + rb_hash_aset (rv, rb_str_new2 ("fsid"), ULL2NUM (r->fsid)); + rb_hash_aset (rv, rb_str_new2 ("flag"), ULL2NUM (r->flag)); + rb_hash_aset (rv, rb_str_new2 ("namemax"), ULL2NUM (r->namemax)); + free (r); + return rv; +} + +static VALUE ruby_guestfs_test0rhashtable (VALUE gv, VALUE valv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rhashtable"); + + const char *val = StringValueCStr (valv); + if (!val) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "val", "test0rhashtable"); + + char **r; + + r = guestfs_test0rhashtable (g, val); + if (r == NULL) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + VALUE rv = rb_hash_new (); + int i; + for (i = 0; r[i] != NULL; i+=2) { + rb_hash_aset (rv, rb_str_new2 (r[i]), rb_str_new2 (r[i+1])); + free (r[i]); + free (r[i+1]); + } + free (r); + return rv; +} + +static VALUE ruby_guestfs_test0rhashtableerr (VALUE gv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "test0rhashtableerr"); + + + char **r; + + r = guestfs_test0rhashtableerr (g); + if (r == NULL) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + VALUE rv = rb_hash_new (); + int i; + for (i = 0; r[i] != NULL; i+=2) { + rb_hash_aset (rv, rb_str_new2 (r[i]), rb_str_new2 (r[i+1])); + free (r[i]); + free (r[i+1]); + } + free (r); + return rv; +} + static VALUE ruby_guestfs_launch (VALUE gv) { guestfs_h *g; @@ -3175,6 +3952,60 @@ void Init__guestfs () rb_define_module_function (m_guestfs, "create", ruby_guestfs_create, 0); rb_define_method (c_guestfs, "close", ruby_guestfs_close, 0); + rb_define_method (c_guestfs, "test0", + ruby_guestfs_test0, 7); + rb_define_method (c_guestfs, "test0rint", + ruby_guestfs_test0rint, 1); + rb_define_method (c_guestfs, "test0rinterr", + ruby_guestfs_test0rinterr, 0); + rb_define_method (c_guestfs, "test0rint64", + ruby_guestfs_test0rint64, 1); + rb_define_method (c_guestfs, "test0rint64err", + ruby_guestfs_test0rint64err, 0); + rb_define_method (c_guestfs, "test0rbool", + ruby_guestfs_test0rbool, 1); + rb_define_method (c_guestfs, "test0rboolerr", + ruby_guestfs_test0rboolerr, 0); + rb_define_method (c_guestfs, "test0rconststring", + ruby_guestfs_test0rconststring, 1); + rb_define_method (c_guestfs, "test0rconststringerr", + ruby_guestfs_test0rconststringerr, 0); + rb_define_method (c_guestfs, "test0rstring", + ruby_guestfs_test0rstring, 1); + rb_define_method (c_guestfs, "test0rstringerr", + ruby_guestfs_test0rstringerr, 0); + rb_define_method (c_guestfs, "test0rstringlist", + ruby_guestfs_test0rstringlist, 1); + rb_define_method (c_guestfs, "test0rstringlisterr", + ruby_guestfs_test0rstringlisterr, 0); + rb_define_method (c_guestfs, "test0rintbool", + ruby_guestfs_test0rintbool, 1); + rb_define_method (c_guestfs, "test0rintboolerr", + ruby_guestfs_test0rintboolerr, 0); + rb_define_method (c_guestfs, "test0rpvlist", + ruby_guestfs_test0rpvlist, 1); + rb_define_method (c_guestfs, "test0rpvlisterr", + ruby_guestfs_test0rpvlisterr, 0); + rb_define_method (c_guestfs, "test0rvglist", + ruby_guestfs_test0rvglist, 1); + rb_define_method (c_guestfs, "test0rvglisterr", + ruby_guestfs_test0rvglisterr, 0); + rb_define_method (c_guestfs, "test0rlvlist", + ruby_guestfs_test0rlvlist, 1); + rb_define_method (c_guestfs, "test0rlvlisterr", + ruby_guestfs_test0rlvlisterr, 0); + rb_define_method (c_guestfs, "test0rstat", + ruby_guestfs_test0rstat, 1); + rb_define_method (c_guestfs, "test0rstaterr", + ruby_guestfs_test0rstaterr, 0); + rb_define_method (c_guestfs, "test0rstatvfs", + ruby_guestfs_test0rstatvfs, 1); + rb_define_method (c_guestfs, "test0rstatvfserr", + ruby_guestfs_test0rstatvfserr, 0); + rb_define_method (c_guestfs, "test0rhashtable", + ruby_guestfs_test0rhashtable, 1); + rb_define_method (c_guestfs, "test0rhashtableerr", + ruby_guestfs_test0rhashtableerr, 0); rb_define_method (c_guestfs, "launch", ruby_guestfs_launch, 0); rb_define_method (c_guestfs, "wait_ready", diff --git a/src/Makefile.am b/src/Makefile.am index b41e91a..c310c9c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -33,6 +33,7 @@ libguestfs_la_SOURCES = \ guestfs_protocol.h \ guestfs-actions.h \ guestfs-actions.c \ + guestfs-bindtests.c \ gettext.h libguestfs_la_CFLAGS = -Wall -DGUESTFS_DEFAULT_PATH='"$(libdir)/guestfs"' diff --git a/src/generator.ml b/src/generator.ml index 6741541..9e17d6e 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -116,6 +116,7 @@ type flags = | FishAlias of string (* provide an alias for this cmd in guestfish *) | FishAction of string (* call this function in guestfish *) | NotInFish (* do not export via guestfish *) + | NotInDocs (* do not add this function to documentation *) let protocol_limit_warning = "Because of the message protocol, there is a transfer limit @@ -253,7 +254,81 @@ and cmd = string list * Apart from that, long descriptions are just perldoc paragraphs. *) -let non_daemon_functions = [ +(* These test functions are used in the language binding tests. *) + +let test_all_args = [ + String "str"; + OptString "optstr"; + StringList "strlist"; + Bool "b"; + Int "integer"; + FileIn "filein"; + FileOut "fileout"; +] + +let test_all_rets = [ + (* except for RErr, which is tested thoroughly elsewhere *) + "test0rint", RInt "valout"; + "test0rint64", RInt64 "valout"; + "test0rbool", RBool "valout"; + "test0rconststring", RConstString "valout"; + "test0rstring", RString "valout"; + "test0rstringlist", RStringList "valout"; + "test0rintbool", RIntBool ("valout", "valout"); + "test0rpvlist", RPVList "valout"; + "test0rvglist", RVGList "valout"; + "test0rlvlist", RLVList "valout"; + "test0rstat", RStat "valout"; + "test0rstatvfs", RStatVFS "valout"; + "test0rhashtable", RHashtable "valout"; +] + +let test_functions = [ + ("test0", (RErr, test_all_args), -1, [NotInFish; NotInDocs], + [], + "internal test function - do not use", + "\ +This is an internal test function which is used to test whether +the automatically generated bindings can handle every possible +parameter type correctly. + +It echos the contents of each parameter to stdout. + +You probably don't want to call this function."); +] @ List.flatten ( + List.map ( + fun (name, ret) -> + [(name, (ret, [String "val"]), -1, [NotInFish; NotInDocs], + [], + "internal test function - do not use", + "\ +This is an internal test function which is used to test whether +the automatically generated bindings can handle every possible +return type correctly. + +It converts string C to the return type. + +You probably don't want to call this function."); + (name ^ "err", (ret, []), -1, [NotInFish; NotInDocs], + [], + "internal test function - do not use", + "\ +This is an internal test function which is used to test whether +the automatically generated bindings can handle every possible +return type correctly. + +This function always returns an error. + +You probably don't want to call this function.")] + ) test_all_rets +) + +(* non_daemon_functions are any functions which don't get processed + * in the daemon, eg. functions for setting and getting local + * configuration values. + *) + +let non_daemon_functions = test_functions @ [ ("launch", (RErr, []), -1, [FishAlias "run"; FishAction "launch"], [], "launch the qemu subprocess", @@ -491,6 +566,10 @@ For more information on states, see L."); ] +(* daemon_functions are any functions which cause some action + * to take place in the daemon. + *) + let daemon_functions = [ ("mount", (RErr, [String "device"; String "mountpoint"]), 1, [], [InitEmpty, Always, TestOutput ( @@ -1579,7 +1658,7 @@ The checksum is returned as a printable string."); ("tar_in", (RErr, [FileIn "tarfile"; String "directory"]), 69, [], [InitBasicFS, Always, TestOutput ( - [["tar_in"; "images/helloworld.tar"; "/"]; + [["tar_in"; "../images/helloworld.tar"; "/"]; ["cat"; "/hello"]], "hello\n")], "unpack tarfile to directory", "\ @@ -1599,7 +1678,7 @@ To download a compressed tarball, use C."); ("tgz_in", (RErr, [FileIn "tarball"; String "directory"]), 71, [], [InitBasicFS, Always, TestOutput ( - [["tgz_in"; "images/helloworld.tar.gz"; "/"]; + [["tgz_in"; "../images/helloworld.tar.gz"; "/"]; ["cat"; "/hello"]], "hello\n")], "unpack compressed tarball to directory", "\ @@ -2455,9 +2534,13 @@ let check_functions () = failwithf "%s param/ret %s should not contain '-' or '_'" name n; if n = "value" then - failwithf "%s has a param/ret called 'value', which causes conflicts in the OCaml bindings, use something like 'val' or a more descriptive name" n; + failwithf "%s has a param/ret called 'value', which causes conflicts in the OCaml bindings, use something like 'val' or a more descriptive name" name; + if n = "int" || n = "char" || n = "short" || n = "long" then + failwithf "%s has a param/ret which conflicts with a C type (eg. 'int', 'char' etc.)" name; + if n = "i" then + failwithf "%s has a param/ret called 'i', which will cause some conflicts in the generated code" name; if n = "argv" || n = "args" then - failwithf "%s has a param/ret called 'argv' or 'args', which will cause some conflicts in the generated code" n + failwithf "%s has a param/ret called 'argv' or 'args', which will cause some conflicts in the generated code" name in (match fst style with @@ -2609,71 +2692,73 @@ let generate_header comment license = let rec generate_actions_pod () = List.iter ( fun (shortname, style, _, flags, _, _, longdesc) -> - let name = "guestfs_" ^ shortname in - pr "=head2 %s\n\n" name; - pr " "; - generate_prototype ~extern:false ~handle:"handle" name style; - pr "\n\n"; - pr "%s\n\n" longdesc; - (match fst style with - | RErr -> - pr "This function returns 0 on success or -1 on error.\n\n" - | RInt _ -> - pr "On error this function returns -1.\n\n" - | RInt64 _ -> - pr "On error this function returns -1.\n\n" - | RBool _ -> - pr "This function returns a C truth value on success or -1 on error.\n\n" - | RConstString _ -> - pr "This function returns a string, or NULL on error. + if not (List.mem NotInDocs flags) then ( + let name = "guestfs_" ^ shortname in + pr "=head2 %s\n\n" name; + pr " "; + generate_prototype ~extern:false ~handle:"handle" name style; + pr "\n\n"; + pr "%s\n\n" longdesc; + (match fst style with + | RErr -> + pr "This function returns 0 on success or -1 on error.\n\n" + | RInt _ -> + pr "On error this function returns -1.\n\n" + | RInt64 _ -> + pr "On error this function returns -1.\n\n" + | RBool _ -> + pr "This function returns a C truth value on success or -1 on error.\n\n" + | RConstString _ -> + pr "This function returns a string, or NULL on error. The string is owned by the guest handle and must I be freed.\n\n" - | RString _ -> - pr "This function returns a string, or NULL on error. + | RString _ -> + pr "This function returns a string, or NULL on error. I.\n\n" - | RStringList _ -> - pr "This function returns a NULL-terminated array of strings + | RStringList _ -> + pr "This function returns a NULL-terminated array of strings (like L), or NULL if there was an error. I.\n\n" - | RIntBool _ -> - pr "This function returns a C, + | RIntBool _ -> + pr "This function returns a C, or NULL if there was an error. I after use>.\n\n" - | RPVList _ -> - pr "This function returns a C + | RPVList _ -> + pr "This function returns a C (see Eguestfs-structs.hE), or NULL if there was an error. I after use>.\n\n" - | RVGList _ -> - pr "This function returns a C + | RVGList _ -> + pr "This function returns a C (see Eguestfs-structs.hE), or NULL if there was an error. I after use>.\n\n" - | RLVList _ -> - pr "This function returns a C + | RLVList _ -> + pr "This function returns a C (see Eguestfs-structs.hE), or NULL if there was an error. I after use>.\n\n" - | RStat _ -> - pr "This function returns a C + | RStat _ -> + pr "This function returns a C (see L and Eguestfs-structs.hE), or NULL if there was an error. I after use>.\n\n" - | RStatVFS _ -> - pr "This function returns a C + | RStatVFS _ -> + pr "This function returns a C (see L and Eguestfs-structs.hE), or NULL if there was an error. I after use>.\n\n" - | RHashtable _ -> - pr "This function returns a NULL-terminated array of + | RHashtable _ -> + pr "This function returns a NULL-terminated array of strings, or NULL if there was an error. The array of strings will always have length C<2n+1>, where C keys and values alternate, followed by the trailing NULL entry. I.\n\n" - ); - if List.mem ProtocolLimitWarning flags then - pr "%s\n\n" protocol_limit_warning; - if List.mem DangerWillRobinson flags then - pr "%s\n\n" danger_will_robinson; + ); + if List.mem ProtocolLimitWarning flags then + pr "%s\n\n" protocol_limit_warning; + if List.mem DangerWillRobinson flags then + pr "%s\n\n" danger_will_robinson + ) ) all_functions_sorted and generate_structs_pod () = @@ -4653,7 +4738,8 @@ char **do_completion (const char *text, int start, int end) and generate_fish_actions_pod () = let all_functions_sorted = List.filter ( - fun (_, _, _, flags, _, _, _) -> not (List.mem NotInFish flags) + fun (_, _, _, flags, _, _, _) -> + not (List.mem NotInFish flags || List.mem NotInDocs flags) ) all_functions_sorted in let rex = Str.regexp "C]+\\)>" in @@ -5581,15 +5667,17 @@ sub new { *) List.iter ( fun (name, style, _, flags, _, _, longdesc) -> - let longdesc = replace_str longdesc "C" in - pr "=item "; - generate_perl_prototype name style; - pr "\n\n"; - pr "%s\n\n" longdesc; - if List.mem ProtocolLimitWarning flags then - pr "%s\n\n" protocol_limit_warning; - if List.mem DangerWillRobinson flags then - pr "%s\n\n" danger_will_robinson + if not (List.mem NotInDocs flags) then ( + let longdesc = replace_str longdesc "C" in + pr "=item "; + generate_perl_prototype name style; + pr "\n\n"; + pr "%s\n\n" longdesc; + if List.mem ProtocolLimitWarning flags then + pr "%s\n\n" protocol_limit_warning; + if List.mem DangerWillRobinson flags then + pr "%s\n\n" danger_will_robinson + ) ) all_functions_sorted; (* End of file. *) @@ -6092,43 +6180,45 @@ class GuestFS: List.iter ( fun (name, style, _, flags, _, _, longdesc) -> - let doc = replace_str longdesc "C doc - | RStringList _ -> - doc ^ "\n\nThis function returns a list of strings." - | RIntBool _ -> - doc ^ "\n\nThis function returns a tuple (int, bool).\n" - | RPVList _ -> - doc ^ "\n\nThis function returns a list of PVs. Each PV is represented as a dictionary." - | RVGList _ -> - doc ^ "\n\nThis function returns a list of VGs. Each VG is represented as a dictionary." - | RLVList _ -> - doc ^ "\n\nThis function returns a list of LVs. Each LV is represented as a dictionary." - | RStat _ -> - doc ^ "\n\nThis function returns a dictionary, with keys matching the various fields in the stat structure." - | RStatVFS _ -> - doc ^ "\n\nThis function returns a dictionary, with keys matching the various fields in the statvfs structure." - | RHashtable _ -> - doc ^ "\n\nThis function returns a dictionary." in - let doc = - if List.mem ProtocolLimitWarning flags then - doc ^ "\n\n" ^ protocol_limit_warning - else doc in - let doc = - if List.mem DangerWillRobinson flags then - doc ^ "\n\n" ^ danger_will_robinson - else doc in - let doc = pod2text ~width:60 name doc in - let doc = List.map (fun line -> replace_str line "\\" "\\\\") doc in - let doc = String.concat "\n " doc in - pr " def %s " name; generate_call_args ~handle:"self" (snd style); pr ":\n"; - pr " u\"\"\"%s\"\"\"\n" doc; + + if not (List.mem NotInDocs flags) then ( + let doc = replace_str longdesc "C doc + | RStringList _ -> + doc ^ "\n\nThis function returns a list of strings." + | RIntBool _ -> + doc ^ "\n\nThis function returns a tuple (int, bool).\n" + | RPVList _ -> + doc ^ "\n\nThis function returns a list of PVs. Each PV is represented as a dictionary." + | RVGList _ -> + doc ^ "\n\nThis function returns a list of VGs. Each VG is represented as a dictionary." + | RLVList _ -> + doc ^ "\n\nThis function returns a list of LVs. Each LV is represented as a dictionary." + | RStat _ -> + doc ^ "\n\nThis function returns a dictionary, with keys matching the various fields in the stat structure." + | RStatVFS _ -> + doc ^ "\n\nThis function returns a dictionary, with keys matching the various fields in the statvfs structure." + | RHashtable _ -> + doc ^ "\n\nThis function returns a dictionary." in + let doc = + if List.mem ProtocolLimitWarning flags then + doc ^ "\n\n" ^ protocol_limit_warning + else doc in + let doc = + if List.mem DangerWillRobinson flags then + doc ^ "\n\n" ^ danger_will_robinson + else doc in + let doc = pod2text ~width:60 name doc in + let doc = List.map (fun line -> replace_str line "\\" "\\\\") doc in + let doc = String.concat "\n " doc in + pr " u\"\"\"%s\"\"\"\n" doc; + ); pr " return libguestfsmod.%s " name; generate_call_args ~handle:"self._o" (snd style); pr "\n"; @@ -6479,30 +6569,32 @@ public class GuestFS { List.iter ( fun (name, style, _, flags, _, shortdesc, longdesc) -> - let doc = replace_str longdesc "C "

" - | nonempty -> nonempty - ) doc in - let doc = String.concat "\n * " doc in - - pr " /**\n"; - pr " * %s\n" shortdesc; - pr " *

\n"; - pr " * %s\n" doc; - pr " * @throws LibGuestFSException\n"; - pr " */\n"; - pr " "; + if not (List.mem NotInDocs flags); then ( + let doc = replace_str longdesc "C "

" + | nonempty -> nonempty + ) doc in + let doc = String.concat "\n * " doc in + + pr " /**\n"; + pr " * %s\n" shortdesc; + pr " *

\n"; + pr " * %s\n" doc; + pr " * @throws LibGuestFSException\n"; + pr " */\n"; + pr " "; + ); generate_java_prototype ~public:true ~semicolon:false name style; pr "\n"; pr " {\n"; @@ -7122,6 +7214,184 @@ and generate_haskell_prototype ~handle ?(hs = false) style = ); pr ")" +and generate_bindtests () = + generate_header CStyle LGPLv2; + + pr "\ +#include +#include +#include +#include + +#include \"guestfs.h\" +#include \"guestfs_protocol.h\" + +#define error guestfs_error + +static void +print_strings (char * const* const argv) +{ + int argc; + + printf (\"[\"); + for (argc = 0; argv[argc] != NULL; ++argc) { + if (argc > 0) printf (\", \"); + printf (\"\\\"%%s\\\"\", argv[argc]); + } + printf (\"]\\n\"); +} + +/* The test0 function prints its parameters to stdout. */ +"; + + let test0, tests = + match test_functions with + | [] -> assert false + | test0 :: tests -> test0, tests in + + let () = + let (name, style, _, _, _, _, _) = test0 in + generate_prototype ~extern:false ~semicolon:false ~newline:true + ~handle:"g" ~prefix:"guestfs_" name style; + pr "{\n"; + List.iter ( + function + | String n + | FileIn n + | FileOut n -> pr " printf (\"%%s\\n\", %s);\n" n + | OptString n -> pr " printf (\"%%s\\n\", %s ? %s : \"null\");\n" n n + | StringList n -> pr " print_strings (%s);\n" n + | Bool n -> pr " printf (\"%%s\\n\", %s ? \"true\" : \"false\");\n" n + | Int n -> pr " printf (\"%%d\\n\", %s);\n" n + ) (snd style); + pr " return 0;\n"; + pr "}\n"; + pr "\n" in + + List.iter ( + fun (name, style, _, _, _, _, _) -> + if String.sub name (String.length name - 3) 3 <> "err" then ( + pr "/* Test normal return. */\n"; + generate_prototype ~extern:false ~semicolon:false ~newline:true + ~handle:"g" ~prefix:"guestfs_" name style; + pr "{\n"; + (match fst style with + | RErr -> + pr " return 0;\n" + | RInt _ -> + pr " int r;\n"; + pr " sscanf (val, \"%%d\", &r);\n"; + pr " return r;\n" + | RInt64 _ -> + pr " int64_t r;\n"; + pr " sscanf (val, \"%%\" SCNi64, &r);\n"; + pr " return r;\n" + | RBool _ -> + pr " return strcmp (val, \"true\") == 0;\n" + | RConstString _ -> + (* Can't return the input string here. Return a static + * string so we ensure we get a segfault if the caller + * tries to free it. + *) + pr " return \"static string\";\n" + | RString _ -> + pr " return strdup (val);\n" + | RStringList _ -> + pr " char **strs;\n"; + pr " int n, i;\n"; + pr " sscanf (val, \"%%d\", &n);\n"; + pr " strs = malloc ((n+1) * sizeof (char *));\n"; + pr " for (i = 0; i < n; ++i) {\n"; + pr " strs[i] = malloc (16);\n"; + pr " snprintf (strs[i], 16, \"%%d\", i);\n"; + pr " }\n"; + pr " strs[n] = NULL;\n"; + pr " return strs;\n" + | RIntBool _ -> + pr " struct guestfs_int_bool *r;\n"; + pr " r = malloc (sizeof (struct guestfs_int_bool));\n"; + pr " sscanf (val, \"%%\" SCNi32, &r->i);\n"; + pr " r->b = 0;\n"; + pr " return r;\n" + | RPVList _ -> + pr " struct guestfs_lvm_pv_list *r;\n"; + pr " int i;\n"; + pr " r = malloc (sizeof (struct guestfs_lvm_pv_list));\n"; + pr " sscanf (val, \"%%d\", &r->len);\n"; + pr " r->val = calloc (r->len, sizeof (struct guestfs_lvm_pv));\n"; + pr " for (i = 0; i < r->len; ++i) {\n"; + pr " r->val[i].pv_name = malloc (16);\n"; + pr " snprintf (r->val[i].pv_name, 16, \"%%d\", i);\n"; + pr " }\n"; + pr " return r;\n" + | RVGList _ -> + pr " struct guestfs_lvm_vg_list *r;\n"; + pr " int i;\n"; + pr " r = malloc (sizeof (struct guestfs_lvm_vg_list));\n"; + pr " sscanf (val, \"%%d\", &r->len);\n"; + pr " r->val = calloc (r->len, sizeof (struct guestfs_lvm_vg));\n"; + pr " for (i = 0; i < r->len; ++i) {\n"; + pr " r->val[i].vg_name = malloc (16);\n"; + pr " snprintf (r->val[i].vg_name, 16, \"%%d\", i);\n"; + pr " }\n"; + pr " return r;\n" + | RLVList _ -> + pr " struct guestfs_lvm_lv_list *r;\n"; + pr " int i;\n"; + pr " r = malloc (sizeof (struct guestfs_lvm_lv_list));\n"; + pr " sscanf (val, \"%%d\", &r->len);\n"; + pr " r->val = calloc (r->len, sizeof (struct guestfs_lvm_lv));\n"; + pr " for (i = 0; i < r->len; ++i) {\n"; + pr " r->val[i].lv_name = malloc (16);\n"; + pr " snprintf (r->val[i].lv_name, 16, \"%%d\", i);\n"; + pr " }\n"; + pr " return r;\n" + | RStat _ -> + pr " struct guestfs_stat *r;\n"; + pr " r = calloc (1, sizeof (*r));\n"; + pr " sscanf (val, \"%%\" SCNi64, &r->dev);\n"; + pr " return r;\n" + | RStatVFS _ -> + pr " struct guestfs_statvfs *r;\n"; + pr " r = calloc (1, sizeof (*r));\n"; + pr " sscanf (val, \"%%\" SCNi64, &r->bsize);\n"; + pr " return r;\n" + | RHashtable _ -> + pr " char **strs;\n"; + pr " int n, i;\n"; + pr " sscanf (val, \"%%d\", &n);\n"; + pr " strs = malloc ((n*2+1) * sizeof (char *));\n"; + pr " for (i = 0; i < n; ++i) {\n"; + pr " strs[i*2] = malloc (16);\n"; + pr " strs[i*2+1] = malloc (16);\n"; + pr " snprintf (strs[i*2], 16, \"%%d\", i);\n"; + pr " snprintf (strs[i*2+1], 16, \"%%d\", i);\n"; + pr " }\n"; + pr " strs[n*2] = NULL;\n"; + pr " return strs;\n" + ); + pr "}\n"; + pr "\n" + ) else ( + pr "/* Test error return. */\n"; + generate_prototype ~extern:false ~semicolon:false ~newline:true + ~handle:"g" ~prefix:"guestfs_" name style; + pr "{\n"; + pr " error (g, \"error\");\n"; + (match fst style with + | RErr | RInt _ | RInt64 _ | RBool _ -> + pr " return -1;\n" + | RConstString _ + | RString _ | RStringList _ | RIntBool _ + | RPVList _ | RVGList _ | RLVList _ | RStat _ | RStatVFS _ + | RHashtable _ -> + pr " return NULL;\n" + ); + pr "}\n"; + pr "\n" + ) + ) tests + let output_to filename = let filename_new = filename ^ ".new" in chan := open_out filename_new; @@ -7183,6 +7453,10 @@ Run it from the top source directory using the command generate_tests (); close (); + let close = output_to "src/guestfs-bindtests.c" in + generate_bindtests (); + close (); + let close = output_to "fish/cmds.c" in generate_fish_cmds (); close (); diff --git a/src/guestfs-actions.h b/src/guestfs-actions.h index b51071b..4364d35 100644 --- a/src/guestfs-actions.h +++ b/src/guestfs-actions.h @@ -19,6 +19,33 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +extern int guestfs_test0 (guestfs_h *handle, const char *str, const char *optstr, char * const* const strlist, int b, int integer, const char *filein, const char *fileout); +extern int guestfs_test0rint (guestfs_h *handle, const char *val); +extern int guestfs_test0rinterr (guestfs_h *handle); +extern int64_t guestfs_test0rint64 (guestfs_h *handle, const char *val); +extern int64_t guestfs_test0rint64err (guestfs_h *handle); +extern int guestfs_test0rbool (guestfs_h *handle, const char *val); +extern int guestfs_test0rboolerr (guestfs_h *handle); +extern const char *guestfs_test0rconststring (guestfs_h *handle, const char *val); +extern const char *guestfs_test0rconststringerr (guestfs_h *handle); +extern char *guestfs_test0rstring (guestfs_h *handle, const char *val); +extern char *guestfs_test0rstringerr (guestfs_h *handle); +extern char **guestfs_test0rstringlist (guestfs_h *handle, const char *val); +extern char **guestfs_test0rstringlisterr (guestfs_h *handle); +extern struct guestfs_int_bool *guestfs_test0rintbool (guestfs_h *handle, const char *val); +extern struct guestfs_int_bool *guestfs_test0rintboolerr (guestfs_h *handle); +extern struct guestfs_lvm_pv_list *guestfs_test0rpvlist (guestfs_h *handle, const char *val); +extern struct guestfs_lvm_pv_list *guestfs_test0rpvlisterr (guestfs_h *handle); +extern struct guestfs_lvm_vg_list *guestfs_test0rvglist (guestfs_h *handle, const char *val); +extern struct guestfs_lvm_vg_list *guestfs_test0rvglisterr (guestfs_h *handle); +extern struct guestfs_lvm_lv_list *guestfs_test0rlvlist (guestfs_h *handle, const char *val); +extern struct guestfs_lvm_lv_list *guestfs_test0rlvlisterr (guestfs_h *handle); +extern struct guestfs_stat *guestfs_test0rstat (guestfs_h *handle, const char *val); +extern struct guestfs_stat *guestfs_test0rstaterr (guestfs_h *handle); +extern struct guestfs_statvfs *guestfs_test0rstatvfs (guestfs_h *handle, const char *val); +extern struct guestfs_statvfs *guestfs_test0rstatvfserr (guestfs_h *handle); +extern char **guestfs_test0rhashtable (guestfs_h *handle, const char *val); +extern char **guestfs_test0rhashtableerr (guestfs_h *handle); extern int guestfs_launch (guestfs_h *handle); extern int guestfs_wait_ready (guestfs_h *handle); extern int guestfs_kill_subprocess (guestfs_h *handle); diff --git a/src/guestfs-bindtests.c b/src/guestfs-bindtests.c new file mode 100644 index 0000000..7279f56 --- /dev/null +++ b/src/guestfs-bindtests.c @@ -0,0 +1,307 @@ +/* libguestfs generated file + * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'. + * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. + * + * Copyright (C) 2009 Red Hat Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include +#include + +#include "guestfs.h" +#include "guestfs_protocol.h" + +#define error guestfs_error + +static void +print_strings (char * const* const argv) +{ + int argc; + + printf ("["); + for (argc = 0; argv[argc] != NULL; ++argc) { + if (argc > 0) printf (", "); + printf ("\"%s\"", argv[argc]); + } + printf ("]\n"); +} + +/* The test0 function prints its parameters to stdout. */ +int guestfs_test0 (guestfs_h *g, + const char *str, + const char *optstr, + char * const* const strlist, + int b, + int integer, + const char *filein, + const char *fileout) +{ + printf ("%s\n", str); + printf ("%s\n", optstr ? optstr : "null"); + print_strings (strlist); + printf ("%s\n", b ? "true" : "false"); + printf ("%d\n", integer); + printf ("%s\n", filein); + printf ("%s\n", fileout); + return 0; +} + +/* Test normal return. */ +int guestfs_test0rint (guestfs_h *g, + const char *val) +{ + int r; + sscanf (val, "%d", &r); + return r; +} + +/* Test error return. */ +int guestfs_test0rinterr (guestfs_h *g) +{ + error (g, "error"); + return -1; +} + +/* Test normal return. */ +int64_t guestfs_test0rint64 (guestfs_h *g, + const char *val) +{ + int64_t r; + sscanf (val, "%" SCNi64, &r); + return r; +} + +/* Test error return. */ +int64_t guestfs_test0rint64err (guestfs_h *g) +{ + error (g, "error"); + return -1; +} + +/* Test normal return. */ +int guestfs_test0rbool (guestfs_h *g, + const char *val) +{ + return strcmp (val, "true") == 0; +} + +/* Test error return. */ +int guestfs_test0rboolerr (guestfs_h *g) +{ + error (g, "error"); + return -1; +} + +/* Test normal return. */ +const char *guestfs_test0rconststring (guestfs_h *g, + const char *val) +{ + return "static string"; +} + +/* Test error return. */ +const char *guestfs_test0rconststringerr (guestfs_h *g) +{ + error (g, "error"); + return NULL; +} + +/* Test normal return. */ +char *guestfs_test0rstring (guestfs_h *g, + const char *val) +{ + return strdup (val); +} + +/* Test error return. */ +char *guestfs_test0rstringerr (guestfs_h *g) +{ + error (g, "error"); + return NULL; +} + +/* Test normal return. */ +char **guestfs_test0rstringlist (guestfs_h *g, + const char *val) +{ + char **strs; + int n, i; + sscanf (val, "%d", &n); + strs = malloc ((n+1) * sizeof (char *)); + for (i = 0; i < n; ++i) { + strs[i] = malloc (16); + snprintf (strs[i], 16, "%d", i); + } + strs[n] = NULL; + return strs; +} + +/* Test error return. */ +char **guestfs_test0rstringlisterr (guestfs_h *g) +{ + error (g, "error"); + return NULL; +} + +/* Test normal return. */ +struct guestfs_int_bool *guestfs_test0rintbool (guestfs_h *g, + const char *val) +{ + struct guestfs_int_bool *r; + r = malloc (sizeof (struct guestfs_int_bool)); + sscanf (val, "%" SCNi32, &r->i); + r->b = 0; + return r; +} + +/* Test error return. */ +struct guestfs_int_bool *guestfs_test0rintboolerr (guestfs_h *g) +{ + error (g, "error"); + return NULL; +} + +/* Test normal return. */ +struct guestfs_lvm_pv_list *guestfs_test0rpvlist (guestfs_h *g, + const char *val) +{ + struct guestfs_lvm_pv_list *r; + int i; + r = malloc (sizeof (struct guestfs_lvm_pv_list)); + sscanf (val, "%d", &r->len); + r->val = calloc (r->len, sizeof (struct guestfs_lvm_pv)); + for (i = 0; i < r->len; ++i) { + r->val[i].pv_name = malloc (16); + snprintf (r->val[i].pv_name, 16, "%d", i); + } + return r; +} + +/* Test error return. */ +struct guestfs_lvm_pv_list *guestfs_test0rpvlisterr (guestfs_h *g) +{ + error (g, "error"); + return NULL; +} + +/* Test normal return. */ +struct guestfs_lvm_vg_list *guestfs_test0rvglist (guestfs_h *g, + const char *val) +{ + struct guestfs_lvm_vg_list *r; + int i; + r = malloc (sizeof (struct guestfs_lvm_vg_list)); + sscanf (val, "%d", &r->len); + r->val = calloc (r->len, sizeof (struct guestfs_lvm_vg)); + for (i = 0; i < r->len; ++i) { + r->val[i].vg_name = malloc (16); + snprintf (r->val[i].vg_name, 16, "%d", i); + } + return r; +} + +/* Test error return. */ +struct guestfs_lvm_vg_list *guestfs_test0rvglisterr (guestfs_h *g) +{ + error (g, "error"); + return NULL; +} + +/* Test normal return. */ +struct guestfs_lvm_lv_list *guestfs_test0rlvlist (guestfs_h *g, + const char *val) +{ + struct guestfs_lvm_lv_list *r; + int i; + r = malloc (sizeof (struct guestfs_lvm_lv_list)); + sscanf (val, "%d", &r->len); + r->val = calloc (r->len, sizeof (struct guestfs_lvm_lv)); + for (i = 0; i < r->len; ++i) { + r->val[i].lv_name = malloc (16); + snprintf (r->val[i].lv_name, 16, "%d", i); + } + return r; +} + +/* Test error return. */ +struct guestfs_lvm_lv_list *guestfs_test0rlvlisterr (guestfs_h *g) +{ + error (g, "error"); + return NULL; +} + +/* Test normal return. */ +struct guestfs_stat *guestfs_test0rstat (guestfs_h *g, + const char *val) +{ + struct guestfs_stat *r; + r = calloc (1, sizeof (*r)); + sscanf (val, "%" SCNi64, &r->dev); + return r; +} + +/* Test error return. */ +struct guestfs_stat *guestfs_test0rstaterr (guestfs_h *g) +{ + error (g, "error"); + return NULL; +} + +/* Test normal return. */ +struct guestfs_statvfs *guestfs_test0rstatvfs (guestfs_h *g, + const char *val) +{ + struct guestfs_statvfs *r; + r = calloc (1, sizeof (*r)); + sscanf (val, "%" SCNi64, &r->bsize); + return r; +} + +/* Test error return. */ +struct guestfs_statvfs *guestfs_test0rstatvfserr (guestfs_h *g) +{ + error (g, "error"); + return NULL; +} + +/* Test normal return. */ +char **guestfs_test0rhashtable (guestfs_h *g, + const char *val) +{ + char **strs; + int n, i; + sscanf (val, "%d", &n); + strs = malloc ((n*2+1) * sizeof (char *)); + for (i = 0; i < n; ++i) { + strs[i*2] = malloc (16); + strs[i*2+1] = malloc (16); + snprintf (strs[i*2], 16, "%d", i); + snprintf (strs[i*2+1], 16, "%d", i); + } + strs[n*2] = NULL; + return strs; +} + +/* Test error return. */ +char **guestfs_test0rhashtableerr (guestfs_h *g) +{ + error (g, "error"); + return NULL; +} + -- 1.8.3.1