| 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 Dump2XYZCmd -u |
| 4 |
> |
gengetopt --file-name=Dump2XYZCmd --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 |
+ |
|
| 31 |
|
#include "Dump2XYZCmd.h" |
| 32 |
|
|
| 33 |
|
const char *gengetopt_args_info_purpose = ""; |
| 58 |
|
" -f, --forces Print forces xyz file (default=off)", |
| 59 |
|
" -u, --vectors Print vectors (dipoles, etc) in xyz file \n (default=off)", |
| 60 |
|
" -c, --charges Print charges in xyz file (default=off)", |
| 61 |
+ |
" -e, --efield Print electric field vector in xyz file \n (default=off)", |
| 62 |
|
0 |
| 63 |
|
}; |
| 64 |
|
|
| 74 |
|
void clear_args (struct gengetopt_args_info *args_info); |
| 75 |
|
|
| 76 |
|
static int |
| 77 |
< |
cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, |
| 77 |
> |
cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info, |
| 78 |
|
struct cmdline_parser_params *params, const char *additional_error); |
| 79 |
|
|
| 80 |
|
static int |
| 107 |
|
args_info->forces_given = 0 ; |
| 108 |
|
args_info->vectors_given = 0 ; |
| 109 |
|
args_info->charges_given = 0 ; |
| 110 |
+ |
args_info->efield_given = 0 ; |
| 111 |
|
} |
| 112 |
|
|
| 113 |
|
static |
| 114 |
|
void clear_args (struct gengetopt_args_info *args_info) |
| 115 |
|
{ |
| 116 |
+ |
FIX_UNUSED (args_info); |
| 117 |
|
args_info->input_arg = NULL; |
| 118 |
|
args_info->input_orig = NULL; |
| 119 |
|
args_info->output_arg = NULL; |
| 142 |
|
args_info->forces_flag = 0; |
| 143 |
|
args_info->vectors_flag = 0; |
| 144 |
|
args_info->charges_flag = 0; |
| 145 |
+ |
args_info->efield_flag = 0; |
| 146 |
|
|
| 147 |
|
} |
| 148 |
|
|
| 172 |
|
args_info->forces_help = gengetopt_args_info_help[18] ; |
| 173 |
|
args_info->vectors_help = gengetopt_args_info_help[19] ; |
| 174 |
|
args_info->charges_help = gengetopt_args_info_help[20] ; |
| 175 |
+ |
args_info->efield_help = gengetopt_args_info_help[21] ; |
| 176 |
|
|
| 177 |
|
} |
| 178 |
|
|
| 179 |
|
void |
| 180 |
|
cmdline_parser_print_version (void) |
| 181 |
|
{ |
| 182 |
< |
printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION); |
| 182 |
> |
printf ("%s %s\n", |
| 183 |
> |
(strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE), |
| 184 |
> |
CMDLINE_PARSER_VERSION); |
| 185 |
|
} |
| 186 |
|
|
| 187 |
|
static void print_help_common(void) { |
| 196 |
|
printf("\n"); |
| 197 |
|
|
| 198 |
|
if (strlen(gengetopt_args_info_description) > 0) |
| 199 |
< |
printf("%s\n", gengetopt_args_info_description); |
| 199 |
> |
printf("%s\n\n", gengetopt_args_info_description); |
| 200 |
|
} |
| 201 |
|
|
| 202 |
|
void |
| 215 |
|
clear_args (args_info); |
| 216 |
|
init_args_info (args_info); |
| 217 |
|
|
| 218 |
< |
args_info->inputs = NULL; |
| 218 |
> |
args_info->inputs = 0; |
| 219 |
|
args_info->inputs_num = 0; |
| 220 |
|
} |
| 221 |
|
|
| 283 |
|
|
| 284 |
|
|
| 285 |
|
static void |
| 286 |
< |
write_into_file(FILE *outfile, const char *opt, const char *arg, char *values[]) |
| 286 |
> |
write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[]) |
| 287 |
|
{ |
| 288 |
+ |
FIX_UNUSED (values); |
| 289 |
|
if (arg) { |
| 290 |
|
fprintf(outfile, "%s=\"%s\"\n", opt, arg); |
| 291 |
|
} else { |
| 347 |
|
write_into_file(outfile, "vectors", 0, 0 ); |
| 348 |
|
if (args_info->charges_given) |
| 349 |
|
write_into_file(outfile, "charges", 0, 0 ); |
| 350 |
+ |
if (args_info->efield_given) |
| 351 |
+ |
write_into_file(outfile, "efield", 0, 0 ); |
| 352 |
|
|
| 353 |
|
|
| 354 |
|
i = EXIT_SUCCESS; |
| 385 |
|
char * |
| 386 |
|
gengetopt_strdup (const char *s) |
| 387 |
|
{ |
| 388 |
< |
char *result = NULL; |
| 388 |
> |
char *result = 0; |
| 389 |
|
if (!s) |
| 390 |
|
return result; |
| 391 |
|
|
| 397 |
|
} |
| 398 |
|
|
| 399 |
|
int |
| 400 |
< |
cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info) |
| 400 |
> |
cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info) |
| 401 |
|
{ |
| 402 |
|
return cmdline_parser2 (argc, argv, args_info, 0, 1, 1); |
| 403 |
|
} |
| 404 |
|
|
| 405 |
|
int |
| 406 |
< |
cmdline_parser_ext (int argc, char * const *argv, struct gengetopt_args_info *args_info, |
| 406 |
> |
cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info, |
| 407 |
|
struct cmdline_parser_params *params) |
| 408 |
|
{ |
| 409 |
|
int result; |
| 410 |
< |
result = cmdline_parser_internal (argc, argv, args_info, params, NULL); |
| 410 |
> |
result = cmdline_parser_internal (argc, argv, args_info, params, 0); |
| 411 |
|
|
| 412 |
|
if (result == EXIT_FAILURE) |
| 413 |
|
{ |
| 419 |
|
} |
| 420 |
|
|
| 421 |
|
int |
| 422 |
< |
cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) |
| 422 |
> |
cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) |
| 423 |
|
{ |
| 424 |
|
int result; |
| 425 |
|
struct cmdline_parser_params params; |
| 430 |
|
params.check_ambiguity = 0; |
| 431 |
|
params.print_errors = 1; |
| 432 |
|
|
| 433 |
< |
result = cmdline_parser_internal (argc, argv, args_info, ¶ms, NULL); |
| 433 |
> |
result = cmdline_parser_internal (argc, argv, args_info, ¶ms, 0); |
| 434 |
|
|
| 435 |
|
if (result == EXIT_FAILURE) |
| 436 |
|
{ |
| 446 |
|
{ |
| 447 |
|
int result = EXIT_SUCCESS; |
| 448 |
|
|
| 449 |
< |
if (cmdline_parser_required2(args_info, prog_name, NULL) > 0) |
| 449 |
> |
if (cmdline_parser_required2(args_info, prog_name, 0) > 0) |
| 450 |
|
result = EXIT_FAILURE; |
| 451 |
|
|
| 452 |
|
if (result == EXIT_FAILURE) |
| 462 |
|
cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error) |
| 463 |
|
{ |
| 464 |
|
int error = 0; |
| 465 |
+ |
FIX_UNUSED (additional_error); |
| 466 |
|
|
| 467 |
|
/* checks for required options */ |
| 468 |
|
if (! args_info->input_given) |
| 501 |
|
static |
| 502 |
|
int update_arg(void *field, char **orig_field, |
| 503 |
|
unsigned int *field_given, unsigned int *prev_given, |
| 504 |
< |
char *value, char *possible_values[], const char *default_value, |
| 504 |
> |
char *value, const char *possible_values[], |
| 505 |
> |
const char *default_value, |
| 506 |
|
cmdline_parser_arg_type arg_type, |
| 507 |
|
int check_ambiguity, int override, |
| 508 |
|
int no_free, int multiple_option, |
| 513 |
|
const char *val = value; |
| 514 |
|
int found; |
| 515 |
|
char **string_field; |
| 516 |
+ |
FIX_UNUSED (field); |
| 517 |
|
|
| 518 |
|
stop_char = 0; |
| 519 |
|
found = 0; |
| 531 |
|
return 1; /* failure */ |
| 532 |
|
} |
| 533 |
|
|
| 534 |
+ |
FIX_UNUSED (default_value); |
| 535 |
|
|
| 536 |
|
if (field_given && *field_given && ! override) |
| 537 |
|
return 0; |
| 595 |
|
|
| 596 |
|
|
| 597 |
|
int |
| 598 |
< |
cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, |
| 598 |
> |
cmdline_parser_internal ( |
| 599 |
> |
int argc, char **argv, struct gengetopt_args_info *args_info, |
| 600 |
|
struct cmdline_parser_params *params, const char *additional_error) |
| 601 |
|
{ |
| 602 |
|
int c; /* Character of the parsed option. */ |
| 652 |
|
{ "forces", 0, NULL, 'f' }, |
| 653 |
|
{ "vectors", 0, NULL, 'u' }, |
| 654 |
|
{ "charges", 0, NULL, 'c' }, |
| 655 |
< |
{ NULL, 0, NULL, 0 } |
| 655 |
> |
{ "efield", 0, NULL, 'e' }, |
| 656 |
> |
{ 0, 0, 0, 0 } |
| 657 |
|
}; |
| 658 |
|
|
| 659 |
< |
c = getopt_long (argc, argv, "hVi:o:n:wmzrts:bvfuc", long_options, &option_index); |
| 659 |
> |
c = getopt_long (argc, argv, "hVi:o:n:wmzrts:bvfuce", long_options, &option_index); |
| 660 |
|
|
| 661 |
|
if (c == -1) break; /* Exit from `while (1)' loop. */ |
| 662 |
|
|
| 816 |
|
if (update_arg((void *)&(args_info->charges_flag), 0, &(args_info->charges_given), |
| 817 |
|
&(local_args_info.charges_given), optarg, 0, 0, ARG_FLAG, |
| 818 |
|
check_ambiguity, override, 1, 0, "charges", 'c', |
| 819 |
+ |
additional_error)) |
| 820 |
+ |
goto failure; |
| 821 |
+ |
|
| 822 |
+ |
break; |
| 823 |
+ |
case 'e': /* Print electric field vector in xyz file. */ |
| 824 |
+ |
|
| 825 |
+ |
|
| 826 |
+ |
if (update_arg((void *)&(args_info->efield_flag), 0, &(args_info->efield_given), |
| 827 |
+ |
&(local_args_info.efield_given), optarg, 0, 0, ARG_FLAG, |
| 828 |
+ |
check_ambiguity, override, 1, 0, "efield", 'e', |
| 829 |
|
additional_error)) |
| 830 |
|
goto failure; |
| 831 |
|
|