| 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 -u -F nanoparticleBuilderCmd |
| 4 |
> |
gengetopt -F nanoparticleBuilderCmd -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 "nanoparticleBuilderCmd.h" |
| 27 |
|
|
| 28 |
|
const char *gengetopt_args_info_purpose = "Builds spherical random or core-shell nanoparticles and outputs an OpenMD \nstartup file"; |
| 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 |
| 83 |
|
static |
| 84 |
|
void clear_args (struct gengetopt_args_info *args_info) |
| 85 |
|
{ |
| 86 |
+ |
FIX_UNUSED (args_info); |
| 87 |
|
args_info->output_arg = NULL; |
| 88 |
|
args_info->output_orig = NULL; |
| 89 |
|
args_info->latticeConstant_orig = NULL; |
| 109 |
|
args_info->latticeConstant_help = gengetopt_args_info_help[3] ; |
| 110 |
|
args_info->radius_help = gengetopt_args_info_help[4] ; |
| 111 |
|
args_info->shellRadius_help = gengetopt_args_info_help[5] ; |
| 112 |
< |
args_info->shellRadius_min = -1; |
| 113 |
< |
args_info->shellRadius_max = -1; |
| 112 |
> |
args_info->shellRadius_min = 0; |
| 113 |
> |
args_info->shellRadius_max = 0; |
| 114 |
|
args_info->molFraction_help = gengetopt_args_info_help[6] ; |
| 115 |
< |
args_info->molFraction_min = -1; |
| 116 |
< |
args_info->molFraction_max = -1; |
| 115 |
> |
args_info->molFraction_min = 0; |
| 116 |
> |
args_info->molFraction_max = 0; |
| 117 |
|
args_info->vacancyPercent_help = gengetopt_args_info_help[7] ; |
| 118 |
|
args_info->vacancyInnerRadius_help = gengetopt_args_info_help[8] ; |
| 119 |
|
args_info->vacancyOuterRadius_help = gengetopt_args_info_help[9] ; |
| 123 |
|
void |
| 124 |
|
cmdline_parser_print_version (void) |
| 125 |
|
{ |
| 126 |
< |
printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION); |
| 126 |
> |
printf ("%s %s\n", |
| 127 |
> |
(strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE), |
| 128 |
> |
CMDLINE_PARSER_VERSION); |
| 129 |
|
} |
| 130 |
|
|
| 131 |
|
static void print_help_common(void) { |
| 140 |
|
printf("\n"); |
| 141 |
|
|
| 142 |
|
if (strlen(gengetopt_args_info_description) > 0) |
| 143 |
< |
printf("%s\n", gengetopt_args_info_description); |
| 143 |
> |
printf("%s\n\n", gengetopt_args_info_description); |
| 144 |
|
} |
| 145 |
|
|
| 146 |
|
void |
| 159 |
|
clear_args (args_info); |
| 160 |
|
init_args_info (args_info); |
| 161 |
|
|
| 162 |
< |
args_info->inputs = NULL; |
| 162 |
> |
args_info->inputs = 0; |
| 163 |
|
args_info->inputs_num = 0; |
| 164 |
|
} |
| 165 |
|
|
| 199 |
|
union generic_value { |
| 200 |
|
double double_arg; |
| 201 |
|
char *string_arg; |
| 202 |
+ |
const char *default_string_arg; |
| 203 |
|
}; |
| 204 |
|
|
| 205 |
|
/** @brief holds temporary values for multiple options */ |
| 217 |
|
struct generic_list *new_node = (struct generic_list *) malloc (sizeof (struct generic_list)); |
| 218 |
|
new_node->next = *list; |
| 219 |
|
*list = new_node; |
| 220 |
< |
new_node->arg.string_arg = NULL; |
| 221 |
< |
new_node->orig = NULL; |
| 220 |
> |
new_node->arg.string_arg = 0; |
| 221 |
> |
new_node->orig = 0; |
| 222 |
|
} |
| 223 |
|
|
| 224 |
+ |
/** |
| 225 |
+ |
* The passed arg parameter is NOT set to 0 from this function |
| 226 |
+ |
*/ |
| 227 |
|
static void |
| 228 |
< |
free_multiple_field(unsigned int len, void **arg, char ***orig) |
| 228 |
> |
free_multiple_field(unsigned int len, void *arg, char ***orig) |
| 229 |
|
{ |
| 230 |
|
unsigned int i; |
| 231 |
< |
if (*arg) { |
| 231 |
> |
if (arg) { |
| 232 |
|
for (i = 0; i < len; ++i) |
| 233 |
|
{ |
| 234 |
|
free_string_field(&((*orig)[i])); |
| 235 |
|
} |
| 236 |
|
|
| 237 |
< |
free (*arg); |
| 227 |
< |
*arg = 0; |
| 237 |
> |
free (arg); |
| 238 |
|
free (*orig); |
| 239 |
|
*orig = 0; |
| 240 |
|
} |
| 249 |
|
free_string_field (&(args_info->output_orig)); |
| 250 |
|
free_string_field (&(args_info->latticeConstant_orig)); |
| 251 |
|
free_string_field (&(args_info->radius_orig)); |
| 252 |
< |
free_multiple_field (args_info->shellRadius_given, (void **)&(args_info->shellRadius_arg), &(args_info->shellRadius_orig)); |
| 253 |
< |
free_multiple_field (args_info->molFraction_given, (void **)&(args_info->molFraction_arg), &(args_info->molFraction_orig)); |
| 252 |
> |
free_multiple_field (args_info->shellRadius_given, (void *)(args_info->shellRadius_arg), &(args_info->shellRadius_orig)); |
| 253 |
> |
args_info->shellRadius_arg = 0; |
| 254 |
> |
free_multiple_field (args_info->molFraction_given, (void *)(args_info->molFraction_arg), &(args_info->molFraction_orig)); |
| 255 |
> |
args_info->molFraction_arg = 0; |
| 256 |
|
free_string_field (&(args_info->vacancyPercent_orig)); |
| 257 |
|
free_string_field (&(args_info->vacancyInnerRadius_orig)); |
| 258 |
|
free_string_field (&(args_info->vacancyOuterRadius_orig)); |
| 269 |
|
|
| 270 |
|
|
| 271 |
|
static void |
| 272 |
< |
write_into_file(FILE *outfile, const char *opt, const char *arg, char *values[]) |
| 272 |
> |
write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[]) |
| 273 |
|
{ |
| 274 |
+ |
FIX_UNUSED (values); |
| 275 |
|
if (arg) { |
| 276 |
|
fprintf(outfile, "%s=\"%s\"\n", opt, arg); |
| 277 |
|
} else { |
| 280 |
|
} |
| 281 |
|
|
| 282 |
|
static void |
| 283 |
< |
write_multiple_into_file(FILE *outfile, int len, const char *opt, char **arg, char *values[]) |
| 283 |
> |
write_multiple_into_file(FILE *outfile, int len, const char *opt, char **arg, const char *values[]) |
| 284 |
|
{ |
| 285 |
|
int i; |
| 286 |
|
|
| 353 |
|
char * |
| 354 |
|
gengetopt_strdup (const char *s) |
| 355 |
|
{ |
| 356 |
< |
char *result = NULL; |
| 356 |
> |
char *result = 0; |
| 357 |
|
if (!s) |
| 358 |
|
return result; |
| 359 |
|
|
| 367 |
|
static char * |
| 368 |
|
get_multiple_arg_token(const char *arg) |
| 369 |
|
{ |
| 370 |
< |
char *tok, *ret; |
| 370 |
> |
const char *tok; |
| 371 |
> |
char *ret; |
| 372 |
|
size_t len, num_of_escape, i, j; |
| 373 |
|
|
| 374 |
|
if (!arg) |
| 375 |
< |
return NULL; |
| 375 |
> |
return 0; |
| 376 |
|
|
| 377 |
|
tok = strchr (arg, ','); |
| 378 |
|
num_of_escape = 0; |
| 416 |
|
return ret; |
| 417 |
|
} |
| 418 |
|
|
| 419 |
< |
static char * |
| 419 |
> |
static const char * |
| 420 |
|
get_multiple_arg_token_next(const char *arg) |
| 421 |
|
{ |
| 422 |
< |
char *tok; |
| 422 |
> |
const char *tok; |
| 423 |
|
|
| 424 |
|
if (!arg) |
| 425 |
< |
return NULL; |
| 425 |
> |
return 0; |
| 426 |
|
|
| 427 |
|
tok = strchr (arg, ','); |
| 428 |
|
|
| 445 |
|
} |
| 446 |
|
|
| 447 |
|
static int |
| 448 |
< |
check_multiple_option_occurrences(const char *prog_name, unsigned int option_given, int min, int max, const char *option_desc); |
| 448 |
> |
check_multiple_option_occurrences(const char *prog_name, unsigned int option_given, unsigned int min, unsigned int max, const char *option_desc); |
| 449 |
|
|
| 450 |
|
int |
| 451 |
< |
check_multiple_option_occurrences(const char *prog_name, unsigned int option_given, int min, int max, const char *option_desc) |
| 451 |
> |
check_multiple_option_occurrences(const char *prog_name, unsigned int option_given, unsigned int min, unsigned int max, const char *option_desc) |
| 452 |
|
{ |
| 453 |
|
int error = 0; |
| 454 |
|
|
| 455 |
< |
if (option_given && ! (min < 0 && max < 0)) |
| 455 |
> |
if (option_given && (min > 0 || max > 0)) |
| 456 |
|
{ |
| 457 |
< |
if (min >= 0 && max >= 0) |
| 457 |
> |
if (min > 0 && max > 0) |
| 458 |
|
{ |
| 459 |
|
if (min == max) |
| 460 |
|
{ |
| 461 |
|
/* specific occurrences */ |
| 462 |
< |
if (option_given != min) |
| 462 |
> |
if (option_given != (unsigned int) min) |
| 463 |
|
{ |
| 464 |
|
fprintf (stderr, "%s: %s option occurrences must be %d\n", |
| 465 |
|
prog_name, option_desc, min); |
| 466 |
|
error = 1; |
| 467 |
|
} |
| 468 |
|
} |
| 469 |
< |
else if (option_given < min |
| 470 |
< |
|| option_given > max) |
| 469 |
> |
else if (option_given < (unsigned int) min |
| 470 |
> |
|| option_given > (unsigned int) max) |
| 471 |
|
{ |
| 472 |
|
/* range occurrences */ |
| 473 |
|
fprintf (stderr, "%s: %s option occurrences must be between %d and %d\n", |
| 475 |
|
error = 1; |
| 476 |
|
} |
| 477 |
|
} |
| 478 |
< |
else if (min >= 0) |
| 478 |
> |
else if (min > 0) |
| 479 |
|
{ |
| 480 |
|
/* at least check */ |
| 481 |
|
if (option_given < min) |
| 485 |
|
error = 1; |
| 486 |
|
} |
| 487 |
|
} |
| 488 |
< |
else if (max >= 0) |
| 488 |
> |
else if (max > 0) |
| 489 |
|
{ |
| 490 |
|
/* at most check */ |
| 491 |
|
if (option_given > max) |
| 500 |
|
return error; |
| 501 |
|
} |
| 502 |
|
int |
| 503 |
< |
cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info) |
| 503 |
> |
cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info) |
| 504 |
|
{ |
| 505 |
|
return cmdline_parser2 (argc, argv, args_info, 0, 1, 1); |
| 506 |
|
} |
| 507 |
|
|
| 508 |
|
int |
| 509 |
< |
cmdline_parser_ext (int argc, char * const *argv, struct gengetopt_args_info *args_info, |
| 509 |
> |
cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info, |
| 510 |
|
struct cmdline_parser_params *params) |
| 511 |
|
{ |
| 512 |
|
int result; |
| 513 |
< |
result = cmdline_parser_internal (argc, argv, args_info, params, NULL); |
| 513 |
> |
result = cmdline_parser_internal (argc, argv, args_info, params, 0); |
| 514 |
|
|
| 515 |
|
if (result == EXIT_FAILURE) |
| 516 |
|
{ |
| 522 |
|
} |
| 523 |
|
|
| 524 |
|
int |
| 525 |
< |
cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) |
| 525 |
> |
cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) |
| 526 |
|
{ |
| 527 |
|
int result; |
| 528 |
|
struct cmdline_parser_params params; |
| 533 |
|
params.check_ambiguity = 0; |
| 534 |
|
params.print_errors = 1; |
| 535 |
|
|
| 536 |
< |
result = cmdline_parser_internal (argc, argv, args_info, ¶ms, NULL); |
| 536 |
> |
result = cmdline_parser_internal (argc, argv, args_info, ¶ms, 0); |
| 537 |
|
|
| 538 |
|
if (result == EXIT_FAILURE) |
| 539 |
|
{ |
| 549 |
|
{ |
| 550 |
|
int result = EXIT_SUCCESS; |
| 551 |
|
|
| 552 |
< |
if (cmdline_parser_required2(args_info, prog_name, NULL) > 0) |
| 552 |
> |
if (cmdline_parser_required2(args_info, prog_name, 0) > 0) |
| 553 |
|
result = EXIT_FAILURE; |
| 554 |
|
|
| 555 |
|
if (result == EXIT_FAILURE) |
| 565 |
|
cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error) |
| 566 |
|
{ |
| 567 |
|
int error = 0; |
| 568 |
+ |
FIX_UNUSED (additional_error); |
| 569 |
|
|
| 570 |
|
/* checks for required options */ |
| 571 |
|
if (! args_info->output_given) |
| 622 |
|
static |
| 623 |
|
int update_arg(void *field, char **orig_field, |
| 624 |
|
unsigned int *field_given, unsigned int *prev_given, |
| 625 |
< |
char *value, char *possible_values[], const char *default_value, |
| 625 |
> |
char *value, const char *possible_values[], |
| 626 |
> |
const char *default_value, |
| 627 |
|
cmdline_parser_arg_type arg_type, |
| 628 |
|
int check_ambiguity, int override, |
| 629 |
|
int no_free, int multiple_option, |
| 634 |
|
const char *val = value; |
| 635 |
|
int found; |
| 636 |
|
char **string_field; |
| 637 |
+ |
FIX_UNUSED (field); |
| 638 |
|
|
| 639 |
|
stop_char = 0; |
| 640 |
|
found = 0; |
| 652 |
|
return 1; /* failure */ |
| 653 |
|
} |
| 654 |
|
|
| 655 |
+ |
FIX_UNUSED (default_value); |
| 656 |
|
|
| 657 |
|
if (field_given && *field_given && ! override) |
| 658 |
|
return 0; |
| 717 |
|
static |
| 718 |
|
int update_multiple_arg_temp(struct generic_list **list, |
| 719 |
|
unsigned int *prev_given, const char *val, |
| 720 |
< |
char *possible_values[], const char *default_value, |
| 720 |
> |
const char *possible_values[], const char *default_value, |
| 721 |
|
cmdline_parser_arg_type arg_type, |
| 722 |
|
const char *long_opt, char short_opt, |
| 723 |
|
const char *additional_error) |
| 724 |
|
{ |
| 725 |
< |
char *multi_token, *multi_next; /* store single arguments */ |
| 725 |
> |
/* store single arguments */ |
| 726 |
> |
char *multi_token; |
| 727 |
> |
const char *multi_next; |
| 728 |
|
|
| 729 |
|
if (arg_type == ARG_NO) { |
| 730 |
|
(*prev_given)++; |
| 836 |
|
} |
| 837 |
|
if (!(*orig_field)) { |
| 838 |
|
*orig_field = (char **) malloc (sizeof (char *)); |
| 839 |
< |
(*orig_field)[0] = NULL; |
| 839 |
> |
(*orig_field)[0] = 0; |
| 840 |
|
} |
| 841 |
|
} |
| 842 |
|
} |
| 843 |
|
} |
| 844 |
|
|
| 845 |
|
int |
| 846 |
< |
cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, |
| 846 |
> |
cmdline_parser_internal ( |
| 847 |
> |
int argc, char **argv, struct gengetopt_args_info *args_info, |
| 848 |
|
struct cmdline_parser_params *params, const char *additional_error) |
| 849 |
|
{ |
| 850 |
|
int c; /* Character of the parsed option. */ |
| 891 |
|
{ "vacancyPercent", 1, NULL, 0 }, |
| 892 |
|
{ "vacancyInnerRadius", 1, NULL, 0 }, |
| 893 |
|
{ "vacancyOuterRadius", 1, NULL, 0 }, |
| 894 |
< |
{ NULL, 0, NULL, 0 } |
| 894 |
> |
{ 0, 0, 0, 0 } |
| 895 |
|
}; |
| 896 |
|
|
| 897 |
|
c = getopt_long (argc, argv, "hVo:", long_options, &option_index); |
| 1031 |
|
|
| 1032 |
|
update_multiple_arg((void *)&(args_info->shellRadius_arg), |
| 1033 |
|
&(args_info->shellRadius_orig), args_info->shellRadius_given, |
| 1034 |
< |
local_args_info.shellRadius_given, 0 , |
| 1034 |
> |
local_args_info.shellRadius_given, 0, |
| 1035 |
|
ARG_DOUBLE, shellRadius_list); |
| 1036 |
|
update_multiple_arg((void *)&(args_info->molFraction_arg), |
| 1037 |
|
&(args_info->molFraction_orig), args_info->molFraction_given, |
| 1038 |
< |
local_args_info.molFraction_given, 0 , |
| 1038 |
> |
local_args_info.molFraction_given, 0, |
| 1039 |
|
ARG_DOUBLE, molFraction_list); |
| 1040 |
|
|
| 1041 |
|
args_info->shellRadius_given += local_args_info.shellRadius_given; |