+
+void
+free_strings (char **argv)
+{
+ int argc;
+
+ for (argc = 0; argv[argc] != NULL; ++argc)
+ free (argv[argc]);
+ free (argv);
+}
+
+void
+print_strings (char * const * const argv)
+{
+ int argc;
+
+ for (argc = 0; argv[argc] != NULL; ++argc)
+ printf ("%s\n", argv[argc]);
+}
+
+int
+is_true (const char *str)
+{
+ return
+ strcasecmp (str, "0") != 0 &&
+ strcasecmp (str, "f") != 0 &&
+ strcasecmp (str, "false") != 0 &&
+ strcasecmp (str, "n") != 0 &&
+ strcasecmp (str, "no") != 0;
+}
+
+/* This is quite inadequate for real use. For example, there is no way
+ * to specify an empty list. We need to use a real parser to allow
+ * quoting, empty lists, etc.
+ */
+char **
+parse_string_list (const char *str)
+{
+ char **argv;
+ const char *p, *pend;
+ int argc, i;
+
+ argc = 1;
+ for (i = 0; str[i]; ++i)
+ if (str[i] == ':') argc++;
+
+ argv = malloc (sizeof (char *) * (argc+1));
+ if (argv == NULL) { perror ("malloc"); exit (1); }
+
+ p = str;
+ i = 0;
+ while (*p) {
+ pend = strchrnul (p, ':');
+ argv[i] = strndup (p, pend-p);
+ i++;
+ p = *pend == ':' ? pend+1 : p;
+ }
+ argv[i] = NULL;
+
+ return argv;
+}