ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/applications/nanoparticleBuilder/icosahedralBuilderCmd.cpp
Revision: 1876
Committed: Fri May 17 17:10:11 2013 UTC (11 years, 11 months ago) by gezelter
File size: 25028 byte(s)
Log Message:
Compilation and portability fixes

File Contents

# Content
1 /*
2 File autogenerated by gengetopt version 2.22.4
3 generated with the following command:
4 gengetopt --file-name=icosahedralBuilderCmd --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 "icosahedralBuilderCmd.h"
31
32 const char *gengetopt_args_info_purpose = "Builds icosahedral nanoparticles and outputs an OpenMD startup file";
33
34 const char *gengetopt_args_info_usage = "Usage: icosahedralBuilder [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 " -o, --output=STRING Output file name",
42 " -n, --shells=INT Nanoparticle shells",
43 " -d, --latticeConstant=DOUBLE Lattice spacing in Angstroms for cubic lattice.",
44 " -c, --columnAtoms=INT Number of atoms along central column \n (Decahedron only)",
45 " -t, --twinAtoms=INT Number of atoms along twin boundary (Decahedron \n only)",
46 " -p, --truncatedPlanes=INT Number of truncated planes (Curling-stone \n Decahedron only)",
47 "\n Group: clusterShape\n a cluster shape is required",
48 " --ico Create an Icosahedral cluster",
49 " --deca Create a regualar Decahedral cluster",
50 " --ino Create an Ino Decahedral cluster",
51 " --marks Create a Marks Decahedral cluster",
52 " --stone Create a Curling-stone Decahedral cluster",
53 0
54 };
55
56 typedef enum {ARG_NO
57 , ARG_STRING
58 , ARG_INT
59 , ARG_DOUBLE
60 } cmdline_parser_arg_type;
61
62 static
63 void clear_given (struct gengetopt_args_info *args_info);
64 static
65 void clear_args (struct gengetopt_args_info *args_info);
66
67 static int
68 cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info,
69 struct cmdline_parser_params *params, const char *additional_error);
70
71 static int
72 cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error);
73
74 static char *
75 gengetopt_strdup (const char *s);
76
77 static
78 void clear_given (struct gengetopt_args_info *args_info)
79 {
80 args_info->help_given = 0 ;
81 args_info->version_given = 0 ;
82 args_info->output_given = 0 ;
83 args_info->shells_given = 0 ;
84 args_info->latticeConstant_given = 0 ;
85 args_info->columnAtoms_given = 0 ;
86 args_info->twinAtoms_given = 0 ;
87 args_info->truncatedPlanes_given = 0 ;
88 args_info->ico_given = 0 ;
89 args_info->deca_given = 0 ;
90 args_info->ino_given = 0 ;
91 args_info->marks_given = 0 ;
92 args_info->stone_given = 0 ;
93 args_info->clusterShape_group_counter = 0 ;
94 }
95
96 static
97 void clear_args (struct gengetopt_args_info *args_info)
98 {
99 FIX_UNUSED (args_info);
100 args_info->output_arg = NULL;
101 args_info->output_orig = NULL;
102 args_info->shells_orig = NULL;
103 args_info->latticeConstant_orig = NULL;
104 args_info->columnAtoms_orig = NULL;
105 args_info->twinAtoms_orig = NULL;
106 args_info->truncatedPlanes_orig = NULL;
107
108 }
109
110 static
111 void init_args_info(struct gengetopt_args_info *args_info)
112 {
113
114
115 args_info->help_help = gengetopt_args_info_help[0] ;
116 args_info->version_help = gengetopt_args_info_help[1] ;
117 args_info->output_help = gengetopt_args_info_help[2] ;
118 args_info->shells_help = gengetopt_args_info_help[3] ;
119 args_info->latticeConstant_help = gengetopt_args_info_help[4] ;
120 args_info->columnAtoms_help = gengetopt_args_info_help[5] ;
121 args_info->twinAtoms_help = gengetopt_args_info_help[6] ;
122 args_info->truncatedPlanes_help = gengetopt_args_info_help[7] ;
123 args_info->ico_help = gengetopt_args_info_help[9] ;
124 args_info->deca_help = gengetopt_args_info_help[10] ;
125 args_info->ino_help = gengetopt_args_info_help[11] ;
126 args_info->marks_help = gengetopt_args_info_help[12] ;
127 args_info->stone_help = gengetopt_args_info_help[13] ;
128
129 }
130
131 void
132 cmdline_parser_print_version (void)
133 {
134 printf ("%s %s\n",
135 (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE),
136 CMDLINE_PARSER_VERSION);
137 }
138
139 static void print_help_common(void) {
140 cmdline_parser_print_version ();
141
142 if (strlen(gengetopt_args_info_purpose) > 0)
143 printf("\n%s\n", gengetopt_args_info_purpose);
144
145 if (strlen(gengetopt_args_info_usage) > 0)
146 printf("\n%s\n", gengetopt_args_info_usage);
147
148 printf("\n");
149
150 if (strlen(gengetopt_args_info_description) > 0)
151 printf("%s\n\n", gengetopt_args_info_description);
152 }
153
154 void
155 cmdline_parser_print_help (void)
156 {
157 int i = 0;
158 print_help_common();
159 while (gengetopt_args_info_help[i])
160 printf("%s\n", gengetopt_args_info_help[i++]);
161 }
162
163 void
164 cmdline_parser_init (struct gengetopt_args_info *args_info)
165 {
166 clear_given (args_info);
167 clear_args (args_info);
168 init_args_info (args_info);
169
170 args_info->inputs = 0;
171 args_info->inputs_num = 0;
172 }
173
174 void
175 cmdline_parser_params_init(struct cmdline_parser_params *params)
176 {
177 if (params)
178 {
179 params->override = 0;
180 params->initialize = 1;
181 params->check_required = 1;
182 params->check_ambiguity = 0;
183 params->print_errors = 1;
184 }
185 }
186
187 struct cmdline_parser_params *
188 cmdline_parser_params_create(void)
189 {
190 struct cmdline_parser_params *params =
191 (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params));
192 cmdline_parser_params_init(params);
193 return params;
194 }
195
196 static void
197 free_string_field (char **s)
198 {
199 if (*s)
200 {
201 free (*s);
202 *s = 0;
203 }
204 }
205
206
207 static void
208 cmdline_parser_release (struct gengetopt_args_info *args_info)
209 {
210 unsigned int i;
211 free_string_field (&(args_info->output_arg));
212 free_string_field (&(args_info->output_orig));
213 free_string_field (&(args_info->shells_orig));
214 free_string_field (&(args_info->latticeConstant_orig));
215 free_string_field (&(args_info->columnAtoms_orig));
216 free_string_field (&(args_info->twinAtoms_orig));
217 free_string_field (&(args_info->truncatedPlanes_orig));
218
219
220 for (i = 0; i < args_info->inputs_num; ++i)
221 free (args_info->inputs [i]);
222
223 if (args_info->inputs_num)
224 free (args_info->inputs);
225
226 clear_given (args_info);
227 }
228
229
230 static void
231 write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
232 {
233 FIX_UNUSED (values);
234 if (arg) {
235 fprintf(outfile, "%s=\"%s\"\n", opt, arg);
236 } else {
237 fprintf(outfile, "%s\n", opt);
238 }
239 }
240
241
242 int
243 cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
244 {
245 int i = 0;
246
247 if (!outfile)
248 {
249 fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE);
250 return EXIT_FAILURE;
251 }
252
253 if (args_info->help_given)
254 write_into_file(outfile, "help", 0, 0 );
255 if (args_info->version_given)
256 write_into_file(outfile, "version", 0, 0 );
257 if (args_info->output_given)
258 write_into_file(outfile, "output", args_info->output_orig, 0);
259 if (args_info->shells_given)
260 write_into_file(outfile, "shells", args_info->shells_orig, 0);
261 if (args_info->latticeConstant_given)
262 write_into_file(outfile, "latticeConstant", args_info->latticeConstant_orig, 0);
263 if (args_info->columnAtoms_given)
264 write_into_file(outfile, "columnAtoms", args_info->columnAtoms_orig, 0);
265 if (args_info->twinAtoms_given)
266 write_into_file(outfile, "twinAtoms", args_info->twinAtoms_orig, 0);
267 if (args_info->truncatedPlanes_given)
268 write_into_file(outfile, "truncatedPlanes", args_info->truncatedPlanes_orig, 0);
269 if (args_info->ico_given)
270 write_into_file(outfile, "ico", 0, 0 );
271 if (args_info->deca_given)
272 write_into_file(outfile, "deca", 0, 0 );
273 if (args_info->ino_given)
274 write_into_file(outfile, "ino", 0, 0 );
275 if (args_info->marks_given)
276 write_into_file(outfile, "marks", 0, 0 );
277 if (args_info->stone_given)
278 write_into_file(outfile, "stone", 0, 0 );
279
280
281 i = EXIT_SUCCESS;
282 return i;
283 }
284
285 int
286 cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info)
287 {
288 FILE *outfile;
289 int i = 0;
290
291 outfile = fopen(filename, "w");
292
293 if (!outfile)
294 {
295 fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename);
296 return EXIT_FAILURE;
297 }
298
299 i = cmdline_parser_dump(outfile, args_info);
300 fclose (outfile);
301
302 return i;
303 }
304
305 void
306 cmdline_parser_free (struct gengetopt_args_info *args_info)
307 {
308 cmdline_parser_release (args_info);
309 }
310
311 /** @brief replacement of strdup, which is not standard */
312 char *
313 gengetopt_strdup (const char *s)
314 {
315 char *result = 0;
316 if (!s)
317 return result;
318
319 result = (char*)malloc(strlen(s) + 1);
320 if (result == (char*)0)
321 return (char*)0;
322 strcpy(result, s);
323 return result;
324 }
325
326 static void
327 reset_group_clusterShape(struct gengetopt_args_info *args_info)
328 {
329 if (! args_info->clusterShape_group_counter)
330 return;
331
332 args_info->ico_given = 0 ;
333 args_info->deca_given = 0 ;
334 args_info->ino_given = 0 ;
335 args_info->marks_given = 0 ;
336 args_info->stone_given = 0 ;
337
338 args_info->clusterShape_group_counter = 0;
339 }
340
341 int
342 cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info)
343 {
344 return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
345 }
346
347 int
348 cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info,
349 struct cmdline_parser_params *params)
350 {
351 int result;
352 result = cmdline_parser_internal (argc, argv, args_info, params, 0);
353
354 if (result == EXIT_FAILURE)
355 {
356 cmdline_parser_free (args_info);
357 exit (EXIT_FAILURE);
358 }
359
360 return result;
361 }
362
363 int
364 cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
365 {
366 int result;
367 struct cmdline_parser_params params;
368
369 params.override = override;
370 params.initialize = initialize;
371 params.check_required = check_required;
372 params.check_ambiguity = 0;
373 params.print_errors = 1;
374
375 result = cmdline_parser_internal (argc, argv, args_info, &params, 0);
376
377 if (result == EXIT_FAILURE)
378 {
379 cmdline_parser_free (args_info);
380 exit (EXIT_FAILURE);
381 }
382
383 return result;
384 }
385
386 int
387 cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
388 {
389 int result = EXIT_SUCCESS;
390
391 if (cmdline_parser_required2(args_info, prog_name, 0) > 0)
392 result = EXIT_FAILURE;
393
394 if (result == EXIT_FAILURE)
395 {
396 cmdline_parser_free (args_info);
397 exit (EXIT_FAILURE);
398 }
399
400 return result;
401 }
402
403 int
404 cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error)
405 {
406 int error = 0;
407 FIX_UNUSED (additional_error);
408
409 /* checks for required options */
410 if (! args_info->output_given)
411 {
412 fprintf (stderr, "%s: '--output' ('-o') option required%s\n", prog_name, (additional_error ? additional_error : ""));
413 error = 1;
414 }
415
416 if (! args_info->shells_given)
417 {
418 fprintf (stderr, "%s: '--shells' ('-n') option required%s\n", prog_name, (additional_error ? additional_error : ""));
419 error = 1;
420 }
421
422 if (args_info->clusterShape_group_counter == 0)
423 {
424 fprintf (stderr, "%s: %d options of group clusterShape were given. One is required%s.\n", prog_name, args_info->clusterShape_group_counter, (additional_error ? additional_error : ""));
425 error = 1;
426 }
427
428
429 /* checks for dependences among options */
430
431 return error;
432 }
433
434
435 static char *package_name = 0;
436
437 /**
438 * @brief updates an option
439 * @param field the generic pointer to the field to update
440 * @param orig_field the pointer to the orig field
441 * @param field_given the pointer to the number of occurrence of this option
442 * @param prev_given the pointer to the number of occurrence already seen
443 * @param value the argument for this option (if null no arg was specified)
444 * @param possible_values the possible values for this option (if specified)
445 * @param default_value the default value (in case the option only accepts fixed values)
446 * @param arg_type the type of this option
447 * @param check_ambiguity @see cmdline_parser_params.check_ambiguity
448 * @param override @see cmdline_parser_params.override
449 * @param no_free whether to free a possible previous value
450 * @param multiple_option whether this is a multiple option
451 * @param long_opt the corresponding long option
452 * @param short_opt the corresponding short option (or '-' if none)
453 * @param additional_error possible further error specification
454 */
455 static
456 int update_arg(void *field, char **orig_field,
457 unsigned int *field_given, unsigned int *prev_given,
458 char *value, const char *possible_values[],
459 const char *default_value,
460 cmdline_parser_arg_type arg_type,
461 int check_ambiguity, int override,
462 int no_free, int multiple_option,
463 const char *long_opt, char short_opt,
464 const char *additional_error)
465 {
466 char *stop_char = 0;
467 const char *val = value;
468 int found;
469 char **string_field;
470 FIX_UNUSED (field);
471
472 stop_char = 0;
473 found = 0;
474
475 if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
476 {
477 if (short_opt != '-')
478 fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n",
479 package_name, long_opt, short_opt,
480 (additional_error ? additional_error : ""));
481 else
482 fprintf (stderr, "%s: `--%s' option given more than once%s\n",
483 package_name, long_opt,
484 (additional_error ? additional_error : ""));
485 return 1; /* failure */
486 }
487
488 FIX_UNUSED (default_value);
489
490 if (field_given && *field_given && ! override)
491 return 0;
492 if (prev_given)
493 (*prev_given)++;
494 if (field_given)
495 (*field_given)++;
496 if (possible_values)
497 val = possible_values[found];
498
499 switch(arg_type) {
500 case ARG_INT:
501 if (val) *((int *)field) = strtol (val, &stop_char, 0);
502 break;
503 case ARG_DOUBLE:
504 if (val) *((double *)field) = strtod (val, &stop_char);
505 break;
506 case ARG_STRING:
507 if (val) {
508 string_field = (char **)field;
509 if (!no_free && *string_field)
510 free (*string_field); /* free previous string */
511 *string_field = gengetopt_strdup (val);
512 }
513 break;
514 default:
515 break;
516 };
517
518 /* check numeric conversion */
519 switch(arg_type) {
520 case ARG_INT:
521 case ARG_DOUBLE:
522 if (val && !(stop_char && *stop_char == '\0')) {
523 fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
524 return 1; /* failure */
525 }
526 break;
527 default:
528 ;
529 };
530
531 /* store the original value */
532 switch(arg_type) {
533 case ARG_NO:
534 break;
535 default:
536 if (value && orig_field) {
537 if (no_free) {
538 *orig_field = value;
539 } else {
540 if (*orig_field)
541 free (*orig_field); /* free previous string */
542 *orig_field = gengetopt_strdup (value);
543 }
544 }
545 };
546
547 return 0; /* OK */
548 }
549
550
551 int
552 cmdline_parser_internal (
553 int argc, char **argv, struct gengetopt_args_info *args_info,
554 struct cmdline_parser_params *params, const char *additional_error)
555 {
556 int c; /* Character of the parsed option. */
557
558 int error = 0;
559 struct gengetopt_args_info local_args_info;
560
561 int override;
562 int initialize;
563 int check_required;
564 int check_ambiguity;
565
566 package_name = argv[0];
567
568 override = params->override;
569 initialize = params->initialize;
570 check_required = params->check_required;
571 check_ambiguity = params->check_ambiguity;
572
573 if (initialize)
574 cmdline_parser_init (args_info);
575
576 cmdline_parser_init (&local_args_info);
577
578 optarg = 0;
579 optind = 0;
580 opterr = params->print_errors;
581 optopt = '?';
582
583 while (1)
584 {
585 int option_index = 0;
586
587 static struct option long_options[] = {
588 { "help", 0, NULL, 'h' },
589 { "version", 0, NULL, 'V' },
590 { "output", 1, NULL, 'o' },
591 { "shells", 1, NULL, 'n' },
592 { "latticeConstant", 1, NULL, 'd' },
593 { "columnAtoms", 1, NULL, 'c' },
594 { "twinAtoms", 1, NULL, 't' },
595 { "truncatedPlanes", 1, NULL, 'p' },
596 { "ico", 0, NULL, 0 },
597 { "deca", 0, NULL, 0 },
598 { "ino", 0, NULL, 0 },
599 { "marks", 0, NULL, 0 },
600 { "stone", 0, NULL, 0 },
601 { 0, 0, 0, 0 }
602 };
603
604 c = getopt_long (argc, argv, "hVo:n:d:c:t:p:", long_options, &option_index);
605
606 if (c == -1) break; /* Exit from `while (1)' loop. */
607
608 switch (c)
609 {
610 case 'h': /* Print help and exit. */
611 cmdline_parser_print_help ();
612 cmdline_parser_free (&local_args_info);
613 exit (EXIT_SUCCESS);
614
615 case 'V': /* Print version and exit. */
616 cmdline_parser_print_version ();
617 cmdline_parser_free (&local_args_info);
618 exit (EXIT_SUCCESS);
619
620 case 'o': /* Output file name. */
621
622
623 if (update_arg( (void *)&(args_info->output_arg),
624 &(args_info->output_orig), &(args_info->output_given),
625 &(local_args_info.output_given), optarg, 0, 0, ARG_STRING,
626 check_ambiguity, override, 0, 0,
627 "output", 'o',
628 additional_error))
629 goto failure;
630
631 break;
632 case 'n': /* Nanoparticle shells. */
633
634
635 if (update_arg( (void *)&(args_info->shells_arg),
636 &(args_info->shells_orig), &(args_info->shells_given),
637 &(local_args_info.shells_given), optarg, 0, 0, ARG_INT,
638 check_ambiguity, override, 0, 0,
639 "shells", 'n',
640 additional_error))
641 goto failure;
642
643 break;
644 case 'd': /* Lattice spacing in Angstroms for cubic lattice.. */
645
646
647 if (update_arg( (void *)&(args_info->latticeConstant_arg),
648 &(args_info->latticeConstant_orig), &(args_info->latticeConstant_given),
649 &(local_args_info.latticeConstant_given), optarg, 0, 0, ARG_DOUBLE,
650 check_ambiguity, override, 0, 0,
651 "latticeConstant", 'd',
652 additional_error))
653 goto failure;
654
655 break;
656 case 'c': /* Number of atoms along central column (Decahedron only). */
657
658
659 if (update_arg( (void *)&(args_info->columnAtoms_arg),
660 &(args_info->columnAtoms_orig), &(args_info->columnAtoms_given),
661 &(local_args_info.columnAtoms_given), optarg, 0, 0, ARG_INT,
662 check_ambiguity, override, 0, 0,
663 "columnAtoms", 'c',
664 additional_error))
665 goto failure;
666
667 break;
668 case 't': /* Number of atoms along twin boundary (Decahedron only). */
669
670
671 if (update_arg( (void *)&(args_info->twinAtoms_arg),
672 &(args_info->twinAtoms_orig), &(args_info->twinAtoms_given),
673 &(local_args_info.twinAtoms_given), optarg, 0, 0, ARG_INT,
674 check_ambiguity, override, 0, 0,
675 "twinAtoms", 't',
676 additional_error))
677 goto failure;
678
679 break;
680 case 'p': /* Number of truncated planes (Curling-stone Decahedron only). */
681
682
683 if (update_arg( (void *)&(args_info->truncatedPlanes_arg),
684 &(args_info->truncatedPlanes_orig), &(args_info->truncatedPlanes_given),
685 &(local_args_info.truncatedPlanes_given), optarg, 0, 0, ARG_INT,
686 check_ambiguity, override, 0, 0,
687 "truncatedPlanes", 'p',
688 additional_error))
689 goto failure;
690
691 break;
692
693 case 0: /* Long option with no short option */
694 /* Create an Icosahedral cluster. */
695 if (strcmp (long_options[option_index].name, "ico") == 0)
696 {
697
698 if (args_info->clusterShape_group_counter && override)
699 reset_group_clusterShape (args_info);
700 args_info->clusterShape_group_counter += 1;
701
702 if (update_arg( 0 ,
703 0 , &(args_info->ico_given),
704 &(local_args_info.ico_given), optarg, 0, 0, ARG_NO,
705 check_ambiguity, override, 0, 0,
706 "ico", '-',
707 additional_error))
708 goto failure;
709
710 }
711 /* Create a regualar Decahedral cluster. */
712 else if (strcmp (long_options[option_index].name, "deca") == 0)
713 {
714
715 if (args_info->clusterShape_group_counter && override)
716 reset_group_clusterShape (args_info);
717 args_info->clusterShape_group_counter += 1;
718
719 if (update_arg( 0 ,
720 0 , &(args_info->deca_given),
721 &(local_args_info.deca_given), optarg, 0, 0, ARG_NO,
722 check_ambiguity, override, 0, 0,
723 "deca", '-',
724 additional_error))
725 goto failure;
726
727 }
728 /* Create an Ino Decahedral cluster. */
729 else if (strcmp (long_options[option_index].name, "ino") == 0)
730 {
731
732 if (args_info->clusterShape_group_counter && override)
733 reset_group_clusterShape (args_info);
734 args_info->clusterShape_group_counter += 1;
735
736 if (update_arg( 0 ,
737 0 , &(args_info->ino_given),
738 &(local_args_info.ino_given), optarg, 0, 0, ARG_NO,
739 check_ambiguity, override, 0, 0,
740 "ino", '-',
741 additional_error))
742 goto failure;
743
744 }
745 /* Create a Marks Decahedral cluster. */
746 else if (strcmp (long_options[option_index].name, "marks") == 0)
747 {
748
749 if (args_info->clusterShape_group_counter && override)
750 reset_group_clusterShape (args_info);
751 args_info->clusterShape_group_counter += 1;
752
753 if (update_arg( 0 ,
754 0 , &(args_info->marks_given),
755 &(local_args_info.marks_given), optarg, 0, 0, ARG_NO,
756 check_ambiguity, override, 0, 0,
757 "marks", '-',
758 additional_error))
759 goto failure;
760
761 }
762 /* Create a Curling-stone Decahedral cluster. */
763 else if (strcmp (long_options[option_index].name, "stone") == 0)
764 {
765
766 if (args_info->clusterShape_group_counter && override)
767 reset_group_clusterShape (args_info);
768 args_info->clusterShape_group_counter += 1;
769
770 if (update_arg( 0 ,
771 0 , &(args_info->stone_given),
772 &(local_args_info.stone_given), optarg, 0, 0, ARG_NO,
773 check_ambiguity, override, 0, 0,
774 "stone", '-',
775 additional_error))
776 goto failure;
777
778 }
779
780 break;
781 case '?': /* Invalid option. */
782 /* `getopt_long' already printed an error message. */
783 goto failure;
784
785 default: /* bug: option not considered. */
786 fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
787 abort ();
788 } /* switch */
789 } /* while */
790
791 if (args_info->clusterShape_group_counter > 1)
792 {
793 fprintf (stderr, "%s: %d options of group clusterShape were given. One is required%s.\n", argv[0], args_info->clusterShape_group_counter, (additional_error ? additional_error : ""));
794 error = 1;
795 }
796
797
798
799 if (check_required)
800 {
801 error += cmdline_parser_required2 (args_info, argv[0], additional_error);
802 }
803
804 cmdline_parser_release (&local_args_info);
805
806 if ( error )
807 return (EXIT_FAILURE);
808
809 if (optind < argc)
810 {
811 int i = 0 ;
812 int found_prog_name = 0;
813 /* whether program name, i.e., argv[0], is in the remaining args
814 (this may happen with some implementations of getopt,
815 but surely not with the one included by gengetopt) */
816
817 i = optind;
818 while (i < argc)
819 if (argv[i++] == argv[0]) {
820 found_prog_name = 1;
821 break;
822 }
823 i = 0;
824
825 args_info->inputs_num = argc - optind - found_prog_name;
826 args_info->inputs =
827 (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ;
828 while (optind < argc)
829 if (argv[optind++] != argv[0])
830 args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind-1]) ;
831 }
832
833 return 0;
834
835 failure:
836
837 cmdline_parser_release (&local_args_info);
838 return (EXIT_FAILURE);
839 }

Properties

Name Value
svn:eol-style native