summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/progs/ingen/cmdline.c590
-rw-r--r--src/progs/ingen/cmdline.ggo23
-rw-r--r--src/progs/ingen/cmdline.h53
-rw-r--r--src/progs/ingen/main.cpp10
4 files changed, 372 insertions, 304 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. */
diff --git a/src/progs/ingen/cmdline.ggo b/src/progs/ingen/cmdline.ggo
index e809689e..994e6ff9 100644
--- a/src/progs/ingen/cmdline.ggo
+++ b/src/progs/ingen/cmdline.ggo
@@ -3,10 +3,25 @@
package "ingen"
purpose "A modular realtime audio processing system"
-description "This executable can be used to launch any configuration of Ingen.
-Ingen can run as a stand-alone server controlled by OSC, or internal to
-another process. The GUI can communicate with the engine via either method,
-and many GUIs (or other things) may connect to an engine via OSC.
+description "Ingen can be run in various configurations. The engine can
+run as a stand-alone server controlled by OSC, or internal to
+another process (e.g. the GUI). The GUI can communicate with the engine
+via either method, and many GUIs (or other things) may connect to an
+engine via OSC.
+
+Examples:
+
+ ingen -e - Run an engine, listen for OSC
+ ingen -g - Run a GUI, connect via OSC
+ ingen -eg - Run an engine and a GUI in one process
+
+The -l (load) option can be used in all cases:
+
+ ingen -el patch.ingen.ttl - Run an engine and load a patch
+ ingen -gl patch.ingen.ttl - Run a GUI and load a patch
+ ingen -egl patch.ingen.ttl - Run an engine and a GUI and load a patch
+
+Options:
"
option "engine" e "Run (JACK) engine" flag off
diff --git a/src/progs/ingen/cmdline.h b/src/progs/ingen/cmdline.h
index 9caa9529..80358089 100644
--- a/src/progs/ingen/cmdline.h
+++ b/src/progs/ingen/cmdline.h
@@ -1,6 +1,6 @@
/** @file cmdline.h
* @brief The header file for the command line option parser
- * generated by GNU Gengetopt version 2.21
+ * generated by GNU Gengetopt
* http://www.gnu.org/software/gengetopt.
* DO NOT modify this file, since it can be overwritten
* @author GNU Gengetopt by Lorenzo Bettini */
@@ -13,6 +13,8 @@
#include "config.h"
#endif
+#include <stdio.h> /* for FILE */
+
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
@@ -58,17 +60,17 @@ struct gengetopt_args_info
char * parallelism_orig; /**< @brief Number of concurrent process threads original value given at command line. */
const char *parallelism_help; /**< @brief Number of concurrent process threads help description. */
- int help_given ; /**< @brief Whether help was given. */
- int version_given ; /**< @brief Whether version was given. */
- int engine_given ; /**< @brief Whether engine was given. */
- int engine_port_given ; /**< @brief Whether engine-port was given. */
- int connect_given ; /**< @brief Whether connect was given. */
- int gui_given ; /**< @brief Whether gui was given. */
- int client_port_given ; /**< @brief Whether client-port was given. */
- int load_given ; /**< @brief Whether load was given. */
- int path_given ; /**< @brief Whether path was given. */
- int run_given ; /**< @brief Whether run was given. */
- int parallelism_given ; /**< @brief Whether parallelism was given. */
+ unsigned int help_given ; /**< @brief Whether help was given. */
+ unsigned int version_given ; /**< @brief Whether version was given. */
+ unsigned int engine_given ; /**< @brief Whether engine was given. */
+ unsigned int engine_port_given ; /**< @brief Whether engine-port was given. */
+ unsigned int connect_given ; /**< @brief Whether connect was given. */
+ unsigned int gui_given ; /**< @brief Whether gui was given. */
+ unsigned int client_port_given ; /**< @brief Whether client-port was given. */
+ unsigned int load_given ; /**< @brief Whether load was given. */
+ unsigned int path_given ; /**< @brief Whether path was given. */
+ unsigned int run_given ; /**< @brief Whether run was given. */
+ unsigned int parallelism_given ; /**< @brief Whether parallelism was given. */
} ;
@@ -76,9 +78,10 @@ struct gengetopt_args_info
struct cmdline_parser_params
{
int override; /**< @brief whether to override possibly already present options (default 0) */
- int initialize; /**< @brief whether to initialize the option structure gengetopt_args_info (default 0) */
- int check_required; /**< @brief whether to check that all required options were provided (default 0) */
+ int initialize; /**< @brief whether to initialize the option structure gengetopt_args_info (default 1) */
+ int check_required; /**< @brief whether to check that all required options were provided (default 1) */
int check_ambiguity; /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */
+ int print_errors; /**< @brief whether getopt_long should print an error message for a bad option (default 1) */
} ;
/** @brief the purpose string of the program */
@@ -126,6 +129,15 @@ int cmdline_parser_ext (int argc, char * const *argv,
struct cmdline_parser_params *params);
/**
+ * Save the contents of the option struct into an already open FILE stream.
+ * @param outfile the stream where to dump options
+ * @param args_info the option struct to dump
+ * @return 0 if everything went fine, NON 0 if an error took place
+ */
+int cmdline_parser_dump(FILE *outfile,
+ struct gengetopt_args_info *args_info);
+
+/**
* Save the contents of the option struct into a (text) file.
* This file can be read by the config file parser (if generated by gengetopt)
* @param filename the file where to save
@@ -145,11 +157,18 @@ void cmdline_parser_print_help(void);
void cmdline_parser_print_version(void);
/**
+ * Initializes all the fields a cmdline_parser_params structure
+ * to their default values
+ * @param params the structure to initialize
+ */
+void cmdline_parser_params_init(struct cmdline_parser_params *params);
+
+/**
* Allocates dynamically a cmdline_parser_params structure and initializes
- * all its fields to 0
- * @return the initialized cmdline_parser_params structure
+ * all its fields to their default values
+ * @return the created and initialized cmdline_parser_params structure
*/
-struct cmdline_parser_params *cmdline_parser_params_init();
+struct cmdline_parser_params *cmdline_parser_params_create(void);
/**
* Initializes the passed gengetopt_args_info structure's fields
diff --git a/src/progs/ingen/main.cpp b/src/progs/ingen/main.cpp
index ea6bf5ed..a589b46b 100644
--- a/src/progs/ingen/main.cpp
+++ b/src/progs/ingen/main.cpp
@@ -66,16 +66,14 @@ main(int argc, char** argv)
return 1;
if (argc <= 1) {
- cerr << "No arguments provided. Try something like:" << endl << endl;
- cerr << "Run an engine: ingen -e" << endl;
- cerr << "Run the GUI: ingen -g" << endl;
- cerr << "Print full help: ingen -h" << endl << endl;
cmdline_parser_print_help();
+ cerr << endl << "*** Ingen requires at least one command line parameter" << endl;
+ cerr << "*** Just want to use a graphical app? Try 'ingen -eg'" << endl;
return 1;
} else if (args.connect_given && args.engine_flag) {
- cerr << "Nonsense arguments, can't both run a local engine "
+ cerr << "\n*** Nonsense arguments, can't both run a local engine "
<< "and connect to a remote one." << endl
- << "(Run separate instances if that is what you want)" << endl;
+ << "*** Run separate instances if that is what you want" << endl;
return 1;
}