| 1 |
|
/* |
| 2 |
< |
File autogenerated by gengetopt version 2.22 |
| 2 |
> |
File autogenerated by gengetopt version 2.22.4 |
| 3 |
|
generated with the following command: |
| 4 |
< |
gengetopt -F HydroCmd |
| 4 |
> |
gengetopt --file-name=HydroCmd --unamed-opts |
| 5 |
|
|
| 6 |
|
The developers of gengetopt consider the fixed text that goes in all |
| 7 |
|
gengetopt output files to be in the public domain: |
| 17 |
|
#include <stdlib.h> |
| 18 |
|
#include <string.h> |
| 19 |
|
|
| 20 |
< |
#include "getopt.h" |
| 20 |
> |
#ifndef FIX_UNUSED |
| 21 |
> |
#define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */ |
| 22 |
> |
#endif |
| 23 |
|
|
| 24 |
+ |
#ifdef WIN32 |
| 25 |
+ |
#include "utils/wingetopt.h" |
| 26 |
+ |
#else |
| 27 |
+ |
#include <getopt.h> |
| 28 |
+ |
#endif |
| 29 |
+ |
|
| 30 |
|
#include "HydroCmd.h" |
| 31 |
|
|
| 32 |
< |
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 +-----------------------------------------------------------------------+"; |
| 32 |
> |
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.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, 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+--------------------------------------------------------------------------+"; |
| 33 |
|
|
| 34 |
< |
const char *gengetopt_args_info_usage = "Usage: Hydro [OPTIONS]..."; |
| 34 |
> |
const char *gengetopt_args_info_usage = "Usage: Hydro [OPTIONS]... [FILES]..."; |
| 35 |
|
|
| 36 |
|
const char *gengetopt_args_info_description = ""; |
| 37 |
|
|
| 56 |
|
void clear_args (struct gengetopt_args_info *args_info); |
| 57 |
|
|
| 58 |
|
static int |
| 59 |
< |
cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, |
| 59 |
> |
cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info, |
| 60 |
|
struct cmdline_parser_params *params, const char *additional_error); |
| 61 |
|
|
| 62 |
|
static int |
| 79 |
|
static |
| 80 |
|
void clear_args (struct gengetopt_args_info *args_info) |
| 81 |
|
{ |
| 82 |
+ |
FIX_UNUSED (args_info); |
| 83 |
|
args_info->input_arg = NULL; |
| 84 |
|
args_info->input_orig = NULL; |
| 85 |
|
args_info->output_arg = gengetopt_strdup ("hydro"); |
| 107 |
|
void |
| 108 |
|
cmdline_parser_print_version (void) |
| 109 |
|
{ |
| 110 |
< |
printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION); |
| 110 |
> |
printf ("%s %s\n", |
| 111 |
> |
(strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE), |
| 112 |
> |
CMDLINE_PARSER_VERSION); |
| 113 |
|
} |
| 114 |
|
|
| 115 |
|
static void print_help_common(void) { |
| 124 |
|
printf("\n"); |
| 125 |
|
|
| 126 |
|
if (strlen(gengetopt_args_info_description) > 0) |
| 127 |
< |
printf("%s\n", gengetopt_args_info_description); |
| 127 |
> |
printf("%s\n\n", gengetopt_args_info_description); |
| 128 |
|
} |
| 129 |
|
|
| 130 |
|
void |
| 142 |
|
clear_given (args_info); |
| 143 |
|
clear_args (args_info); |
| 144 |
|
init_args_info (args_info); |
| 145 |
+ |
|
| 146 |
+ |
args_info->inputs = 0; |
| 147 |
+ |
args_info->inputs_num = 0; |
| 148 |
|
} |
| 149 |
|
|
| 150 |
|
void |
| 183 |
|
static void |
| 184 |
|
cmdline_parser_release (struct gengetopt_args_info *args_info) |
| 185 |
|
{ |
| 186 |
< |
|
| 186 |
> |
unsigned int i; |
| 187 |
|
free_string_field (&(args_info->input_arg)); |
| 188 |
|
free_string_field (&(args_info->input_orig)); |
| 189 |
|
free_string_field (&(args_info->output_arg)); |
| 192 |
|
free_string_field (&(args_info->model_orig)); |
| 193 |
|
|
| 194 |
|
|
| 195 |
+ |
for (i = 0; i < args_info->inputs_num; ++i) |
| 196 |
+ |
free (args_info->inputs [i]); |
| 197 |
|
|
| 198 |
+ |
if (args_info->inputs_num) |
| 199 |
+ |
free (args_info->inputs); |
| 200 |
+ |
|
| 201 |
|
clear_given (args_info); |
| 202 |
|
} |
| 203 |
|
|
| 204 |
|
|
| 205 |
|
static void |
| 206 |
< |
write_into_file(FILE *outfile, const char *opt, const char *arg, char *values[]) |
| 206 |
> |
write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[]) |
| 207 |
|
{ |
| 208 |
+ |
FIX_UNUSED (values); |
| 209 |
|
if (arg) { |
| 210 |
|
fprintf(outfile, "%s=\"%s\"\n", opt, arg); |
| 211 |
|
} else { |
| 273 |
|
char * |
| 274 |
|
gengetopt_strdup (const char *s) |
| 275 |
|
{ |
| 276 |
< |
char *result = NULL; |
| 276 |
> |
char *result = 0; |
| 277 |
|
if (!s) |
| 278 |
|
return result; |
| 279 |
|
|
| 285 |
|
} |
| 286 |
|
|
| 287 |
|
int |
| 288 |
< |
cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info) |
| 288 |
> |
cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info) |
| 289 |
|
{ |
| 290 |
|
return cmdline_parser2 (argc, argv, args_info, 0, 1, 1); |
| 291 |
|
} |
| 292 |
|
|
| 293 |
|
int |
| 294 |
< |
cmdline_parser_ext (int argc, char * const *argv, struct gengetopt_args_info *args_info, |
| 294 |
> |
cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info, |
| 295 |
|
struct cmdline_parser_params *params) |
| 296 |
|
{ |
| 297 |
|
int result; |
| 298 |
< |
result = cmdline_parser_internal (argc, argv, args_info, params, NULL); |
| 298 |
> |
result = cmdline_parser_internal (argc, argv, args_info, params, 0); |
| 299 |
|
|
| 300 |
|
if (result == EXIT_FAILURE) |
| 301 |
|
{ |
| 307 |
|
} |
| 308 |
|
|
| 309 |
|
int |
| 310 |
< |
cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) |
| 310 |
> |
cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) |
| 311 |
|
{ |
| 312 |
|
int result; |
| 313 |
|
struct cmdline_parser_params params; |
| 318 |
|
params.check_ambiguity = 0; |
| 319 |
|
params.print_errors = 1; |
| 320 |
|
|
| 321 |
< |
result = cmdline_parser_internal (argc, argv, args_info, ¶ms, NULL); |
| 321 |
> |
result = cmdline_parser_internal (argc, argv, args_info, ¶ms, 0); |
| 322 |
|
|
| 323 |
|
if (result == EXIT_FAILURE) |
| 324 |
|
{ |
| 334 |
|
{ |
| 335 |
|
int result = EXIT_SUCCESS; |
| 336 |
|
|
| 337 |
< |
if (cmdline_parser_required2(args_info, prog_name, NULL) > 0) |
| 337 |
> |
if (cmdline_parser_required2(args_info, prog_name, 0) > 0) |
| 338 |
|
result = EXIT_FAILURE; |
| 339 |
|
|
| 340 |
|
if (result == EXIT_FAILURE) |
| 350 |
|
cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error) |
| 351 |
|
{ |
| 352 |
|
int error = 0; |
| 353 |
+ |
FIX_UNUSED (additional_error); |
| 354 |
|
|
| 355 |
|
/* checks for required options */ |
| 356 |
|
if (! args_info->input_given) |
| 395 |
|
static |
| 396 |
|
int update_arg(void *field, char **orig_field, |
| 397 |
|
unsigned int *field_given, unsigned int *prev_given, |
| 398 |
< |
char *value, char *possible_values[], const char *default_value, |
| 398 |
> |
char *value, const char *possible_values[], |
| 399 |
> |
const char *default_value, |
| 400 |
|
cmdline_parser_arg_type arg_type, |
| 401 |
|
int check_ambiguity, int override, |
| 402 |
|
int no_free, int multiple_option, |
| 403 |
|
const char *long_opt, char short_opt, |
| 404 |
|
const char *additional_error) |
| 405 |
|
{ |
| 384 |
– |
char *stop_char = 0; |
| 406 |
|
const char *val = value; |
| 407 |
|
int found; |
| 408 |
|
char **string_field; |
| 409 |
+ |
FIX_UNUSED (field); |
| 410 |
|
|
| 389 |
– |
stop_char = 0; |
| 411 |
|
found = 0; |
| 412 |
|
|
| 413 |
|
if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given))) |
| 423 |
|
return 1; /* failure */ |
| 424 |
|
} |
| 425 |
|
|
| 426 |
+ |
FIX_UNUSED (default_value); |
| 427 |
|
|
| 428 |
|
if (field_given && *field_given && ! override) |
| 429 |
|
return 0; |
| 473 |
|
|
| 474 |
|
|
| 475 |
|
int |
| 476 |
< |
cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, |
| 476 |
> |
cmdline_parser_internal ( |
| 477 |
> |
int argc, char **argv, struct gengetopt_args_info *args_info, |
| 478 |
|
struct cmdline_parser_params *params, const char *additional_error) |
| 479 |
|
{ |
| 480 |
|
int c; /* Character of the parsed option. */ |
| 515 |
|
{ "output", 1, NULL, 'o' }, |
| 516 |
|
{ "model", 1, NULL, 0 }, |
| 517 |
|
{ "beads", 0, NULL, 'b' }, |
| 518 |
< |
{ NULL, 0, NULL, 0 } |
| 518 |
> |
{ 0, 0, 0, 0 } |
| 519 |
|
}; |
| 520 |
|
|
| 521 |
|
c = getopt_long (argc, argv, "hVi:o:b", long_options, &option_index); |
| 608 |
|
if ( error ) |
| 609 |
|
return (EXIT_FAILURE); |
| 610 |
|
|
| 611 |
+ |
if (optind < argc) |
| 612 |
+ |
{ |
| 613 |
+ |
int i = 0 ; |
| 614 |
+ |
int found_prog_name = 0; |
| 615 |
+ |
/* whether program name, i.e., argv[0], is in the remaining args |
| 616 |
+ |
(this may happen with some implementations of getopt, |
| 617 |
+ |
but surely not with the one included by gengetopt) */ |
| 618 |
+ |
|
| 619 |
+ |
i = optind; |
| 620 |
+ |
while (i < argc) |
| 621 |
+ |
if (argv[i++] == argv[0]) { |
| 622 |
+ |
found_prog_name = 1; |
| 623 |
+ |
break; |
| 624 |
+ |
} |
| 625 |
+ |
i = 0; |
| 626 |
+ |
|
| 627 |
+ |
args_info->inputs_num = argc - optind - found_prog_name; |
| 628 |
+ |
args_info->inputs = |
| 629 |
+ |
(char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ; |
| 630 |
+ |
while (optind < argc) |
| 631 |
+ |
if (argv[optind++] != argv[0]) |
| 632 |
+ |
args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind-1]) ; |
| 633 |
+ |
} |
| 634 |
+ |
|
| 635 |
|
return 0; |
| 636 |
|
|
| 637 |
|
failure: |