| 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 -F HydroCmd -u |
| 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 |
+ |
#include <getopt.h> |
| 25 |
+ |
|
| 26 |
|
#include "HydroCmd.h" |
| 27 |
|
|
| 28 |
|
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 +-----------------------------------------------------------------------+"; |
| 29 |
|
|
| 30 |
< |
const char *gengetopt_args_info_usage = "Usage: Hydro [OPTIONS]..."; |
| 30 |
> |
const char *gengetopt_args_info_usage = "Usage: Hydro [OPTIONS]... [FILES]..."; |
| 31 |
|
|
| 32 |
|
const char *gengetopt_args_info_description = ""; |
| 33 |
|
|
| 52 |
|
void clear_args (struct gengetopt_args_info *args_info); |
| 53 |
|
|
| 54 |
|
static int |
| 55 |
< |
cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, |
| 55 |
> |
cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info, |
| 56 |
|
struct cmdline_parser_params *params, const char *additional_error); |
| 57 |
|
|
| 58 |
|
static int |
| 75 |
|
static |
| 76 |
|
void clear_args (struct gengetopt_args_info *args_info) |
| 77 |
|
{ |
| 78 |
+ |
FIX_UNUSED (args_info); |
| 79 |
|
args_info->input_arg = NULL; |
| 80 |
|
args_info->input_orig = NULL; |
| 81 |
|
args_info->output_arg = gengetopt_strdup ("hydro"); |
| 103 |
|
void |
| 104 |
|
cmdline_parser_print_version (void) |
| 105 |
|
{ |
| 106 |
< |
printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION); |
| 106 |
> |
printf ("%s %s\n", |
| 107 |
> |
(strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE), |
| 108 |
> |
CMDLINE_PARSER_VERSION); |
| 109 |
|
} |
| 110 |
|
|
| 111 |
|
static void print_help_common(void) { |
| 120 |
|
printf("\n"); |
| 121 |
|
|
| 122 |
|
if (strlen(gengetopt_args_info_description) > 0) |
| 123 |
< |
printf("%s\n", gengetopt_args_info_description); |
| 123 |
> |
printf("%s\n\n", gengetopt_args_info_description); |
| 124 |
|
} |
| 125 |
|
|
| 126 |
|
void |
| 138 |
|
clear_given (args_info); |
| 139 |
|
clear_args (args_info); |
| 140 |
|
init_args_info (args_info); |
| 141 |
+ |
|
| 142 |
+ |
args_info->inputs = 0; |
| 143 |
+ |
args_info->inputs_num = 0; |
| 144 |
|
} |
| 145 |
|
|
| 146 |
|
void |
| 179 |
|
static void |
| 180 |
|
cmdline_parser_release (struct gengetopt_args_info *args_info) |
| 181 |
|
{ |
| 182 |
< |
|
| 182 |
> |
unsigned int i; |
| 183 |
|
free_string_field (&(args_info->input_arg)); |
| 184 |
|
free_string_field (&(args_info->input_orig)); |
| 185 |
|
free_string_field (&(args_info->output_arg)); |
| 188 |
|
free_string_field (&(args_info->model_orig)); |
| 189 |
|
|
| 190 |
|
|
| 191 |
+ |
for (i = 0; i < args_info->inputs_num; ++i) |
| 192 |
+ |
free (args_info->inputs [i]); |
| 193 |
|
|
| 194 |
+ |
if (args_info->inputs_num) |
| 195 |
+ |
free (args_info->inputs); |
| 196 |
+ |
|
| 197 |
|
clear_given (args_info); |
| 198 |
|
} |
| 199 |
|
|
| 200 |
|
|
| 201 |
|
static void |
| 202 |
< |
write_into_file(FILE *outfile, const char *opt, const char *arg, char *values[]) |
| 202 |
> |
write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[]) |
| 203 |
|
{ |
| 204 |
+ |
FIX_UNUSED (values); |
| 205 |
|
if (arg) { |
| 206 |
|
fprintf(outfile, "%s=\"%s\"\n", opt, arg); |
| 207 |
|
} else { |
| 269 |
|
char * |
| 270 |
|
gengetopt_strdup (const char *s) |
| 271 |
|
{ |
| 272 |
< |
char *result = NULL; |
| 272 |
> |
char *result = 0; |
| 273 |
|
if (!s) |
| 274 |
|
return result; |
| 275 |
|
|
| 281 |
|
} |
| 282 |
|
|
| 283 |
|
int |
| 284 |
< |
cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info) |
| 284 |
> |
cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info) |
| 285 |
|
{ |
| 286 |
|
return cmdline_parser2 (argc, argv, args_info, 0, 1, 1); |
| 287 |
|
} |
| 288 |
|
|
| 289 |
|
int |
| 290 |
< |
cmdline_parser_ext (int argc, char * const *argv, struct gengetopt_args_info *args_info, |
| 290 |
> |
cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info, |
| 291 |
|
struct cmdline_parser_params *params) |
| 292 |
|
{ |
| 293 |
|
int result; |
| 294 |
< |
result = cmdline_parser_internal (argc, argv, args_info, params, NULL); |
| 294 |
> |
result = cmdline_parser_internal (argc, argv, args_info, params, 0); |
| 295 |
|
|
| 296 |
|
if (result == EXIT_FAILURE) |
| 297 |
|
{ |
| 303 |
|
} |
| 304 |
|
|
| 305 |
|
int |
| 306 |
< |
cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) |
| 306 |
> |
cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) |
| 307 |
|
{ |
| 308 |
|
int result; |
| 309 |
|
struct cmdline_parser_params params; |
| 314 |
|
params.check_ambiguity = 0; |
| 315 |
|
params.print_errors = 1; |
| 316 |
|
|
| 317 |
< |
result = cmdline_parser_internal (argc, argv, args_info, ¶ms, NULL); |
| 317 |
> |
result = cmdline_parser_internal (argc, argv, args_info, ¶ms, 0); |
| 318 |
|
|
| 319 |
|
if (result == EXIT_FAILURE) |
| 320 |
|
{ |
| 330 |
|
{ |
| 331 |
|
int result = EXIT_SUCCESS; |
| 332 |
|
|
| 333 |
< |
if (cmdline_parser_required2(args_info, prog_name, NULL) > 0) |
| 333 |
> |
if (cmdline_parser_required2(args_info, prog_name, 0) > 0) |
| 334 |
|
result = EXIT_FAILURE; |
| 335 |
|
|
| 336 |
|
if (result == EXIT_FAILURE) |
| 346 |
|
cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error) |
| 347 |
|
{ |
| 348 |
|
int error = 0; |
| 349 |
+ |
FIX_UNUSED (additional_error); |
| 350 |
|
|
| 351 |
|
/* checks for required options */ |
| 352 |
|
if (! args_info->input_given) |
| 391 |
|
static |
| 392 |
|
int update_arg(void *field, char **orig_field, |
| 393 |
|
unsigned int *field_given, unsigned int *prev_given, |
| 394 |
< |
char *value, char *possible_values[], const char *default_value, |
| 394 |
> |
char *value, const char *possible_values[], |
| 395 |
> |
const char *default_value, |
| 396 |
|
cmdline_parser_arg_type arg_type, |
| 397 |
|
int check_ambiguity, int override, |
| 398 |
|
int no_free, int multiple_option, |
| 403 |
|
const char *val = value; |
| 404 |
|
int found; |
| 405 |
|
char **string_field; |
| 406 |
+ |
FIX_UNUSED (field); |
| 407 |
|
|
| 408 |
|
stop_char = 0; |
| 409 |
|
found = 0; |
| 421 |
|
return 1; /* failure */ |
| 422 |
|
} |
| 423 |
|
|
| 424 |
+ |
FIX_UNUSED (default_value); |
| 425 |
|
|
| 426 |
|
if (field_given && *field_given && ! override) |
| 427 |
|
return 0; |
| 471 |
|
|
| 472 |
|
|
| 473 |
|
int |
| 474 |
< |
cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, |
| 474 |
> |
cmdline_parser_internal ( |
| 475 |
> |
int argc, char **argv, struct gengetopt_args_info *args_info, |
| 476 |
|
struct cmdline_parser_params *params, const char *additional_error) |
| 477 |
|
{ |
| 478 |
|
int c; /* Character of the parsed option. */ |
| 513 |
|
{ "output", 1, NULL, 'o' }, |
| 514 |
|
{ "model", 1, NULL, 0 }, |
| 515 |
|
{ "beads", 0, NULL, 'b' }, |
| 516 |
< |
{ NULL, 0, NULL, 0 } |
| 516 |
> |
{ 0, 0, 0, 0 } |
| 517 |
|
}; |
| 518 |
|
|
| 519 |
|
c = getopt_long (argc, argv, "hVi:o:b", long_options, &option_index); |
| 606 |
|
if ( error ) |
| 607 |
|
return (EXIT_FAILURE); |
| 608 |
|
|
| 609 |
+ |
if (optind < argc) |
| 610 |
+ |
{ |
| 611 |
+ |
int i = 0 ; |
| 612 |
+ |
int found_prog_name = 0; |
| 613 |
+ |
/* whether program name, i.e., argv[0], is in the remaining args |
| 614 |
+ |
(this may happen with some implementations of getopt, |
| 615 |
+ |
but surely not with the one included by gengetopt) */ |
| 616 |
+ |
|
| 617 |
+ |
i = optind; |
| 618 |
+ |
while (i < argc) |
| 619 |
+ |
if (argv[i++] == argv[0]) { |
| 620 |
+ |
found_prog_name = 1; |
| 621 |
+ |
break; |
| 622 |
+ |
} |
| 623 |
+ |
i = 0; |
| 624 |
+ |
|
| 625 |
+ |
args_info->inputs_num = argc - optind - found_prog_name; |
| 626 |
+ |
args_info->inputs = |
| 627 |
+ |
(char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ; |
| 628 |
+ |
while (optind < argc) |
| 629 |
+ |
if (argv[optind++] != argv[0]) |
| 630 |
+ |
args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind-1]) ; |
| 631 |
+ |
} |
| 632 |
+ |
|
| 633 |
|
return 0; |
| 634 |
|
|
| 635 |
|
failure: |