21#define FIX_UNUSED(X) (void) (X)
27const char *gengetopt_args_info_purpose =
"";
29const char *gengetopt_args_info_usage =
"Usage: randomBuilder [OPTIONS]... [FILES]...";
31const char *gengetopt_args_info_versiontext =
"";
33const char *gengetopt_args_info_description =
"";
35const char *gengetopt_args_info_help[] = {
36 " -h, --help Print help and exit",
37 " -V, --version Print version and exit",
38 " -o, --output=STRING Output file name (mandatory)",
39 " --density=DOUBLE density (g/cm^3) (mandatory)",
40 " --nx=INT number of unit cells in x (mandatory)",
41 " --ny=INT number of unit cells in y (mandatory)",
42 " --nz=INT number of unit cells in z (mandatory)",
43 " --molFraction=DOUBLE (Default) Builds a multi-component random mixed\n nanoparticle. Mole Fraction must be specified for\n each componet > 1 in MD file.",
44 " -l, --lattice=STRING Lattice Type (possible values=\"FCC\", \"BCC\",\n \"SC\")",
52} cmdline_parser_arg_type;
64cmdline_parser_required2 (
struct gengetopt_args_info *args_info,
const char *prog_name,
const char *additional_error);
66const char *cmdline_parser_lattice_values[] = {
"FCC",
"BCC",
"SC", 0};
69gengetopt_strdup (
const char *s);
88 FIX_UNUSED (args_info);
107 args_info->
help_help = gengetopt_args_info_help[0] ;
109 args_info->
output_help = gengetopt_args_info_help[2] ;
111 args_info->
nx_help = gengetopt_args_info_help[4] ;
112 args_info->
ny_help = gengetopt_args_info_help[5] ;
113 args_info->
nz_help = gengetopt_args_info_help[6] ;
122cmdline_parser_print_version (
void)
128 if (strlen(gengetopt_args_info_versiontext) > 0)
129 printf(
"\n%s\n", gengetopt_args_info_versiontext);
132static void print_help_common(
void) {
133 cmdline_parser_print_version ();
135 if (strlen(gengetopt_args_info_purpose) > 0)
136 printf(
"\n%s\n", gengetopt_args_info_purpose);
138 if (strlen(gengetopt_args_info_usage) > 0)
139 printf(
"\n%s\n", gengetopt_args_info_usage);
143 if (strlen(gengetopt_args_info_description) > 0)
144 printf(
"%s\n\n", gengetopt_args_info_description);
148cmdline_parser_print_help (
void)
152 while (gengetopt_args_info_help[i])
153 printf(
"%s\n", gengetopt_args_info_help[i++]);
159 clear_given (args_info);
160 clear_args (args_info);
161 init_args_info (args_info);
190free_string_field (
char **s)
204 const char *default_string_arg;
210 union generic_value arg;
212 struct generic_list *next;
218static void add_node(
struct generic_list **list) {
219 struct generic_list *new_node = (
struct generic_list *) malloc (
sizeof (
struct generic_list));
220 new_node->next = *list;
222 new_node->arg.string_arg = 0;
230free_multiple_field(
unsigned int len,
void *arg,
char ***orig)
234 for (i = 0; i < len; ++i)
236 free_string_field(&((*orig)[i]));
253 free_string_field (&(args_info->
nx_orig));
254 free_string_field (&(args_info->
ny_orig));
255 free_string_field (&(args_info->
nz_orig));
263 free (args_info->
inputs [i]);
268 clear_given (args_info);
279check_possible_values(
const char *val,
const char *values[])
289 for (i = 0, len = strlen(val); values[i]; ++i)
291 if (strncmp(val, values[i], len) == 0)
295 if (strlen(values[i]) == len)
303 return (found ? -2 : -1);
308write_into_file(FILE *outfile,
const char *opt,
const char *arg,
const char *values[])
313 found = check_possible_values(arg, values);
316 fprintf(outfile,
"%s=\"%s\" # %s\n", opt, arg, values[found]);
318 fprintf(outfile,
"%s=\"%s\"\n", opt, arg);
320 fprintf(outfile,
"%s\n", opt);
325write_multiple_into_file(FILE *outfile,
int len,
const char *opt,
char **arg,
const char *values[])
329 for (i = 0; i < len; ++i)
330 write_into_file(outfile, opt, (arg ? arg[i] : 0), values);
345 write_into_file(outfile,
"help", 0, 0 );
347 write_into_file(outfile,
"version", 0, 0 );
349 write_into_file(outfile,
"output", args_info->
output_orig, 0);
351 write_into_file(outfile,
"density", args_info->
density_orig, 0);
353 write_into_file(outfile,
"nx", args_info->
nx_orig, 0);
355 write_into_file(outfile,
"ny", args_info->
ny_orig, 0);
357 write_into_file(outfile,
"nz", args_info->
nz_orig, 0);
360 write_into_file(outfile,
"lattice", args_info->
lattice_orig, cmdline_parser_lattice_values);
373 outfile = fopen(filename,
"w");
381 i = cmdline_parser_dump(outfile, args_info);
390 cmdline_parser_release (args_info);
395gengetopt_strdup (
const char *s)
401 result = (
char*)malloc(strlen(s) + 1);
402 if (result == (
char*)0)
409get_multiple_arg_token(
const char *arg)
413 size_t len, num_of_escape, i, j;
418 tok = strchr (arg,
',');
424 if (*(tok-1) ==
'\\')
427 tok = strchr (tok+1,
',');
435 len = (size_t)(tok - arg + 1);
437 len = strlen (arg) + 1;
439 len -= num_of_escape;
441 ret = (
char *) malloc (len);
445 while (arg[i] && (j < len-1))
447 if (arg[i] ==
'\\' &&
461get_multiple_arg_token_next(
const char *arg)
468 tok = strchr (arg,
',');
473 if (*(tok-1) ==
'\\')
476 tok = strchr (tok+1,
',');
482 if (! tok || strlen(tok) == 1)
489check_multiple_option_occurrences(
const char *prog_name,
unsigned int option_given,
unsigned int min,
unsigned int max,
const char *option_desc);
492check_multiple_option_occurrences(
const char *prog_name,
unsigned int option_given,
unsigned int min,
unsigned int max,
const char *option_desc)
494 int error_occurred = 0;
496 if (option_given && (min > 0 || max > 0))
498 if (min > 0 && max > 0)
503 if (option_given != (
unsigned int) min)
505 fprintf (stderr,
"%s: %s option occurrences must be %d\n",
506 prog_name, option_desc, min);
510 else if (option_given < (
unsigned int) min
511 || option_given > (
unsigned int) max)
514 fprintf (stderr,
"%s: %s option occurrences must be between %d and %d\n",
515 prog_name, option_desc, min, max);
522 if (option_given < min)
524 fprintf (stderr,
"%s: %s option occurrences must be at least %d\n",
525 prog_name, option_desc, min);
532 if (option_given > max)
534 fprintf (stderr,
"%s: %s option occurrences must be at most %d\n",
535 prog_name, option_desc, max);
541 return error_occurred;
546 return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
554 result = cmdline_parser_internal (argc, argv, args_info, params, 0);
560cmdline_parser2 (
int argc,
char **argv,
struct gengetopt_args_info *args_info,
int override,
int initialize,
int check_required)
571 result = cmdline_parser_internal (argc, argv, args_info, ¶ms, 0);
579 int result = EXIT_SUCCESS;
581 if (cmdline_parser_required2(args_info, prog_name, 0) > 0)
582 result = EXIT_FAILURE;
588cmdline_parser_required2 (
struct gengetopt_args_info *args_info,
const char *prog_name,
const char *additional_error)
590 int error_occurred = 0;
591 FIX_UNUSED (additional_error);
596 fprintf (stderr,
"%s: '--output' ('-o') option required%s\n", prog_name, (additional_error ? additional_error :
""));
602 fprintf (stderr,
"%s: '--density' option required%s\n", prog_name, (additional_error ? additional_error :
""));
608 fprintf (stderr,
"%s: '--nx' option required%s\n", prog_name, (additional_error ? additional_error :
""));
614 fprintf (stderr,
"%s: '--ny' option required%s\n", prog_name, (additional_error ? additional_error :
""));
620 fprintf (stderr,
"%s: '--nz' option required%s\n", prog_name, (additional_error ? additional_error :
""));
630 return error_occurred;
688#ifndef required_argument
689#define required_argument 1
692#ifndef optional_argument
693#define optional_argument 2
696struct custom_getopt_data {
738static char *custom_optarg;
755static int custom_optind = 1;
761static int custom_opterr = 1;
767static int custom_optopt =
'?';
777static void exchange(
char **argv,
struct custom_getopt_data *d)
779 int bottom = d->first_nonopt;
780 int middle = d->last_nonopt;
781 int top = d->custom_optind;
790 while (top > middle && middle > bottom) {
791 if (top - middle > middle - bottom) {
793 int len = middle - bottom;
797 for (i = 0; i < len; i++) {
798 tem = argv[bottom + i];
800 argv[top - (middle - bottom) + i];
801 argv[top - (middle - bottom) + i] = tem;
807 int len = top - middle;
811 for (i = 0; i < len; i++) {
812 tem = argv[bottom + i];
813 argv[bottom + i] = argv[middle + i];
814 argv[middle + i] = tem;
821 d->first_nonopt += (d->custom_optind - d->last_nonopt);
822 d->last_nonopt = d->custom_optind;
826static void custom_getopt_initialize(
struct custom_getopt_data *d)
833 d->first_nonopt = d->last_nonopt = d->custom_optind;
838#define NONOPTION_P (argv[d->custom_optind][0] != '-' || argv[d->custom_optind][1] == '\0')
841static int shuffle_argv(
int argc,
char *
const *argv,
const struct option *longopts,
842 struct custom_getopt_data *d)
848 if (d->last_nonopt > d->custom_optind)
849 d->last_nonopt = d->custom_optind;
850 if (d->first_nonopt > d->custom_optind)
851 d->first_nonopt = d->custom_optind;
856 if (d->first_nonopt != d->last_nonopt &&
857 d->last_nonopt != d->custom_optind)
858 exchange((
char **) argv, d);
859 else if (d->last_nonopt != d->custom_optind)
860 d->first_nonopt = d->custom_optind;
865 while (d->custom_optind < argc && NONOPTION_P)
867 d->last_nonopt = d->custom_optind;
873 if (d->custom_optind != argc && !strcmp(argv[d->custom_optind],
"--")) {
875 if (d->first_nonopt != d->last_nonopt
876 && d->last_nonopt != d->custom_optind)
877 exchange((
char **) argv, d);
878 else if (d->first_nonopt == d->last_nonopt)
879 d->first_nonopt = d->custom_optind;
880 d->last_nonopt = argc;
881 d->custom_optind = argc;
887 if (d->custom_optind == argc) {
892 if (d->first_nonopt != d->last_nonopt)
893 d->custom_optind = d->first_nonopt;
901 d->custom_optarg = argv[d->custom_optind++];
908 d->nextchar = (argv[d->custom_optind] + 1 + (longopts != NULL && argv[d->custom_optind][1] ==
'-'));
922static int check_long_opt(
int argc,
char *
const *argv,
const char *optstring,
923 const struct option *longopts,
int *longind,
924 int print_errors,
struct custom_getopt_data *d)
927 const struct option *p;
928 const struct option *pfound = NULL;
934 for (nameend = d->nextchar; *nameend && *nameend !=
'='; nameend++)
938 for (p = longopts, option_index = 0; p->name; p++, option_index++)
939 if (!strncmp(p->name, d->nextchar, nameend - d->nextchar)) {
940 if ((
unsigned int) (nameend - d->nextchar)
941 == (
unsigned int) strlen(p->name)) {
944 indfound = option_index;
947 }
else if (pfound == NULL) {
950 indfound = option_index;
951 }
else if (pfound->has_arg != p->has_arg
952 || pfound->flag != p->flag
953 || pfound->val != p->val)
957 if (ambig && !exact) {
960 "%s: option `%s' is ambiguous\n",
961 argv[0], argv[d->custom_optind]);
963 d->nextchar += strlen(d->nextchar);
965 d->custom_optopt = 0;
969 option_index = indfound;
972 if (pfound->has_arg != no_argument)
973 d->custom_optarg = nameend + 1;
976 if (argv[d->custom_optind - 1][1] ==
'-') {
978 fprintf(stderr,
"%s: option `--%s' doesn't allow an argument\n",
979 argv[0], pfound->name);
982 fprintf(stderr,
"%s: option `%c%s' doesn't allow an argument\n",
983 argv[0], argv[d->custom_optind - 1][0], pfound->name);
987 d->nextchar += strlen(d->nextchar);
988 d->custom_optopt = pfound->val;
991 }
else if (pfound->has_arg == required_argument) {
992 if (d->custom_optind < argc)
993 d->custom_optarg = argv[d->custom_optind++];
997 "%s: option `%s' requires an argument\n",
999 argv[d->custom_optind - 1]);
1001 d->nextchar += strlen(d->nextchar);
1002 d->custom_optopt = pfound->val;
1003 return optstring[0] ==
':' ?
':' :
'?';
1006 d->nextchar += strlen(d->nextchar);
1007 if (longind != NULL)
1008 *longind = option_index;
1010 *(pfound->flag) = pfound->val;
1021 if (argv[d->custom_optind][1] ==
'-') {
1024 "%s: unrecognized option `--%s'\n",
1025 argv[0], d->nextchar);
1029 "%s: unrecognized option `%c%s'\n",
1030 argv[0], argv[d->custom_optind][0],
1034 d->nextchar = (
char *)
"";
1036 d->custom_optopt = 0;
1040static int check_short_opt(
int argc,
char *
const *argv,
const char *optstring,
1041 int print_errors,
struct custom_getopt_data *d)
1043 char c = *d->nextchar++;
1044 const char *temp = strchr(optstring, c);
1047 if (*d->nextchar ==
'\0')
1049 if (!temp || c ==
':') {
1051 fprintf(stderr,
"%s: invalid option -- %c\n", argv[0], c);
1053 d->custom_optopt = c;
1056 if (temp[1] ==
':') {
1057 if (temp[2] ==
':') {
1059 if (*d->nextchar !=
'\0') {
1060 d->custom_optarg = d->nextchar;
1063 d->custom_optarg = NULL;
1067 if (*d->nextchar !=
'\0') {
1068 d->custom_optarg = d->nextchar;
1075 }
else if (d->custom_optind == argc) {
1078 "%s: option requires an argument -- %c\n",
1081 d->custom_optopt = c;
1082 if (optstring[0] ==
':')
1092 d->custom_optarg = argv[d->custom_optind++];
1169static int getopt_internal_r(
int argc,
char *
const *argv,
const char *optstring,
1170 const struct option *longopts,
int *longind,
1171 struct custom_getopt_data *d)
1173 int ret, print_errors = d->custom_opterr;
1175 if (optstring[0] ==
':')
1179 d->custom_optarg = NULL;
1185 if (d->custom_optind == 0 || !d->initialized) {
1186 if (d->custom_optind == 0)
1187 d->custom_optind = 1;
1188 custom_getopt_initialize(d);
1190 if (d->nextchar == NULL || *d->nextchar ==
'\0') {
1191 ret = shuffle_argv(argc, argv, longopts, d);
1195 if (longopts && (argv[d->custom_optind][1] ==
'-' ))
1196 return check_long_opt(argc, argv, optstring, longopts,
1197 longind, print_errors, d);
1198 return check_short_opt(argc, argv, optstring, print_errors, d);
1201static int custom_getopt_internal(
int argc,
char *
const *argv,
const char *optstring,
1202 const struct option *longopts,
int *longind)
1206 static struct custom_getopt_data d;
1208 d.custom_optind = custom_optind;
1209 d.custom_opterr = custom_opterr;
1210 result = getopt_internal_r(argc, argv, optstring, longopts,
1212 custom_optind = d.custom_optind;
1213 custom_optarg = d.custom_optarg;
1214 custom_optopt = d.custom_optopt;
1218static int custom_getopt_long (
int argc,
char *
const *argv,
const char *options,
1219 const struct option *long_options,
int *opt_index)
1221 return custom_getopt_internal(argc, argv, options, long_options,
1226static char *package_name = 0;
1247int update_arg(
void *field,
char **orig_field,
1248 unsigned int *field_given,
unsigned int *prev_given,
1249 char *value,
const char *possible_values[],
1250 const char *default_value,
1251 cmdline_parser_arg_type arg_type,
1252 int check_ambiguity,
int override,
1253 int no_free,
int multiple_option,
1254 const char *long_opt,
char short_opt,
1255 const char *additional_error)
1257 char *stop_char = 0;
1258 const char *val = value;
1260 char **string_field;
1266 if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
1268 if (short_opt !=
'-')
1269 fprintf (stderr,
"%s: `--%s' (`-%c') option given more than once%s\n",
1270 package_name, long_opt, short_opt,
1271 (additional_error ? additional_error :
""));
1273 fprintf (stderr,
"%s: `--%s' option given more than once%s\n",
1274 package_name, long_opt,
1275 (additional_error ? additional_error :
""));
1279 if (possible_values && (found = check_possible_values((value ? value : default_value), possible_values)) < 0)
1281 if (short_opt !=
'-')
1282 fprintf (stderr,
"%s: %s argument, \"%s\", for option `--%s' (`-%c')%s\n",
1283 package_name, (found == -2) ?
"ambiguous" :
"invalid", value, long_opt, short_opt,
1284 (additional_error ? additional_error :
""));
1286 fprintf (stderr,
"%s: %s argument, \"%s\", for option `--%s'%s\n",
1287 package_name, (found == -2) ?
"ambiguous" :
"invalid", value, long_opt,
1288 (additional_error ? additional_error :
""));
1292 if (field_given && *field_given && !
override)
1298 if (possible_values)
1299 val = possible_values[found];
1303 if (val) *((
int *)field) = strtol (val, &stop_char, 0);
1306 if (val) *((
double *)field) = strtod (val, &stop_char);
1310 string_field = (
char **)field;
1311 if (!no_free && *string_field)
1312 free (*string_field);
1313 *string_field = gengetopt_strdup (val);
1324 if (val && !(stop_char && *stop_char ==
'\0')) {
1325 fprintf(stderr,
"%s: invalid numeric value: %s\n", package_name, val);
1338 if (value && orig_field) {
1340 *orig_field = value;
1344 *orig_field = gengetopt_strdup (value);
1357int update_multiple_arg_temp(
struct generic_list **list,
1358 unsigned int *prev_given,
const char *val,
1359 const char *possible_values[],
const char *default_value,
1360 cmdline_parser_arg_type arg_type,
1361 const char *long_opt,
char short_opt,
1362 const char *additional_error)
1366 const char *multi_next;
1368 if (arg_type == ARG_NO) {
1373 multi_token = get_multiple_arg_token(val);
1374 multi_next = get_multiple_arg_token_next (val);
1379 if (update_arg((
void *)&((*list)->arg), &((*list)->orig), 0,
1380 prev_given, multi_token, possible_values, default_value,
1381 arg_type, 0, 1, 1, 1, long_opt, short_opt, additional_error)) {
1382 if (multi_token) free(multi_token);
1388 multi_token = get_multiple_arg_token(multi_next);
1389 multi_next = get_multiple_arg_token_next (multi_next);
1402void free_list(
struct generic_list *list,
short string_arg)
1405 struct generic_list *tmp;
1409 if (string_arg && list->arg.string_arg)
1410 free (list->arg.string_arg);
1423void update_multiple_arg(
void *field,
char ***orig_field,
1424 unsigned int field_given,
unsigned int prev_given,
union generic_value *default_value,
1425 cmdline_parser_arg_type arg_type,
1426 struct generic_list *list)
1429 struct generic_list *tmp;
1431 if (prev_given && list) {
1432 *orig_field = (
char **) realloc (*orig_field, (field_given + prev_given) *
sizeof (
char *));
1436 *((
int **)field) = (
int *)realloc (*((
int **)field), (field_given + prev_given) *
sizeof (int));
break;
1438 *((
double **)field) = (
double *)realloc (*((
double **)field), (field_given + prev_given) *
sizeof (double));
break;
1440 *((
char ***)field) = (
char **)realloc (*((
char ***)field), (field_given + prev_given) *
sizeof (
char *));
break;
1445 for (i = (prev_given - 1); i >= 0; --i)
1451 (*((
int **)field))[i + field_given] = tmp->arg.int_arg;
break;
1453 (*((
double **)field))[i + field_given] = tmp->arg.double_arg;
break;
1455 (*((
char ***)field))[i + field_given] = tmp->arg.string_arg;
break;
1459 (*orig_field) [i + field_given] = list->orig;
1464 if (default_value && ! field_given) {
1467 if (! *((
int **)field)) {
1468 *((
int **)field) = (
int *)malloc (
sizeof (
int));
1469 (*((
int **)field))[0] = default_value->int_arg;
1473 if (! *((
double **)field)) {
1474 *((
double **)field) = (
double *)malloc (
sizeof (
double));
1475 (*((
double **)field))[0] = default_value->double_arg;
1479 if (! *((
char ***)field)) {
1480 *((
char ***)field) = (
char **)malloc (
sizeof (
char *));
1481 (*((
char ***)field))[0] = gengetopt_strdup(default_value->string_arg);
1486 if (!(*orig_field)) {
1487 *orig_field = (
char **) malloc (
sizeof (
char *));
1488 (*orig_field)[0] = 0;
1495cmdline_parser_internal (
1501 struct generic_list * molFraction_list = NULL;
1502 int error_occurred = 0;
1508 int check_ambiguity;
1515 package_name = argv[0];
1534 int option_index = 0;
1536 static struct option long_options[] = {
1537 {
"help", 0, NULL,
'h' },
1538 {
"version", 0, NULL,
'V' },
1539 {
"output", 1, NULL,
'o' },
1540 {
"density", 1, NULL, 0 },
1541 {
"nx", 1, NULL, 0 },
1542 {
"ny", 1, NULL, 0 },
1543 {
"nz", 1, NULL, 0 },
1544 {
"molFraction", 1, NULL, 0 },
1545 {
"lattice", 1, NULL,
'l' },
1549 custom_optarg = optarg;
1550 custom_optind = optind;
1551 custom_opterr = opterr;
1552 custom_optopt = optopt;
1554 c = custom_getopt_long (argc, argv,
"hVo:l:", long_options, &option_index);
1556 optarg = custom_optarg;
1557 optind = custom_optind;
1558 opterr = custom_opterr;
1559 optopt = custom_optopt;
1566 cmdline_parser_print_help ();
1567 cmdline_parser_free (&local_args_info);
1568 exit (EXIT_SUCCESS);
1571 cmdline_parser_print_version ();
1572 cmdline_parser_free (&local_args_info);
1573 exit (EXIT_SUCCESS);
1578 if (update_arg( (
void *)&(args_info->
output_arg),
1580 &(local_args_info.output_given), optarg, 0, 0, ARG_STRING,
1581 check_ambiguity,
override, 0, 0,
1590 if (update_arg( (
void *)&(args_info->
lattice_arg),
1592 &(local_args_info.lattice_given), optarg, cmdline_parser_lattice_values, 0, ARG_STRING,
1593 check_ambiguity,
override, 0, 0,
1602 if (strcmp (long_options[option_index].name,
"density") == 0)
1606 if (update_arg( (
void *)&(args_info->
density_arg),
1608 &(local_args_info.density_given), optarg, 0, 0, ARG_DOUBLE,
1609 check_ambiguity,
override, 0, 0,
1616 else if (strcmp (long_options[option_index].name,
"nx") == 0)
1620 if (update_arg( (
void *)&(args_info->
nx_arg),
1622 &(local_args_info.nx_given), optarg, 0, 0, ARG_INT,
1623 check_ambiguity,
override, 0, 0,
1630 else if (strcmp (long_options[option_index].name,
"ny") == 0)
1634 if (update_arg( (
void *)&(args_info->
ny_arg),
1636 &(local_args_info.ny_given), optarg, 0, 0, ARG_INT,
1637 check_ambiguity,
override, 0, 0,
1644 else if (strcmp (long_options[option_index].name,
"nz") == 0)
1648 if (update_arg( (
void *)&(args_info->
nz_arg),
1650 &(local_args_info.nz_given), optarg, 0, 0, ARG_INT,
1651 check_ambiguity,
override, 0, 0,
1658 else if (strcmp (long_options[option_index].name,
"molFraction") == 0)
1661 if (update_multiple_arg_temp(&molFraction_list,
1662 &(local_args_info.molFraction_given), optarg, 0, 0, ARG_DOUBLE,
1675 fprintf (stderr,
"%s: option unknown: %c%s\n",
CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error :
""));
1683 local_args_info.molFraction_given, 0,
1684 ARG_DOUBLE, molFraction_list);
1687 local_args_info.molFraction_given = 0;
1691 error_occurred += cmdline_parser_required2 (args_info, argv[0], additional_error);
1694 cmdline_parser_release (&local_args_info);
1696 if ( error_occurred )
1697 return (EXIT_FAILURE);
1702 int found_prog_name = 0;
1708 args_info->
inputs_num = argc - optind - found_prog_name;
1710 (
char **)(malloc ((args_info->
inputs_num)*
sizeof(
char *))) ;
1711 while (optind < argc)
1712 args_info->
inputs[ i++ ] = gengetopt_strdup (argv[optind++]) ;
1718 free_list (molFraction_list, 0 );
1720 cmdline_parser_release (&local_args_info);
1721 return (EXIT_FAILURE);
#define CMDLINE_PARSER_VERSION
the program version
#define CMDLINE_PARSER_PACKAGE_NAME
the complete program name (used for help and version)
#define CMDLINE_PARSER_PACKAGE
the program name (used for printing errors)
The header file for the command line option parser generated by GNU Gengetopt version 2....
The additional parameters to pass to parser functions.
int print_errors
whether getopt_long should print an error message for a bad option (default 1)
int check_required
whether to check that all required options were provided (default 1)
int check_ambiguity
whether to check for options already specified in the option structure gengetopt_args_info (default 0...
int initialize
whether to initialize the option structure gengetopt_args_info (default 1)
int override
whether to override possibly already present options (default 0)
Where the command line options are stored.
unsigned int output_given
Whether output was given.
char ** molFraction_orig
Builds a multi-component random alloy nanoparticle.
unsigned int density_given
Whether density was given.
char * output_orig
output file name original value given at command line.
const char * output_help
output file name help description.
unsigned int ny_given
Whether ny was given.
const char * molFraction_help
Builds a multi-component random alloy nanoparticle.
char * nx_orig
number of unit cells in x original value given at command line.
const char * ny_help
number of unit cells in y help description.
unsigned inputs_num
unamed options number
unsigned int nx_given
Whether nx was given.
unsigned int molFraction_given
Whether molFraction was given.
unsigned int nz_given
Whether nz was given.
unsigned int lattice_given
Whether lattice was given.
char * density_orig
density (g/cm^3) original value given at command line.
const char * lattice_help
Lattice Type help description.
const char * help_help
Print help and exit help description.
double * molFraction_arg
Builds a multi-component random alloy nanoparticle.
char * ny_orig
number of unit cells in y original value given at command line.
char * output_arg
output file name.
char ** inputs
unamed options (options without names)
unsigned int molFraction_min
Builds a multi-component random alloy nanoparticle.
const char * nx_help
number of unit cells in x help description.
int ny_arg
number of unit cells in y.
char * nz_orig
number of unit cells in z original value given at command line.
int nz_arg
number of unit cells in z.
unsigned int molFraction_max
Builds a multi-component random alloy nanoparticle.
const char * nz_help
number of unit cells in z help description.
double density_arg
density (g/cm^3).
unsigned int help_given
Whether help was given.
int nx_arg
number of unit cells in x.
char * lattice_orig
Lattice Type original value given at command line.
unsigned int version_given
Whether version was given.
const char * version_help
Print version and exit help description.
char * lattice_arg
Lattice Type.
const char * density_help
density (g/cm^3) help description.
int cmdline_parser_required(struct gengetopt_args_info *args_info, const char *prog_name)
Checks that all the required options were specified.
struct cmdline_parser_params * cmdline_parser_params_create(void)
Allocates dynamically a cmdline_parser_params structure and initializes all its fields to their defau...
void cmdline_parser_init(struct gengetopt_args_info *args_info)
Initializes the passed gengetopt_args_info structure's fields (also set default values for options th...
void cmdline_parser_params_init(struct cmdline_parser_params *params)
Initializes all the fields a cmdline_parser_params structure to their default values.