+
+/*
+ * This routine parses the input command line.
+ * It makes a copy in args, then builds an
+ * argc, argk, but no argv (values).
+ * This routine is useful for scanning command lines where the data
+ * is a filename and no keywords are expected. If we scan a filename
+ * for keywords, any = in the filename will be interpreted as the
+ * end of a keyword, and this is not good.
+ *
+ * argc = count of arguments
+ * argk[i] = argument keyword (part preceding =)
+ * argv[i] = NULL
+ *
+ * example: arg1 arg2=abc arg3=
+ *
+ * argc = c
+ * argk[0] = arg1
+ * argv[0] = NULL
+ * argk[1] = arg2=abc
+ * argv[1] = NULL
+ * argk[2] = arg3
+ * argv[2] =
+ */
+int parse_args_only(POOLMEM *cmd, POOLMEM **args, int *argc,
+ char **argk, char **argv, int max_args)
+{
+ char *p, *n;
+
+ pm_strcpy(args, cmd);
+ strip_trailing_junk(*args);
+ p = *args;
+ *argc = 0;
+ /*
+ * Pick up all arguments
+ */
+ while (*argc < max_args) {
+ n = next_arg(&p);
+ if (*n) {
+ argk[*argc] = n;
+ argv[(*argc)++] = NULL;
+ } else {
+ break;
+ }
+ }
+ return 1;
+}
+