--- trunk/src/applications/nanoparticleBuilder/nanoparticleBuilderCmd.c 2009/11/25 20:02:06 1390 +++ branches/development/src/applications/nanoparticleBuilder/nanoparticleBuilderCmd.cpp 2011/10/03 20:32:45 1655 @@ -1,7 +1,7 @@ /* - File autogenerated by gengetopt version 2.22 + File autogenerated by gengetopt version 2.22.4 generated with the following command: - gengetopt -u -F nanoparticleBuilderCmd + gengetopt -F nanoparticleBuilderCmd -u The developers of gengetopt consider the fixed text that goes in all gengetopt output files to be in the public domain: @@ -17,8 +17,12 @@ #include #include -#include "getopt.h" +#ifndef FIX_UNUSED +#define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */ +#endif +#include + #include "nanoparticleBuilderCmd.h" const char *gengetopt_args_info_purpose = "Builds spherical random or core-shell nanoparticles and outputs an OpenMD \nstartup file"; @@ -52,7 +56,7 @@ static int void clear_args (struct gengetopt_args_info *args_info); static int -cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, +cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info, struct cmdline_parser_params *params, const char *additional_error); static int @@ -79,6 +83,7 @@ void clear_args (struct gengetopt_args_info *args_info static void clear_args (struct gengetopt_args_info *args_info) { + FIX_UNUSED (args_info); args_info->output_arg = NULL; args_info->output_orig = NULL; args_info->latticeConstant_orig = NULL; @@ -104,11 +109,11 @@ void init_args_info(struct gengetopt_args_info *args_i args_info->latticeConstant_help = gengetopt_args_info_help[3] ; args_info->radius_help = gengetopt_args_info_help[4] ; args_info->shellRadius_help = gengetopt_args_info_help[5] ; - args_info->shellRadius_min = -1; - args_info->shellRadius_max = -1; + args_info->shellRadius_min = 0; + args_info->shellRadius_max = 0; args_info->molFraction_help = gengetopt_args_info_help[6] ; - args_info->molFraction_min = -1; - args_info->molFraction_max = -1; + args_info->molFraction_min = 0; + args_info->molFraction_max = 0; args_info->vacancyPercent_help = gengetopt_args_info_help[7] ; args_info->vacancyInnerRadius_help = gengetopt_args_info_help[8] ; args_info->vacancyOuterRadius_help = gengetopt_args_info_help[9] ; @@ -118,7 +123,9 @@ cmdline_parser_print_version (void) void cmdline_parser_print_version (void) { - printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION); + printf ("%s %s\n", + (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE), + CMDLINE_PARSER_VERSION); } static void print_help_common(void) { @@ -133,7 +140,7 @@ static void print_help_common(void) { 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 @@ -152,7 +159,7 @@ cmdline_parser_init (struct gengetopt_args_info *args_ clear_args (args_info); init_args_info (args_info); - args_info->inputs = NULL; + args_info->inputs = 0; args_info->inputs_num = 0; } @@ -192,6 +199,7 @@ union generic_value { union generic_value { double double_arg; char *string_arg; + const char *default_string_arg; }; /** @brief holds temporary values for multiple options */ @@ -209,22 +217,24 @@ static void add_node(struct generic_list **list) { struct generic_list *new_node = (struct generic_list *) malloc (sizeof (struct generic_list)); new_node->next = *list; *list = new_node; - new_node->arg.string_arg = NULL; - new_node->orig = NULL; + new_node->arg.string_arg = 0; + new_node->orig = 0; } +/** + * The passed arg parameter is NOT set to 0 from this function + */ static void -free_multiple_field(unsigned int len, void **arg, char ***orig) +free_multiple_field(unsigned int len, void *arg, char ***orig) { unsigned int i; - if (*arg) { + if (arg) { for (i = 0; i < len; ++i) { free_string_field(&((*orig)[i])); } - free (*arg); - *arg = 0; + free (arg); free (*orig); *orig = 0; } @@ -239,8 +249,10 @@ cmdline_parser_release (struct gengetopt_args_info *ar free_string_field (&(args_info->output_orig)); free_string_field (&(args_info->latticeConstant_orig)); free_string_field (&(args_info->radius_orig)); - free_multiple_field (args_info->shellRadius_given, (void **)&(args_info->shellRadius_arg), &(args_info->shellRadius_orig)); - free_multiple_field (args_info->molFraction_given, (void **)&(args_info->molFraction_arg), &(args_info->molFraction_orig)); + free_multiple_field (args_info->shellRadius_given, (void *)(args_info->shellRadius_arg), &(args_info->shellRadius_orig)); + args_info->shellRadius_arg = 0; + free_multiple_field (args_info->molFraction_given, (void *)(args_info->molFraction_arg), &(args_info->molFraction_orig)); + args_info->molFraction_arg = 0; free_string_field (&(args_info->vacancyPercent_orig)); free_string_field (&(args_info->vacancyInnerRadius_orig)); free_string_field (&(args_info->vacancyOuterRadius_orig)); @@ -257,8 +269,9 @@ static void static void -write_into_file(FILE *outfile, const char *opt, const char *arg, char *values[]) +write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[]) { + FIX_UNUSED (values); if (arg) { fprintf(outfile, "%s=\"%s\"\n", opt, arg); } else { @@ -267,7 +280,7 @@ static void } static void -write_multiple_into_file(FILE *outfile, int len, const char *opt, char **arg, char *values[]) +write_multiple_into_file(FILE *outfile, int len, const char *opt, char **arg, const char *values[]) { int i; @@ -340,7 +353,7 @@ gengetopt_strdup (const char *s) char * gengetopt_strdup (const char *s) { - char *result = NULL; + char *result = 0; if (!s) return result; @@ -354,11 +367,12 @@ get_multiple_arg_token(const char *arg) static char * get_multiple_arg_token(const char *arg) { - char *tok, *ret; + const char *tok; + char *ret; size_t len, num_of_escape, i, j; if (!arg) - return NULL; + return 0; tok = strchr (arg, ','); num_of_escape = 0; @@ -402,13 +416,13 @@ get_multiple_arg_token(const char *arg) return ret; } -static char * +static const char * get_multiple_arg_token_next(const char *arg) { - char *tok; + const char *tok; if (!arg) - return NULL; + return 0; tok = strchr (arg, ','); @@ -431,29 +445,29 @@ static int } static int -check_multiple_option_occurrences(const char *prog_name, unsigned int option_given, int min, int max, const char *option_desc); +check_multiple_option_occurrences(const char *prog_name, unsigned int option_given, unsigned int min, unsigned int max, const char *option_desc); int -check_multiple_option_occurrences(const char *prog_name, unsigned int option_given, int min, int max, const char *option_desc) +check_multiple_option_occurrences(const char *prog_name, unsigned int option_given, unsigned int min, unsigned int max, const char *option_desc) { int error = 0; - if (option_given && ! (min < 0 && max < 0)) + if (option_given && (min > 0 || max > 0)) { - if (min >= 0 && max >= 0) + if (min > 0 && max > 0) { if (min == max) { /* specific occurrences */ - if (option_given != min) + if (option_given != (unsigned int) min) { fprintf (stderr, "%s: %s option occurrences must be %d\n", prog_name, option_desc, min); error = 1; } } - else if (option_given < min - || option_given > max) + else if (option_given < (unsigned int) min + || option_given > (unsigned int) max) { /* range occurrences */ fprintf (stderr, "%s: %s option occurrences must be between %d and %d\n", @@ -461,7 +475,7 @@ check_multiple_option_occurrences(const char *prog_nam error = 1; } } - else if (min >= 0) + else if (min > 0) { /* at least check */ if (option_given < min) @@ -471,7 +485,7 @@ check_multiple_option_occurrences(const char *prog_nam error = 1; } } - else if (max >= 0) + else if (max > 0) { /* at most check */ if (option_given > max) @@ -486,17 +500,17 @@ int return error; } int -cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info) +cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info) { return cmdline_parser2 (argc, argv, args_info, 0, 1, 1); } int -cmdline_parser_ext (int argc, char * const *argv, struct gengetopt_args_info *args_info, +cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info, struct cmdline_parser_params *params) { int result; - result = cmdline_parser_internal (argc, argv, args_info, params, NULL); + result = cmdline_parser_internal (argc, argv, args_info, params, 0); if (result == EXIT_FAILURE) { @@ -508,7 +522,7 @@ int } int -cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) +cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) { int result; struct cmdline_parser_params params; @@ -519,7 +533,7 @@ cmdline_parser2 (int argc, char * const *argv, struct params.check_ambiguity = 0; params.print_errors = 1; - result = cmdline_parser_internal (argc, argv, args_info, ¶ms, NULL); + result = cmdline_parser_internal (argc, argv, args_info, ¶ms, 0); if (result == EXIT_FAILURE) { @@ -535,7 +549,7 @@ cmdline_parser_required (struct gengetopt_args_info *a { int result = EXIT_SUCCESS; - if (cmdline_parser_required2(args_info, prog_name, NULL) > 0) + if (cmdline_parser_required2(args_info, prog_name, 0) > 0) result = EXIT_FAILURE; if (result == EXIT_FAILURE) @@ -551,6 +565,7 @@ cmdline_parser_required2 (struct gengetopt_args_info * cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error) { int error = 0; + FIX_UNUSED (additional_error); /* checks for required options */ if (! args_info->output_given) @@ -607,7 +622,8 @@ int update_arg(void *field, char **orig_field, 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, + char *value, const char *possible_values[], + const char *default_value, cmdline_parser_arg_type arg_type, int check_ambiguity, int override, int no_free, int multiple_option, @@ -618,6 +634,7 @@ int update_arg(void *field, char **orig_field, const char *val = value; int found; char **string_field; + FIX_UNUSED (field); stop_char = 0; found = 0; @@ -635,6 +652,7 @@ int update_arg(void *field, char **orig_field, return 1; /* failure */ } + FIX_UNUSED (default_value); if (field_given && *field_given && ! override) return 0; @@ -699,12 +717,14 @@ int update_multiple_arg_temp(struct generic_list **lis static int update_multiple_arg_temp(struct generic_list **list, unsigned int *prev_given, const char *val, - char *possible_values[], const char *default_value, + const char *possible_values[], const char *default_value, cmdline_parser_arg_type arg_type, const char *long_opt, char short_opt, const char *additional_error) { - char *multi_token, *multi_next; /* store single arguments */ + /* store single arguments */ + char *multi_token; + const char *multi_next; if (arg_type == ARG_NO) { (*prev_given)++; @@ -816,14 +836,15 @@ void update_multiple_arg(void *field, char ***orig_fie } if (!(*orig_field)) { *orig_field = (char **) malloc (sizeof (char *)); - (*orig_field)[0] = NULL; + (*orig_field)[0] = 0; } } } } int -cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, +cmdline_parser_internal ( + int argc, char **argv, struct gengetopt_args_info *args_info, struct cmdline_parser_params *params, const char *additional_error) { int c; /* Character of the parsed option. */ @@ -870,7 +891,7 @@ cmdline_parser_internal (int argc, char * const *argv, { "vacancyPercent", 1, NULL, 0 }, { "vacancyInnerRadius", 1, NULL, 0 }, { "vacancyOuterRadius", 1, NULL, 0 }, - { NULL, 0, NULL, 0 } + { 0, 0, 0, 0 } }; c = getopt_long (argc, argv, "hVo:", long_options, &option_index); @@ -1010,11 +1031,11 @@ cmdline_parser_internal (int argc, char * const *argv, update_multiple_arg((void *)&(args_info->shellRadius_arg), &(args_info->shellRadius_orig), args_info->shellRadius_given, - local_args_info.shellRadius_given, 0 , + local_args_info.shellRadius_given, 0, ARG_DOUBLE, shellRadius_list); update_multiple_arg((void *)&(args_info->molFraction_arg), &(args_info->molFraction_orig), args_info->molFraction_given, - local_args_info.molFraction_given, 0 , + local_args_info.molFraction_given, 0, ARG_DOUBLE, molFraction_list); args_info->shellRadius_given += local_args_info.shellRadius_given;