summaryrefslogtreecommitdiffstats
path: root/src/progs/ingen/cmdline.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-07-30 00:51:11 +0000
committerDavid Robillard <d@drobilla.net>2008-07-30 00:51:11 +0000
commitb617344041f036d4539bbbbdbfd14165c31c5720 (patch)
tree5e1e4c74befd7a357ecdc4f43908c53958921629 /src/progs/ingen/cmdline.c
parentd0f0e1ba4f19cf3c32069ed5217175f29ee87aa7 (diff)
downloadingen-b617344041f036d4539bbbbdbfd14165c31c5720.tar.gz
ingen-b617344041f036d4539bbbbdbfd14165c31c5720.tar.bz2
ingen-b617344041f036d4539bbbbdbfd14165c31c5720.zip
More helpful command line output.
git-svn-id: http://svn.drobilla.net/lad/ingen@1309 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/progs/ingen/cmdline.c')
-rw-r--r--src/progs/ingen/cmdline.c590
1 files changed, 313 insertions, 277 deletions
diff --git a/src/progs/ingen/cmdline.c b/src/progs/ingen/cmdline.c
index f4ea58d4..ea48135c 100644
--- a/src/progs/ingen/cmdline.c
+++ b/src/progs/ingen/cmdline.c
@@ -1,7 +1,7 @@
/*
- File autogenerated by gengetopt version 2.21
+ File autogenerated by gengetopt
generated with the following command:
- gengetopt
+ gengetopt -g
The developers of gengetopt consider the fixed text that goes in all
gengetopt output files to be in the public domain:
@@ -25,7 +25,7 @@ const char *gengetopt_args_info_purpose = "A modular realtime audio processing s
const char *gengetopt_args_info_usage = "Usage: ingen [OPTIONS]...";
-const char *gengetopt_args_info_description = "This executable can be used to launch any configuration of Ingen.\nIngen can run as a stand-alone server controlled by OSC, or internal to\nanother process. The GUI can communicate with the engine via either method,\nand many GUIs (or other things) may connect to an engine via OSC.\n";
+const char *gengetopt_args_info_description = "Ingen can be run in various configurations. The engine can\nrun as a stand-alone server controlled by OSC, or internal to\nanother process (e.g. the GUI). The GUI can communicate with the engine\nvia either method, and many GUIs (or other things) may connect to an\nengine via OSC.\n\nExamples:\n\n ingen -e - Run an engine, listen for OSC \n ingen -g - Run a GUI, connect via OSC \n ingen -eg - Run an engine and a GUI in one process\n\nThe -l (load) option can be used in all cases:\n \n ingen -el patch.ingen.ttl - Run an engine and load a patch\n ingen -gl patch.ingen.ttl - Run a GUI and load a patch\n ingen -egl patch.ingen.ttl - Run an engine and a GUI and load a patch\n\nOptions:\n";
const char *gengetopt_args_info_help[] = {
" -h, --help Print help and exit",
@@ -42,6 +42,12 @@ const char *gengetopt_args_info_help[] = {
0
};
+typedef enum {ARG_NO
+ , ARG_FLAG
+ , ARG_STRING
+ , ARG_INT
+} cmdline_parser_arg_type;
+
static
void clear_given (struct gengetopt_args_info *args_info);
static
@@ -95,6 +101,8 @@ void clear_args (struct gengetopt_args_info *args_info)
static
void init_args_info(struct gengetopt_args_info *args_info)
{
+
+
args_info->help_help = gengetopt_args_info_help[0] ;
args_info->version_help = gengetopt_args_info_help[1] ;
args_info->engine_help = gengetopt_args_info_help[2] ;
@@ -115,20 +123,26 @@ cmdline_parser_print_version (void)
printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION);
}
-void
-cmdline_parser_print_help (void)
-{
- int i = 0;
+static void print_help_common(void) {
cmdline_parser_print_version ();
if (strlen(gengetopt_args_info_purpose) > 0)
printf("\n%s\n", gengetopt_args_info_purpose);
- printf("\n%s\n\n", gengetopt_args_info_usage);
+ if (strlen(gengetopt_args_info_usage) > 0)
+ printf("\n%s\n", gengetopt_args_info_usage);
+
+ printf("\n");
if (strlen(gengetopt_args_info_description) > 0)
- printf("%s\n", gengetopt_args_info_description);
+ printf("%s\n\n", gengetopt_args_info_description);
+}
+void
+cmdline_parser_print_help (void)
+{
+ int i = 0;
+ print_help_common();
while (gengetopt_args_info_help[i])
printf("%s\n", gengetopt_args_info_help[i++]);
}
@@ -141,84 +155,109 @@ cmdline_parser_init (struct gengetopt_args_info *args_info)
init_args_info (args_info);
}
-struct cmdline_parser_params *
-cmdline_parser_params_init()
+void
+cmdline_parser_params_init(struct cmdline_parser_params *params)
{
- struct cmdline_parser_params *params =
- (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params));
-
if (params)
{
params->override = 0;
- params->initialize = 0;
- params->check_required = 0;
+ params->initialize = 1;
+ params->check_required = 1;
params->check_ambiguity = 0;
+ params->print_errors = 1;
}
-
+}
+
+struct cmdline_parser_params *
+cmdline_parser_params_create(void)
+{
+ struct cmdline_parser_params *params =
+ (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params));
+ cmdline_parser_params_init(params);
return params;
}
static void
-cmdline_parser_release (struct gengetopt_args_info *args_info)
+free_string_field (char **s)
{
-
- if (args_info->engine_port_orig)
- {
- free (args_info->engine_port_orig); /* free previous argument */
- args_info->engine_port_orig = 0;
- }
- if (args_info->connect_arg)
- {
- free (args_info->connect_arg); /* free previous argument */
- args_info->connect_arg = 0;
- }
- if (args_info->connect_orig)
- {
- free (args_info->connect_orig); /* free previous argument */
- args_info->connect_orig = 0;
- }
- if (args_info->client_port_orig)
+ if (*s)
{
- free (args_info->client_port_orig); /* free previous argument */
- args_info->client_port_orig = 0;
+ free (*s);
+ *s = 0;
}
- if (args_info->load_arg)
- {
- free (args_info->load_arg); /* free previous argument */
- args_info->load_arg = 0;
- }
- if (args_info->load_orig)
- {
- free (args_info->load_orig); /* free previous argument */
- args_info->load_orig = 0;
- }
- if (args_info->path_arg)
- {
- free (args_info->path_arg); /* free previous argument */
- args_info->path_arg = 0;
- }
- if (args_info->path_orig)
- {
- free (args_info->path_orig); /* free previous argument */
- args_info->path_orig = 0;
- }
- if (args_info->run_arg)
- {
- free (args_info->run_arg); /* free previous argument */
- args_info->run_arg = 0;
- }
- if (args_info->run_orig)
- {
- free (args_info->run_orig); /* free previous argument */
- args_info->run_orig = 0;
- }
- if (args_info->parallelism_orig)
+}
+
+
+static void
+cmdline_parser_release (struct gengetopt_args_info *args_info)
+{
+
+ free_string_field (&(args_info->engine_port_orig));
+ free_string_field (&(args_info->connect_arg));
+ free_string_field (&(args_info->connect_orig));
+ free_string_field (&(args_info->client_port_orig));
+ free_string_field (&(args_info->load_arg));
+ free_string_field (&(args_info->load_orig));
+ free_string_field (&(args_info->path_arg));
+ free_string_field (&(args_info->path_orig));
+ free_string_field (&(args_info->run_arg));
+ free_string_field (&(args_info->run_orig));
+ free_string_field (&(args_info->parallelism_orig));
+
+
+
+ clear_given (args_info);
+}
+
+
+static void
+write_into_file(FILE *outfile, const char *opt, const char *arg, char *values[])
+{
+ if (arg) {
+ fprintf(outfile, "%s=\"%s\"\n", opt, arg);
+ } else {
+ fprintf(outfile, "%s\n", opt);
+ }
+}
+
+
+int
+cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
+{
+ int i = 0;
+
+ if (!outfile)
{
- free (args_info->parallelism_orig); /* free previous argument */
- args_info->parallelism_orig = 0;
+ fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE);
+ return EXIT_FAILURE;
}
+
+ if (args_info->help_given)
+ write_into_file(outfile, "help", 0, 0 );
+ if (args_info->version_given)
+ write_into_file(outfile, "version", 0, 0 );
+ if (args_info->engine_given)
+ write_into_file(outfile, "engine", 0, 0 );
+ if (args_info->engine_port_given)
+ write_into_file(outfile, "engine-port", args_info->engine_port_orig, 0);
+ if (args_info->connect_given)
+ write_into_file(outfile, "connect", args_info->connect_orig, 0);
+ if (args_info->gui_given)
+ write_into_file(outfile, "gui", 0, 0 );
+ if (args_info->client_port_given)
+ write_into_file(outfile, "client-port", args_info->client_port_orig, 0);
+ if (args_info->load_given)
+ write_into_file(outfile, "load", args_info->load_orig, 0);
+ if (args_info->path_given)
+ write_into_file(outfile, "path", args_info->path_orig, 0);
+ if (args_info->run_given)
+ write_into_file(outfile, "run", args_info->run_orig, 0);
+ if (args_info->parallelism_given)
+ write_into_file(outfile, "parallelism", args_info->parallelism_orig, 0);
- clear_given (args_info);
+
+ i = EXIT_SUCCESS;
+ return i;
}
int
@@ -235,71 +274,9 @@ cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_
return EXIT_FAILURE;
}
- if (args_info->help_given) {
- fprintf(outfile, "%s\n", "help");
- }
- if (args_info->version_given) {
- fprintf(outfile, "%s\n", "version");
- }
- if (args_info->engine_given) {
- fprintf(outfile, "%s\n", "engine");
- }
- if (args_info->engine_port_given) {
- if (args_info->engine_port_orig) {
- fprintf(outfile, "%s=\"%s\"\n", "engine-port", args_info->engine_port_orig);
- } else {
- fprintf(outfile, "%s\n", "engine-port");
- }
- }
- if (args_info->connect_given) {
- if (args_info->connect_orig) {
- fprintf(outfile, "%s=\"%s\"\n", "connect", args_info->connect_orig);
- } else {
- fprintf(outfile, "%s\n", "connect");
- }
- }
- if (args_info->gui_given) {
- fprintf(outfile, "%s\n", "gui");
- }
- if (args_info->client_port_given) {
- if (args_info->client_port_orig) {
- fprintf(outfile, "%s=\"%s\"\n", "client-port", args_info->client_port_orig);
- } else {
- fprintf(outfile, "%s\n", "client-port");
- }
- }
- if (args_info->load_given) {
- if (args_info->load_orig) {
- fprintf(outfile, "%s=\"%s\"\n", "load", args_info->load_orig);
- } else {
- fprintf(outfile, "%s\n", "load");
- }
- }
- if (args_info->path_given) {
- if (args_info->path_orig) {
- fprintf(outfile, "%s=\"%s\"\n", "path", args_info->path_orig);
- } else {
- fprintf(outfile, "%s\n", "path");
- }
- }
- if (args_info->run_given) {
- if (args_info->run_orig) {
- fprintf(outfile, "%s=\"%s\"\n", "run", args_info->run_orig);
- } else {
- fprintf(outfile, "%s\n", "run");
- }
- }
- if (args_info->parallelism_given) {
- if (args_info->parallelism_orig) {
- fprintf(outfile, "%s=\"%s\"\n", "parallelism", args_info->parallelism_orig);
- } else {
- fprintf(outfile, "%s\n", "parallelism");
- }
- }
-
+ i = cmdline_parser_dump(outfile, args_info);
fclose (outfile);
- i = EXIT_SUCCESS;
return i;
}
@@ -309,9 +286,7 @@ cmdline_parser_free (struct gengetopt_args_info *args_info)
cmdline_parser_release (args_info);
}
-
-/* gengetopt_strdup() */
-/* strdup.c replacement of strdup, which is not standard */
+/** @brief replacement of strdup, which is not standard */
char *
gengetopt_strdup (const char *s)
{
@@ -358,6 +333,7 @@ cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_
params.initialize = initialize;
params.check_required = check_required;
params.check_ambiguity = 0;
+ params.print_errors = 1;
result = cmdline_parser_internal (argc, argv, args_info, &params, NULL);
@@ -376,6 +352,120 @@ cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog
return EXIT_SUCCESS;
}
+
+static char *package_name = 0;
+
+/**
+ * @brief updates an option
+ * @param field the generic pointer to the field to update
+ * @param orig_field the pointer to the orig field
+ * @param field_given the pointer to the number of occurrence of this option
+ * @param prev_given the pointer to the number of occurrence already seen
+ * @param value the argument for this option (if null no arg was specified)
+ * @param possible_values the possible values for this option (if specified)
+ * @param default_value the default value (in case the option only accepts fixed values)
+ * @param arg_type the type of this option
+ * @param check_ambiguity @see cmdline_parser_params.check_ambiguity
+ * @param override @see cmdline_parser_params.override
+ * @param no_free whether to free a possible previous value
+ * @param multiple_option whether this is a multiple option
+ * @param long_opt the corresponding long option
+ * @param short_opt the corresponding short option (or '-' if none)
+ * @param additional_error possible further error specification
+ */
+static
+int update_arg(void *field, char **orig_field,
+ unsigned int *field_given, unsigned int *prev_given,
+ char *value, char *possible_values[], const char *default_value,
+ cmdline_parser_arg_type arg_type,
+ int check_ambiguity, int override,
+ int no_free, int multiple_option,
+ const char *long_opt, char short_opt,
+ const char *additional_error)
+{
+ char *stop_char = 0;
+ const char *val = value;
+ int found;
+ char **string_field;
+
+ stop_char = 0;
+ found = 0;
+
+ if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
+ {
+ if (short_opt != '-')
+ fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n",
+ package_name, long_opt, short_opt,
+ (additional_error ? additional_error : ""));
+ else
+ fprintf (stderr, "%s: `--%s' option given more than once%s\n",
+ package_name, long_opt,
+ (additional_error ? additional_error : ""));
+ return 1; /* failure */
+ }
+
+
+ if (field_given && *field_given && ! override)
+ return 0;
+ if (prev_given)
+ (*prev_given)++;
+ if (field_given)
+ (*field_given)++;
+ if (possible_values)
+ val = possible_values[found];
+
+ switch(arg_type) {
+ case ARG_FLAG:
+ *((int *)field) = !*((int *)field);
+ break;
+ case ARG_INT:
+ if (val) *((int *)field) = strtol (val, &stop_char, 0);
+ break;
+ case ARG_STRING:
+ if (val) {
+ string_field = (char **)field;
+ if (!no_free && *string_field)
+ free (*string_field); /* free previous string */
+ *string_field = gengetopt_strdup (val);
+ }
+ break;
+ default:
+ break;
+ };
+
+ /* check numeric conversion */
+ switch(arg_type) {
+ case ARG_INT:
+ if (val && !(stop_char && *stop_char == '\0')) {
+ fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
+ return 1; /* failure */
+ }
+ break;
+ default:
+ ;
+ };
+
+ /* store the original value */
+ switch(arg_type) {
+ case ARG_NO:
+ case ARG_FLAG:
+ break;
+ default:
+ if (value && orig_field) {
+ if (no_free) {
+ *orig_field = value;
+ } else {
+ if (*orig_field)
+ free (*orig_field); /* free previous string */
+ *orig_field = gengetopt_strdup (value);
+ }
+ }
+ };
+
+ return 0; /* OK */
+}
+
+
int
cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info,
struct cmdline_parser_params *params, const char *additional_error)
@@ -390,6 +480,8 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf
int check_required;
int check_ambiguity;
+ package_name = argv[0];
+
override = params->override;
initialize = params->initialize;
check_required = params->check_required;
@@ -402,13 +494,12 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf
optarg = 0;
optind = 0;
- opterr = 1;
+ opterr = params->print_errors;
optopt = '?';
while (1)
{
int option_index = 0;
- char *stop_char;
static struct option long_options[] = {
{ "help", 0, NULL, 'h' },
@@ -425,7 +516,6 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf
{ NULL, 0, NULL, 0 }
};
- stop_char = 0;
c = getopt_long (argc, argv, "hVeE:c:gC:l:L:r:p:", long_options, &option_index);
if (c == -1) break; /* Exit from `while (1)' loop. */
@@ -443,164 +533,110 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf
exit (EXIT_SUCCESS);
case 'e': /* Run (JACK) engine. */
- if (local_args_info.engine_given || (check_ambiguity && args_info->engine_given))
- {
- fprintf (stderr, "%s: `--engine' (`-e') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
- goto failure;
- }
- if (args_info->engine_given && ! override)
- continue;
- local_args_info.engine_given = 1;
- args_info->engine_given = 1;
- args_info->engine_flag = !(args_info->engine_flag);
+
+
+ if (update_arg((void *)&(args_info->engine_flag), 0, &(args_info->engine_given),
+ &(local_args_info.engine_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "engine", 'e',
+ additional_error))
+ goto failure;
+
break;
-
case 'E': /* Engine OSC port. */
- if (local_args_info.engine_port_given || (check_ambiguity && args_info->engine_port_given))
- {
- fprintf (stderr, "%s: `--engine-port' (`-E') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
- goto failure;
- }
- if (args_info->engine_port_given && ! override)
- continue;
- local_args_info.engine_port_given = 1;
- args_info->engine_port_given = 1;
- args_info->engine_port_arg = strtol (optarg, &stop_char, 0);
- if (!(stop_char && *stop_char == '\0')) {
- fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
+
+
+ if (update_arg( (void *)&(args_info->engine_port_arg),
+ &(args_info->engine_port_orig), &(args_info->engine_port_given),
+ &(local_args_info.engine_port_given), optarg, 0, "16180", ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "engine-port", 'E',
+ additional_error))
goto failure;
- }
- if (args_info->engine_port_orig)
- free (args_info->engine_port_orig); /* free previous string */
- args_info->engine_port_orig = gengetopt_strdup (optarg);
+
break;
-
case 'c': /* Connect to existing engine at OSC URI. */
- if (local_args_info.connect_given || (check_ambiguity && args_info->connect_given))
- {
- fprintf (stderr, "%s: `--connect' (`-c') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
- goto failure;
- }
- if (args_info->connect_given && ! override)
- continue;
- local_args_info.connect_given = 1;
- args_info->connect_given = 1;
- if (args_info->connect_arg)
- free (args_info->connect_arg); /* free previous string */
- args_info->connect_arg = gengetopt_strdup (optarg);
- if (args_info->connect_orig)
- free (args_info->connect_orig); /* free previous string */
- args_info->connect_orig = gengetopt_strdup (optarg);
+
+
+ if (update_arg( (void *)&(args_info->connect_arg),
+ &(args_info->connect_orig), &(args_info->connect_given),
+ &(local_args_info.connect_given), optarg, 0, "osc.udp://localhost:16180", ARG_STRING,
+ check_ambiguity, override, 0, 0,
+ "connect", 'c',
+ additional_error))
+ goto failure;
+
break;
-
case 'g': /* Launch the GTK graphical interface. */
- if (local_args_info.gui_given || (check_ambiguity && args_info->gui_given))
- {
- fprintf (stderr, "%s: `--gui' (`-g') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
- goto failure;
- }
- if (args_info->gui_given && ! override)
- continue;
- local_args_info.gui_given = 1;
- args_info->gui_given = 1;
- args_info->gui_flag = !(args_info->gui_flag);
+
+
+ if (update_arg((void *)&(args_info->gui_flag), 0, &(args_info->gui_given),
+ &(local_args_info.gui_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "gui", 'g',
+ additional_error))
+ goto failure;
+
break;
-
case 'C': /* Client OSC port. */
- if (local_args_info.client_port_given || (check_ambiguity && args_info->client_port_given))
- {
- fprintf (stderr, "%s: `--client-port' (`-C') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
- goto failure;
- }
- if (args_info->client_port_given && ! override)
- continue;
- local_args_info.client_port_given = 1;
- args_info->client_port_given = 1;
- args_info->client_port_arg = strtol (optarg, &stop_char, 0);
- if (!(stop_char && *stop_char == '\0')) {
- fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
+
+
+ if (update_arg( (void *)&(args_info->client_port_arg),
+ &(args_info->client_port_orig), &(args_info->client_port_given),
+ &(local_args_info.client_port_given), optarg, 0, 0, ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "client-port", 'C',
+ additional_error))
goto failure;
- }
- if (args_info->client_port_orig)
- free (args_info->client_port_orig); /* free previous string */
- args_info->client_port_orig = gengetopt_strdup (optarg);
+
break;
-
case 'l': /* Load patch. */
- if (local_args_info.load_given || (check_ambiguity && args_info->load_given))
- {
- fprintf (stderr, "%s: `--load' (`-l') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
- goto failure;
- }
- if (args_info->load_given && ! override)
- continue;
- local_args_info.load_given = 1;
- args_info->load_given = 1;
- if (args_info->load_arg)
- free (args_info->load_arg); /* free previous string */
- args_info->load_arg = gengetopt_strdup (optarg);
- if (args_info->load_orig)
- free (args_info->load_orig); /* free previous string */
- args_info->load_orig = gengetopt_strdup (optarg);
+
+
+ if (update_arg( (void *)&(args_info->load_arg),
+ &(args_info->load_orig), &(args_info->load_given),
+ &(local_args_info.load_given), optarg, 0, 0, ARG_STRING,
+ check_ambiguity, override, 0, 0,
+ "load", 'l',
+ additional_error))
+ goto failure;
+
break;
-
case 'L': /* Target path for loaded patch. */
- if (local_args_info.path_given || (check_ambiguity && args_info->path_given))
- {
- fprintf (stderr, "%s: `--path' (`-L') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
- goto failure;
- }
- if (args_info->path_given && ! override)
- continue;
- local_args_info.path_given = 1;
- args_info->path_given = 1;
- if (args_info->path_arg)
- free (args_info->path_arg); /* free previous string */
- args_info->path_arg = gengetopt_strdup (optarg);
- if (args_info->path_orig)
- free (args_info->path_orig); /* free previous string */
- args_info->path_orig = gengetopt_strdup (optarg);
+
+
+ if (update_arg( (void *)&(args_info->path_arg),
+ &(args_info->path_orig), &(args_info->path_given),
+ &(local_args_info.path_given), optarg, 0, 0, ARG_STRING,
+ check_ambiguity, override, 0, 0,
+ "path", 'L',
+ additional_error))
+ goto failure;
+
break;
-
case 'r': /* Run script. */
- if (local_args_info.run_given || (check_ambiguity && args_info->run_given))
- {
- fprintf (stderr, "%s: `--run' (`-r') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
- goto failure;
- }
- if (args_info->run_given && ! override)
- continue;
- local_args_info.run_given = 1;
- args_info->run_given = 1;
- if (args_info->run_arg)
- free (args_info->run_arg); /* free previous string */
- args_info->run_arg = gengetopt_strdup (optarg);
- if (args_info->run_orig)
- free (args_info->run_orig); /* free previous string */
- args_info->run_orig = gengetopt_strdup (optarg);
+
+
+ if (update_arg( (void *)&(args_info->run_arg),
+ &(args_info->run_orig), &(args_info->run_given),
+ &(local_args_info.run_given), optarg, 0, 0, ARG_STRING,
+ check_ambiguity, override, 0, 0,
+ "run", 'r',
+ additional_error))
+ goto failure;
+
break;
-
case 'p': /* Number of concurrent process threads. */
- if (local_args_info.parallelism_given || (check_ambiguity && args_info->parallelism_given))
- {
- fprintf (stderr, "%s: `--parallelism' (`-p') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
- goto failure;
- }
- if (args_info->parallelism_given && ! override)
- continue;
- local_args_info.parallelism_given = 1;
- args_info->parallelism_given = 1;
- args_info->parallelism_arg = strtol (optarg, &stop_char, 0);
- if (!(stop_char && *stop_char == '\0')) {
- fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
+
+
+ if (update_arg( (void *)&(args_info->parallelism_arg),
+ &(args_info->parallelism_orig), &(args_info->parallelism_given),
+ &(local_args_info.parallelism_given), optarg, 0, "1", ARG_INT,
+ check_ambiguity, override, 0, 0,
+ "parallelism", 'p',
+ additional_error))
goto failure;
- }
- if (args_info->parallelism_orig)
- free (args_info->parallelism_orig); /* free previous string */
- args_info->parallelism_orig = gengetopt_strdup (optarg);
+
break;
-
case 0: /* Long option with no short option */
case '?': /* Invalid option. */
/* `getopt_long' already printed an error message. */