ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/applications/dynamicProps/DynamicPropsCmd.cpp
(Generate patch)

Comparing trunk/src/applications/dynamicProps/DynamicPropsCmd.c (file contents):
Revision 876 by tim, Mon Jan 30 22:25:27 2006 UTC vs.
Revision 1112 by chuckv, Wed Jan 3 20:47:00 2007 UTC

# Line 1 | Line 1
1   /*
2 <  File autogenerated by gengetopt version 2.11
2 >  File autogenerated by gengetopt version 2.15
3    generated with the following command:
4 <  /home/maul/gezelter/tim/program/gengetopt-2.11/src/gengetopt -F DynamicPropsCmd
4 >  gengetopt -u -i DynamicProps.ggo -F DynamicPropsCmd
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
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <string.h>
15
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   #include "getopt.h"
21  
22   #include "DynamicPropsCmd.h"
23  
24 + static
25 + void clear_given (struct gengetopt_args_info *args_info);
26 + static
27 + void clear_args (struct gengetopt_args_info *args_info);
28 +
29 + static int
30 + cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required, const char *additional_error);
31 +
32 + static int
33 + cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error);
34 +
35 + static char *
36 + gengetopt_strdup (const char *s);
37 +
38 + static
39 + void clear_given (struct gengetopt_args_info *args_info)
40 + {
41 +  args_info->help_given = 0 ;
42 +  args_info->version_given = 0 ;
43 +  args_info->input_given = 0 ;
44 +  args_info->output_given = 0 ;
45 +  args_info->sele1_given = 0 ;
46 +  args_info->sele2_given = 0 ;
47 +  args_info->order_given = 0 ;
48 +  args_info->rcorr_given = 0 ;
49 +  args_info->vcorr_given = 0 ;
50 +  args_info->dcorr_given = 0 ;
51 +  args_info->lcorr_given = 0 ;
52 +  args_info->r_rcorr_given = 0 ;
53 +  args_info->thetacorr_given = 0 ;
54 +  args_info->dynamicProps_group_counter = 0 ;
55 + }
56 +
57 + static
58 + void clear_args (struct gengetopt_args_info *args_info)
59 + {
60 +  args_info->input_arg = NULL;
61 +  args_info->input_orig = NULL;
62 +  args_info->output_arg = NULL;
63 +  args_info->output_orig = NULL;
64 +  args_info->sele1_arg = NULL;
65 +  args_info->sele1_orig = NULL;
66 +  args_info->sele2_arg = NULL;
67 +  args_info->sele2_orig = NULL;
68 +  args_info->order_orig = NULL;
69 +  
70 + }
71 +
72   void
73   cmdline_parser_print_version (void)
74   {
# Line 32 | Line 79 | cmdline_parser_print_help (void)
79   cmdline_parser_print_help (void)
80   {
81    cmdline_parser_print_version ();
82 <  printf("\n"
83 <  "Usage: %s [OPTIONS]...\n", CMDLINE_PARSER_PACKAGE);
84 <  printf("\n");
85 <  printf("  -h, --help                    Print help and exit\n");
86 <  printf("  -V, --version                 Print version and exit\n");
87 <  printf("  -i, --input=filename          input dump file\n");
88 <  printf("  -o, --output=filename         output file name\n");
89 <  printf("      --sele1=selection script  select first stuntdouble set\n");
90 <  printf("      --sele2=selection script  select second stuntdouble set (if sele2 is not \n                                  set, use script from sele1)\n");
91 <  printf("      --order=INT               Lengendre Polynomial Order\n");
92 <  printf("\n");
93 <  printf(" Group: dynamicProps  an option of this group is required\n");
94 <  printf("  -r, --rcorr                   rmsd\n");
95 <  printf("  -v, --vcorr                   velocity correlation function\n");
96 <  printf("  -d, --dcorr                   dipole correlation function\n");
97 <  printf("  -l, --lcorr                   Lengendre correlation function\n");
82 >  printf("\nUsage: DynamicProps [OPTIONS]... [FILES]...\n\n");
83 >  printf("%s\n","  -h, --help                    Print help and exit");
84 >  printf("%s\n","  -V, --version                 Print version and exit");
85 >  printf("%s\n","  -i, --input=filename          input dump file");
86 >  printf("%s\n","  -o, --output=filename         output file name");
87 >  printf("%s\n","      --sele1=selection script  select first stuntdouble set");
88 >  printf("%s\n","      --sele2=selection script  select second stuntdouble set (if sele2 is not \n                                  set, use script from sele1)");
89 >  printf("%s\n","      --order=INT               Lengendre Polynomial Order");
90 >  printf("%s\n","\n Group: dynamicProps\n   an option of this group is required");
91 >  printf("%s\n","  -r, --rcorr                   rmsd");
92 >  printf("%s\n","  -v, --vcorr                   velocity correlation function");
93 >  printf("%s\n","  -d, --dcorr                   dipole correlation function");
94 >  printf("%s\n","  -l, --lcorr                   Lengendre correlation function");
95 >  printf("%s\n","      --r_rcorr                 Radial rmsd");
96 >  printf("%s\n","      --thetacorr               Angular rmsd");
97 >  
98   }
99  
100 + void
101 + cmdline_parser_init (struct gengetopt_args_info *args_info)
102 + {
103 +  clear_given (args_info);
104 +  clear_args (args_info);
105  
106 < static char *gengetopt_strdup (const char *s);
106 >  args_info->inputs = NULL;
107 >  args_info->inputs_num = 0;
108 > }
109  
110 + static void
111 + cmdline_parser_release (struct gengetopt_args_info *args_info)
112 + {
113 +  
114 +  unsigned int i;
115 +  if (args_info->input_arg)
116 +    {
117 +      free (args_info->input_arg); /* free previous argument */
118 +      args_info->input_arg = 0;
119 +    }
120 +  if (args_info->input_orig)
121 +    {
122 +      free (args_info->input_orig); /* free previous argument */
123 +      args_info->input_orig = 0;
124 +    }
125 +  if (args_info->output_arg)
126 +    {
127 +      free (args_info->output_arg); /* free previous argument */
128 +      args_info->output_arg = 0;
129 +    }
130 +  if (args_info->output_orig)
131 +    {
132 +      free (args_info->output_orig); /* free previous argument */
133 +      args_info->output_orig = 0;
134 +    }
135 +  if (args_info->sele1_arg)
136 +    {
137 +      free (args_info->sele1_arg); /* free previous argument */
138 +      args_info->sele1_arg = 0;
139 +    }
140 +  if (args_info->sele1_orig)
141 +    {
142 +      free (args_info->sele1_orig); /* free previous argument */
143 +      args_info->sele1_orig = 0;
144 +    }
145 +  if (args_info->sele2_arg)
146 +    {
147 +      free (args_info->sele2_arg); /* free previous argument */
148 +      args_info->sele2_arg = 0;
149 +    }
150 +  if (args_info->sele2_orig)
151 +    {
152 +      free (args_info->sele2_orig); /* free previous argument */
153 +      args_info->sele2_orig = 0;
154 +    }
155 +  if (args_info->order_orig)
156 +    {
157 +      free (args_info->order_orig); /* free previous argument */
158 +      args_info->order_orig = 0;
159 +    }
160 +  
161 +  for (i = 0; i < args_info->inputs_num; ++i)
162 +    free (args_info->inputs [i]);
163 +  
164 +  if (args_info->inputs_num)
165 +    free (args_info->inputs);
166 +  
167 +  clear_given (args_info);
168 + }
169 +
170 + int
171 + cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info)
172 + {
173 +  FILE *outfile;
174 +  int i = 0;
175 +
176 +  outfile = fopen(filename, "w");
177 +
178 +  if (!outfile)
179 +    {
180 +      fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename);
181 +      return EXIT_FAILURE;
182 +    }
183 +
184 +  if (args_info->help_given) {
185 +    fprintf(outfile, "%s\n", "help");
186 +  }
187 +  if (args_info->version_given) {
188 +    fprintf(outfile, "%s\n", "version");
189 +  }
190 +  if (args_info->input_given) {
191 +    if (args_info->input_orig) {
192 +      fprintf(outfile, "%s=\"%s\"\n", "input", args_info->input_orig);
193 +    } else {
194 +      fprintf(outfile, "%s\n", "input");
195 +    }
196 +  }
197 +  if (args_info->output_given) {
198 +    if (args_info->output_orig) {
199 +      fprintf(outfile, "%s=\"%s\"\n", "output", args_info->output_orig);
200 +    } else {
201 +      fprintf(outfile, "%s\n", "output");
202 +    }
203 +  }
204 +  if (args_info->sele1_given) {
205 +    if (args_info->sele1_orig) {
206 +      fprintf(outfile, "%s=\"%s\"\n", "sele1", args_info->sele1_orig);
207 +    } else {
208 +      fprintf(outfile, "%s\n", "sele1");
209 +    }
210 +  }
211 +  if (args_info->sele2_given) {
212 +    if (args_info->sele2_orig) {
213 +      fprintf(outfile, "%s=\"%s\"\n", "sele2", args_info->sele2_orig);
214 +    } else {
215 +      fprintf(outfile, "%s\n", "sele2");
216 +    }
217 +  }
218 +  if (args_info->order_given) {
219 +    if (args_info->order_orig) {
220 +      fprintf(outfile, "%s=\"%s\"\n", "order", args_info->order_orig);
221 +    } else {
222 +      fprintf(outfile, "%s\n", "order");
223 +    }
224 +  }
225 +  if (args_info->rcorr_given) {
226 +    fprintf(outfile, "%s\n", "rcorr");
227 +  }
228 +  if (args_info->vcorr_given) {
229 +    fprintf(outfile, "%s\n", "vcorr");
230 +  }
231 +  if (args_info->dcorr_given) {
232 +    fprintf(outfile, "%s\n", "dcorr");
233 +  }
234 +  if (args_info->lcorr_given) {
235 +    fprintf(outfile, "%s\n", "lcorr");
236 +  }
237 +  if (args_info->r_rcorr_given) {
238 +    fprintf(outfile, "%s\n", "r_rcorr");
239 +  }
240 +  if (args_info->thetacorr_given) {
241 +    fprintf(outfile, "%s\n", "thetacorr");
242 +  }
243 +  
244 +  fclose (outfile);
245 +
246 +  i = EXIT_SUCCESS;
247 +  return i;
248 + }
249 +
250 + void
251 + cmdline_parser_free (struct gengetopt_args_info *args_info)
252 + {
253 +  cmdline_parser_release (args_info);
254 + }
255 +
256 +
257   /* gengetopt_strdup() */
258   /* strdup.c replacement of strdup, which is not standard */
259   char *
260   gengetopt_strdup (const char *s)
261   {
262 <  char *result = (char*)malloc(strlen(s) + 1);
262 >  char *result = NULL;
263 >  if (!s)
264 >    return result;
265 >
266 >  result = (char*)malloc(strlen(s) + 1);
267    if (result == (char*)0)
268      return (char*)0;
269    strcpy(result, s);
270    return result;
271   }
272  
273 < int
274 < cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
273 > static void
274 > reset_group_dynamicProps(struct gengetopt_args_info *args_info);
275 >
276 > static void
277 > reset_group_dynamicProps(struct gengetopt_args_info *args_info)
278   {
279 <  int c;        /* Character of the parsed option.  */
280 <  int missing_required_options = 0;
73 <  int dynamicProps_group_counter = 0;
279 >  if (! args_info->dynamicProps_group_counter)
280 >    return;
281    
75
76  args_info->help_given = 0 ;
77  args_info->version_given = 0 ;
78  args_info->input_given = 0 ;
79  args_info->output_given = 0 ;
80  args_info->sele1_given = 0 ;
81  args_info->sele2_given = 0 ;
82  args_info->order_given = 0 ;
282    args_info->rcorr_given = 0 ;
283    args_info->vcorr_given = 0 ;
284    args_info->dcorr_given = 0 ;
285    args_info->lcorr_given = 0 ;
286 < #define clear_args() { \
287 <  args_info->input_arg = NULL; \
288 <  args_info->output_arg = NULL; \
289 <  args_info->sele1_arg = NULL; \
91 <  args_info->sele2_arg = NULL; \
286 >  args_info->r_rcorr_given = 0 ;
287 >  args_info->thetacorr_given = 0 ;
288 >
289 >  args_info->dynamicProps_group_counter = 0;
290   }
291  
292 <  clear_args();
292 > int
293 > cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
294 > {
295 >  return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
296 > }
297  
298 + int
299 + cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
300 + {
301 +  int result;
302 +
303 +  result = cmdline_parser_internal (argc, argv, args_info, override, initialize, check_required, NULL);
304 +
305 +  if (result == EXIT_FAILURE)
306 +    {
307 +      cmdline_parser_free (args_info);
308 +      exit (EXIT_FAILURE);
309 +    }
310 +  
311 +  return result;
312 + }
313 +
314 + int
315 + cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
316 + {
317 +  int result = EXIT_SUCCESS;
318 +
319 +  if (cmdline_parser_required2(args_info, prog_name, NULL) > 0)
320 +    result = EXIT_FAILURE;
321 +
322 +  if (result == EXIT_FAILURE)
323 +    {
324 +      cmdline_parser_free (args_info);
325 +      exit (EXIT_FAILURE);
326 +    }
327 +  
328 +  return result;
329 + }
330 +
331 + int
332 + cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error)
333 + {
334 +  int error = 0;
335 +
336 +  if (! args_info->input_given)
337 +    {
338 +      fprintf (stderr, "%s: '--input' ('-i') option required%s\n", prog_name, (additional_error ? additional_error : ""));
339 +      error = 1;
340 +    }
341 +  if (args_info->dynamicProps_group_counter == 0)
342 +    {
343 +      fprintf (stderr, "%s: %d options of group dynamicProps were given. One is required.%s\n", prog_name, args_info->dynamicProps_group_counter, (additional_error ? additional_error : ""));
344 +      error = 1;
345 +    }
346 +  
347 +
348 +  return error;
349 + }
350 +
351 + int
352 + cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required, const char *additional_error)
353 + {
354 +  int c;        /* Character of the parsed option.  */
355 +
356 +  int error = 0;
357 +  struct gengetopt_args_info local_args_info;
358 +
359 +  if (initialize)
360 +    cmdline_parser_init (args_info);
361 +
362 +  cmdline_parser_init (&local_args_info);
363 +
364    optarg = 0;
365    optind = 1;
366    opterr = 1;
# Line 115 | Line 383 | cmdline_parser (int argc, char * const *argv, struct g
383          { "vcorr",      0, NULL, 'v' },
384          { "dcorr",      0, NULL, 'd' },
385          { "lcorr",      0, NULL, 'l' },
386 +        { "r_rcorr",    0, NULL, 0 },
387 +        { "thetacorr",  0, NULL, 0 },
388          { NULL, 0, NULL, 0 }
389        };
390  
# Line 126 | Line 396 | cmdline_parser (int argc, char * const *argv, struct g
396        switch (c)
397          {
398          case 'h':       /* Print help and exit.  */
129          clear_args ();
399            cmdline_parser_print_help ();
400 +          cmdline_parser_free (&local_args_info);
401            exit (EXIT_SUCCESS);
402  
403          case 'V':       /* Print version and exit.  */
134          clear_args ();
404            cmdline_parser_print_version ();
405 +          cmdline_parser_free (&local_args_info);
406            exit (EXIT_SUCCESS);
407  
408          case 'i':       /* input dump file.  */
409 <          if (args_info->input_given)
409 >          if (local_args_info.input_given)
410              {
411 <              fprintf (stderr, "%s: `--input' (`-i') option given more than once\n", CMDLINE_PARSER_PACKAGE);
412 <              clear_args ();
143 <              exit (EXIT_FAILURE);
411 >              fprintf (stderr, "%s: `--input' (`-i') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
412 >              goto failure;
413              }
414 +          if (args_info->input_given && ! override)
415 +            continue;
416 +          local_args_info.input_given = 1;
417            args_info->input_given = 1;
418 +          if (args_info->input_arg)
419 +            free (args_info->input_arg); /* free previous string */
420            args_info->input_arg = gengetopt_strdup (optarg);
421 +          if (args_info->input_orig)
422 +            free (args_info->input_orig); /* free previous string */
423 +          args_info->input_orig = gengetopt_strdup (optarg);
424            break;
425  
426          case 'o':       /* output file name.  */
427 <          if (args_info->output_given)
427 >          if (local_args_info.output_given)
428              {
429 <              fprintf (stderr, "%s: `--output' (`-o') option given more than once\n", CMDLINE_PARSER_PACKAGE);
430 <              clear_args ();
154 <              exit (EXIT_FAILURE);
429 >              fprintf (stderr, "%s: `--output' (`-o') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
430 >              goto failure;
431              }
432 +          if (args_info->output_given && ! override)
433 +            continue;
434 +          local_args_info.output_given = 1;
435            args_info->output_given = 1;
436 +          if (args_info->output_arg)
437 +            free (args_info->output_arg); /* free previous string */
438            args_info->output_arg = gengetopt_strdup (optarg);
439 +          if (args_info->output_orig)
440 +            free (args_info->output_orig); /* free previous string */
441 +          args_info->output_orig = gengetopt_strdup (optarg);
442            break;
443  
444          case 'r':       /* rmsd.  */
445 <          if (args_info->rcorr_given)
445 >          if (local_args_info.rcorr_given)
446              {
447 <              fprintf (stderr, "%s: `--rcorr' (`-r') option given more than once\n", CMDLINE_PARSER_PACKAGE);
448 <              clear_args ();
165 <              exit (EXIT_FAILURE);
447 >              fprintf (stderr, "%s: `--rcorr' (`-r') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
448 >              goto failure;
449              }
450 +          if (args_info->rcorr_given && ! override)
451 +            continue;
452 +          local_args_info.rcorr_given = 1;
453            args_info->rcorr_given = 1;
454 <          dynamicProps_group_counter += 1;
455 <        break;
454 >          if (args_info->dynamicProps_group_counter && override)
455 >            reset_group_dynamicProps (args_info);
456 >          args_info->dynamicProps_group_counter += 1;
457 >          break;
458  
459          case 'v':       /* velocity correlation function.  */
460 <          if (args_info->vcorr_given)
460 >          if (local_args_info.vcorr_given)
461              {
462 <              fprintf (stderr, "%s: `--vcorr' (`-v') option given more than once\n", CMDLINE_PARSER_PACKAGE);
463 <              clear_args ();
176 <              exit (EXIT_FAILURE);
462 >              fprintf (stderr, "%s: `--vcorr' (`-v') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
463 >              goto failure;
464              }
465 +          if (args_info->vcorr_given && ! override)
466 +            continue;
467 +          local_args_info.vcorr_given = 1;
468            args_info->vcorr_given = 1;
469 <          dynamicProps_group_counter += 1;
470 <        break;
469 >          if (args_info->dynamicProps_group_counter && override)
470 >            reset_group_dynamicProps (args_info);
471 >          args_info->dynamicProps_group_counter += 1;
472 >          break;
473  
474          case 'd':       /* dipole correlation function.  */
475 <          if (args_info->dcorr_given)
475 >          if (local_args_info.dcorr_given)
476              {
477 <              fprintf (stderr, "%s: `--dcorr' (`-d') option given more than once\n", CMDLINE_PARSER_PACKAGE);
478 <              clear_args ();
187 <              exit (EXIT_FAILURE);
477 >              fprintf (stderr, "%s: `--dcorr' (`-d') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
478 >              goto failure;
479              }
480 +          if (args_info->dcorr_given && ! override)
481 +            continue;
482 +          local_args_info.dcorr_given = 1;
483            args_info->dcorr_given = 1;
484 <          dynamicProps_group_counter += 1;
485 <        break;
484 >          if (args_info->dynamicProps_group_counter && override)
485 >            reset_group_dynamicProps (args_info);
486 >          args_info->dynamicProps_group_counter += 1;
487 >          break;
488  
489          case 'l':       /* Lengendre correlation function.  */
490 <          if (args_info->lcorr_given)
490 >          if (local_args_info.lcorr_given)
491              {
492 <              fprintf (stderr, "%s: `--lcorr' (`-l') option given more than once\n", CMDLINE_PARSER_PACKAGE);
493 <              clear_args ();
198 <              exit (EXIT_FAILURE);
492 >              fprintf (stderr, "%s: `--lcorr' (`-l') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
493 >              goto failure;
494              }
495 +          if (args_info->lcorr_given && ! override)
496 +            continue;
497 +          local_args_info.lcorr_given = 1;
498            args_info->lcorr_given = 1;
499 <          dynamicProps_group_counter += 1;
500 <        break;
499 >          if (args_info->dynamicProps_group_counter && override)
500 >            reset_group_dynamicProps (args_info);
501 >          args_info->dynamicProps_group_counter += 1;
502 >          break;
503  
504  
505          case 0: /* Long option with no short option */
506            /* select first stuntdouble set.  */
507            if (strcmp (long_options[option_index].name, "sele1") == 0)
508            {
509 <            if (args_info->sele1_given)
509 >            if (local_args_info.sele1_given)
510                {
511 <                fprintf (stderr, "%s: `--sele1' option given more than once\n", CMDLINE_PARSER_PACKAGE);
512 <                clear_args ();
213 <                exit (EXIT_FAILURE);
511 >                fprintf (stderr, "%s: `--sele1' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
512 >                goto failure;
513                }
514 +            if (args_info->sele1_given && ! override)
515 +              continue;
516 +            local_args_info.sele1_given = 1;
517              args_info->sele1_given = 1;
518 +            if (args_info->sele1_arg)
519 +              free (args_info->sele1_arg); /* free previous string */
520              args_info->sele1_arg = gengetopt_strdup (optarg);
521 <            break;
521 >            if (args_info->sele1_orig)
522 >              free (args_info->sele1_orig); /* free previous string */
523 >            args_info->sele1_orig = gengetopt_strdup (optarg);
524            }
219          
525            /* select second stuntdouble set (if sele2 is not set, use script from sele1).  */
526            else if (strcmp (long_options[option_index].name, "sele2") == 0)
527            {
528 <            if (args_info->sele2_given)
528 >            if (local_args_info.sele2_given)
529                {
530 <                fprintf (stderr, "%s: `--sele2' option given more than once\n", CMDLINE_PARSER_PACKAGE);
531 <                clear_args ();
227 <                exit (EXIT_FAILURE);
530 >                fprintf (stderr, "%s: `--sele2' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
531 >                goto failure;
532                }
533 +            if (args_info->sele2_given && ! override)
534 +              continue;
535 +            local_args_info.sele2_given = 1;
536              args_info->sele2_given = 1;
537 +            if (args_info->sele2_arg)
538 +              free (args_info->sele2_arg); /* free previous string */
539              args_info->sele2_arg = gengetopt_strdup (optarg);
540 <            break;
540 >            if (args_info->sele2_orig)
541 >              free (args_info->sele2_orig); /* free previous string */
542 >            args_info->sele2_orig = gengetopt_strdup (optarg);
543            }
233          
544            /* Lengendre Polynomial Order.  */
545            else if (strcmp (long_options[option_index].name, "order") == 0)
546            {
547 <            if (args_info->order_given)
547 >            if (local_args_info.order_given)
548                {
549 <                fprintf (stderr, "%s: `--order' option given more than once\n", CMDLINE_PARSER_PACKAGE);
550 <                clear_args ();
241 <                exit (EXIT_FAILURE);
549 >                fprintf (stderr, "%s: `--order' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
550 >                goto failure;
551                }
552 +            if (args_info->order_given && ! override)
553 +              continue;
554 +            local_args_info.order_given = 1;
555              args_info->order_given = 1;
556 <            args_info->order_arg = strtol (optarg,&stop_char,0);
556 >            args_info->order_arg = strtol (optarg, &stop_char, 0);
557 >            if (!(stop_char && *stop_char == '\0')) {
558 >              fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg);
559 >              goto failure;
560 >            }
561 >            if (args_info->order_orig)
562 >              free (args_info->order_orig); /* free previous string */
563 >            args_info->order_orig = gengetopt_strdup (optarg);
564 >          }
565 >          /* Radial rmsd.  */
566 >          else if (strcmp (long_options[option_index].name, "r_rcorr") == 0)
567 >          {
568 >            if (local_args_info.r_rcorr_given)
569 >              {
570 >                fprintf (stderr, "%s: `--r_rcorr' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
571 >                goto failure;
572 >              }
573 >            if (args_info->r_rcorr_given && ! override)
574 >              continue;
575 >            local_args_info.r_rcorr_given = 1;
576 >            args_info->r_rcorr_given = 1;
577 >            if (args_info->dynamicProps_group_counter && override)
578 >              reset_group_dynamicProps (args_info);
579 >            args_info->dynamicProps_group_counter += 1;
580              break;
581            }
582 +          /* Angular rmsd.  */
583 +          else if (strcmp (long_options[option_index].name, "thetacorr") == 0)
584 +          {
585 +            if (local_args_info.thetacorr_given)
586 +              {
587 +                fprintf (stderr, "%s: `--thetacorr' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
588 +                goto failure;
589 +              }
590 +            if (args_info->thetacorr_given && ! override)
591 +              continue;
592 +            local_args_info.thetacorr_given = 1;
593 +            args_info->thetacorr_given = 1;
594 +            if (args_info->dynamicProps_group_counter && override)
595 +              reset_group_dynamicProps (args_info);
596 +            args_info->dynamicProps_group_counter += 1;
597 +            break;
598 +          }
599            
600 <
600 >          break;
601          case '?':       /* Invalid option.  */
602            /* `getopt_long' already printed an error message.  */
603 <          exit (EXIT_FAILURE);
603 >          goto failure;
604  
605          default:        /* bug: option not considered.  */
606 <          fprintf (stderr, "%s: option unknown: %c\n", CMDLINE_PARSER_PACKAGE, c);
606 >          fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
607            abort ();
608          } /* switch */
609      } /* while */
610  
611 <  if ( dynamicProps_group_counter != 1)
611 >  if (args_info->dynamicProps_group_counter > 1)
612      {
613 <      fprintf (stderr, "%s: %d options of group dynamicProps were given. One is required\n", CMDLINE_PARSER_PACKAGE, dynamicProps_group_counter);
614 <      missing_required_options = 1;
613 >      fprintf (stderr, "%s: %d options of group dynamicProps were given. One is required.%s\n", argv[0], args_info->dynamicProps_group_counter, (additional_error ? additional_error : ""));
614 >      error = 1;
615      }
616    
617  
618 <  if (! args_info->input_given)
618 >
619 >  if (check_required)
620      {
621 <      fprintf (stderr, "%s: '--input' ('-i') option required\n", CMDLINE_PARSER_PACKAGE);
269 <      missing_required_options = 1;
621 >      error += cmdline_parser_required2 (args_info, argv[0], additional_error);
622      }
271  if ( missing_required_options )
272    exit (EXIT_FAILURE);
623  
624 +  cmdline_parser_release (&local_args_info);
625 +
626 +  if ( error )
627 +    return (EXIT_FAILURE);
628 +
629 +  if (optind < argc)
630 +    {
631 +      int i = 0 ;
632 +
633 +      args_info->inputs_num = argc - optind ;
634 +      args_info->inputs =
635 +        (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ;
636 +      while (optind < argc)
637 +        args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind++]) ;
638 +    }
639 +
640    return 0;
641 +
642 + failure:
643 +  
644 +  cmdline_parser_release (&local_args_info);
645 +  return (EXIT_FAILURE);
646   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines