[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[certi-cvs] applications/HLA_TestsSuite test_FOMParse_cmdli...
From: |
certi-cvs |
Subject: |
[certi-cvs] applications/HLA_TestsSuite test_FOMParse_cmdli... |
Date: |
Sat, 01 Nov 2008 20:25:09 +0000 |
CVSROOT: /sources/certi
Module name: applications
Changes by: Eric NOULARD <erk> 08/11/01 20:25:09
Modified files:
HLA_TestsSuite : test_FOMParse_cmdline.c test_FOMParse_cmdline.h
test_FOMParse.ggo
Log message:
Gives better command line description
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/test_FOMParse_cmdline.c?cvsroot=certi&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/test_FOMParse_cmdline.h?cvsroot=certi&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/test_FOMParse.ggo?cvsroot=certi&r1=1.3&r2=1.4
Patches:
Index: test_FOMParse_cmdline.c
===================================================================
RCS file: /sources/certi/applications/HLA_TestsSuite/test_FOMParse_cmdline.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- test_FOMParse_cmdline.c 29 Oct 2008 17:15:23 -0000 1.3
+++ test_FOMParse_cmdline.c 1 Nov 2008 20:25:08 -0000 1.4
@@ -1,5 +1,5 @@
/*
- File autogenerated by gengetopt version 2.21
+ File autogenerated by gengetopt version 2.22.1
generated with the following command:
gengetopt -i test_FOMParse.ggo -F test_FOMParse_cmdline -G
@@ -22,7 +22,7 @@
const char *gengetopt_args_info_purpose = "test FOM parsing";
-const char *gengetopt_args_info_usage = "Usage: test_FOMParse -f <fedfile> -n
<FederationName> [-v]";
+const char *gengetopt_args_info_usage = "Usage: test_FOMParse [-v] -f
<fedfile> -n <FederationName> [-o <ObjectClassName> [-a <AttributeName>]] [-i
<InteractionClassName> [-p <ParameterName]]";
const char *gengetopt_args_info_description = "A FOM parse test which is part
of the CERTI HLA TestsSuite";
@@ -32,14 +32,19 @@
" -f, --fedfile=STRING The FED file (XML or FED) to be used",
" -n, --fedname=STRING The Federation name",
" -j, --joinname=STRING The federate name used to join the federation",
- " -o, --objectclass=STRING The object class to subscribe to (or publish)",
- " -a, --attribute=STRING The attribute name to subscribe to (or
publish)",
- " -i, --interaction=STRING The interaction class name to subscribe to (or
\n publish)",
- " -p, --parameter=STRING The parameter name to subscribe to (or
publish)",
+ " -o, --objectclass=STRING The object class for which you want to know the
\n handle",
+ " -a, --attribute=STRING The attribute name (needs -o) for which you
want to \n know the handle",
+ " -i, --interaction=STRING The interaction class for which you want to
know \n the handle",
+ " -p, --parameter=STRING The parameter name (needs -i) for which you
want to \n know the handle",
" -v, --verbose verbose mode (default=off)",
0
};
+typedef enum {ARG_NO
+ , ARG_FLAG
+ , ARG_STRING
+} cmdline_parser_arg_type;
+
static
void clear_given (struct gengetopt_args_info *args_info);
static
@@ -94,6 +99,8 @@
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->fedfile_help = gengetopt_args_info_help[2] ;
@@ -113,20 +120,26 @@
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++]);
}
@@ -139,99 +152,110 @@
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->fedfile_arg)
- {
- free (args_info->fedfile_arg); /* free previous argument */
- args_info->fedfile_arg = 0;
- }
- if (args_info->fedfile_orig)
- {
- free (args_info->fedfile_orig); /* free previous argument */
- args_info->fedfile_orig = 0;
- }
- if (args_info->fedname_arg)
- {
- free (args_info->fedname_arg); /* free previous argument */
- args_info->fedname_arg = 0;
- }
- if (args_info->fedname_orig)
- {
- free (args_info->fedname_orig); /* free previous argument */
- args_info->fedname_orig = 0;
- }
- if (args_info->joinname_arg)
- {
- free (args_info->joinname_arg); /* free previous argument */
- args_info->joinname_arg = 0;
- }
- if (args_info->joinname_orig)
- {
- free (args_info->joinname_orig); /* free previous argument */
- args_info->joinname_orig = 0;
- }
- if (args_info->objectclass_arg)
- {
- free (args_info->objectclass_arg); /* free previous argument */
- args_info->objectclass_arg = 0;
- }
- if (args_info->objectclass_orig)
- {
- free (args_info->objectclass_orig); /* free previous argument */
- args_info->objectclass_orig = 0;
- }
- if (args_info->attribute_arg)
- {
- free (args_info->attribute_arg); /* free previous argument */
- args_info->attribute_arg = 0;
- }
- if (args_info->attribute_orig)
- {
- free (args_info->attribute_orig); /* free previous argument */
- args_info->attribute_orig = 0;
- }
- if (args_info->interaction_arg)
+ if (*s)
{
- free (args_info->interaction_arg); /* free previous argument */
- args_info->interaction_arg = 0;
+ free (*s);
+ *s = 0;
}
- if (args_info->interaction_orig)
- {
- free (args_info->interaction_orig); /* free previous argument */
- args_info->interaction_orig = 0;
- }
- if (args_info->parameter_arg)
- {
- free (args_info->parameter_arg); /* free previous argument */
- args_info->parameter_arg = 0;
+}
+
+
+static void
+cmdline_parser_release (struct gengetopt_args_info *args_info)
+{
+
+ free_string_field (&(args_info->fedfile_arg));
+ free_string_field (&(args_info->fedfile_orig));
+ free_string_field (&(args_info->fedname_arg));
+ free_string_field (&(args_info->fedname_orig));
+ free_string_field (&(args_info->joinname_arg));
+ free_string_field (&(args_info->joinname_orig));
+ free_string_field (&(args_info->objectclass_arg));
+ free_string_field (&(args_info->objectclass_orig));
+ free_string_field (&(args_info->attribute_arg));
+ free_string_field (&(args_info->attribute_orig));
+ free_string_field (&(args_info->interaction_arg));
+ free_string_field (&(args_info->interaction_orig));
+ free_string_field (&(args_info->parameter_arg));
+ free_string_field (&(args_info->parameter_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);
}
- if (args_info->parameter_orig)
+}
+
+
+int
+cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
+{
+ int i = 0;
+
+ if (!outfile)
{
- free (args_info->parameter_orig); /* free previous argument */
- args_info->parameter_orig = 0;
+ fprintf (stderr, "%s: cannot dump options to stream\n",
CMDLINE_PARSER_PACKAGE);
+ return EXIT_FAILURE;
}
- clear_given (args_info);
+ 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->fedfile_given)
+ write_into_file(outfile, "fedfile", args_info->fedfile_orig, 0);
+ if (args_info->fedname_given)
+ write_into_file(outfile, "fedname", args_info->fedname_orig, 0);
+ if (args_info->joinname_given)
+ write_into_file(outfile, "joinname", args_info->joinname_orig, 0);
+ if (args_info->objectclass_given)
+ write_into_file(outfile, "objectclass", args_info->objectclass_orig, 0);
+ if (args_info->attribute_given)
+ write_into_file(outfile, "attribute", args_info->attribute_orig, 0);
+ if (args_info->interaction_given)
+ write_into_file(outfile, "interaction", args_info->interaction_orig, 0);
+ if (args_info->parameter_given)
+ write_into_file(outfile, "parameter", args_info->parameter_orig, 0);
+ if (args_info->verbose_given)
+ write_into_file(outfile, "verbose", 0, 0 );
+
+
+ i = EXIT_SUCCESS;
+ return i;
}
int
@@ -248,68 +272,9 @@
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->fedfile_given) {
- if (args_info->fedfile_orig) {
- fprintf(outfile, "%s=\"%s\"\n", "fedfile", args_info->fedfile_orig);
- } else {
- fprintf(outfile, "%s\n", "fedfile");
- }
- }
- if (args_info->fedname_given) {
- if (args_info->fedname_orig) {
- fprintf(outfile, "%s=\"%s\"\n", "fedname", args_info->fedname_orig);
- } else {
- fprintf(outfile, "%s\n", "fedname");
- }
- }
- if (args_info->joinname_given) {
- if (args_info->joinname_orig) {
- fprintf(outfile, "%s=\"%s\"\n", "joinname", args_info->joinname_orig);
- } else {
- fprintf(outfile, "%s\n", "joinname");
- }
- }
- if (args_info->objectclass_given) {
- if (args_info->objectclass_orig) {
- fprintf(outfile, "%s=\"%s\"\n", "objectclass",
args_info->objectclass_orig);
- } else {
- fprintf(outfile, "%s\n", "objectclass");
- }
- }
- if (args_info->attribute_given) {
- if (args_info->attribute_orig) {
- fprintf(outfile, "%s=\"%s\"\n", "attribute", args_info->attribute_orig);
- } else {
- fprintf(outfile, "%s\n", "attribute");
- }
- }
- if (args_info->interaction_given) {
- if (args_info->interaction_orig) {
- fprintf(outfile, "%s=\"%s\"\n", "interaction",
args_info->interaction_orig);
- } else {
- fprintf(outfile, "%s\n", "interaction");
- }
- }
- if (args_info->parameter_given) {
- if (args_info->parameter_orig) {
- fprintf(outfile, "%s=\"%s\"\n", "parameter", args_info->parameter_orig);
- } else {
- fprintf(outfile, "%s\n", "parameter");
- }
- }
- if (args_info->verbose_given) {
- fprintf(outfile, "%s\n", "verbose");
- }
-
+ i = cmdline_parser_dump(outfile, args_info);
fclose (outfile);
- i = EXIT_SUCCESS;
return i;
}
@@ -319,9 +284,7 @@
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)
{
@@ -368,6 +331,7 @@
params.initialize = initialize;
params.check_required = check_required;
params.check_ambiguity = 0;
+ params.print_errors = 1;
result = cmdline_parser_internal (argc, argv, args_info, ¶ms, NULL);
@@ -863,7 +827,7 @@
int print_errors, struct custom_getopt_data *d)
{
char c = *d->nextchar++;
- char *temp = strchr(optstring, c);
+ const char *temp = strchr(optstring, c);
/* Increment `custom_optind' when we start to process its last
character. */
if (*d->nextchar == '\0')
@@ -1044,6 +1008,106 @@
opt_index);
}
+
+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_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;
+ };
+
+
+ /* 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)
@@ -1058,6 +1122,8 @@
int check_required;
int check_ambiguity;
+ package_name = argv[0];
+
override = params->override;
initialize = params->initialize;
check_required = params->check_required;
@@ -1070,13 +1136,12 @@
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' },
@@ -1092,7 +1157,6 @@
{ NULL, 0, NULL, 0 }
};
- stop_char = 0;
custom_optarg = optarg;
custom_optind = optind;
custom_opterr = opterr;
@@ -1120,144 +1184,99 @@
exit (EXIT_SUCCESS);
case 'f': /* The FED file (XML or FED) to be used. */
- if (local_args_info.fedfile_given || (check_ambiguity &&
args_info->fedfile_given))
- {
- fprintf (stderr, "%s: `--fedfile' (`-f') option given more than
once%s\n", argv[0], (additional_error ? additional_error : ""));
+
+
+ if (update_arg( (void *)&(args_info->fedfile_arg),
+ &(args_info->fedfile_orig), &(args_info->fedfile_given),
+ &(local_args_info.fedfile_given), optarg, 0, 0, ARG_STRING,
+ check_ambiguity, override, 0, 0,
+ "fedfile", 'f',
+ additional_error))
goto failure;
- }
- if (args_info->fedfile_given && ! override)
- continue;
- local_args_info.fedfile_given = 1;
- args_info->fedfile_given = 1;
- if (args_info->fedfile_arg)
- free (args_info->fedfile_arg); /* free previous string */
- args_info->fedfile_arg = gengetopt_strdup (optarg);
- if (args_info->fedfile_orig)
- free (args_info->fedfile_orig); /* free previous string */
- args_info->fedfile_orig = gengetopt_strdup (optarg);
- break;
+ break;
case 'n': /* The Federation name. */
- if (local_args_info.fedname_given || (check_ambiguity &&
args_info->fedname_given))
- {
- fprintf (stderr, "%s: `--fedname' (`-n') option given more than
once%s\n", argv[0], (additional_error ? additional_error : ""));
+
+
+ if (update_arg( (void *)&(args_info->fedname_arg),
+ &(args_info->fedname_orig), &(args_info->fedname_given),
+ &(local_args_info.fedname_given), optarg, 0, 0, ARG_STRING,
+ check_ambiguity, override, 0, 0,
+ "fedname", 'n',
+ additional_error))
goto failure;
- }
- if (args_info->fedname_given && ! override)
- continue;
- local_args_info.fedname_given = 1;
- args_info->fedname_given = 1;
- if (args_info->fedname_arg)
- free (args_info->fedname_arg); /* free previous string */
- args_info->fedname_arg = gengetopt_strdup (optarg);
- if (args_info->fedname_orig)
- free (args_info->fedname_orig); /* free previous string */
- args_info->fedname_orig = gengetopt_strdup (optarg);
- break;
+ break;
case 'j': /* The federate name used to join the federation. */
- if (local_args_info.joinname_given || (check_ambiguity &&
args_info->joinname_given))
- {
- fprintf (stderr, "%s: `--joinname' (`-j') option given more than
once%s\n", argv[0], (additional_error ? additional_error : ""));
+
+
+ if (update_arg( (void *)&(args_info->joinname_arg),
+ &(args_info->joinname_orig), &(args_info->joinname_given),
+ &(local_args_info.joinname_given), optarg, 0, 0, ARG_STRING,
+ check_ambiguity, override, 0, 0,
+ "joinname", 'j',
+ additional_error))
goto failure;
- }
- if (args_info->joinname_given && ! override)
- continue;
- local_args_info.joinname_given = 1;
- args_info->joinname_given = 1;
- if (args_info->joinname_arg)
- free (args_info->joinname_arg); /* free previous string */
- args_info->joinname_arg = gengetopt_strdup (optarg);
- if (args_info->joinname_orig)
- free (args_info->joinname_orig); /* free previous string */
- args_info->joinname_orig = gengetopt_strdup (optarg);
+
break;
+ case 'o': /* The object class for which you want to know the
handle. */
- case 'o': /* The object class to subscribe to (or publish). */
- if (local_args_info.objectclass_given || (check_ambiguity &&
args_info->objectclass_given))
- {
- fprintf (stderr, "%s: `--objectclass' (`-o') option given more
than once%s\n", argv[0], (additional_error ? additional_error : ""));
+
+ if (update_arg( (void *)&(args_info->objectclass_arg),
+ &(args_info->objectclass_orig), &(args_info->objectclass_given),
+ &(local_args_info.objectclass_given), optarg, 0, 0, ARG_STRING,
+ check_ambiguity, override, 0, 0,
+ "objectclass", 'o',
+ additional_error))
goto failure;
- }
- if (args_info->objectclass_given && ! override)
- continue;
- local_args_info.objectclass_given = 1;
- args_info->objectclass_given = 1;
- if (args_info->objectclass_arg)
- free (args_info->objectclass_arg); /* free previous string */
- args_info->objectclass_arg = gengetopt_strdup (optarg);
- if (args_info->objectclass_orig)
- free (args_info->objectclass_orig); /* free previous string */
- args_info->objectclass_orig = gengetopt_strdup (optarg);
+
break;
+ case 'a': /* The attribute name (needs -o) for which you want to
know the handle. */
- case 'a': /* The attribute name to subscribe to (or publish). */
- if (local_args_info.attribute_given || (check_ambiguity &&
args_info->attribute_given))
- {
- fprintf (stderr, "%s: `--attribute' (`-a') option given more
than once%s\n", argv[0], (additional_error ? additional_error : ""));
+
+ if (update_arg( (void *)&(args_info->attribute_arg),
+ &(args_info->attribute_orig), &(args_info->attribute_given),
+ &(local_args_info.attribute_given), optarg, 0, 0, ARG_STRING,
+ check_ambiguity, override, 0, 0,
+ "attribute", 'a',
+ additional_error))
goto failure;
- }
- if (args_info->attribute_given && ! override)
- continue;
- local_args_info.attribute_given = 1;
- args_info->attribute_given = 1;
- if (args_info->attribute_arg)
- free (args_info->attribute_arg); /* free previous string */
- args_info->attribute_arg = gengetopt_strdup (optarg);
- if (args_info->attribute_orig)
- free (args_info->attribute_orig); /* free previous string */
- args_info->attribute_orig = gengetopt_strdup (optarg);
+
break;
+ case 'i': /* The interaction class for which you want to know the
handle. */
- case 'i': /* The interaction class name to subscribe to (or
publish). */
- if (local_args_info.interaction_given || (check_ambiguity &&
args_info->interaction_given))
- {
- fprintf (stderr, "%s: `--interaction' (`-i') option given more
than once%s\n", argv[0], (additional_error ? additional_error : ""));
+
+ if (update_arg( (void *)&(args_info->interaction_arg),
+ &(args_info->interaction_orig), &(args_info->interaction_given),
+ &(local_args_info.interaction_given), optarg, 0, 0, ARG_STRING,
+ check_ambiguity, override, 0, 0,
+ "interaction", 'i',
+ additional_error))
goto failure;
- }
- if (args_info->interaction_given && ! override)
- continue;
- local_args_info.interaction_given = 1;
- args_info->interaction_given = 1;
- if (args_info->interaction_arg)
- free (args_info->interaction_arg); /* free previous string */
- args_info->interaction_arg = gengetopt_strdup (optarg);
- if (args_info->interaction_orig)
- free (args_info->interaction_orig); /* free previous string */
- args_info->interaction_orig = gengetopt_strdup (optarg);
+
break;
+ case 'p': /* The parameter name (needs -i) for which you want to
know the handle. */
- case 'p': /* The parameter name to subscribe to (or publish). */
- if (local_args_info.parameter_given || (check_ambiguity &&
args_info->parameter_given))
- {
- fprintf (stderr, "%s: `--parameter' (`-p') option given more
than once%s\n", argv[0], (additional_error ? additional_error : ""));
+
+ if (update_arg( (void *)&(args_info->parameter_arg),
+ &(args_info->parameter_orig), &(args_info->parameter_given),
+ &(local_args_info.parameter_given), optarg, 0, 0, ARG_STRING,
+ check_ambiguity, override, 0, 0,
+ "parameter", 'p',
+ additional_error))
goto failure;
- }
- if (args_info->parameter_given && ! override)
- continue;
- local_args_info.parameter_given = 1;
- args_info->parameter_given = 1;
- if (args_info->parameter_arg)
- free (args_info->parameter_arg); /* free previous string */
- args_info->parameter_arg = gengetopt_strdup (optarg);
- if (args_info->parameter_orig)
- free (args_info->parameter_orig); /* free previous string */
- args_info->parameter_orig = gengetopt_strdup (optarg);
- break;
+ break;
case 'v': /* verbose mode. */
- if (local_args_info.verbose_given || (check_ambiguity &&
args_info->verbose_given))
- {
- fprintf (stderr, "%s: `--verbose' (`-v') option given more than
once%s\n", argv[0], (additional_error ? additional_error : ""));
+
+
+ if (update_arg((void *)&(args_info->verbose_flag), 0,
&(args_info->verbose_given),
+ &(local_args_info.verbose_given), optarg, 0, 0, ARG_FLAG,
+ check_ambiguity, override, 1, 0, "verbose", 'v',
+ additional_error))
goto failure;
- }
- if (args_info->verbose_given && ! override)
- continue;
- local_args_info.verbose_given = 1;
- args_info->verbose_given = 1;
- args_info->verbose_flag = !(args_info->verbose_flag);
- break;
+ break;
case 0: /* Long option with no short option */
case '?': /* Invalid option. */
Index: test_FOMParse_cmdline.h
===================================================================
RCS file: /sources/certi/applications/HLA_TestsSuite/test_FOMParse_cmdline.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- test_FOMParse_cmdline.h 29 Oct 2008 17:15:23 -0000 1.3
+++ test_FOMParse_cmdline.h 1 Nov 2008 20:25:08 -0000 1.4
@@ -1,6 +1,6 @@
/** @file test_FOMParse_cmdline.h
* @brief The header file for the command line option parser
- * generated by GNU Gengetopt version 2.21
+ * generated by GNU Gengetopt version 2.22.1
* 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 */
@@ -41,31 +43,31 @@
char * joinname_arg; /**< @brief The federate name used to join the
federation. */
char * joinname_orig; /**< @brief The federate name used to join the
federation original value given at command line. */
const char *joinname_help; /**< @brief The federate name used to join the
federation help description. */
- char * objectclass_arg; /**< @brief The object class to subscribe to
(or publish). */
- char * objectclass_orig; /**< @brief The object class to subscribe to
(or publish) original value given at command line. */
- const char *objectclass_help; /**< @brief The object class to subscribe to
(or publish) help description. */
- char * attribute_arg; /**< @brief The attribute name to subscribe to
(or publish). */
- char * attribute_orig; /**< @brief The attribute name to subscribe to
(or publish) original value given at command line. */
- const char *attribute_help; /**< @brief The attribute name to subscribe to
(or publish) help description. */
- char * interaction_arg; /**< @brief The interaction class name to
subscribe to (or publish). */
- char * interaction_orig; /**< @brief The interaction class name to
subscribe to (or publish) original value given at command line. */
- const char *interaction_help; /**< @brief The interaction class name to
subscribe to (or publish) help description. */
- char * parameter_arg; /**< @brief The parameter name to subscribe to
(or publish). */
- char * parameter_orig; /**< @brief The parameter name to subscribe to
(or publish) original value given at command line. */
- const char *parameter_help; /**< @brief The parameter name to subscribe to
(or publish) help description. */
+ char * objectclass_arg; /**< @brief The object class for which you want
to know the handle. */
+ char * objectclass_orig; /**< @brief The object class for which you want
to know the handle original value given at command line. */
+ const char *objectclass_help; /**< @brief The object class for which you
want to know the handle help description. */
+ char * attribute_arg; /**< @brief The attribute name (needs -o) for
which you want to know the handle. */
+ char * attribute_orig; /**< @brief The attribute name (needs -o) for
which you want to know the handle original value given at command line. */
+ const char *attribute_help; /**< @brief The attribute name (needs -o) for
which you want to know the handle help description. */
+ char * interaction_arg; /**< @brief The interaction class for which you
want to know the handle. */
+ char * interaction_orig; /**< @brief The interaction class for which you
want to know the handle original value given at command line. */
+ const char *interaction_help; /**< @brief The interaction class for which
you want to know the handle help description. */
+ char * parameter_arg; /**< @brief The parameter name (needs -i) for
which you want to know the handle. */
+ char * parameter_orig; /**< @brief The parameter name (needs -i) for
which you want to know the handle original value given at command line. */
+ const char *parameter_help; /**< @brief The parameter name (needs -i) for
which you want to know the handle help description. */
int verbose_flag; /**< @brief verbose mode (default=off). */
const char *verbose_help; /**< @brief verbose mode help description. */
- int help_given ; /**< @brief Whether help was given. */
- int version_given ; /**< @brief Whether version was given. */
- int fedfile_given ; /**< @brief Whether fedfile was given. */
- int fedname_given ; /**< @brief Whether fedname was given. */
- int joinname_given ; /**< @brief Whether joinname was given. */
- int objectclass_given ; /**< @brief Whether objectclass was given. */
- int attribute_given ; /**< @brief Whether attribute was given. */
- int interaction_given ; /**< @brief Whether interaction was given. */
- int parameter_given ; /**< @brief Whether parameter was given. */
- int verbose_given ; /**< @brief Whether verbose was given. */
+ unsigned int help_given ; /**< @brief Whether help was given. */
+ unsigned int version_given ; /**< @brief Whether version was given. */
+ unsigned int fedfile_given ; /**< @brief Whether fedfile was given. */
+ unsigned int fedname_given ; /**< @brief Whether fedname was given. */
+ unsigned int joinname_given ; /**< @brief Whether joinname was given.
*/
+ unsigned int objectclass_given ; /**< @brief Whether objectclass was
given. */
+ unsigned int attribute_given ; /**< @brief Whether attribute was
given. */
+ unsigned int interaction_given ; /**< @brief Whether interaction was
given. */
+ unsigned int parameter_given ; /**< @brief Whether parameter was
given. */
+ unsigned int verbose_given ; /**< @brief Whether verbose was given. */
} ;
@@ -73,9 +75,10 @@
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 */
@@ -123,6 +126,15 @@
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
@@ -142,11 +154,18 @@
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
Index: test_FOMParse.ggo
===================================================================
RCS file: /sources/certi/applications/HLA_TestsSuite/test_FOMParse.ggo,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- test_FOMParse.ggo 29 Oct 2008 17:15:23 -0000 1.3
+++ test_FOMParse.ggo 1 Nov 2008 20:25:09 -0000 1.4
@@ -3,7 +3,7 @@
package "FOMParse"
version "0.1"
purpose "test FOM parsing"
-usage "test_FOMParse -f <fedfile> -n <FederationName> [-v]"
+usage "test_FOMParse [-v] -f <fedfile> -n <FederationName> [-o
<ObjectClassName> [-a <AttributeName>]] [-i <InteractionClassName> [-p
<ParameterName]]"
description "A FOM parse test which is part of the CERTI HLA TestsSuite"
# gengetopt options
@@ -13,8 +13,8 @@
option "fedfile" f "The FED file (XML or FED) to be used"
string required
option "fedname" n "The Federation name"
string required
option "joinname" j "The federate name used to join the federation"
string optional
-option "objectclass" o "The object class to subscribe to (or publish)"
string optional
-option "attribute" a "The attribute name to subscribe to (or publish)"
string optional
-option "interaction" i "The interaction class name to subscribe to (or
publish)" string optional
-option "parameter" p "The parameter name to subscribe to (or publish)"
string optional
+option "objectclass" o "The object class for which you want to know the
handle" string optional
+option "attribute" a "The attribute name (needs -o) for which you want to
know the handle" string optional
+option "interaction" i "The interaction class for which you want to know the
handle" string optional
+option "parameter" p "The parameter name (needs -i) for which you want to
know the handle" string optional
option "verbose" v "verbose mode"
flag off
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [certi-cvs] applications/HLA_TestsSuite test_FOMParse_cmdli...,
certi-cvs <=