Implement list-devices and list-partitions.
[libguestfs.git] / daemon / guestfsd.c
index 6730c1d..a243c0b 100644 (file)
@@ -272,6 +272,20 @@ count_strings (char **argv)
   return argc;
 }
 
+static int
+compare (const void *vp1, const void *vp2)
+{
+  char * const *p1 = (char * const *) vp1;
+  char * const *p2 = (char * const *) vp2;
+  return strcmp (*p1, *p2);
+}
+
+void
+sort_strings (char **argv, int len)
+{
+  qsort (argv, len, sizeof (char *), compare);
+}
+
 void
 free_strings (char **argv)
 {
@@ -282,6 +296,16 @@ free_strings (char **argv)
   free (argv);
 }
 
+void
+free_stringslen (char **argv, int len)
+{
+  int i;
+
+  for (i = 0; i < len; ++i)
+    free (argv[i]);
+  free (argv);
+}
+
 /* This is a more sane version of 'system(3)' for running external
  * commands.  It uses fork/execvp, so we don't need to worry about
  * quoting of parameters, and it allows us to capture any error