ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/applications/sequentialProps/SequentialPropsCmd.cpp
Revision: 2081
Committed: Tue Mar 17 18:22:18 2015 UTC (10 years, 1 month ago) by gezelter
File size: 28392 byte(s)
Log Message:
ContactAngle2 now requires specification of the location of the 
droplet centroid in X&Y axes.

File Contents

# Content
1 /*
2 File autogenerated by gengetopt version 2.22.4
3 generated with the following command:
4 gengetopt --file-name=SequentialPropsCmd --unamed-opts
5
6 The developers of gengetopt consider the fixed text that goes in all
7 gengetopt output files to be in the public domain:
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 #ifdef WIN32
25 #include "utils/wingetopt.h"
26 #else
27 #include <getopt.h>
28 #endif
29
30 #include "SequentialPropsCmd.h"
31
32 const char *gengetopt_args_info_purpose = "";
33
34 const char *gengetopt_args_info_usage = "Usage: SequentialProps [OPTIONS]... [FILES]...";
35
36 const char *gengetopt_args_info_description = "";
37
38 const char *gengetopt_args_info_help[] = {
39 " -h, --help Print help and exit",
40 " -V, --version Print version and exit",
41 " -i, --input=filename input dump file",
42 " -o, --output=filename output file name",
43 " --sele1=selection script select first stuntdouble set",
44 " --sele2=selection script select second stuntdouble set (if sele2 is not \n set, use script from sele1)",
45 " -b, --nbins=INT number of bins (general purpose) \n (default=`100')",
46 " --nbins_z=INT number of bins in z axis (default=`100')",
47 " -x, --centroidX=DOUBLE Location of droplet centroid in x",
48 " -y, --centroidY=DOUBLE Location of droplet centroid in y",
49 " -z, --referenceZ=DOUBLE Reference z-height of solid surface",
50 " -r, --dropletR=DOUBLE Droplet radius in angstroms",
51 " --threshDens=DOUBLE Threshold Density in g/cm^3",
52 " --bufferLength=DOUBLE Buffer length in angstroms",
53 "\n Group: sequentialProps\n an option of this group is required",
54 " -c, --com selection center of mass",
55 " --ca1 contact angle of selection (using center of \n mass)",
56 " --ca2 contact angle of selection (using density \n profile)",
57 0
58 };
59
60 typedef enum {ARG_NO
61 , ARG_STRING
62 , ARG_INT
63 , ARG_DOUBLE
64 } cmdline_parser_arg_type;
65
66 static
67 void clear_given (struct gengetopt_args_info *args_info);
68 static
69 void clear_args (struct gengetopt_args_info *args_info);
70
71 static int
72 cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info,
73 struct cmdline_parser_params *params, const char *additional_error);
74
75 static int
76 cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error);
77
78 static char *
79 gengetopt_strdup (const char *s);
80
81 static
82 void clear_given (struct gengetopt_args_info *args_info)
83 {
84 args_info->help_given = 0 ;
85 args_info->version_given = 0 ;
86 args_info->input_given = 0 ;
87 args_info->output_given = 0 ;
88 args_info->sele1_given = 0 ;
89 args_info->sele2_given = 0 ;
90 args_info->nbins_given = 0 ;
91 args_info->nbins_z_given = 0 ;
92 args_info->centroidX_given = 0 ;
93 args_info->centroidY_given = 0 ;
94 args_info->referenceZ_given = 0 ;
95 args_info->dropletR_given = 0 ;
96 args_info->threshDens_given = 0 ;
97 args_info->bufferLength_given = 0 ;
98 args_info->com_given = 0 ;
99 args_info->ca1_given = 0 ;
100 args_info->ca2_given = 0 ;
101 args_info->sequentialProps_group_counter = 0 ;
102 }
103
104 static
105 void clear_args (struct gengetopt_args_info *args_info)
106 {
107 FIX_UNUSED (args_info);
108 args_info->input_arg = NULL;
109 args_info->input_orig = NULL;
110 args_info->output_arg = NULL;
111 args_info->output_orig = NULL;
112 args_info->sele1_arg = NULL;
113 args_info->sele1_orig = NULL;
114 args_info->sele2_arg = NULL;
115 args_info->sele2_orig = NULL;
116 args_info->nbins_arg = 100;
117 args_info->nbins_orig = NULL;
118 args_info->nbins_z_arg = 100;
119 args_info->nbins_z_orig = NULL;
120 args_info->centroidX_orig = NULL;
121 args_info->centroidY_orig = NULL;
122 args_info->referenceZ_orig = NULL;
123 args_info->dropletR_orig = NULL;
124 args_info->threshDens_orig = NULL;
125 args_info->bufferLength_orig = NULL;
126
127 }
128
129 static
130 void init_args_info(struct gengetopt_args_info *args_info)
131 {
132
133
134 args_info->help_help = gengetopt_args_info_help[0] ;
135 args_info->version_help = gengetopt_args_info_help[1] ;
136 args_info->input_help = gengetopt_args_info_help[2] ;
137 args_info->output_help = gengetopt_args_info_help[3] ;
138 args_info->sele1_help = gengetopt_args_info_help[4] ;
139 args_info->sele2_help = gengetopt_args_info_help[5] ;
140 args_info->nbins_help = gengetopt_args_info_help[6] ;
141 args_info->nbins_z_help = gengetopt_args_info_help[7] ;
142 args_info->centroidX_help = gengetopt_args_info_help[8] ;
143 args_info->centroidY_help = gengetopt_args_info_help[9] ;
144 args_info->referenceZ_help = gengetopt_args_info_help[10] ;
145 args_info->dropletR_help = gengetopt_args_info_help[11] ;
146 args_info->threshDens_help = gengetopt_args_info_help[12] ;
147 args_info->bufferLength_help = gengetopt_args_info_help[13] ;
148 args_info->com_help = gengetopt_args_info_help[15] ;
149 args_info->ca1_help = gengetopt_args_info_help[16] ;
150 args_info->ca2_help = gengetopt_args_info_help[17] ;
151
152 }
153
154 void
155 cmdline_parser_print_version (void)
156 {
157 printf ("%s %s\n",
158 (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE),
159 CMDLINE_PARSER_VERSION);
160 }
161
162 static void print_help_common(void) {
163 cmdline_parser_print_version ();
164
165 if (strlen(gengetopt_args_info_purpose) > 0)
166 printf("\n%s\n", gengetopt_args_info_purpose);
167
168 if (strlen(gengetopt_args_info_usage) > 0)
169 printf("\n%s\n", gengetopt_args_info_usage);
170
171 printf("\n");
172
173 if (strlen(gengetopt_args_info_description) > 0)
174 printf("%s\n\n", gengetopt_args_info_description);
175 }
176
177 void
178 cmdline_parser_print_help (void)
179 {
180 int i = 0;
181 print_help_common();
182 while (gengetopt_args_info_help[i])
183 printf("%s\n", gengetopt_args_info_help[i++]);
184 }
185
186 void
187 cmdline_parser_init (struct gengetopt_args_info *args_info)
188 {
189 clear_given (args_info);
190 clear_args (args_info);
191 init_args_info (args_info);
192
193 args_info->inputs = 0;
194 args_info->inputs_num = 0;
195 }
196
197 void
198 cmdline_parser_params_init(struct cmdline_parser_params *params)
199 {
200 if (params)
201 {
202 params->override = 0;
203 params->initialize = 1;
204 params->check_required = 1;
205 params->check_ambiguity = 0;
206 params->print_errors = 1;
207 }
208 }
209
210 struct cmdline_parser_params *
211 cmdline_parser_params_create(void)
212 {
213 struct cmdline_parser_params *params =
214 (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params));
215 cmdline_parser_params_init(params);
216 return params;
217 }
218
219 static void
220 free_string_field (char **s)
221 {
222 if (*s)
223 {
224 free (*s);
225 *s = 0;
226 }
227 }
228
229
230 static void
231 cmdline_parser_release (struct gengetopt_args_info *args_info)
232 {
233 unsigned int i;
234 free_string_field (&(args_info->input_arg));
235 free_string_field (&(args_info->input_orig));
236 free_string_field (&(args_info->output_arg));
237 free_string_field (&(args_info->output_orig));
238 free_string_field (&(args_info->sele1_arg));
239 free_string_field (&(args_info->sele1_orig));
240 free_string_field (&(args_info->sele2_arg));
241 free_string_field (&(args_info->sele2_orig));
242 free_string_field (&(args_info->nbins_orig));
243 free_string_field (&(args_info->nbins_z_orig));
244 free_string_field (&(args_info->centroidX_orig));
245 free_string_field (&(args_info->centroidY_orig));
246 free_string_field (&(args_info->referenceZ_orig));
247 free_string_field (&(args_info->dropletR_orig));
248 free_string_field (&(args_info->threshDens_orig));
249 free_string_field (&(args_info->bufferLength_orig));
250
251
252 for (i = 0; i < args_info->inputs_num; ++i)
253 free (args_info->inputs [i]);
254
255 if (args_info->inputs_num)
256 free (args_info->inputs);
257
258 clear_given (args_info);
259 }
260
261
262 static void
263 write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
264 {
265 FIX_UNUSED (values);
266 if (arg) {
267 fprintf(outfile, "%s=\"%s\"\n", opt, arg);
268 } else {
269 fprintf(outfile, "%s\n", opt);
270 }
271 }
272
273
274 int
275 cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
276 {
277 int i = 0;
278
279 if (!outfile)
280 {
281 fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE);
282 return EXIT_FAILURE;
283 }
284
285 if (args_info->help_given)
286 write_into_file(outfile, "help", 0, 0 );
287 if (args_info->version_given)
288 write_into_file(outfile, "version", 0, 0 );
289 if (args_info->input_given)
290 write_into_file(outfile, "input", args_info->input_orig, 0);
291 if (args_info->output_given)
292 write_into_file(outfile, "output", args_info->output_orig, 0);
293 if (args_info->sele1_given)
294 write_into_file(outfile, "sele1", args_info->sele1_orig, 0);
295 if (args_info->sele2_given)
296 write_into_file(outfile, "sele2", args_info->sele2_orig, 0);
297 if (args_info->nbins_given)
298 write_into_file(outfile, "nbins", args_info->nbins_orig, 0);
299 if (args_info->nbins_z_given)
300 write_into_file(outfile, "nbins_z", args_info->nbins_z_orig, 0);
301 if (args_info->centroidX_given)
302 write_into_file(outfile, "centroidX", args_info->centroidX_orig, 0);
303 if (args_info->centroidY_given)
304 write_into_file(outfile, "centroidY", args_info->centroidY_orig, 0);
305 if (args_info->referenceZ_given)
306 write_into_file(outfile, "referenceZ", args_info->referenceZ_orig, 0);
307 if (args_info->dropletR_given)
308 write_into_file(outfile, "dropletR", args_info->dropletR_orig, 0);
309 if (args_info->threshDens_given)
310 write_into_file(outfile, "threshDens", args_info->threshDens_orig, 0);
311 if (args_info->bufferLength_given)
312 write_into_file(outfile, "bufferLength", args_info->bufferLength_orig, 0);
313 if (args_info->com_given)
314 write_into_file(outfile, "com", 0, 0 );
315 if (args_info->ca1_given)
316 write_into_file(outfile, "ca1", 0, 0 );
317 if (args_info->ca2_given)
318 write_into_file(outfile, "ca2", 0, 0 );
319
320
321 i = EXIT_SUCCESS;
322 return i;
323 }
324
325 int
326 cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info)
327 {
328 FILE *outfile;
329 int i = 0;
330
331 outfile = fopen(filename, "w");
332
333 if (!outfile)
334 {
335 fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename);
336 return EXIT_FAILURE;
337 }
338
339 i = cmdline_parser_dump(outfile, args_info);
340 fclose (outfile);
341
342 return i;
343 }
344
345 void
346 cmdline_parser_free (struct gengetopt_args_info *args_info)
347 {
348 cmdline_parser_release (args_info);
349 }
350
351 /** @brief replacement of strdup, which is not standard */
352 char *
353 gengetopt_strdup (const char *s)
354 {
355 char *result = 0;
356 if (!s)
357 return result;
358
359 result = (char*)malloc(strlen(s) + 1);
360 if (result == (char*)0)
361 return (char*)0;
362 strcpy(result, s);
363 return result;
364 }
365
366 static void
367 reset_group_sequentialProps(struct gengetopt_args_info *args_info)
368 {
369 if (! args_info->sequentialProps_group_counter)
370 return;
371
372 args_info->com_given = 0 ;
373 args_info->ca1_given = 0 ;
374 args_info->ca2_given = 0 ;
375
376 args_info->sequentialProps_group_counter = 0;
377 }
378
379 int
380 cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info)
381 {
382 return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
383 }
384
385 int
386 cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info,
387 struct cmdline_parser_params *params)
388 {
389 int result;
390 result = cmdline_parser_internal (argc, argv, args_info, params, 0);
391
392 if (result == EXIT_FAILURE)
393 {
394 cmdline_parser_free (args_info);
395 exit (EXIT_FAILURE);
396 }
397
398 return result;
399 }
400
401 int
402 cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
403 {
404 int result;
405 struct cmdline_parser_params params;
406
407 params.override = override;
408 params.initialize = initialize;
409 params.check_required = check_required;
410 params.check_ambiguity = 0;
411 params.print_errors = 1;
412
413 result = cmdline_parser_internal (argc, argv, args_info, &params, 0);
414
415 if (result == EXIT_FAILURE)
416 {
417 cmdline_parser_free (args_info);
418 exit (EXIT_FAILURE);
419 }
420
421 return result;
422 }
423
424 int
425 cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
426 {
427 int result = EXIT_SUCCESS;
428
429 if (cmdline_parser_required2(args_info, prog_name, 0) > 0)
430 result = EXIT_FAILURE;
431
432 if (result == EXIT_FAILURE)
433 {
434 cmdline_parser_free (args_info);
435 exit (EXIT_FAILURE);
436 }
437
438 return result;
439 }
440
441 int
442 cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error)
443 {
444 int error = 0;
445 FIX_UNUSED (additional_error);
446
447 /* checks for required options */
448 if (! args_info->input_given)
449 {
450 fprintf (stderr, "%s: '--input' ('-i') option required%s\n", prog_name, (additional_error ? additional_error : ""));
451 error = 1;
452 }
453
454 if (args_info->sequentialProps_group_counter == 0)
455 {
456 fprintf (stderr, "%s: %d options of group sequentialProps were given. One is required%s.\n", prog_name, args_info->sequentialProps_group_counter, (additional_error ? additional_error : ""));
457 error = 1;
458 }
459
460
461 /* checks for dependences among options */
462
463 return error;
464 }
465
466
467 static char *package_name = 0;
468
469 /**
470 * @brief updates an option
471 * @param field the generic pointer to the field to update
472 * @param orig_field the pointer to the orig field
473 * @param field_given the pointer to the number of occurrence of this option
474 * @param prev_given the pointer to the number of occurrence already seen
475 * @param value the argument for this option (if null no arg was specified)
476 * @param possible_values the possible values for this option (if specified)
477 * @param default_value the default value (in case the option only accepts fixed values)
478 * @param arg_type the type of this option
479 * @param check_ambiguity @see cmdline_parser_params.check_ambiguity
480 * @param override @see cmdline_parser_params.override
481 * @param no_free whether to free a possible previous value
482 * @param multiple_option whether this is a multiple option
483 * @param long_opt the corresponding long option
484 * @param short_opt the corresponding short option (or '-' if none)
485 * @param additional_error possible further error specification
486 */
487 static
488 int update_arg(void *field, char **orig_field,
489 unsigned int *field_given, unsigned int *prev_given,
490 char *value, const char *possible_values[],
491 const char *default_value,
492 cmdline_parser_arg_type arg_type,
493 int check_ambiguity, int override,
494 int no_free, int multiple_option,
495 const char *long_opt, char short_opt,
496 const char *additional_error)
497 {
498 char *stop_char = 0;
499 const char *val = value;
500 int found;
501 char **string_field;
502 FIX_UNUSED (field);
503
504 stop_char = 0;
505 found = 0;
506
507 if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
508 {
509 if (short_opt != '-')
510 fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n",
511 package_name, long_opt, short_opt,
512 (additional_error ? additional_error : ""));
513 else
514 fprintf (stderr, "%s: `--%s' option given more than once%s\n",
515 package_name, long_opt,
516 (additional_error ? additional_error : ""));
517 return 1; /* failure */
518 }
519
520 FIX_UNUSED (default_value);
521
522 if (field_given && *field_given && ! override)
523 return 0;
524 if (prev_given)
525 (*prev_given)++;
526 if (field_given)
527 (*field_given)++;
528 if (possible_values)
529 val = possible_values[found];
530
531 switch(arg_type) {
532 case ARG_INT:
533 if (val) *((int *)field) = strtol (val, &stop_char, 0);
534 break;
535 case ARG_DOUBLE:
536 if (val) *((double *)field) = strtod (val, &stop_char);
537 break;
538 case ARG_STRING:
539 if (val) {
540 string_field = (char **)field;
541 if (!no_free && *string_field)
542 free (*string_field); /* free previous string */
543 *string_field = gengetopt_strdup (val);
544 }
545 break;
546 default:
547 break;
548 };
549
550 /* check numeric conversion */
551 switch(arg_type) {
552 case ARG_INT:
553 case ARG_DOUBLE:
554 if (val && !(stop_char && *stop_char == '\0')) {
555 fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
556 return 1; /* failure */
557 }
558 break;
559 default:
560 ;
561 };
562
563 /* store the original value */
564 switch(arg_type) {
565 case ARG_NO:
566 break;
567 default:
568 if (value && orig_field) {
569 if (no_free) {
570 *orig_field = value;
571 } else {
572 if (*orig_field)
573 free (*orig_field); /* free previous string */
574 *orig_field = gengetopt_strdup (value);
575 }
576 }
577 };
578
579 return 0; /* OK */
580 }
581
582
583 int
584 cmdline_parser_internal (
585 int argc, char **argv, struct gengetopt_args_info *args_info,
586 struct cmdline_parser_params *params, const char *additional_error)
587 {
588 int c; /* Character of the parsed option. */
589
590 int error = 0;
591 struct gengetopt_args_info local_args_info;
592
593 int override;
594 int initialize;
595 int check_required;
596 int check_ambiguity;
597
598 package_name = argv[0];
599
600 override = params->override;
601 initialize = params->initialize;
602 check_required = params->check_required;
603 check_ambiguity = params->check_ambiguity;
604
605 if (initialize)
606 cmdline_parser_init (args_info);
607
608 cmdline_parser_init (&local_args_info);
609
610 optarg = 0;
611 optind = 0;
612 opterr = params->print_errors;
613 optopt = '?';
614
615 while (1)
616 {
617 int option_index = 0;
618
619 static struct option long_options[] = {
620 { "help", 0, NULL, 'h' },
621 { "version", 0, NULL, 'V' },
622 { "input", 1, NULL, 'i' },
623 { "output", 1, NULL, 'o' },
624 { "sele1", 1, NULL, 0 },
625 { "sele2", 1, NULL, 0 },
626 { "nbins", 1, NULL, 'b' },
627 { "nbins_z", 1, NULL, 0 },
628 { "centroidX", 1, NULL, 'x' },
629 { "centroidY", 1, NULL, 'y' },
630 { "referenceZ", 1, NULL, 'z' },
631 { "dropletR", 1, NULL, 'r' },
632 { "threshDens", 1, NULL, 0 },
633 { "bufferLength", 1, NULL, 0 },
634 { "com", 0, NULL, 'c' },
635 { "ca1", 0, NULL, 0 },
636 { "ca2", 0, NULL, 0 },
637 { 0, 0, 0, 0 }
638 };
639
640 c = getopt_long (argc, argv, "hVi:o:b:x:y:z:r:c", long_options, &option_index);
641
642 if (c == -1) break; /* Exit from `while (1)' loop. */
643
644 switch (c)
645 {
646 case 'h': /* Print help and exit. */
647 cmdline_parser_print_help ();
648 cmdline_parser_free (&local_args_info);
649 exit (EXIT_SUCCESS);
650
651 case 'V': /* Print version and exit. */
652 cmdline_parser_print_version ();
653 cmdline_parser_free (&local_args_info);
654 exit (EXIT_SUCCESS);
655
656 case 'i': /* input dump file. */
657
658
659 if (update_arg( (void *)&(args_info->input_arg),
660 &(args_info->input_orig), &(args_info->input_given),
661 &(local_args_info.input_given), optarg, 0, 0, ARG_STRING,
662 check_ambiguity, override, 0, 0,
663 "input", 'i',
664 additional_error))
665 goto failure;
666
667 break;
668 case 'o': /* output file name. */
669
670
671 if (update_arg( (void *)&(args_info->output_arg),
672 &(args_info->output_orig), &(args_info->output_given),
673 &(local_args_info.output_given), optarg, 0, 0, ARG_STRING,
674 check_ambiguity, override, 0, 0,
675 "output", 'o',
676 additional_error))
677 goto failure;
678
679 break;
680 case 'b': /* number of bins (general purpose). */
681
682
683 if (update_arg( (void *)&(args_info->nbins_arg),
684 &(args_info->nbins_orig), &(args_info->nbins_given),
685 &(local_args_info.nbins_given), optarg, 0, "100", ARG_INT,
686 check_ambiguity, override, 0, 0,
687 "nbins", 'b',
688 additional_error))
689 goto failure;
690
691 break;
692 case 'x': /* Location of droplet centroid in x. */
693
694
695 if (update_arg( (void *)&(args_info->centroidX_arg),
696 &(args_info->centroidX_orig), &(args_info->centroidX_given),
697 &(local_args_info.centroidX_given), optarg, 0, 0, ARG_DOUBLE,
698 check_ambiguity, override, 0, 0,
699 "centroidX", 'x',
700 additional_error))
701 goto failure;
702
703 break;
704 case 'y': /* Location of droplet centroid in y. */
705
706
707 if (update_arg( (void *)&(args_info->centroidY_arg),
708 &(args_info->centroidY_orig), &(args_info->centroidY_given),
709 &(local_args_info.centroidY_given), optarg, 0, 0, ARG_DOUBLE,
710 check_ambiguity, override, 0, 0,
711 "centroidY", 'y',
712 additional_error))
713 goto failure;
714
715 break;
716 case 'z': /* Reference z-height of solid surface. */
717
718
719 if (update_arg( (void *)&(args_info->referenceZ_arg),
720 &(args_info->referenceZ_orig), &(args_info->referenceZ_given),
721 &(local_args_info.referenceZ_given), optarg, 0, 0, ARG_DOUBLE,
722 check_ambiguity, override, 0, 0,
723 "referenceZ", 'z',
724 additional_error))
725 goto failure;
726
727 break;
728 case 'r': /* Droplet radius in angstroms. */
729
730
731 if (update_arg( (void *)&(args_info->dropletR_arg),
732 &(args_info->dropletR_orig), &(args_info->dropletR_given),
733 &(local_args_info.dropletR_given), optarg, 0, 0, ARG_DOUBLE,
734 check_ambiguity, override, 0, 0,
735 "dropletR", 'r',
736 additional_error))
737 goto failure;
738
739 break;
740 case 'c': /* selection center of mass. */
741
742 if (args_info->sequentialProps_group_counter && override)
743 reset_group_sequentialProps (args_info);
744 args_info->sequentialProps_group_counter += 1;
745
746 if (update_arg( 0 ,
747 0 , &(args_info->com_given),
748 &(local_args_info.com_given), optarg, 0, 0, ARG_NO,
749 check_ambiguity, override, 0, 0,
750 "com", 'c',
751 additional_error))
752 goto failure;
753
754 break;
755
756 case 0: /* Long option with no short option */
757 /* select first stuntdouble set. */
758 if (strcmp (long_options[option_index].name, "sele1") == 0)
759 {
760
761
762 if (update_arg( (void *)&(args_info->sele1_arg),
763 &(args_info->sele1_orig), &(args_info->sele1_given),
764 &(local_args_info.sele1_given), optarg, 0, 0, ARG_STRING,
765 check_ambiguity, override, 0, 0,
766 "sele1", '-',
767 additional_error))
768 goto failure;
769
770 }
771 /* select second stuntdouble set (if sele2 is not set, use script from sele1). */
772 else if (strcmp (long_options[option_index].name, "sele2") == 0)
773 {
774
775
776 if (update_arg( (void *)&(args_info->sele2_arg),
777 &(args_info->sele2_orig), &(args_info->sele2_given),
778 &(local_args_info.sele2_given), optarg, 0, 0, ARG_STRING,
779 check_ambiguity, override, 0, 0,
780 "sele2", '-',
781 additional_error))
782 goto failure;
783
784 }
785 /* number of bins in z axis. */
786 else if (strcmp (long_options[option_index].name, "nbins_z") == 0)
787 {
788
789
790 if (update_arg( (void *)&(args_info->nbins_z_arg),
791 &(args_info->nbins_z_orig), &(args_info->nbins_z_given),
792 &(local_args_info.nbins_z_given), optarg, 0, "100", ARG_INT,
793 check_ambiguity, override, 0, 0,
794 "nbins_z", '-',
795 additional_error))
796 goto failure;
797
798 }
799 /* Threshold Density in g/cm^3. */
800 else if (strcmp (long_options[option_index].name, "threshDens") == 0)
801 {
802
803
804 if (update_arg( (void *)&(args_info->threshDens_arg),
805 &(args_info->threshDens_orig), &(args_info->threshDens_given),
806 &(local_args_info.threshDens_given), optarg, 0, 0, ARG_DOUBLE,
807 check_ambiguity, override, 0, 0,
808 "threshDens", '-',
809 additional_error))
810 goto failure;
811
812 }
813 /* Buffer length in angstroms. */
814 else if (strcmp (long_options[option_index].name, "bufferLength") == 0)
815 {
816
817
818 if (update_arg( (void *)&(args_info->bufferLength_arg),
819 &(args_info->bufferLength_orig), &(args_info->bufferLength_given),
820 &(local_args_info.bufferLength_given), optarg, 0, 0, ARG_DOUBLE,
821 check_ambiguity, override, 0, 0,
822 "bufferLength", '-',
823 additional_error))
824 goto failure;
825
826 }
827 /* contact angle of selection (using center of mass). */
828 else if (strcmp (long_options[option_index].name, "ca1") == 0)
829 {
830
831 if (args_info->sequentialProps_group_counter && override)
832 reset_group_sequentialProps (args_info);
833 args_info->sequentialProps_group_counter += 1;
834
835 if (update_arg( 0 ,
836 0 , &(args_info->ca1_given),
837 &(local_args_info.ca1_given), optarg, 0, 0, ARG_NO,
838 check_ambiguity, override, 0, 0,
839 "ca1", '-',
840 additional_error))
841 goto failure;
842
843 }
844 /* contact angle of selection (using density profile). */
845 else if (strcmp (long_options[option_index].name, "ca2") == 0)
846 {
847
848 if (args_info->sequentialProps_group_counter && override)
849 reset_group_sequentialProps (args_info);
850 args_info->sequentialProps_group_counter += 1;
851
852 if (update_arg( 0 ,
853 0 , &(args_info->ca2_given),
854 &(local_args_info.ca2_given), optarg, 0, 0, ARG_NO,
855 check_ambiguity, override, 0, 0,
856 "ca2", '-',
857 additional_error))
858 goto failure;
859
860 }
861
862 break;
863 case '?': /* Invalid option. */
864 /* `getopt_long' already printed an error message. */
865 goto failure;
866
867 default: /* bug: option not considered. */
868 fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
869 abort ();
870 } /* switch */
871 } /* while */
872
873 if (args_info->sequentialProps_group_counter > 1)
874 {
875 fprintf (stderr, "%s: %d options of group sequentialProps were given. One is required%s.\n", argv[0], args_info->sequentialProps_group_counter, (additional_error ? additional_error : ""));
876 error = 1;
877 }
878
879
880
881 if (check_required)
882 {
883 error += cmdline_parser_required2 (args_info, argv[0], additional_error);
884 }
885
886 cmdline_parser_release (&local_args_info);
887
888 if ( error )
889 return (EXIT_FAILURE);
890
891 if (optind < argc)
892 {
893 int i = 0 ;
894 int found_prog_name = 0;
895 /* whether program name, i.e., argv[0], is in the remaining args
896 (this may happen with some implementations of getopt,
897 but surely not with the one included by gengetopt) */
898
899 i = optind;
900 while (i < argc)
901 if (argv[i++] == argv[0]) {
902 found_prog_name = 1;
903 break;
904 }
905 i = 0;
906
907 args_info->inputs_num = argc - optind - found_prog_name;
908 args_info->inputs =
909 (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ;
910 while (optind < argc)
911 if (argv[optind++] != argv[0])
912 args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind-1]) ;
913 }
914
915 return 0;
916
917 failure:
918
919 cmdline_parser_release (&local_args_info);
920 return (EXIT_FAILURE);
921 }

Properties

Name Value
svn:eol-style native