OpenMD 3.0
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
omd2omdCmd.cpp
1/*
2 File autogenerated by gengetopt version 2.23
3 generated with the following command:
4 gengetopt --no-handle-error --include-getopt --show-required --unamed-opts --file-name=omd2omdCmd --c-extension=cpp --header-extension=hpp
5
6 The developers of gengetopt consider the fixed text that goes in all
7 gengetopt output files to be in the public domain:
8 we make no copyright claims on it.
9*/
10
11/* If we use autoconf. */
12#ifdef HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <stdio.h>
17#include <stdlib.h>
18#include <string.h>
19
20#ifndef FIX_UNUSED
21#define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */
22#endif
23
24
25#include "omd2omdCmd.hpp"
26
27const char *gengetopt_args_info_purpose = "Takes a MetaData file and maps all StuntDoubles back to the periodic box.\nWill optionally replicate the system in the three box directions, or \ntranslate every object in the box and before writing out a new MetaData file.\n\nExample:\n omd2omd -i lipidSystem.omd -o bigLipidSystem.omd -x 2 -y 2 -z 1 -v 35.0";
28
29const char *gengetopt_args_info_usage = "Usage: omd2omd [OPTION]... [FILE]...";
30
31const char *gengetopt_args_info_versiontext = "";
32
33const char *gengetopt_args_info_description = "";
34
35const char *gengetopt_args_info_help[] = {
36 " -h, --help Print help and exit",
37 " -V, --version Print version and exit",
38 " -i, --input=filename use specified input (.omd, .dump, .eor) file\n (mandatory)",
39 " -o, --output=filename use specified output file (mandatory)",
40 " -x, --repeatX=INT make the system repeat in the x direction\n (default=`1')",
41 " -y, --repeatY=INT make the system repeat in the y direction\n (default=`1')",
42 " -z, --repeatZ=INT make the system repeat in the z direction\n (default=`1')",
43 " -t, --translateX=DOUBLE translate all x coordinates by some amount\n (default=`0.0')",
44 " -u, --translateY=DOUBLE translate all y coordinates by some amount\n (default=`0.0')",
45 " -v, --translateZ=DOUBLE translate all z coordinates by some amount\n (default=`0.0')",
46 " -p, --rotatePhi=DOUBLE rotate all coordinates Euler angle Phi\n (default=`0.0')",
47 " -q, --rotateTheta=DOUBLE rotate all coordinates Euler angle Theta\n (default=`0.0')",
48 " -r, --rotatePsi=DOUBLE rotate all coordinates Euler angle Psi\n (default=`0.0')",
49 " -m, --repairMolecules=INT rewrap molecules around the molecular center of\n mass (default=`1')",
50 0
51};
52
53typedef enum {ARG_NO
54 , ARG_STRING
55 , ARG_INT
56 , ARG_DOUBLE
57} cmdline_parser_arg_type;
58
59static
60void clear_given (struct gengetopt_args_info *args_info);
61static
62void clear_args (struct gengetopt_args_info *args_info);
63
64static int
65cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info,
66 struct cmdline_parser_params *params, const char *additional_error);
67
68static int
69cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error);
70
71static char *
72gengetopt_strdup (const char *s);
73
74static
75void clear_given (struct gengetopt_args_info *args_info)
76{
77 args_info->help_given = 0 ;
78 args_info->version_given = 0 ;
79 args_info->input_given = 0 ;
80 args_info->output_given = 0 ;
81 args_info->repeatX_given = 0 ;
82 args_info->repeatY_given = 0 ;
83 args_info->repeatZ_given = 0 ;
84 args_info->translateX_given = 0 ;
85 args_info->translateY_given = 0 ;
86 args_info->translateZ_given = 0 ;
87 args_info->rotatePhi_given = 0 ;
88 args_info->rotateTheta_given = 0 ;
89 args_info->rotatePsi_given = 0 ;
90 args_info->repairMolecules_given = 0 ;
91}
92
93static
94void clear_args (struct gengetopt_args_info *args_info)
95{
96 FIX_UNUSED (args_info);
97 args_info->input_arg = NULL;
98 args_info->input_orig = NULL;
99 args_info->output_arg = NULL;
100 args_info->output_orig = NULL;
101 args_info->repeatX_arg = 1;
102 args_info->repeatX_orig = NULL;
103 args_info->repeatY_arg = 1;
104 args_info->repeatY_orig = NULL;
105 args_info->repeatZ_arg = 1;
106 args_info->repeatZ_orig = NULL;
107 args_info->translateX_arg = 0.0;
108 args_info->translateX_orig = NULL;
109 args_info->translateY_arg = 0.0;
110 args_info->translateY_orig = NULL;
111 args_info->translateZ_arg = 0.0;
112 args_info->translateZ_orig = NULL;
113 args_info->rotatePhi_arg = 0.0;
114 args_info->rotatePhi_orig = NULL;
115 args_info->rotateTheta_arg = 0.0;
116 args_info->rotateTheta_orig = NULL;
117 args_info->rotatePsi_arg = 0.0;
118 args_info->rotatePsi_orig = NULL;
119 args_info->repairMolecules_arg = 1;
120 args_info->repairMolecules_orig = NULL;
121
122}
123
124static
125void init_args_info(struct gengetopt_args_info *args_info)
126{
127
128
129 args_info->help_help = gengetopt_args_info_help[0] ;
130 args_info->version_help = gengetopt_args_info_help[1] ;
131 args_info->input_help = gengetopt_args_info_help[2] ;
132 args_info->output_help = gengetopt_args_info_help[3] ;
133 args_info->repeatX_help = gengetopt_args_info_help[4] ;
134 args_info->repeatY_help = gengetopt_args_info_help[5] ;
135 args_info->repeatZ_help = gengetopt_args_info_help[6] ;
136 args_info->translateX_help = gengetopt_args_info_help[7] ;
137 args_info->translateY_help = gengetopt_args_info_help[8] ;
138 args_info->translateZ_help = gengetopt_args_info_help[9] ;
139 args_info->rotatePhi_help = gengetopt_args_info_help[10] ;
140 args_info->rotateTheta_help = gengetopt_args_info_help[11] ;
141 args_info->rotatePsi_help = gengetopt_args_info_help[12] ;
142 args_info->repairMolecules_help = gengetopt_args_info_help[13] ;
143
144}
145
146void
147cmdline_parser_print_version (void)
148{
149 printf ("%s %s\n",
152
153 if (strlen(gengetopt_args_info_versiontext) > 0)
154 printf("\n%s\n", gengetopt_args_info_versiontext);
155}
156
157static void print_help_common(void)
158{
159 size_t len_purpose = strlen(gengetopt_args_info_purpose);
160 size_t len_usage = strlen(gengetopt_args_info_usage);
161
162 if (len_usage > 0) {
163 printf("%s\n", gengetopt_args_info_usage);
164 }
165 if (len_purpose > 0) {
166 printf("%s\n", gengetopt_args_info_purpose);
167 }
168
169 if (len_usage || len_purpose) {
170 printf("\n");
171 }
172
173 if (strlen(gengetopt_args_info_description) > 0) {
174 printf("%s\n\n", gengetopt_args_info_description);
175 }
176}
177
178void
179cmdline_parser_print_help (void)
180{
181 int i = 0;
182 print_help_common();
183 while (gengetopt_args_info_help[i])
184 printf("%s\n", gengetopt_args_info_help[i++]);
185}
186
187void
188cmdline_parser_init (struct gengetopt_args_info *args_info)
189{
190 clear_given (args_info);
191 clear_args (args_info);
192 init_args_info (args_info);
193
194 args_info->inputs = 0;
195 args_info->inputs_num = 0;
196}
197
198void
199cmdline_parser_params_init(struct cmdline_parser_params *params)
200{
201 if (params)
202 {
203 params->override = 0;
204 params->initialize = 1;
205 params->check_required = 1;
206 params->check_ambiguity = 0;
207 params->print_errors = 1;
208 }
209}
210
213{
214 struct cmdline_parser_params *params =
215 (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params));
217 return params;
218}
219
220static void
221free_string_field (char **s)
222{
223 if (*s)
224 {
225 free (*s);
226 *s = 0;
227 }
228}
229
230
231static void
232cmdline_parser_release (struct gengetopt_args_info *args_info)
233{
234 unsigned int i;
235 free_string_field (&(args_info->input_arg));
236 free_string_field (&(args_info->input_orig));
237 free_string_field (&(args_info->output_arg));
238 free_string_field (&(args_info->output_orig));
239 free_string_field (&(args_info->repeatX_orig));
240 free_string_field (&(args_info->repeatY_orig));
241 free_string_field (&(args_info->repeatZ_orig));
242 free_string_field (&(args_info->translateX_orig));
243 free_string_field (&(args_info->translateY_orig));
244 free_string_field (&(args_info->translateZ_orig));
245 free_string_field (&(args_info->rotatePhi_orig));
246 free_string_field (&(args_info->rotateTheta_orig));
247 free_string_field (&(args_info->rotatePsi_orig));
248 free_string_field (&(args_info->repairMolecules_orig));
249
250
251 for (i = 0; i < args_info->inputs_num; ++i)
252 free (args_info->inputs [i]);
253
254 if (args_info->inputs_num)
255 free (args_info->inputs);
256
257 clear_given (args_info);
258}
259
260
261static void
262write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
263{
264 FIX_UNUSED (values);
265 if (arg) {
266 fprintf(outfile, "%s=\"%s\"\n", opt, arg);
267 } else {
268 fprintf(outfile, "%s\n", opt);
269 }
270}
271
272
273int
274cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
275{
276 int i = 0;
277
278 if (!outfile)
279 {
280 fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE);
281 return EXIT_FAILURE;
282 }
283
284 if (args_info->help_given)
285 write_into_file(outfile, "help", 0, 0 );
286 if (args_info->version_given)
287 write_into_file(outfile, "version", 0, 0 );
288 if (args_info->input_given)
289 write_into_file(outfile, "input", args_info->input_orig, 0);
290 if (args_info->output_given)
291 write_into_file(outfile, "output", args_info->output_orig, 0);
292 if (args_info->repeatX_given)
293 write_into_file(outfile, "repeatX", args_info->repeatX_orig, 0);
294 if (args_info->repeatY_given)
295 write_into_file(outfile, "repeatY", args_info->repeatY_orig, 0);
296 if (args_info->repeatZ_given)
297 write_into_file(outfile, "repeatZ", args_info->repeatZ_orig, 0);
298 if (args_info->translateX_given)
299 write_into_file(outfile, "translateX", args_info->translateX_orig, 0);
300 if (args_info->translateY_given)
301 write_into_file(outfile, "translateY", args_info->translateY_orig, 0);
302 if (args_info->translateZ_given)
303 write_into_file(outfile, "translateZ", args_info->translateZ_orig, 0);
304 if (args_info->rotatePhi_given)
305 write_into_file(outfile, "rotatePhi", args_info->rotatePhi_orig, 0);
306 if (args_info->rotateTheta_given)
307 write_into_file(outfile, "rotateTheta", args_info->rotateTheta_orig, 0);
308 if (args_info->rotatePsi_given)
309 write_into_file(outfile, "rotatePsi", args_info->rotatePsi_orig, 0);
310 if (args_info->repairMolecules_given)
311 write_into_file(outfile, "repairMolecules", args_info->repairMolecules_orig, 0);
312
313
314 i = EXIT_SUCCESS;
315 return i;
316}
317
318int
319cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info)
320{
321 FILE *outfile;
322 int i = 0;
323
324 outfile = fopen(filename, "w");
325
326 if (!outfile)
327 {
328 fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename);
329 return EXIT_FAILURE;
330 }
331
332 i = cmdline_parser_dump(outfile, args_info);
333 fclose (outfile);
334
335 return i;
336}
337
338void
340{
341 cmdline_parser_release (args_info);
342}
343
344/** @brief replacement of strdup, which is not standard */
345char *
346gengetopt_strdup (const char *s)
347{
348 char *result = 0;
349 if (!s)
350 return result;
351
352 result = (char*)malloc(strlen(s) + 1);
353 if (result == (char*)0)
354 return (char*)0;
355 strcpy(result, s);
356 return result;
357}
358
359int
360cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info)
361{
362 return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
363}
364
365int
366cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info,
367 struct cmdline_parser_params *params)
368{
369 int result;
370 result = cmdline_parser_internal (argc, argv, args_info, params, 0);
371
372 return result;
373}
374
375int
376cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
377{
378 int result;
379 struct cmdline_parser_params params;
380
381 params.override = override;
382 params.initialize = initialize;
384 params.check_ambiguity = 0;
385 params.print_errors = 1;
386
387 result = cmdline_parser_internal (argc, argv, args_info, &params, 0);
388
389 return result;
390}
391
392int
393cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
394{
395 int result = EXIT_SUCCESS;
396
397 if (cmdline_parser_required2(args_info, prog_name, 0) > 0)
398 result = EXIT_FAILURE;
399
400 return result;
401}
402
403int
404cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error)
405{
406 int error_occurred = 0;
407 FIX_UNUSED (additional_error);
408
409 /* checks for required options */
410 if (! args_info->input_given)
411 {
412 fprintf (stderr, "%s: '--input' ('-i') option required%s\n", prog_name, (additional_error ? additional_error : ""));
413 error_occurred = 1;
414 }
415
416 if (! args_info->output_given)
417 {
418 fprintf (stderr, "%s: '--output' ('-o') option required%s\n", prog_name, (additional_error ? additional_error : ""));
419 error_occurred = 1;
420 }
421
422
423 /* checks for dependences among options */
424
425 return error_occurred;
426}
427
428/*
429 * Extracted from the glibc source tree, version 2.3.6
430 *
431 * Licensed under the GPL as per the whole glibc source tree.
432 *
433 * This file was modified so that getopt_long can be called
434 * many times without risking previous memory to be spoiled.
435 *
436 * Modified by Andre Noll and Lorenzo Bettini for use in
437 * GNU gengetopt generated files.
438 *
439 */
440
441/*
442 * we must include anything we need since this file is not thought to be
443 * inserted in a file already using getopt.h
444 *
445 * Lorenzo
446 */
447
448struct option
449{
450 const char *name;
451 /* has_arg can't be an enum because some compilers complain about
452 type mismatches in all the code that assumes it is an int. */
453 int has_arg;
454 int *flag;
455 int val;
456};
457
458/* This version of `getopt' appears to the caller like standard Unix `getopt'
459 but it behaves differently for the user, since it allows the user
460 to intersperse the options with the other arguments.
461
462 As `getopt' works, it permutes the elements of ARGV so that,
463 when it is done, all the options precede everything else. Thus
464 all application programs are extended to handle flexible argument order.
465*/
466/*
467 If the field `flag' is not NULL, it points to a variable that is set
468 to the value given in the field `val' when the option is found, but
469 left unchanged if the option is not found.
470
471 To have a long-named option do something other than set an `int' to
472 a compiled-in constant, such as set a value from `custom_optarg', set the
473 option's `flag' field to zero and its `val' field to a nonzero
474 value (the equivalent single-letter option character, if there is
475 one). For long options that have a zero `flag' field, `getopt'
476 returns the contents of the `val' field. */
477
478/* Names for the values of the `has_arg' field of `struct option'. */
479#ifndef no_argument
480#define no_argument 0
481#endif
482
483#ifndef required_argument
484#define required_argument 1
485#endif
486
487#ifndef optional_argument
488#define optional_argument 2
489#endif
490
491struct custom_getopt_data {
492 /*
493 * These have exactly the same meaning as the corresponding global variables,
494 * except that they are used for the reentrant versions of getopt.
495 */
496 int custom_optind;
497 int custom_opterr;
498 int custom_optopt;
499 char *custom_optarg;
500
501 /* True if the internal members have been initialized. */
502 int initialized;
503
504 /*
505 * The next char to be scanned in the option-element in which the last option
506 * character we returned was found. This allows us to pick up the scan where
507 * we left off. If this is zero, or a null string, it means resume the scan by
508 * advancing to the next ARGV-element.
509 */
510 char *nextchar;
511
512 /*
513 * Describe the part of ARGV that contains non-options that have been skipped.
514 * `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is
515 * the index after the last of them.
516 */
517 int first_nonopt;
518 int last_nonopt;
519};
520
521/*
522 * the variables optarg, optind, opterr and optopt are renamed with
523 * the custom_ prefix so that they don't interfere with getopt ones.
524 *
525 * Moreover they're static so they are visible only from within the
526 * file where this very file will be included.
527 */
528
529/*
530 * For communication from `custom_getopt' to the caller. When `custom_getopt' finds an
531 * option that takes an argument, the argument value is returned here.
532 */
533static char *custom_optarg;
534
535/*
536 * Index in ARGV of the next element to be scanned. This is used for
537 * communication to and from the caller and for communication between
538 * successive calls to `custom_getopt'.
539 *
540 * On entry to `custom_getopt', 1 means this is the first call; initialize.
541 *
542 * When `custom_getopt' returns -1, this is the index of the first of the non-option
543 * elements that the caller should itself scan.
544 *
545 * Otherwise, `custom_optind' communicates from one call to the next how much of ARGV
546 * has been scanned so far.
547 *
548 * 1003.2 says this must be 1 before any call.
549 */
550static int custom_optind = 1;
551
552/*
553 * Callers store zero here to inhibit the error message for unrecognized
554 * options.
555 */
556static int custom_opterr = 1;
557
558/*
559 * Set to an option character which was unrecognized. This must be initialized
560 * on some systems to avoid linking in the system's own getopt implementation.
561 */
562static int custom_optopt = '?';
563
564/*
565 * Exchange two adjacent subsequences of ARGV. One subsequence is elements
566 * [first_nonopt,last_nonopt) which contains all the non-options that have been
567 * skipped so far. The other is elements [last_nonopt,custom_optind), which contains
568 * all the options processed since those non-options were skipped.
569 * `first_nonopt' and `last_nonopt' are relocated so that they describe the new
570 * indices of the non-options in ARGV after they are moved.
571 */
572static void exchange(char **argv, struct custom_getopt_data *d)
573{
574 int bottom = d->first_nonopt;
575 int middle = d->last_nonopt;
576 int top = d->custom_optind;
577 char *tem;
578
579 /*
580 * Exchange the shorter segment with the far end of the longer segment.
581 * That puts the shorter segment into the right place. It leaves the
582 * longer segment in the right place overall, but it consists of two
583 * parts that need to be swapped next.
584 */
585 while (top > middle && middle > bottom) {
586 if (top - middle > middle - bottom) {
587 /* Bottom segment is the short one. */
588 int len = middle - bottom;
589 int i;
590
591 /* Swap it with the top part of the top segment. */
592 for (i = 0; i < len; i++) {
593 tem = argv[bottom + i];
594 argv[bottom + i] =
595 argv[top - (middle - bottom) + i];
596 argv[top - (middle - bottom) + i] = tem;
597 }
598 /* Exclude the moved bottom segment from further swapping. */
599 top -= len;
600 } else {
601 /* Top segment is the short one. */
602 int len = top - middle;
603 int i;
604
605 /* Swap it with the bottom part of the bottom segment. */
606 for (i = 0; i < len; i++) {
607 tem = argv[bottom + i];
608 argv[bottom + i] = argv[middle + i];
609 argv[middle + i] = tem;
610 }
611 /* Exclude the moved top segment from further swapping. */
612 bottom += len;
613 }
614 }
615 /* Update records for the slots the non-options now occupy. */
616 d->first_nonopt += (d->custom_optind - d->last_nonopt);
617 d->last_nonopt = d->custom_optind;
618}
619
620/* Initialize the internal data when the first call is made. */
621static void custom_getopt_initialize(struct custom_getopt_data *d)
622{
623 /*
624 * Start processing options with ARGV-element 1 (since ARGV-element 0
625 * is the program name); the sequence of previously skipped non-option
626 * ARGV-elements is empty.
627 */
628 d->first_nonopt = d->last_nonopt = d->custom_optind;
629 d->nextchar = NULL;
630 d->initialized = 1;
631}
632
633#define NONOPTION_P (argv[d->custom_optind][0] != '-' || argv[d->custom_optind][1] == '\0')
634
635/* return: zero: continue, nonzero: return given value to user */
636static int shuffle_argv(int argc, char *const *argv,const struct option *longopts,
637 struct custom_getopt_data *d)
638{
639 /*
640 * Give FIRST_NONOPT & LAST_NONOPT rational values if CUSTOM_OPTIND has been
641 * moved back by the user (who may also have changed the arguments).
642 */
643 if (d->last_nonopt > d->custom_optind)
644 d->last_nonopt = d->custom_optind;
645 if (d->first_nonopt > d->custom_optind)
646 d->first_nonopt = d->custom_optind;
647 /*
648 * If we have just processed some options following some
649 * non-options, exchange them so that the options come first.
650 */
651 if (d->first_nonopt != d->last_nonopt &&
652 d->last_nonopt != d->custom_optind)
653 exchange((char **) argv, d);
654 else if (d->last_nonopt != d->custom_optind)
655 d->first_nonopt = d->custom_optind;
656 /*
657 * Skip any additional non-options and extend the range of
658 * non-options previously skipped.
659 */
660 while (d->custom_optind < argc && NONOPTION_P)
661 d->custom_optind++;
662 d->last_nonopt = d->custom_optind;
663 /*
664 * The special ARGV-element `--' means premature end of options. Skip
665 * it like a null option, then exchange with previous non-options as if
666 * it were an option, then skip everything else like a non-option.
667 */
668 if (d->custom_optind != argc && !strcmp(argv[d->custom_optind], "--")) {
669 d->custom_optind++;
670 if (d->first_nonopt != d->last_nonopt
671 && d->last_nonopt != d->custom_optind)
672 exchange((char **) argv, d);
673 else if (d->first_nonopt == d->last_nonopt)
674 d->first_nonopt = d->custom_optind;
675 d->last_nonopt = argc;
676 d->custom_optind = argc;
677 }
678 /*
679 * If we have done all the ARGV-elements, stop the scan and back over
680 * any non-options that we skipped and permuted.
681 */
682 if (d->custom_optind == argc) {
683 /*
684 * Set the next-arg-index to point at the non-options that we
685 * previously skipped, so the caller will digest them.
686 */
687 if (d->first_nonopt != d->last_nonopt)
688 d->custom_optind = d->first_nonopt;
689 return -1;
690 }
691 /*
692 * If we have come to a non-option and did not permute it, either stop
693 * the scan or describe it to the caller and pass it by.
694 */
695 if (NONOPTION_P) {
696 d->custom_optarg = argv[d->custom_optind++];
697 return 1;
698 }
699 /*
700 * We have found another option-ARGV-element. Skip the initial
701 * punctuation.
702 */
703 d->nextchar = (argv[d->custom_optind] + 1 + (longopts != NULL && argv[d->custom_optind][1] == '-'));
704 return 0;
705}
706
707/*
708 * Check whether the ARGV-element is a long option.
709 *
710 * If there's a long option "fubar" and the ARGV-element is "-fu", consider
711 * that an abbreviation of the long option, just like "--fu", and not "-f" with
712 * arg "u".
713 *
714 * This distinction seems to be the most useful approach.
715 *
716 */
717static int check_long_opt(int argc, char *const *argv, const char *optstring,
718 const struct option *longopts, int *longind,
719 int print_errors, struct custom_getopt_data *d)
720{
721 char *nameend;
722 const struct option *p;
723 const struct option *pfound = NULL;
724 int exact = 0;
725 int ambig = 0;
726 int indfound = -1;
727 int option_index;
728
729 for (nameend = d->nextchar; *nameend && *nameend != '='; nameend++)
730 /* Do nothing. */ ;
731
732 /* Test all long options for either exact match or abbreviated matches */
733 for (p = longopts, option_index = 0; p->name; p++, option_index++)
734 if (!strncmp(p->name, d->nextchar, nameend - d->nextchar)) {
735 if ((unsigned int) (nameend - d->nextchar)
736 == (unsigned int) strlen(p->name)) {
737 /* Exact match found. */
738 pfound = p;
739 indfound = option_index;
740 exact = 1;
741 break;
742 } else if (pfound == NULL) {
743 /* First nonexact match found. */
744 pfound = p;
745 indfound = option_index;
746 } else if (pfound->has_arg != p->has_arg
747 || pfound->flag != p->flag
748 || pfound->val != p->val)
749 /* Second or later nonexact match found. */
750 ambig = 1;
751 }
752 if (ambig && !exact) {
753 if (print_errors) {
754 fprintf(stderr,
755 "%s: option `%s' is ambiguous\n",
756 argv[0], argv[d->custom_optind]);
757 }
758 d->nextchar += strlen(d->nextchar);
759 d->custom_optind++;
760 d->custom_optopt = 0;
761 return '?';
762 }
763 if (pfound) {
764 option_index = indfound;
765 d->custom_optind++;
766 if (*nameend) {
767 if (pfound->has_arg != no_argument)
768 d->custom_optarg = nameend + 1;
769 else {
770 if (print_errors) {
771 if (argv[d->custom_optind - 1][1] == '-') {
772 /* --option */
773 fprintf(stderr, "%s: option `--%s' doesn't allow an argument\n",
774 argv[0], pfound->name);
775 } else {
776 /* +option or -option */
777 fprintf(stderr, "%s: option `%c%s' doesn't allow an argument\n",
778 argv[0], argv[d->custom_optind - 1][0], pfound->name);
779 }
780
781 }
782 d->nextchar += strlen(d->nextchar);
783 d->custom_optopt = pfound->val;
784 return '?';
785 }
786 } else if (pfound->has_arg == required_argument) {
787 if (d->custom_optind < argc)
788 d->custom_optarg = argv[d->custom_optind++];
789 else {
790 if (print_errors) {
791 fprintf(stderr,
792 "%s: option `%s' requires an argument\n",
793 argv[0],
794 argv[d->custom_optind - 1]);
795 }
796 d->nextchar += strlen(d->nextchar);
797 d->custom_optopt = pfound->val;
798 return optstring[0] == ':' ? ':' : '?';
799 }
800 }
801 d->nextchar += strlen(d->nextchar);
802 if (longind != NULL)
803 *longind = option_index;
804 if (pfound->flag) {
805 *(pfound->flag) = pfound->val;
806 return 0;
807 }
808 return pfound->val;
809 }
810 /*
811 * Can't find it as a long option. If this is not getopt_long_only, or
812 * the option starts with '--' or is not a valid short option, then
813 * it's an error. Otherwise interpret it as a short option.
814 */
815 if (print_errors) {
816 if (argv[d->custom_optind][1] == '-') {
817 /* --option */
818 fprintf(stderr,
819 "%s: unrecognized option `--%s'\n",
820 argv[0], d->nextchar);
821 } else {
822 /* +option or -option */
823 fprintf(stderr,
824 "%s: unrecognized option `%c%s'\n",
825 argv[0], argv[d->custom_optind][0],
826 d->nextchar);
827 }
828 }
829 d->nextchar = (char *) "";
830 d->custom_optind++;
831 d->custom_optopt = 0;
832 return '?';
833}
834
835static int check_short_opt(int argc, char *const *argv, const char *optstring,
836 int print_errors, struct custom_getopt_data *d)
837{
838 char c = *d->nextchar++;
839 const char *temp = strchr(optstring, c);
840
841 /* Increment `custom_optind' when we start to process its last character. */
842 if (*d->nextchar == '\0')
843 ++d->custom_optind;
844 if (!temp || c == ':') {
845 if (print_errors)
846 fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c);
847
848 d->custom_optopt = c;
849 return '?';
850 }
851 if (temp[1] == ':') {
852 if (temp[2] == ':') {
853 /* This is an option that accepts an argument optionally. */
854 if (*d->nextchar != '\0') {
855 d->custom_optarg = d->nextchar;
856 d->custom_optind++;
857 } else
858 d->custom_optarg = NULL;
859 d->nextchar = NULL;
860 } else {
861 /* This is an option that requires an argument. */
862 if (*d->nextchar != '\0') {
863 d->custom_optarg = d->nextchar;
864 /*
865 * If we end this ARGV-element by taking the
866 * rest as an arg, we must advance to the next
867 * element now.
868 */
869 d->custom_optind++;
870 } else if (d->custom_optind == argc) {
871 if (print_errors) {
872 fprintf(stderr,
873 "%s: option requires an argument -- %c\n",
874 argv[0], c);
875 }
876 d->custom_optopt = c;
877 if (optstring[0] == ':')
878 c = ':';
879 else
880 c = '?';
881 } else
882 /*
883 * We already incremented `custom_optind' once;
884 * increment it again when taking next ARGV-elt
885 * as argument.
886 */
887 d->custom_optarg = argv[d->custom_optind++];
888 d->nextchar = NULL;
889 }
890 }
891 return c;
892}
893
894/*
895 * Scan elements of ARGV for option characters given in OPTSTRING.
896 *
897 * If an element of ARGV starts with '-', and is not exactly "-" or "--",
898 * then it is an option element. The characters of this element
899 * (aside from the initial '-') are option characters. If `getopt'
900 * is called repeatedly, it returns successively each of the option characters
901 * from each of the option elements.
902 *
903 * If `getopt' finds another option character, it returns that character,
904 * updating `custom_optind' and `nextchar' so that the next call to `getopt' can
905 * resume the scan with the following option character or ARGV-element.
906 *
907 * If there are no more option characters, `getopt' returns -1.
908 * Then `custom_optind' is the index in ARGV of the first ARGV-element
909 * that is not an option. (The ARGV-elements have been permuted
910 * so that those that are not options now come last.)
911 *
912 * OPTSTRING is a string containing the legitimate option characters.
913 * If an option character is seen that is not listed in OPTSTRING,
914 * return '?' after printing an error message. If you set `custom_opterr' to
915 * zero, the error message is suppressed but we still return '?'.
916 *
917 * If a char in OPTSTRING is followed by a colon, that means it wants an arg,
918 * so the following text in the same ARGV-element, or the text of the following
919 * ARGV-element, is returned in `custom_optarg'. Two colons mean an option that
920 * wants an optional arg; if there is text in the current ARGV-element,
921 * it is returned in `custom_optarg', otherwise `custom_optarg' is set to zero.
922 *
923 * If OPTSTRING starts with `-' or `+', it requests different methods of
924 * handling the non-option ARGV-elements.
925 * See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
926 *
927 * Long-named options begin with `--' instead of `-'.
928 * Their names may be abbreviated as long as the abbreviation is unique
929 * or is an exact match for some defined option. If they have an
930 * argument, it follows the option name in the same ARGV-element, separated
931 * from the option name by a `=', or else the in next ARGV-element.
932 * When `getopt' finds a long-named option, it returns 0 if that option's
933 * `flag' field is nonzero, the value of the option's `val' field
934 * if the `flag' field is zero.
935 *
936 * The elements of ARGV aren't really const, because we permute them.
937 * But we pretend they're const in the prototype to be compatible
938 * with other systems.
939 *
940 * LONGOPTS is a vector of `struct option' terminated by an
941 * element containing a name which is zero.
942 *
943 * LONGIND returns the index in LONGOPT of the long-named option found.
944 * It is only valid when a long-named option has been found by the most
945 * recent call.
946 *
947 * Return the option character from OPTS just read. Return -1 when there are
948 * no more options. For unrecognized options, or options missing arguments,
949 * `custom_optopt' is set to the option letter, and '?' is returned.
950 *
951 * The OPTS string is a list of characters which are recognized option letters,
952 * optionally followed by colons, specifying that that letter takes an
953 * argument, to be placed in `custom_optarg'.
954 *
955 * If a letter in OPTS is followed by two colons, its argument is optional.
956 * This behavior is specific to the GNU `getopt'.
957 *
958 * The argument `--' causes premature termination of argument scanning,
959 * explicitly telling `getopt' that there are no more options. If OPTS begins
960 * with `--', then non-option arguments are treated as arguments to the option
961 * '\0'. This behavior is specific to the GNU `getopt'.
962 */
963
964static int getopt_internal_r(int argc, char *const *argv, const char *optstring,
965 const struct option *longopts, int *longind,
966 struct custom_getopt_data *d)
967{
968 int ret, print_errors = d->custom_opterr;
969
970 if (optstring[0] == ':')
971 print_errors = 0;
972 if (argc < 1)
973 return -1;
974 d->custom_optarg = NULL;
975
976 /*
977 * This is a big difference with GNU getopt, since optind == 0
978 * means initialization while here 1 means first call.
979 */
980 if (d->custom_optind == 0 || !d->initialized) {
981 if (d->custom_optind == 0)
982 d->custom_optind = 1; /* Don't scan ARGV[0], the program name. */
983 custom_getopt_initialize(d);
984 }
985 if (d->nextchar == NULL || *d->nextchar == '\0') {
986 ret = shuffle_argv(argc, argv, longopts, d);
987 if (ret)
988 return ret;
989 }
990 if (longopts && (argv[d->custom_optind][1] == '-' ))
991 return check_long_opt(argc, argv, optstring, longopts,
992 longind, print_errors, d);
993 return check_short_opt(argc, argv, optstring, print_errors, d);
994}
995
996static int custom_getopt_internal(int argc, char *const *argv, const char *optstring,
997 const struct option *longopts, int *longind)
998{
999 int result;
1000 /* Keep a global copy of all internal members of d */
1001 static struct custom_getopt_data d;
1002
1003 d.custom_optind = custom_optind;
1004 d.custom_opterr = custom_opterr;
1005 result = getopt_internal_r(argc, argv, optstring, longopts,
1006 longind, &d);
1007 custom_optind = d.custom_optind;
1008 custom_optarg = d.custom_optarg;
1009 custom_optopt = d.custom_optopt;
1010 return result;
1011}
1012
1013static int custom_getopt_long (int argc, char *const *argv, const char *options,
1014 const struct option *long_options, int *opt_index)
1015{
1016 return custom_getopt_internal(argc, argv, options, long_options,
1017 opt_index);
1018}
1019
1020
1021static char *package_name = 0;
1022
1023/**
1024 * @brief updates an option
1025 * @param field the generic pointer to the field to update
1026 * @param orig_field the pointer to the orig field
1027 * @param field_given the pointer to the number of occurrence of this option
1028 * @param prev_given the pointer to the number of occurrence already seen
1029 * @param value the argument for this option (if null no arg was specified)
1030 * @param possible_values the possible values for this option (if specified)
1031 * @param default_value the default value (in case the option only accepts fixed values)
1032 * @param arg_type the type of this option
1033 * @param check_ambiguity @see cmdline_parser_params.check_ambiguity
1034 * @param override @see cmdline_parser_params.override
1035 * @param no_free whether to free a possible previous value
1036 * @param multiple_option whether this is a multiple option
1037 * @param long_opt the corresponding long option
1038 * @param short_opt the corresponding short option (or '-' if none)
1039 * @param additional_error possible further error specification
1040 */
1041static
1042int update_arg(void *field, char **orig_field,
1043 unsigned int *field_given, unsigned int *prev_given,
1044 char *value, const char *possible_values[],
1045 const char *default_value,
1046 cmdline_parser_arg_type arg_type,
1047 int check_ambiguity, int override,
1048 int no_free, int multiple_option,
1049 const char *long_opt, char short_opt,
1050 const char *additional_error)
1051{
1052 char *stop_char = 0;
1053 const char *val = value;
1054 int found;
1055 char **string_field;
1056 FIX_UNUSED (field);
1057
1058 stop_char = 0;
1059 found = 0;
1060
1061 if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
1062 {
1063 if (short_opt != '-')
1064 fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n",
1065 package_name, long_opt, short_opt,
1066 (additional_error ? additional_error : ""));
1067 else
1068 fprintf (stderr, "%s: `--%s' option given more than once%s\n",
1069 package_name, long_opt,
1070 (additional_error ? additional_error : ""));
1071 return 1; /* failure */
1072 }
1073
1074 FIX_UNUSED (default_value);
1075
1076 if (field_given && *field_given && ! override)
1077 return 0;
1078 if (prev_given)
1079 (*prev_given)++;
1080 if (field_given)
1081 (*field_given)++;
1082 if (possible_values)
1083 val = possible_values[found];
1084
1085 switch(arg_type) {
1086 case ARG_INT:
1087 if (val) *((int *)field) = strtol (val, &stop_char, 0);
1088 break;
1089 case ARG_DOUBLE:
1090 if (val) *((double *)field) = strtod (val, &stop_char);
1091 break;
1092 case ARG_STRING:
1093 if (val) {
1094 string_field = (char **)field;
1095 if (!no_free && *string_field)
1096 free (*string_field); /* free previous string */
1097 *string_field = gengetopt_strdup (val);
1098 }
1099 break;
1100 default:
1101 break;
1102 };
1103
1104 /* check numeric conversion */
1105 switch(arg_type) {
1106 case ARG_INT:
1107 case ARG_DOUBLE:
1108 if (val && !(stop_char && *stop_char == '\0')) {
1109 fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
1110 return 1; /* failure */
1111 }
1112 break;
1113 default:
1114 ;
1115 };
1116
1117 /* store the original value */
1118 switch(arg_type) {
1119 case ARG_NO:
1120 break;
1121 default:
1122 if (value && orig_field) {
1123 if (no_free) {
1124 *orig_field = value;
1125 } else {
1126 if (*orig_field)
1127 free (*orig_field); /* free previous string */
1128 *orig_field = gengetopt_strdup (value);
1129 }
1130 }
1131 };
1132
1133 return 0; /* OK */
1134}
1135
1136
1137int
1138cmdline_parser_internal (
1139 int argc, char **argv, struct gengetopt_args_info *args_info,
1140 struct cmdline_parser_params *params, const char *additional_error)
1141{
1142 int c; /* Character of the parsed option. */
1143
1144 int error_occurred = 0;
1145 struct gengetopt_args_info local_args_info;
1146
1147 int override;
1148 int initialize;
1149 int check_required;
1150 int check_ambiguity;
1151
1152 char *optarg;
1153 int optind;
1154 int opterr;
1155 int optopt;
1156
1157 package_name = argv[0];
1158
1159 /* TODO: Why is this here? It is not used anywhere. */
1160 override = params->override;
1161 FIX_UNUSED(override);
1162
1163 initialize = params->initialize;
1164 check_required = params->check_required;
1165
1166 /* TODO: Why is this here? It is not used anywhere. */
1167 check_ambiguity = params->check_ambiguity;
1168 FIX_UNUSED(check_ambiguity);
1169
1170 if (initialize)
1171 cmdline_parser_init (args_info);
1172
1173 cmdline_parser_init (&local_args_info);
1174
1175 optarg = 0;
1176 optind = 0;
1177 opterr = params->print_errors;
1178 optopt = '?';
1179
1180 while (1)
1181 {
1182 int option_index = 0;
1183
1184 static struct option long_options[] = {
1185 { "help", 0, NULL, 'h' },
1186 { "version", 0, NULL, 'V' },
1187 { "input", 1, NULL, 'i' },
1188 { "output", 1, NULL, 'o' },
1189 { "repeatX", 1, NULL, 'x' },
1190 { "repeatY", 1, NULL, 'y' },
1191 { "repeatZ", 1, NULL, 'z' },
1192 { "translateX", 1, NULL, 't' },
1193 { "translateY", 1, NULL, 'u' },
1194 { "translateZ", 1, NULL, 'v' },
1195 { "rotatePhi", 1, NULL, 'p' },
1196 { "rotateTheta", 1, NULL, 'q' },
1197 { "rotatePsi", 1, NULL, 'r' },
1198 { "repairMolecules", 1, NULL, 'm' },
1199 { 0, 0, 0, 0 }
1200 };
1201
1202 custom_optarg = optarg;
1203 custom_optind = optind;
1204 custom_opterr = opterr;
1205 custom_optopt = optopt;
1206
1207 c = custom_getopt_long (argc, argv, "hVi:o:x:y:z:t:u:v:p:q:r:m:", long_options, &option_index);
1208
1209 optarg = custom_optarg;
1210 optind = custom_optind;
1211 opterr = custom_opterr;
1212 optopt = custom_optopt;
1213
1214 if (c == -1) break; /* Exit from `while (1)' loop. */
1215
1216 switch (c)
1217 {
1218 case 'h': /* Print help and exit. */
1219 cmdline_parser_print_help ();
1220 cmdline_parser_free (&local_args_info);
1221 exit (EXIT_SUCCESS);
1222
1223 case 'V': /* Print version and exit. */
1224 cmdline_parser_print_version ();
1225 cmdline_parser_free (&local_args_info);
1226 exit (EXIT_SUCCESS);
1227
1228 case 'i': /* use specified input (.omd, .dump, .eor) file. */
1229
1230
1231 if (update_arg( (void *)&(args_info->input_arg),
1232 &(args_info->input_orig), &(args_info->input_given),
1233 &(local_args_info.input_given), optarg, 0, 0, ARG_STRING,
1234 check_ambiguity, override, 0, 0,
1235 "input", 'i',
1236 additional_error))
1237 goto failure;
1238
1239 break;
1240 case 'o': /* use specified output file. */
1241
1242
1243 if (update_arg( (void *)&(args_info->output_arg),
1244 &(args_info->output_orig), &(args_info->output_given),
1245 &(local_args_info.output_given), optarg, 0, 0, ARG_STRING,
1246 check_ambiguity, override, 0, 0,
1247 "output", 'o',
1248 additional_error))
1249 goto failure;
1250
1251 break;
1252 case 'x': /* make the system repeat in the x direction. */
1253
1254
1255 if (update_arg( (void *)&(args_info->repeatX_arg),
1256 &(args_info->repeatX_orig), &(args_info->repeatX_given),
1257 &(local_args_info.repeatX_given), optarg, 0, "1", ARG_INT,
1258 check_ambiguity, override, 0, 0,
1259 "repeatX", 'x',
1260 additional_error))
1261 goto failure;
1262
1263 break;
1264 case 'y': /* make the system repeat in the y direction. */
1265
1266
1267 if (update_arg( (void *)&(args_info->repeatY_arg),
1268 &(args_info->repeatY_orig), &(args_info->repeatY_given),
1269 &(local_args_info.repeatY_given), optarg, 0, "1", ARG_INT,
1270 check_ambiguity, override, 0, 0,
1271 "repeatY", 'y',
1272 additional_error))
1273 goto failure;
1274
1275 break;
1276 case 'z': /* make the system repeat in the z direction. */
1277
1278
1279 if (update_arg( (void *)&(args_info->repeatZ_arg),
1280 &(args_info->repeatZ_orig), &(args_info->repeatZ_given),
1281 &(local_args_info.repeatZ_given), optarg, 0, "1", ARG_INT,
1282 check_ambiguity, override, 0, 0,
1283 "repeatZ", 'z',
1284 additional_error))
1285 goto failure;
1286
1287 break;
1288 case 't': /* translate all x coordinates by some amount. */
1289
1290
1291 if (update_arg( (void *)&(args_info->translateX_arg),
1292 &(args_info->translateX_orig), &(args_info->translateX_given),
1293 &(local_args_info.translateX_given), optarg, 0, "0.0", ARG_DOUBLE,
1294 check_ambiguity, override, 0, 0,
1295 "translateX", 't',
1296 additional_error))
1297 goto failure;
1298
1299 break;
1300 case 'u': /* translate all y coordinates by some amount. */
1301
1302
1303 if (update_arg( (void *)&(args_info->translateY_arg),
1304 &(args_info->translateY_orig), &(args_info->translateY_given),
1305 &(local_args_info.translateY_given), optarg, 0, "0.0", ARG_DOUBLE,
1306 check_ambiguity, override, 0, 0,
1307 "translateY", 'u',
1308 additional_error))
1309 goto failure;
1310
1311 break;
1312 case 'v': /* translate all z coordinates by some amount. */
1313
1314
1315 if (update_arg( (void *)&(args_info->translateZ_arg),
1316 &(args_info->translateZ_orig), &(args_info->translateZ_given),
1317 &(local_args_info.translateZ_given), optarg, 0, "0.0", ARG_DOUBLE,
1318 check_ambiguity, override, 0, 0,
1319 "translateZ", 'v',
1320 additional_error))
1321 goto failure;
1322
1323 break;
1324 case 'p': /* rotate all coordinates Euler angle Phi. */
1325
1326
1327 if (update_arg( (void *)&(args_info->rotatePhi_arg),
1328 &(args_info->rotatePhi_orig), &(args_info->rotatePhi_given),
1329 &(local_args_info.rotatePhi_given), optarg, 0, "0.0", ARG_DOUBLE,
1330 check_ambiguity, override, 0, 0,
1331 "rotatePhi", 'p',
1332 additional_error))
1333 goto failure;
1334
1335 break;
1336 case 'q': /* rotate all coordinates Euler angle Theta. */
1337
1338
1339 if (update_arg( (void *)&(args_info->rotateTheta_arg),
1340 &(args_info->rotateTheta_orig), &(args_info->rotateTheta_given),
1341 &(local_args_info.rotateTheta_given), optarg, 0, "0.0", ARG_DOUBLE,
1342 check_ambiguity, override, 0, 0,
1343 "rotateTheta", 'q',
1344 additional_error))
1345 goto failure;
1346
1347 break;
1348 case 'r': /* rotate all coordinates Euler angle Psi. */
1349
1350
1351 if (update_arg( (void *)&(args_info->rotatePsi_arg),
1352 &(args_info->rotatePsi_orig), &(args_info->rotatePsi_given),
1353 &(local_args_info.rotatePsi_given), optarg, 0, "0.0", ARG_DOUBLE,
1354 check_ambiguity, override, 0, 0,
1355 "rotatePsi", 'r',
1356 additional_error))
1357 goto failure;
1358
1359 break;
1360 case 'm': /* rewrap molecules around the molecular center of mass. */
1361
1362
1363 if (update_arg( (void *)&(args_info->repairMolecules_arg),
1364 &(args_info->repairMolecules_orig), &(args_info->repairMolecules_given),
1365 &(local_args_info.repairMolecules_given), optarg, 0, "1", ARG_INT,
1366 check_ambiguity, override, 0, 0,
1367 "repairMolecules", 'm',
1368 additional_error))
1369 goto failure;
1370
1371 break;
1372
1373 case 0: /* Long option with no short option */
1374 case '?': /* Invalid option. */
1375 /* `getopt_long' already printed an error message. */
1376 goto failure;
1377
1378 default: /* bug: option not considered. */
1379 fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
1380 abort ();
1381 } /* switch */
1382 } /* while */
1383
1384
1385
1386 if (check_required)
1387 {
1388 error_occurred += cmdline_parser_required2 (args_info, argv[0], additional_error);
1389 }
1390
1391 cmdline_parser_release (&local_args_info);
1392
1393 if ( error_occurred )
1394 return (EXIT_FAILURE);
1395
1396 if (optind < argc)
1397 {
1398 int i = 0 ;
1399 int found_prog_name = 0;
1400 /* whether program name, i.e., argv[0], is in the remaining args
1401 (this may happen with some implementations of getopt,
1402 but surely not with the one included by gengetopt) */
1403
1404
1405 args_info->inputs_num = argc - optind - found_prog_name;
1406 args_info->inputs =
1407 (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ;
1408 while (optind < argc)
1409 args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind++]) ;
1410 }
1411
1412 return 0;
1413
1414failure:
1415
1416 cmdline_parser_release (&local_args_info);
1417 return (EXIT_FAILURE);
1418}
1419/* vim: set ft=c noet ts=8 sts=8 sw=8 tw=80 nojs spell : */
#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.
double translateY_arg
translate all y coordinates by some amount (default='0.0').
int repeatY_arg
The number of images to repeat in the y direction (default='0').
const char * rotatePsi_help
rotate all coordinates Euler angle Psi help description.
unsigned int output_given
Whether output was given.
double translateZ_arg
translate all z coordinates by some amount (default='0.0').
char * rotateTheta_orig
rotate all coordinates Euler angle Theta original value given at command line.
unsigned int repeatY_given
Whether repeatY was given.
char * output_orig
output file name original value given at command line.
const char * output_help
output file name help description.
char * repeatX_orig
The number of images to repeat in the x direction original value given at command line.
char * translateY_orig
translate all y coordinates by some amount original value given at command line.
unsigned int repeatX_given
Whether repeatX was given.
int repeatX_arg
The number of images to repeat in the x direction (default='0').
char * repairMolecules_orig
rewrap molecules around the molecular center of mass original value given at command line.
char * translateX_orig
translate all x coordinates by some amount original value given at command line.
const char * repeatY_help
The number of images to repeat in the y direction help description.
double rotateTheta_arg
rotate all coordinates Euler angle Theta (default='0.0').
unsigned inputs_num
unamed options number
char * rotatePsi_orig
rotate all coordinates Euler angle Psi original value given at command line.
const char * repeatX_help
The number of images to repeat in the x direction help description.
unsigned int repairMolecules_given
Whether repairMolecules was given.
const char * translateX_help
translate all x coordinates by some amount help description.
int repairMolecules_arg
rewrap molecules around the molecular center of mass (default='1').
const char * help_help
Print help and exit help description.
char * output_arg
output file name.
char * repeatZ_orig
The number of images to repeat in the z direction original value given at command line.
const char * translateZ_help
translate all z coordinates by some amount help description.
char ** inputs
unamed options (options without names)
const char * translateY_help
translate all y coordinates by some amount help description.
char * input_arg
input dump file.
int repeatZ_arg
The number of images to repeat in the z direction (default='0').
unsigned int rotatePhi_given
Whether rotatePhi was given.
unsigned int repeatZ_given
Whether repeatZ was given.
unsigned int translateY_given
Whether translateY was given.
char * repeatY_orig
The number of images to repeat in the y direction original value given at command line.
double rotatePhi_arg
rotate all coordinates Euler angle Phi (default='0.0').
unsigned int help_given
Whether help was given.
unsigned int rotateTheta_given
Whether rotateTheta was given.
const char * repeatZ_help
The number of images to repeat in the z direction help description.
unsigned int rotatePsi_given
Whether rotatePsi was given.
unsigned int input_given
Whether input was given.
unsigned int translateX_given
Whether translateX was given.
char * translateZ_orig
translate all z coordinates by some amount original value given at command line.
const char * repairMolecules_help
rewrap molecules around the molecular center of mass help description.
unsigned int version_given
Whether version was given.
const char * version_help
Print version and exit help description.
char * input_orig
input dump file original value given at command line.
char * rotatePhi_orig
rotate all coordinates Euler angle Phi original value given at command line.
const char * rotateTheta_help
rotate all coordinates Euler angle Theta help description.
double rotatePsi_arg
rotate all coordinates Euler angle Psi (default='0.0').
const char * rotatePhi_help
rotate all coordinates Euler angle Phi help description.
double translateX_arg
translate all x coordinates by some amount (default='0.0').
const char * input_help
input dump file help description.
unsigned int translateZ_given
Whether translateZ was given.
int cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
Save the contents of the option struct into an already open FILE stream.
int cmdline_parser(int argc, char **argv, struct gengetopt_args_info *args_info)
The command line parser.
int cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info)
Save the contents of the option struct into a (text) file.
int cmdline_parser2(int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
The command line parser (version with additional parameters - deprecated)
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...
int cmdline_parser_ext(int argc, char **argv, struct gengetopt_args_info *args_info, struct cmdline_parser_params *params)
The command line parser (version with additional parameters)
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_free(struct gengetopt_args_info *args_info)
Deallocates the string fields of the gengetopt_args_info structure (but does not deallocate the struc...
void cmdline_parser_params_init(struct cmdline_parser_params *params)
Initializes all the fields a cmdline_parser_params structure to their default values.