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

Comparing trunk/src/applications/dynamicProps/DynamicPropsCmd.c (file contents):
Revision 917 by tim, Fri Mar 24 17:29:07 2006 UTC vs.
Revision 1566 by chuckv, Thu May 19 18:12:09 2011 UTC

# Line 1 | Line 1
1   /*
2 <  File autogenerated by gengetopt version 2.11
2 >  File autogenerated by gengetopt version 2.22.4
3    generated with the following command:
4 <  /home/maul/gezelter/tim/program/gengetopt-2.11/src/gengetopt -F DynamicPropsCmd
4 >  gengetopt
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 < /* If we use autoconf.  */
21 < #ifdef HAVE_CONFIG_H
18 < #include "config.h"
20 > #ifndef FIX_UNUSED
21 > #define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */
22   #endif
23  
24 < #include "getopt.h"
24 > #include <getopt.h>
25  
26   #include "DynamicPropsCmd.h"
27  
28 + const char *gengetopt_args_info_purpose = "";
29 +
30 + const char *gengetopt_args_info_usage = "Usage: DynamicProps [OPTIONS]...";
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 +  "  -i, --input=filename          input dump file",
38 +  "  -o, --output=filename         output file name",
39 +  "      --sele1=selection script  select first stuntdouble set",
40 +  "      --sele2=selection script  select second stuntdouble set (if sele2 is not \n                                  set, use script from sele1)",
41 +  "      --order=INT               Lengendre Polynomial Order",
42 +  "\n Group: dynamicProps\n   an option of this group is required",
43 +  "  -r, --rcorr                   rmsd",
44 +  "  -v, --vcorr                   velocity correlation function",
45 +  "  -d, --dcorr                   dipole correlation function",
46 +  "  -l, --lcorr                   Lengendre correlation function",
47 +  "      --r_rcorr                 Radial rmsd",
48 +  "      --thetacorr               Angular rmsd",
49 +  "      --drcorr                  Directional rmsd for particles with unit \n                                  vectors",
50 +  "      --helfandEcorr            Helfand moment for thermal conductvity",
51 +  "      --stresscorr              Stress tensor correlation function",
52 +    0
53 + };
54 +
55 + typedef enum {ARG_NO
56 +  , ARG_STRING
57 +  , ARG_INT
58 + } cmdline_parser_arg_type;
59 +
60 + static
61 + void clear_given (struct gengetopt_args_info *args_info);
62 + static
63 + void clear_args (struct gengetopt_args_info *args_info);
64 +
65 + static int
66 + cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info,
67 +                        struct cmdline_parser_params *params, const char *additional_error);
68 +
69 + static int
70 + cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error);
71 +
72 + static char *
73 + gengetopt_strdup (const char *s);
74 +
75 + static
76 + void clear_given (struct gengetopt_args_info *args_info)
77 + {
78 +  args_info->help_given = 0 ;
79 +  args_info->version_given = 0 ;
80 +  args_info->input_given = 0 ;
81 +  args_info->output_given = 0 ;
82 +  args_info->sele1_given = 0 ;
83 +  args_info->sele2_given = 0 ;
84 +  args_info->order_given = 0 ;
85 +  args_info->rcorr_given = 0 ;
86 +  args_info->vcorr_given = 0 ;
87 +  args_info->dcorr_given = 0 ;
88 +  args_info->lcorr_given = 0 ;
89 +  args_info->r_rcorr_given = 0 ;
90 +  args_info->thetacorr_given = 0 ;
91 +  args_info->drcorr_given = 0 ;
92 +  args_info->helfandEcorr_given = 0 ;
93 +  args_info->stresscorr_given = 0 ;
94 +  args_info->dynamicProps_group_counter = 0 ;
95 + }
96 +
97 + static
98 + void clear_args (struct gengetopt_args_info *args_info)
99 + {
100 +  FIX_UNUSED (args_info);
101 +  args_info->input_arg = NULL;
102 +  args_info->input_orig = NULL;
103 +  args_info->output_arg = NULL;
104 +  args_info->output_orig = NULL;
105 +  args_info->sele1_arg = NULL;
106 +  args_info->sele1_orig = NULL;
107 +  args_info->sele2_arg = NULL;
108 +  args_info->sele2_orig = NULL;
109 +  args_info->order_orig = NULL;
110 +  
111 + }
112 +
113 + static
114 + void init_args_info(struct gengetopt_args_info *args_info)
115 + {
116 +
117 +
118 +  args_info->help_help = gengetopt_args_info_help[0] ;
119 +  args_info->version_help = gengetopt_args_info_help[1] ;
120 +  args_info->input_help = gengetopt_args_info_help[2] ;
121 +  args_info->output_help = gengetopt_args_info_help[3] ;
122 +  args_info->sele1_help = gengetopt_args_info_help[4] ;
123 +  args_info->sele2_help = gengetopt_args_info_help[5] ;
124 +  args_info->order_help = gengetopt_args_info_help[6] ;
125 +  args_info->rcorr_help = gengetopt_args_info_help[8] ;
126 +  args_info->vcorr_help = gengetopt_args_info_help[9] ;
127 +  args_info->dcorr_help = gengetopt_args_info_help[10] ;
128 +  args_info->lcorr_help = gengetopt_args_info_help[11] ;
129 +  args_info->r_rcorr_help = gengetopt_args_info_help[12] ;
130 +  args_info->thetacorr_help = gengetopt_args_info_help[13] ;
131 +  args_info->drcorr_help = gengetopt_args_info_help[14] ;
132 +  args_info->helfandEcorr_help = gengetopt_args_info_help[15] ;
133 +  args_info->stresscorr_help = gengetopt_args_info_help[16] ;
134 +  
135 + }
136 +
137   void
138   cmdline_parser_print_version (void)
139   {
140 <  printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION);
140 >  printf ("%s %s\n",
141 >     (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE),
142 >     CMDLINE_PARSER_VERSION);
143   }
144  
145 + static void print_help_common(void) {
146 +  cmdline_parser_print_version ();
147 +
148 +  if (strlen(gengetopt_args_info_purpose) > 0)
149 +    printf("\n%s\n", gengetopt_args_info_purpose);
150 +
151 +  if (strlen(gengetopt_args_info_usage) > 0)
152 +    printf("\n%s\n", gengetopt_args_info_usage);
153 +
154 +  printf("\n");
155 +
156 +  if (strlen(gengetopt_args_info_description) > 0)
157 +    printf("%s\n\n", gengetopt_args_info_description);
158 + }
159 +
160   void
161   cmdline_parser_print_help (void)
162   {
163 <  cmdline_parser_print_version ();
164 <  printf("\n"
165 <  "Usage: %s [OPTIONS]...\n", CMDLINE_PARSER_PACKAGE);
166 <  printf("\n");
38 <  printf("  -h, --help                    Print help and exit\n");
39 <  printf("  -V, --version                 Print version and exit\n");
40 <  printf("  -i, --input=filename          input dump file\n");
41 <  printf("  -o, --output=filename         output file name\n");
42 <  printf("      --sele1=selection script  select first stuntdouble set\n");
43 <  printf("      --sele2=selection script  select second stuntdouble set (if sele2 is not \n                                  set, use script from sele1)\n");
44 <  printf("      --order=INT               Lengendre Polynomial Order\n");
45 <  printf("\n");
46 <  printf(" Group: dynamicProps  an option of this group is required\n");
47 <  printf("  -r, --rcorr                   rmsd\n");
48 <  printf("  -v, --vcorr                   velocity correlation function\n");
49 <  printf("  -d, --dcorr                   dipole correlation function\n");
50 <  printf("  -l, --lcorr                   Lengendre correlation function\n");
163 >  int i = 0;
164 >  print_help_common();
165 >  while (gengetopt_args_info_help[i])
166 >    printf("%s\n", gengetopt_args_info_help[i++]);
167   }
168  
169 + void
170 + cmdline_parser_init (struct gengetopt_args_info *args_info)
171 + {
172 +  clear_given (args_info);
173 +  clear_args (args_info);
174 +  init_args_info (args_info);
175 + }
176  
177 < static char *gengetopt_strdup (const char *s);
177 > void
178 > cmdline_parser_params_init(struct cmdline_parser_params *params)
179 > {
180 >  if (params)
181 >    {
182 >      params->override = 0;
183 >      params->initialize = 1;
184 >      params->check_required = 1;
185 >      params->check_ambiguity = 0;
186 >      params->print_errors = 1;
187 >    }
188 > }
189  
190 < /* gengetopt_strdup() */
191 < /* strdup.c replacement of strdup, which is not standard */
190 > struct cmdline_parser_params *
191 > cmdline_parser_params_create(void)
192 > {
193 >  struct cmdline_parser_params *params =
194 >    (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params));
195 >  cmdline_parser_params_init(params);  
196 >  return params;
197 > }
198 >
199 > static void
200 > free_string_field (char **s)
201 > {
202 >  if (*s)
203 >    {
204 >      free (*s);
205 >      *s = 0;
206 >    }
207 > }
208 >
209 >
210 > static void
211 > cmdline_parser_release (struct gengetopt_args_info *args_info)
212 > {
213 >
214 >  free_string_field (&(args_info->input_arg));
215 >  free_string_field (&(args_info->input_orig));
216 >  free_string_field (&(args_info->output_arg));
217 >  free_string_field (&(args_info->output_orig));
218 >  free_string_field (&(args_info->sele1_arg));
219 >  free_string_field (&(args_info->sele1_orig));
220 >  free_string_field (&(args_info->sele2_arg));
221 >  free_string_field (&(args_info->sele2_orig));
222 >  free_string_field (&(args_info->order_orig));
223 >  
224 >  
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->input_given)
258 >    write_into_file(outfile, "input", args_info->input_orig, 0);
259 >  if (args_info->output_given)
260 >    write_into_file(outfile, "output", args_info->output_orig, 0);
261 >  if (args_info->sele1_given)
262 >    write_into_file(outfile, "sele1", args_info->sele1_orig, 0);
263 >  if (args_info->sele2_given)
264 >    write_into_file(outfile, "sele2", args_info->sele2_orig, 0);
265 >  if (args_info->order_given)
266 >    write_into_file(outfile, "order", args_info->order_orig, 0);
267 >  if (args_info->rcorr_given)
268 >    write_into_file(outfile, "rcorr", 0, 0 );
269 >  if (args_info->vcorr_given)
270 >    write_into_file(outfile, "vcorr", 0, 0 );
271 >  if (args_info->dcorr_given)
272 >    write_into_file(outfile, "dcorr", 0, 0 );
273 >  if (args_info->lcorr_given)
274 >    write_into_file(outfile, "lcorr", 0, 0 );
275 >  if (args_info->r_rcorr_given)
276 >    write_into_file(outfile, "r_rcorr", 0, 0 );
277 >  if (args_info->thetacorr_given)
278 >    write_into_file(outfile, "thetacorr", 0, 0 );
279 >  if (args_info->drcorr_given)
280 >    write_into_file(outfile, "drcorr", 0, 0 );
281 >  if (args_info->helfandEcorr_given)
282 >    write_into_file(outfile, "helfandEcorr", 0, 0 );
283 >  if (args_info->stresscorr_given)
284 >    write_into_file(outfile, "stresscorr", 0, 0 );
285 >  
286 >
287 >  i = EXIT_SUCCESS;
288 >  return i;
289 > }
290 >
291 > int
292 > cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info)
293 > {
294 >  FILE *outfile;
295 >  int i = 0;
296 >
297 >  outfile = fopen(filename, "w");
298 >
299 >  if (!outfile)
300 >    {
301 >      fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename);
302 >      return EXIT_FAILURE;
303 >    }
304 >
305 >  i = cmdline_parser_dump(outfile, args_info);
306 >  fclose (outfile);
307 >
308 >  return i;
309 > }
310 >
311 > void
312 > cmdline_parser_free (struct gengetopt_args_info *args_info)
313 > {
314 >  cmdline_parser_release (args_info);
315 > }
316 >
317 > /** @brief replacement of strdup, which is not standard */
318   char *
319   gengetopt_strdup (const char *s)
320   {
321 <  char *result = (char*)malloc(strlen(s) + 1);
321 >  char *result = 0;
322 >  if (!s)
323 >    return result;
324 >
325 >  result = (char*)malloc(strlen(s) + 1);
326    if (result == (char*)0)
327      return (char*)0;
328    strcpy(result, s);
329    return result;
330   }
331  
332 < int
333 < cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
332 > static void
333 > reset_group_dynamicProps(struct gengetopt_args_info *args_info)
334   {
335 <  int c;        /* Character of the parsed option.  */
336 <  int missing_required_options = 0;
73 <  int dynamicProps_group_counter = 0;
335 >  if (! args_info->dynamicProps_group_counter)
336 >    return;
337    
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 ;
338    args_info->rcorr_given = 0 ;
339    args_info->vcorr_given = 0 ;
340    args_info->dcorr_given = 0 ;
341    args_info->lcorr_given = 0 ;
342 < #define clear_args() { \
343 <  args_info->input_arg = NULL; \
344 <  args_info->output_arg = NULL; \
345 <  args_info->sele1_arg = NULL; \
346 <  args_info->sele2_arg = NULL; \
342 >  args_info->r_rcorr_given = 0 ;
343 >  args_info->thetacorr_given = 0 ;
344 >  args_info->drcorr_given = 0 ;
345 >  args_info->helfandEcorr_given = 0 ;
346 >  args_info->stresscorr_given = 0 ;
347 >
348 >  args_info->dynamicProps_group_counter = 0;
349   }
350  
351 <  clear_args();
351 > int
352 > cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info)
353 > {
354 >  return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
355 > }
356  
357 + int
358 + cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info,
359 +                   struct cmdline_parser_params *params)
360 + {
361 +  int result;
362 +  result = cmdline_parser_internal (argc, argv, args_info, params, 0);
363 +
364 +  if (result == EXIT_FAILURE)
365 +    {
366 +      cmdline_parser_free (args_info);
367 +      exit (EXIT_FAILURE);
368 +    }
369 +  
370 +  return result;
371 + }
372 +
373 + int
374 + cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
375 + {
376 +  int result;
377 +  struct cmdline_parser_params params;
378 +  
379 +  params.override = override;
380 +  params.initialize = initialize;
381 +  params.check_required = check_required;
382 +  params.check_ambiguity = 0;
383 +  params.print_errors = 1;
384 +
385 +  result = cmdline_parser_internal (argc, argv, args_info, &params, 0);
386 +
387 +  if (result == EXIT_FAILURE)
388 +    {
389 +      cmdline_parser_free (args_info);
390 +      exit (EXIT_FAILURE);
391 +    }
392 +  
393 +  return result;
394 + }
395 +
396 + int
397 + cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
398 + {
399 +  int result = EXIT_SUCCESS;
400 +
401 +  if (cmdline_parser_required2(args_info, prog_name, 0) > 0)
402 +    result = EXIT_FAILURE;
403 +
404 +  if (result == EXIT_FAILURE)
405 +    {
406 +      cmdline_parser_free (args_info);
407 +      exit (EXIT_FAILURE);
408 +    }
409 +  
410 +  return result;
411 + }
412 +
413 + int
414 + cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error)
415 + {
416 +  int error = 0;
417 +  FIX_UNUSED (additional_error);
418 +
419 +  /* checks for required options */
420 +  if (! args_info->input_given)
421 +    {
422 +      fprintf (stderr, "%s: '--input' ('-i') option required%s\n", prog_name, (additional_error ? additional_error : ""));
423 +      error = 1;
424 +    }
425 +  
426 +  if (args_info->dynamicProps_group_counter == 0)
427 +    {
428 +      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 : ""));
429 +      error = 1;
430 +    }
431 +  
432 +
433 +  /* checks for dependences among options */
434 +
435 +  return error;
436 + }
437 +
438 +
439 + static char *package_name = 0;
440 +
441 + /**
442 + * @brief updates an option
443 + * @param field the generic pointer to the field to update
444 + * @param orig_field the pointer to the orig field
445 + * @param field_given the pointer to the number of occurrence of this option
446 + * @param prev_given the pointer to the number of occurrence already seen
447 + * @param value the argument for this option (if null no arg was specified)
448 + * @param possible_values the possible values for this option (if specified)
449 + * @param default_value the default value (in case the option only accepts fixed values)
450 + * @param arg_type the type of this option
451 + * @param check_ambiguity @see cmdline_parser_params.check_ambiguity
452 + * @param override @see cmdline_parser_params.override
453 + * @param no_free whether to free a possible previous value
454 + * @param multiple_option whether this is a multiple option
455 + * @param long_opt the corresponding long option
456 + * @param short_opt the corresponding short option (or '-' if none)
457 + * @param additional_error possible further error specification
458 + */
459 + static
460 + int update_arg(void *field, char **orig_field,
461 +               unsigned int *field_given, unsigned int *prev_given,
462 +               char *value, const char *possible_values[],
463 +               const char *default_value,
464 +               cmdline_parser_arg_type arg_type,
465 +               int check_ambiguity, int override,
466 +               int no_free, int multiple_option,
467 +               const char *long_opt, char short_opt,
468 +               const char *additional_error)
469 + {
470 +  char *stop_char = 0;
471 +  const char *val = value;
472 +  int found;
473 +  char **string_field;
474 +  FIX_UNUSED (field);
475 +
476 +  stop_char = 0;
477 +  found = 0;
478 +
479 +  if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
480 +    {
481 +      if (short_opt != '-')
482 +        fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n",
483 +               package_name, long_opt, short_opt,
484 +               (additional_error ? additional_error : ""));
485 +      else
486 +        fprintf (stderr, "%s: `--%s' option given more than once%s\n",
487 +               package_name, long_opt,
488 +               (additional_error ? additional_error : ""));
489 +      return 1; /* failure */
490 +    }
491 +
492 +  FIX_UNUSED (default_value);
493 +    
494 +  if (field_given && *field_given && ! override)
495 +    return 0;
496 +  if (prev_given)
497 +    (*prev_given)++;
498 +  if (field_given)
499 +    (*field_given)++;
500 +  if (possible_values)
501 +    val = possible_values[found];
502 +
503 +  switch(arg_type) {
504 +  case ARG_INT:
505 +    if (val) *((int *)field) = strtol (val, &stop_char, 0);
506 +    break;
507 +  case ARG_STRING:
508 +    if (val) {
509 +      string_field = (char **)field;
510 +      if (!no_free && *string_field)
511 +        free (*string_field); /* free previous string */
512 +      *string_field = gengetopt_strdup (val);
513 +    }
514 +    break;
515 +  default:
516 +    break;
517 +  };
518 +
519 +  /* check numeric conversion */
520 +  switch(arg_type) {
521 +  case ARG_INT:
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 = 1;
580 <  opterr = 1;
579 >  optind = 0;
580 >  opterr = params->print_errors;
581    optopt = '?';
582  
583    while (1)
584      {
585        int option_index = 0;
104      char *stop_char;
586  
587        static struct option long_options[] = {
588          { "help",       0, NULL, 'h' },
# Line 115 | Line 596 | cmdline_parser (int argc, char * const *argv, struct g
596          { "vcorr",      0, NULL, 'v' },
597          { "dcorr",      0, NULL, 'd' },
598          { "lcorr",      0, NULL, 'l' },
599 <        { NULL, 0, NULL, 0 }
599 >        { "r_rcorr",    0, NULL, 0 },
600 >        { "thetacorr",  0, NULL, 0 },
601 >        { "drcorr",     0, NULL, 0 },
602 >        { "helfandEcorr",       0, NULL, 0 },
603 >        { "stresscorr", 0, NULL, 0 },
604 >        { 0,  0, 0, 0 }
605        };
606  
121      stop_char = 0;
607        c = getopt_long (argc, argv, "hVi:o:rvdl", long_options, &option_index);
608  
609        if (c == -1) break;       /* Exit from `while (1)' loop.  */
# Line 126 | Line 611 | cmdline_parser (int argc, char * const *argv, struct g
611        switch (c)
612          {
613          case 'h':       /* Print help and exit.  */
129          clear_args ();
614            cmdline_parser_print_help ();
615 +          cmdline_parser_free (&local_args_info);
616            exit (EXIT_SUCCESS);
617  
618          case 'V':       /* Print version and exit.  */
134          clear_args ();
619            cmdline_parser_print_version ();
620 +          cmdline_parser_free (&local_args_info);
621            exit (EXIT_SUCCESS);
622  
623          case 'i':       /* input dump file.  */
624 <          if (args_info->input_given)
625 <            {
626 <              fprintf (stderr, "%s: `--input' (`-i') option given more than once\n", CMDLINE_PARSER_PACKAGE);
627 <              clear_args ();
628 <              exit (EXIT_FAILURE);
629 <            }
630 <          args_info->input_given = 1;
631 <          args_info->input_arg = gengetopt_strdup (optarg);
624 >        
625 >        
626 >          if (update_arg( (void *)&(args_info->input_arg),
627 >               &(args_info->input_orig), &(args_info->input_given),
628 >              &(local_args_info.input_given), optarg, 0, 0, ARG_STRING,
629 >              check_ambiguity, override, 0, 0,
630 >              "input", 'i',
631 >              additional_error))
632 >            goto failure;
633 >        
634            break;
148
635          case 'o':       /* output file name.  */
636 <          if (args_info->output_given)
637 <            {
638 <              fprintf (stderr, "%s: `--output' (`-o') option given more than once\n", CMDLINE_PARSER_PACKAGE);
639 <              clear_args ();
640 <              exit (EXIT_FAILURE);
641 <            }
642 <          args_info->output_given = 1;
643 <          args_info->output_arg = gengetopt_strdup (optarg);
636 >        
637 >        
638 >          if (update_arg( (void *)&(args_info->output_arg),
639 >               &(args_info->output_orig), &(args_info->output_given),
640 >              &(local_args_info.output_given), optarg, 0, 0, ARG_STRING,
641 >              check_ambiguity, override, 0, 0,
642 >              "output", 'o',
643 >              additional_error))
644 >            goto failure;
645 >        
646            break;
159
647          case 'r':       /* rmsd.  */
648 <          if (args_info->rcorr_given)
649 <            {
650 <              fprintf (stderr, "%s: `--rcorr' (`-r') option given more than once\n", CMDLINE_PARSER_PACKAGE);
651 <              clear_args ();
652 <              exit (EXIT_FAILURE);
653 <            }
654 <          args_info->rcorr_given = 1;
655 <          dynamicProps_group_counter += 1;
656 <        break;
657 <
648 >        
649 >          if (args_info->dynamicProps_group_counter && override)
650 >            reset_group_dynamicProps (args_info);
651 >          args_info->dynamicProps_group_counter += 1;
652 >        
653 >          if (update_arg( 0 ,
654 >               0 , &(args_info->rcorr_given),
655 >              &(local_args_info.rcorr_given), optarg, 0, 0, ARG_NO,
656 >              check_ambiguity, override, 0, 0,
657 >              "rcorr", 'r',
658 >              additional_error))
659 >            goto failure;
660 >        
661 >          break;
662          case 'v':       /* velocity correlation function.  */
663 <          if (args_info->vcorr_given)
664 <            {
665 <              fprintf (stderr, "%s: `--vcorr' (`-v') option given more than once\n", CMDLINE_PARSER_PACKAGE);
666 <              clear_args ();
667 <              exit (EXIT_FAILURE);
668 <            }
669 <          args_info->vcorr_given = 1;
670 <          dynamicProps_group_counter += 1;
671 <        break;
672 <
663 >        
664 >          if (args_info->dynamicProps_group_counter && override)
665 >            reset_group_dynamicProps (args_info);
666 >          args_info->dynamicProps_group_counter += 1;
667 >        
668 >          if (update_arg( 0 ,
669 >               0 , &(args_info->vcorr_given),
670 >              &(local_args_info.vcorr_given), optarg, 0, 0, ARG_NO,
671 >              check_ambiguity, override, 0, 0,
672 >              "vcorr", 'v',
673 >              additional_error))
674 >            goto failure;
675 >        
676 >          break;
677          case 'd':       /* dipole correlation function.  */
678 <          if (args_info->dcorr_given)
679 <            {
680 <              fprintf (stderr, "%s: `--dcorr' (`-d') option given more than once\n", CMDLINE_PARSER_PACKAGE);
681 <              clear_args ();
682 <              exit (EXIT_FAILURE);
683 <            }
684 <          args_info->dcorr_given = 1;
685 <          dynamicProps_group_counter += 1;
686 <        break;
687 <
678 >        
679 >          if (args_info->dynamicProps_group_counter && override)
680 >            reset_group_dynamicProps (args_info);
681 >          args_info->dynamicProps_group_counter += 1;
682 >        
683 >          if (update_arg( 0 ,
684 >               0 , &(args_info->dcorr_given),
685 >              &(local_args_info.dcorr_given), optarg, 0, 0, ARG_NO,
686 >              check_ambiguity, override, 0, 0,
687 >              "dcorr", 'd',
688 >              additional_error))
689 >            goto failure;
690 >        
691 >          break;
692          case 'l':       /* Lengendre correlation function.  */
693 <          if (args_info->lcorr_given)
694 <            {
695 <              fprintf (stderr, "%s: `--lcorr' (`-l') option given more than once\n", CMDLINE_PARSER_PACKAGE);
696 <              clear_args ();
697 <              exit (EXIT_FAILURE);
698 <            }
699 <          args_info->lcorr_given = 1;
700 <          dynamicProps_group_counter += 1;
701 <        break;
693 >        
694 >          if (args_info->dynamicProps_group_counter && override)
695 >            reset_group_dynamicProps (args_info);
696 >          args_info->dynamicProps_group_counter += 1;
697 >        
698 >          if (update_arg( 0 ,
699 >               0 , &(args_info->lcorr_given),
700 >              &(local_args_info.lcorr_given), optarg, 0, 0, ARG_NO,
701 >              check_ambiguity, override, 0, 0,
702 >              "lcorr", 'l',
703 >              additional_error))
704 >            goto failure;
705 >        
706 >          break;
707  
204
708          case 0: /* Long option with no short option */
709            /* select first stuntdouble set.  */
710            if (strcmp (long_options[option_index].name, "sele1") == 0)
711            {
209            if (args_info->sele1_given)
210              {
211                fprintf (stderr, "%s: `--sele1' option given more than once\n", CMDLINE_PARSER_PACKAGE);
212                clear_args ();
213                exit (EXIT_FAILURE);
214              }
215            args_info->sele1_given = 1;
216            args_info->sele1_arg = gengetopt_strdup (optarg);
217            break;
218          }
712            
713 +          
714 +            if (update_arg( (void *)&(args_info->sele1_arg),
715 +                 &(args_info->sele1_orig), &(args_info->sele1_given),
716 +                &(local_args_info.sele1_given), optarg, 0, 0, ARG_STRING,
717 +                check_ambiguity, override, 0, 0,
718 +                "sele1", '-',
719 +                additional_error))
720 +              goto failure;
721 +          
722 +          }
723            /* select second stuntdouble set (if sele2 is not set, use script from sele1).  */
724            else if (strcmp (long_options[option_index].name, "sele2") == 0)
725            {
223            if (args_info->sele2_given)
224              {
225                fprintf (stderr, "%s: `--sele2' option given more than once\n", CMDLINE_PARSER_PACKAGE);
226                clear_args ();
227                exit (EXIT_FAILURE);
228              }
229            args_info->sele2_given = 1;
230            args_info->sele2_arg = gengetopt_strdup (optarg);
231            break;
232          }
726            
727 +          
728 +            if (update_arg( (void *)&(args_info->sele2_arg),
729 +                 &(args_info->sele2_orig), &(args_info->sele2_given),
730 +                &(local_args_info.sele2_given), optarg, 0, 0, ARG_STRING,
731 +                check_ambiguity, override, 0, 0,
732 +                "sele2", '-',
733 +                additional_error))
734 +              goto failure;
735 +          
736 +          }
737            /* Lengendre Polynomial Order.  */
738            else if (strcmp (long_options[option_index].name, "order") == 0)
739            {
740 <            if (args_info->order_given)
741 <              {
742 <                fprintf (stderr, "%s: `--order' option given more than once\n", CMDLINE_PARSER_PACKAGE);
743 <                clear_args ();
744 <                exit (EXIT_FAILURE);
745 <              }
746 <            args_info->order_given = 1;
747 <            args_info->order_arg = strtol (optarg,&stop_char,0);
748 <            break;
740 >          
741 >          
742 >            if (update_arg( (void *)&(args_info->order_arg),
743 >                 &(args_info->order_orig), &(args_info->order_given),
744 >                &(local_args_info.order_given), optarg, 0, 0, ARG_INT,
745 >                check_ambiguity, override, 0, 0,
746 >                "order", '-',
747 >                additional_error))
748 >              goto failure;
749 >          
750            }
751 +          /* Radial rmsd.  */
752 +          else if (strcmp (long_options[option_index].name, "r_rcorr") == 0)
753 +          {
754            
755 <
755 >            if (args_info->dynamicProps_group_counter && override)
756 >              reset_group_dynamicProps (args_info);
757 >            args_info->dynamicProps_group_counter += 1;
758 >          
759 >            if (update_arg( 0 ,
760 >                 0 , &(args_info->r_rcorr_given),
761 >                &(local_args_info.r_rcorr_given), optarg, 0, 0, ARG_NO,
762 >                check_ambiguity, override, 0, 0,
763 >                "r_rcorr", '-',
764 >                additional_error))
765 >              goto failure;
766 >          
767 >          }
768 >          /* Angular rmsd.  */
769 >          else if (strcmp (long_options[option_index].name, "thetacorr") == 0)
770 >          {
771 >          
772 >            if (args_info->dynamicProps_group_counter && override)
773 >              reset_group_dynamicProps (args_info);
774 >            args_info->dynamicProps_group_counter += 1;
775 >          
776 >            if (update_arg( 0 ,
777 >                 0 , &(args_info->thetacorr_given),
778 >                &(local_args_info.thetacorr_given), optarg, 0, 0, ARG_NO,
779 >                check_ambiguity, override, 0, 0,
780 >                "thetacorr", '-',
781 >                additional_error))
782 >              goto failure;
783 >          
784 >          }
785 >          /* Directional rmsd for particles with unit vectors.  */
786 >          else if (strcmp (long_options[option_index].name, "drcorr") == 0)
787 >          {
788 >          
789 >            if (args_info->dynamicProps_group_counter && override)
790 >              reset_group_dynamicProps (args_info);
791 >            args_info->dynamicProps_group_counter += 1;
792 >          
793 >            if (update_arg( 0 ,
794 >                 0 , &(args_info->drcorr_given),
795 >                &(local_args_info.drcorr_given), optarg, 0, 0, ARG_NO,
796 >                check_ambiguity, override, 0, 0,
797 >                "drcorr", '-',
798 >                additional_error))
799 >              goto failure;
800 >          
801 >          }
802 >          /* Helfand moment for thermal conductvity.  */
803 >          else if (strcmp (long_options[option_index].name, "helfandEcorr") == 0)
804 >          {
805 >          
806 >            if (args_info->dynamicProps_group_counter && override)
807 >              reset_group_dynamicProps (args_info);
808 >            args_info->dynamicProps_group_counter += 1;
809 >          
810 >            if (update_arg( 0 ,
811 >                 0 , &(args_info->helfandEcorr_given),
812 >                &(local_args_info.helfandEcorr_given), optarg, 0, 0, ARG_NO,
813 >                check_ambiguity, override, 0, 0,
814 >                "helfandEcorr", '-',
815 >                additional_error))
816 >              goto failure;
817 >          
818 >          }
819 >          /* Stress tensor correlation function.  */
820 >          else if (strcmp (long_options[option_index].name, "stresscorr") == 0)
821 >          {
822 >          
823 >            if (args_info->dynamicProps_group_counter && override)
824 >              reset_group_dynamicProps (args_info);
825 >            args_info->dynamicProps_group_counter += 1;
826 >          
827 >            if (update_arg( 0 ,
828 >                 0 , &(args_info->stresscorr_given),
829 >                &(local_args_info.stresscorr_given), optarg, 0, 0, ARG_NO,
830 >                check_ambiguity, override, 0, 0,
831 >                "stresscorr", '-',
832 >                additional_error))
833 >              goto failure;
834 >          
835 >          }
836 >          
837 >          break;
838          case '?':       /* Invalid option.  */
839            /* `getopt_long' already printed an error message.  */
840 <          exit (EXIT_FAILURE);
840 >          goto failure;
841  
842          default:        /* bug: option not considered.  */
843 <          fprintf (stderr, "%s: option unknown: %c\n", CMDLINE_PARSER_PACKAGE, c);
843 >          fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
844            abort ();
845          } /* switch */
846      } /* while */
847  
848 <  if ( dynamicProps_group_counter != 1)
848 >  if (args_info->dynamicProps_group_counter > 1)
849      {
850 <      fprintf (stderr, "%s: %d options of group dynamicProps were given. One is required\n", CMDLINE_PARSER_PACKAGE, dynamicProps_group_counter);
851 <      missing_required_options = 1;
850 >      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 : ""));
851 >      error = 1;
852      }
853    
854  
855 <  if (! args_info->input_given)
855 >
856 >  if (check_required)
857      {
858 <      fprintf (stderr, "%s: '--input' ('-i') option required\n", CMDLINE_PARSER_PACKAGE);
269 <      missing_required_options = 1;
858 >      error += cmdline_parser_required2 (args_info, argv[0], additional_error);
859      }
271  if ( missing_required_options )
272    exit (EXIT_FAILURE);
860  
861 +  cmdline_parser_release (&local_args_info);
862 +
863 +  if ( error )
864 +    return (EXIT_FAILURE);
865 +
866    return 0;
867 +
868 + failure:
869 +  
870 +  cmdline_parser_release (&local_args_info);
871 +  return (EXIT_FAILURE);
872   }

Comparing trunk/src/applications/dynamicProps/DynamicPropsCmd.c (property svn:keywords):
Revision 917 by tim, Fri Mar 24 17:29:07 2006 UTC vs.
Revision 1566 by chuckv, Thu May 19 18:12:09 2011 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines