summaryrefslogtreecommitdiffstats
path: root/src/guestfs-bindtests.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/guestfs-bindtests.c')
-rw-r--r--src/guestfs-bindtests.c307
1 files changed, 307 insertions, 0 deletions
diff --git a/src/guestfs-bindtests.c b/src/guestfs-bindtests.c
new file mode 100644
index 00000000..7279f566
--- /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 <stdio.h>
+#include <stdlib.h>
+#include <inttypes.h>
+#include <string.h>
+
+#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;
+}
+