Improve error message when appliance doesn't match library.
[libguestfs.git] / perl / Guestfs.xs
index c26faa1..5905dc5 100644 (file)
@@ -2549,3 +2549,56 @@ PREINIT:
  OUTPUT:
       RETVAL
 
+SV *
+sh (g, command)
+      guestfs_h *g;
+      char *command;
+PREINIT:
+      char *output;
+   CODE:
+      output = guestfs_sh (g, command);
+      if (output == NULL)
+        croak ("sh: %s", guestfs_last_error (g));
+      RETVAL = newSVpv (output, 0);
+      free (output);
+ OUTPUT:
+      RETVAL
+
+void
+sh_lines (g, command)
+      guestfs_h *g;
+      char *command;
+PREINIT:
+      char **lines;
+      int i, n;
+ PPCODE:
+      lines = guestfs_sh_lines (g, command);
+      if (lines == NULL)
+        croak ("sh_lines: %s", guestfs_last_error (g));
+      for (n = 0; lines[n] != NULL; ++n) /**/;
+      EXTEND (SP, n);
+      for (i = 0; i < n; ++i) {
+        PUSHs (sv_2mortal (newSVpv (lines[i], 0)));
+        free (lines[i]);
+      }
+      free (lines);
+
+void
+glob_expand (g, pattern)
+      guestfs_h *g;
+      char *pattern;
+PREINIT:
+      char **paths;
+      int i, n;
+ PPCODE:
+      paths = guestfs_glob_expand (g, pattern);
+      if (paths == NULL)
+        croak ("glob_expand: %s", guestfs_last_error (g));
+      for (n = 0; paths[n] != NULL; ++n) /**/;
+      EXTEND (SP, n);
+      for (i = 0; i < n; ++i) {
+        PUSHs (sv_2mortal (newSVpv (paths[i], 0)));
+        free (paths[i]);
+      }
+      free (paths);
+