--- trunk/src/applications/hydrodynamics/HydroCmd.c 2009/11/25 20:02:06 1390 +++ trunk/src/applications/hydrodynamics/HydroCmd.cpp 2013/06/19 13:44:43 1891 @@ -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 -F HydroCmd + gengetopt --file-name=HydroCmd --unamed-opts The developers of gengetopt consider the fixed text that goes in all gengetopt output files to be in the public domain: @@ -17,13 +17,21 @@ #include #include -#include "getopt.h" +#ifndef FIX_UNUSED +#define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */ +#endif +#ifdef WIN32 +#include "utils/wingetopt.h" +#else +#include +#endif + #include "HydroCmd.h" -const char *gengetopt_args_info_purpose = "\n +-----------------------------------------------------------------------+\n | ____ __ ___ ____ |\n | / __ \\____ ___ ____ / |/ // __ \\ The Open Molecular Dynamics |\n | / / / / __ \\/ _ \\/ __ \\ / /|_/ // / / / Engine (formerly OOPSE). |\n | / /_/ / /_/ / __/ / / // / / // /_/ / |\n | \\____/ .___/\\___/_/ /_//_/ /_//_____/ Copyright 2004-2009 by the |\n | /_/ University of Notre Dame. |\n | |\n | http://www.openmd.net |\n | |\n | OpenMD is an OpenScience project. All source code is available for |\n | any use whatsoever under a BSD-style license. |\n | |\n | Support OpenScience! If you use OpenMD or its source code in your |\n | research, please cite the appropriate papers when you publish your |\n | work. Good starting points are: |\n | |\n | [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |\n | [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). |\n | [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). |\n | [4] Vardeman & Gezelter, in progress (2009). |\n +-----------------------------------------------------------------------+"; +const char *gengetopt_args_info_purpose = "\n+--------------------------------------------------------------------------+\n| ____ __ ___ ____ |\n| / __ \\____ ___ ____ / |/ // __ \\ The Open Molecular Dynamics |\n| / / / / __ \\/ _ \\/ __ \\ / /|_/ // / / / Engine (formerly OOPSE). |\n| / /_/ / /_/ / __/ / / // / / // /_/ / |\n| \\____/ .___/\\___/_/ /_//_/ /_//_____/ Copyright 2004-2013 by the |\n| /_/ University of Notre Dame. |\n| |\n| http://www.openmd.org |\n| |\n| OpenMD is an OpenScience project. All source code is available for |\n| any use whatsoever under a BSD-style license. |\n| |\n| Support OpenScience! If you use OpenMD or its source code in your |\n| research, please cite the appropriate papers when you publish your |\n| work. Good starting points are: |\n| |\n| [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |\n| [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). |\n| [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). |\n| [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). |\n| [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). |\n| [6] Kuang & Gezelter, Mol. Phys., 110, 691-701 (2012). |\n+--------------------------------------------------------------------------+"; -const char *gengetopt_args_info_usage = "Usage: Hydro [OPTIONS]..."; +const char *gengetopt_args_info_usage = "Usage: Hydro [OPTIONS]... [FILES]..."; const char *gengetopt_args_info_description = ""; @@ -48,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 @@ -71,6 +79,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->input_arg = NULL; args_info->input_orig = NULL; args_info->output_arg = gengetopt_strdup ("hydro"); @@ -98,7 +107,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) { @@ -113,7 +124,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 @@ -131,6 +142,9 @@ cmdline_parser_init (struct gengetopt_args_info *args_ clear_given (args_info); clear_args (args_info); init_args_info (args_info); + + args_info->inputs = 0; + args_info->inputs_num = 0; } void @@ -169,7 +183,7 @@ cmdline_parser_release (struct gengetopt_args_info *ar static void cmdline_parser_release (struct gengetopt_args_info *args_info) { - + unsigned int i; free_string_field (&(args_info->input_arg)); free_string_field (&(args_info->input_orig)); free_string_field (&(args_info->output_arg)); @@ -178,14 +192,20 @@ cmdline_parser_release (struct gengetopt_args_info *ar free_string_field (&(args_info->model_orig)); + for (i = 0; i < args_info->inputs_num; ++i) + free (args_info->inputs [i]); + if (args_info->inputs_num) + free (args_info->inputs); + clear_given (args_info); } 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 { @@ -253,7 +273,7 @@ gengetopt_strdup (const char *s) char * gengetopt_strdup (const char *s) { - char *result = NULL; + char *result = 0; if (!s) return result; @@ -265,17 +285,17 @@ int } 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) { @@ -287,7 +307,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; @@ -298,7 +318,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) { @@ -314,7 +334,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) @@ -330,6 +350,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->input_given) @@ -374,19 +395,19 @@ 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, const char *long_opt, char short_opt, const char *additional_error) { - char *stop_char = 0; const char *val = value; int found; char **string_field; + FIX_UNUSED (field); - stop_char = 0; found = 0; if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given))) @@ -402,6 +423,7 @@ int update_arg(void *field, char **orig_field, return 1; /* failure */ } + FIX_UNUSED (default_value); if (field_given && *field_given && ! override) return 0; @@ -451,7 +473,8 @@ int 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. */ @@ -492,7 +515,7 @@ cmdline_parser_internal (int argc, char * const *argv, { "output", 1, NULL, 'o' }, { "model", 1, NULL, 0 }, { "beads", 0, NULL, 'b' }, - { NULL, 0, NULL, 0 } + { 0, 0, 0, 0 } }; c = getopt_long (argc, argv, "hVi:o:b", long_options, &option_index); @@ -585,6 +608,30 @@ cmdline_parser_internal (int argc, char * const *argv, if ( error ) return (EXIT_FAILURE); + if (optind < argc) + { + int i = 0 ; + int found_prog_name = 0; + /* whether program name, i.e., argv[0], is in the remaining args + (this may happen with some implementations of getopt, + but surely not with the one included by gengetopt) */ + + i = optind; + while (i < argc) + if (argv[i++] == argv[0]) { + found_prog_name = 1; + break; + } + i = 0; + + args_info->inputs_num = argc - optind - found_prog_name; + args_info->inputs = + (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ; + while (optind < argc) + if (argv[optind++] != argv[0]) + args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind-1]) ; + } + return 0; failure: