ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/applications/nanoparticleBuilder/icosahedralBuilderCmd.cpp
Revision: 1862
Committed: Fri Apr 12 20:45:04 2013 UTC (12 years, 1 month ago) by gezelter
File size: 24973 byte(s)
Log Message:
Adding nanoparticle generators, fixing a Qhull static link bug

File Contents

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

Properties

Name Value
svn:eol-style native