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 507 by gezelter, Fri Apr 15 22:04:00 2005 UTC vs.
trunk/src/applications/dynamicProps/DynamicPropsCmd.cpp (file contents), Revision 2024 by gezelter, Thu Oct 16 19:13:51 2014 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/bin/gengetopt -F DynamicPropsCmd
4 >  gengetopt --file-name=DynamicPropsCmd --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 < /* 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 > #ifdef WIN32
25 > #include "utils/wingetopt.h"
26 > #else
27 > #include <getopt.h>
28 > #endif
29  
30   #include "DynamicPropsCmd.h"
31  
32 + const char *gengetopt_args_info_purpose = "";
33 +
34 + const char *gengetopt_args_info_usage = "Usage: DynamicProps [OPTIONS]... [FILES]...";
35 +
36 + const char *gengetopt_args_info_description = "";
37 +
38 + const char *gengetopt_args_info_help[] = {
39 +  "  -h, --help                    Print help and exit",
40 +  "  -V, --version                 Print version and exit",
41 +  "  -i, --input=filename          input dump file",
42 +  "  -o, --output=filename         output file name",
43 +  "      --sele1=selection script  select first stuntdouble set",
44 +  "      --sele2=selection script  select second stuntdouble set (if sele2 is not \n                                  set, use script from sele1)",
45 +  "      --order=INT               Lengendre Polynomial Order",
46 +  "  -z, --nzbins=INT              Number of Z bins  (default=`100')",
47 +  "  -m, --memory=memory specification\n                                Available memory (defaults to 2G)  \n                                  (default=`2G')",
48 +  "\n Group: dynamicProps\n   an option of this group is required",
49 +  "  -s, --selecorr                selection correlation function",
50 +  "  -r, --rcorr                   rmsd",
51 +  "  -v, --vcorr                   velocity correlation function",
52 +  "      --vcorrZ                  velocity correlation function along z-axis",
53 +  "      --vcorrR                  velocity correlation function projected \n                                  radially",
54 +  "  -d, --dcorr                   dipole correlation function",
55 +  "  -l, --lcorr                   Lengendre correlation function",
56 +  "      --lcorrZ                  Lengendre correlation function binned by Z",
57 +  "      --cohZ                    Lengendre correlation function for OH bond \n                                  vectors binned by Z",
58 +  "  -M, --sdcorr                  System dipole correlation function",
59 +  "      --r_rcorr                 Radial rmsd",
60 +  "      --thetacorr               Angular rmsd",
61 +  "      --drcorr                  Directional rmsd for particles with unit \n                                  vectors",
62 +  "      --helfandEcorr            Helfand moment for thermal conductvity",
63 +  "  -p, --momentum                Helfand momentum for viscosity",
64 +  "      --stresscorr              Stress tensor correlation function",
65 +  "  -b, --bondcorr                Bond extension correlation function",
66 +  "  -f, --freqfluccorr            Frequency Fluctuation correlation function",
67 +    0
68 + };
69 +
70 + typedef enum {ARG_NO
71 +  , ARG_STRING
72 +  , ARG_INT
73 + } cmdline_parser_arg_type;
74 +
75 + static
76 + void clear_given (struct gengetopt_args_info *args_info);
77 + static
78 + void clear_args (struct gengetopt_args_info *args_info);
79 +
80 + static int
81 + cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info,
82 +                        struct cmdline_parser_params *params, const char *additional_error);
83 +
84 + static int
85 + cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error);
86 +
87 + static char *
88 + gengetopt_strdup (const char *s);
89 +
90 + static
91 + void clear_given (struct gengetopt_args_info *args_info)
92 + {
93 +  args_info->help_given = 0 ;
94 +  args_info->version_given = 0 ;
95 +  args_info->input_given = 0 ;
96 +  args_info->output_given = 0 ;
97 +  args_info->sele1_given = 0 ;
98 +  args_info->sele2_given = 0 ;
99 +  args_info->order_given = 0 ;
100 +  args_info->nzbins_given = 0 ;
101 +  args_info->memory_given = 0 ;
102 +  args_info->selecorr_given = 0 ;
103 +  args_info->rcorr_given = 0 ;
104 +  args_info->vcorr_given = 0 ;
105 +  args_info->vcorrZ_given = 0 ;
106 +  args_info->vcorrR_given = 0 ;
107 +  args_info->dcorr_given = 0 ;
108 +  args_info->lcorr_given = 0 ;
109 +  args_info->lcorrZ_given = 0 ;
110 +  args_info->cohZ_given = 0 ;
111 +  args_info->sdcorr_given = 0 ;
112 +  args_info->r_rcorr_given = 0 ;
113 +  args_info->thetacorr_given = 0 ;
114 +  args_info->drcorr_given = 0 ;
115 +  args_info->helfandEcorr_given = 0 ;
116 +  args_info->momentum_given = 0 ;
117 +  args_info->stresscorr_given = 0 ;
118 +  args_info->bondcorr_given = 0 ;
119 +  args_info->freqfluccorr_given = 0 ;
120 +  args_info->dynamicProps_group_counter = 0 ;
121 + }
122 +
123 + static
124 + void clear_args (struct gengetopt_args_info *args_info)
125 + {
126 +  FIX_UNUSED (args_info);
127 +  args_info->input_arg = NULL;
128 +  args_info->input_orig = NULL;
129 +  args_info->output_arg = NULL;
130 +  args_info->output_orig = NULL;
131 +  args_info->sele1_arg = NULL;
132 +  args_info->sele1_orig = NULL;
133 +  args_info->sele2_arg = NULL;
134 +  args_info->sele2_orig = NULL;
135 +  args_info->order_orig = NULL;
136 +  args_info->nzbins_arg = 100;
137 +  args_info->nzbins_orig = NULL;
138 +  args_info->memory_arg = gengetopt_strdup ("2G");
139 +  args_info->memory_orig = NULL;
140 +  
141 + }
142 +
143 + static
144 + void init_args_info(struct gengetopt_args_info *args_info)
145 + {
146 +
147 +
148 +  args_info->help_help = gengetopt_args_info_help[0] ;
149 +  args_info->version_help = gengetopt_args_info_help[1] ;
150 +  args_info->input_help = gengetopt_args_info_help[2] ;
151 +  args_info->output_help = gengetopt_args_info_help[3] ;
152 +  args_info->sele1_help = gengetopt_args_info_help[4] ;
153 +  args_info->sele2_help = gengetopt_args_info_help[5] ;
154 +  args_info->order_help = gengetopt_args_info_help[6] ;
155 +  args_info->nzbins_help = gengetopt_args_info_help[7] ;
156 +  args_info->memory_help = gengetopt_args_info_help[8] ;
157 +  args_info->selecorr_help = gengetopt_args_info_help[10] ;
158 +  args_info->rcorr_help = gengetopt_args_info_help[11] ;
159 +  args_info->vcorr_help = gengetopt_args_info_help[12] ;
160 +  args_info->vcorrZ_help = gengetopt_args_info_help[13] ;
161 +  args_info->vcorrR_help = gengetopt_args_info_help[14] ;
162 +  args_info->dcorr_help = gengetopt_args_info_help[15] ;
163 +  args_info->lcorr_help = gengetopt_args_info_help[16] ;
164 +  args_info->lcorrZ_help = gengetopt_args_info_help[17] ;
165 +  args_info->cohZ_help = gengetopt_args_info_help[18] ;
166 +  args_info->sdcorr_help = gengetopt_args_info_help[19] ;
167 +  args_info->r_rcorr_help = gengetopt_args_info_help[20] ;
168 +  args_info->thetacorr_help = gengetopt_args_info_help[21] ;
169 +  args_info->drcorr_help = gengetopt_args_info_help[22] ;
170 +  args_info->helfandEcorr_help = gengetopt_args_info_help[23] ;
171 +  args_info->momentum_help = gengetopt_args_info_help[24] ;
172 +  args_info->stresscorr_help = gengetopt_args_info_help[25] ;
173 +  args_info->bondcorr_help = gengetopt_args_info_help[26] ;
174 +  args_info->freqfluccorr_help = gengetopt_args_info_help[27] ;
175 +  
176 + }
177 +
178   void
179   cmdline_parser_print_version (void)
180   {
181 <  printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION);
181 >  printf ("%s %s\n",
182 >     (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE),
183 >     CMDLINE_PARSER_VERSION);
184   }
185  
186 + static void print_help_common(void) {
187 +  cmdline_parser_print_version ();
188 +
189 +  if (strlen(gengetopt_args_info_purpose) > 0)
190 +    printf("\n%s\n", gengetopt_args_info_purpose);
191 +
192 +  if (strlen(gengetopt_args_info_usage) > 0)
193 +    printf("\n%s\n", gengetopt_args_info_usage);
194 +
195 +  printf("\n");
196 +
197 +  if (strlen(gengetopt_args_info_description) > 0)
198 +    printf("%s\n\n", gengetopt_args_info_description);
199 + }
200 +
201   void
202   cmdline_parser_print_help (void)
203   {
204 <  cmdline_parser_print_version ();
205 <  printf("\n"
206 <         "Usage: %s [OPTIONS]...\n", CMDLINE_PARSER_PACKAGE);
207 <  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("\n");
45 <  printf(" Group: dynamicProps  an option of this group is required\n");
46 <  printf("  -r, --rcorr                   rmsd\n");
47 <  printf("  -v, --vcorr                   velocity correlation function\n");
48 <  printf("  -d, --dcorr                   dipole correlation function\n");
204 >  int i = 0;
205 >  print_help_common();
206 >  while (gengetopt_args_info_help[i])
207 >    printf("%s\n", gengetopt_args_info_help[i++]);
208   }
209  
210 + void
211 + cmdline_parser_init (struct gengetopt_args_info *args_info)
212 + {
213 +  clear_given (args_info);
214 +  clear_args (args_info);
215 +  init_args_info (args_info);
216  
217 < static char *gengetopt_strdup (const char *s);
217 >  args_info->inputs = 0;
218 >  args_info->inputs_num = 0;
219 > }
220  
221 < /* gengetopt_strdup() */
222 < /* strdup.c replacement of strdup, which is not standard */
56 < char *
57 < gengetopt_strdup (const char *s)
221 > void
222 > cmdline_parser_params_init(struct cmdline_parser_params *params)
223   {
224 <  char *result = (char*)malloc(strlen(s) + 1);
225 <  if (result == (char*)0)
226 <    return (char*)0;
227 <  strcpy(result, s);
228 <  return result;
224 >  if (params)
225 >    {
226 >      params->override = 0;
227 >      params->initialize = 1;
228 >      params->check_required = 1;
229 >      params->check_ambiguity = 0;
230 >      params->print_errors = 1;
231 >    }
232   }
233  
234 + struct cmdline_parser_params *
235 + cmdline_parser_params_create(void)
236 + {
237 +  struct cmdline_parser_params *params =
238 +    (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params));
239 +  cmdline_parser_params_init(params);  
240 +  return params;
241 + }
242 +
243 + static void
244 + free_string_field (char **s)
245 + {
246 +  if (*s)
247 +    {
248 +      free (*s);
249 +      *s = 0;
250 +    }
251 + }
252 +
253 +
254 + static void
255 + cmdline_parser_release (struct gengetopt_args_info *args_info)
256 + {
257 +  unsigned int i;
258 +  free_string_field (&(args_info->input_arg));
259 +  free_string_field (&(args_info->input_orig));
260 +  free_string_field (&(args_info->output_arg));
261 +  free_string_field (&(args_info->output_orig));
262 +  free_string_field (&(args_info->sele1_arg));
263 +  free_string_field (&(args_info->sele1_orig));
264 +  free_string_field (&(args_info->sele2_arg));
265 +  free_string_field (&(args_info->sele2_orig));
266 +  free_string_field (&(args_info->order_orig));
267 +  free_string_field (&(args_info->nzbins_orig));
268 +  free_string_field (&(args_info->memory_arg));
269 +  free_string_field (&(args_info->memory_orig));
270 +  
271 +  
272 +  for (i = 0; i < args_info->inputs_num; ++i)
273 +    free (args_info->inputs [i]);
274 +
275 +  if (args_info->inputs_num)
276 +    free (args_info->inputs);
277 +
278 +  clear_given (args_info);
279 + }
280 +
281 +
282 + static void
283 + write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
284 + {
285 +  FIX_UNUSED (values);
286 +  if (arg) {
287 +    fprintf(outfile, "%s=\"%s\"\n", opt, arg);
288 +  } else {
289 +    fprintf(outfile, "%s\n", opt);
290 +  }
291 + }
292 +
293 +
294   int
295 < cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
295 > cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
296   {
297 <  int c;        /* Character of the parsed option.  */
298 <  int missing_required_options = 0;
299 <  int dynamicProps_group_counter = 0;
297 >  int i = 0;
298 >
299 >  if (!outfile)
300 >    {
301 >      fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE);
302 >      return EXIT_FAILURE;
303 >    }
304 >
305 >  if (args_info->help_given)
306 >    write_into_file(outfile, "help", 0, 0 );
307 >  if (args_info->version_given)
308 >    write_into_file(outfile, "version", 0, 0 );
309 >  if (args_info->input_given)
310 >    write_into_file(outfile, "input", args_info->input_orig, 0);
311 >  if (args_info->output_given)
312 >    write_into_file(outfile, "output", args_info->output_orig, 0);
313 >  if (args_info->sele1_given)
314 >    write_into_file(outfile, "sele1", args_info->sele1_orig, 0);
315 >  if (args_info->sele2_given)
316 >    write_into_file(outfile, "sele2", args_info->sele2_orig, 0);
317 >  if (args_info->order_given)
318 >    write_into_file(outfile, "order", args_info->order_orig, 0);
319 >  if (args_info->nzbins_given)
320 >    write_into_file(outfile, "nzbins", args_info->nzbins_orig, 0);
321 >  if (args_info->memory_given)
322 >    write_into_file(outfile, "memory", args_info->memory_orig, 0);
323 >  if (args_info->selecorr_given)
324 >    write_into_file(outfile, "selecorr", 0, 0 );
325 >  if (args_info->rcorr_given)
326 >    write_into_file(outfile, "rcorr", 0, 0 );
327 >  if (args_info->vcorr_given)
328 >    write_into_file(outfile, "vcorr", 0, 0 );
329 >  if (args_info->vcorrZ_given)
330 >    write_into_file(outfile, "vcorrZ", 0, 0 );
331 >  if (args_info->vcorrR_given)
332 >    write_into_file(outfile, "vcorrR", 0, 0 );
333 >  if (args_info->dcorr_given)
334 >    write_into_file(outfile, "dcorr", 0, 0 );
335 >  if (args_info->lcorr_given)
336 >    write_into_file(outfile, "lcorr", 0, 0 );
337 >  if (args_info->lcorrZ_given)
338 >    write_into_file(outfile, "lcorrZ", 0, 0 );
339 >  if (args_info->cohZ_given)
340 >    write_into_file(outfile, "cohZ", 0, 0 );
341 >  if (args_info->sdcorr_given)
342 >    write_into_file(outfile, "sdcorr", 0, 0 );
343 >  if (args_info->r_rcorr_given)
344 >    write_into_file(outfile, "r_rcorr", 0, 0 );
345 >  if (args_info->thetacorr_given)
346 >    write_into_file(outfile, "thetacorr", 0, 0 );
347 >  if (args_info->drcorr_given)
348 >    write_into_file(outfile, "drcorr", 0, 0 );
349 >  if (args_info->helfandEcorr_given)
350 >    write_into_file(outfile, "helfandEcorr", 0, 0 );
351 >  if (args_info->momentum_given)
352 >    write_into_file(outfile, "momentum", 0, 0 );
353 >  if (args_info->stresscorr_given)
354 >    write_into_file(outfile, "stresscorr", 0, 0 );
355 >  if (args_info->bondcorr_given)
356 >    write_into_file(outfile, "bondcorr", 0, 0 );
357 >  if (args_info->freqfluccorr_given)
358 >    write_into_file(outfile, "freqfluccorr", 0, 0 );
359    
360  
361 <  args_info->help_given = 0 ;
362 <  args_info->version_given = 0 ;
363 <  args_info->input_given = 0 ;
364 <  args_info->output_given = 0 ;
365 <  args_info->sele1_given = 0 ;
366 <  args_info->sele2_given = 0 ;
361 >  i = EXIT_SUCCESS;
362 >  return i;
363 > }
364 >
365 > int
366 > cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info)
367 > {
368 >  FILE *outfile;
369 >  int i = 0;
370 >
371 >  outfile = fopen(filename, "w");
372 >
373 >  if (!outfile)
374 >    {
375 >      fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename);
376 >      return EXIT_FAILURE;
377 >    }
378 >
379 >  i = cmdline_parser_dump(outfile, args_info);
380 >  fclose (outfile);
381 >
382 >  return i;
383 > }
384 >
385 > void
386 > cmdline_parser_free (struct gengetopt_args_info *args_info)
387 > {
388 >  cmdline_parser_release (args_info);
389 > }
390 >
391 > /** @brief replacement of strdup, which is not standard */
392 > char *
393 > gengetopt_strdup (const char *s)
394 > {
395 >  char *result = 0;
396 >  if (!s)
397 >    return result;
398 >
399 >  result = (char*)malloc(strlen(s) + 1);
400 >  if (result == (char*)0)
401 >    return (char*)0;
402 >  strcpy(result, s);
403 >  return result;
404 > }
405 >
406 > static void
407 > reset_group_dynamicProps(struct gengetopt_args_info *args_info)
408 > {
409 >  if (! args_info->dynamicProps_group_counter)
410 >    return;
411 >  
412 >  args_info->selecorr_given = 0 ;
413    args_info->rcorr_given = 0 ;
414    args_info->vcorr_given = 0 ;
415 +  args_info->vcorrZ_given = 0 ;
416 +  args_info->vcorrR_given = 0 ;
417    args_info->dcorr_given = 0 ;
418 < #define clear_args() {                          \
419 <    args_info->input_arg = NULL;                \
420 <    args_info->output_arg = NULL;               \
421 <    args_info->sele1_arg = NULL;                \
422 <    args_info->sele2_arg = NULL;                \
423 <  }
418 >  args_info->lcorr_given = 0 ;
419 >  args_info->lcorrZ_given = 0 ;
420 >  args_info->cohZ_given = 0 ;
421 >  args_info->sdcorr_given = 0 ;
422 >  args_info->r_rcorr_given = 0 ;
423 >  args_info->thetacorr_given = 0 ;
424 >  args_info->drcorr_given = 0 ;
425 >  args_info->helfandEcorr_given = 0 ;
426 >  args_info->momentum_given = 0 ;
427 >  args_info->stresscorr_given = 0 ;
428 >  args_info->bondcorr_given = 0 ;
429 >  args_info->freqfluccorr_given = 0 ;
430  
431 <  clear_args();
431 >  args_info->dynamicProps_group_counter = 0;
432 > }
433  
434 + int
435 + cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info)
436 + {
437 +  return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
438 + }
439 +
440 + int
441 + cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info,
442 +                   struct cmdline_parser_params *params)
443 + {
444 +  int result;
445 +  result = cmdline_parser_internal (argc, argv, args_info, params, 0);
446 +
447 +  if (result == EXIT_FAILURE)
448 +    {
449 +      cmdline_parser_free (args_info);
450 +      exit (EXIT_FAILURE);
451 +    }
452 +  
453 +  return result;
454 + }
455 +
456 + int
457 + cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
458 + {
459 +  int result;
460 +  struct cmdline_parser_params params;
461 +  
462 +  params.override = override;
463 +  params.initialize = initialize;
464 +  params.check_required = check_required;
465 +  params.check_ambiguity = 0;
466 +  params.print_errors = 1;
467 +
468 +  result = cmdline_parser_internal (argc, argv, args_info, &params, 0);
469 +
470 +  if (result == EXIT_FAILURE)
471 +    {
472 +      cmdline_parser_free (args_info);
473 +      exit (EXIT_FAILURE);
474 +    }
475 +  
476 +  return result;
477 + }
478 +
479 + int
480 + cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
481 + {
482 +  int result = EXIT_SUCCESS;
483 +
484 +  if (cmdline_parser_required2(args_info, prog_name, 0) > 0)
485 +    result = EXIT_FAILURE;
486 +
487 +  if (result == EXIT_FAILURE)
488 +    {
489 +      cmdline_parser_free (args_info);
490 +      exit (EXIT_FAILURE);
491 +    }
492 +  
493 +  return result;
494 + }
495 +
496 + int
497 + cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error)
498 + {
499 +  int error = 0;
500 +  FIX_UNUSED (additional_error);
501 +
502 +  /* checks for required options */
503 +  if (! args_info->input_given)
504 +    {
505 +      fprintf (stderr, "%s: '--input' ('-i') option required%s\n", prog_name, (additional_error ? additional_error : ""));
506 +      error = 1;
507 +    }
508 +  
509 +  if (args_info->dynamicProps_group_counter == 0)
510 +    {
511 +      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 : ""));
512 +      error = 1;
513 +    }
514 +  
515 +
516 +  /* checks for dependences among options */
517 +
518 +  return error;
519 + }
520 +
521 +
522 + static char *package_name = 0;
523 +
524 + /**
525 + * @brief updates an option
526 + * @param field the generic pointer to the field to update
527 + * @param orig_field the pointer to the orig field
528 + * @param field_given the pointer to the number of occurrence of this option
529 + * @param prev_given the pointer to the number of occurrence already seen
530 + * @param value the argument for this option (if null no arg was specified)
531 + * @param possible_values the possible values for this option (if specified)
532 + * @param default_value the default value (in case the option only accepts fixed values)
533 + * @param arg_type the type of this option
534 + * @param check_ambiguity @see cmdline_parser_params.check_ambiguity
535 + * @param override @see cmdline_parser_params.override
536 + * @param no_free whether to free a possible previous value
537 + * @param multiple_option whether this is a multiple option
538 + * @param long_opt the corresponding long option
539 + * @param short_opt the corresponding short option (or '-' if none)
540 + * @param additional_error possible further error specification
541 + */
542 + static
543 + int update_arg(void *field, char **orig_field,
544 +               unsigned int *field_given, unsigned int *prev_given,
545 +               char *value, const char *possible_values[],
546 +               const char *default_value,
547 +               cmdline_parser_arg_type arg_type,
548 +               int check_ambiguity, int override,
549 +               int no_free, int multiple_option,
550 +               const char *long_opt, char short_opt,
551 +               const char *additional_error)
552 + {
553 +  char *stop_char = 0;
554 +  const char *val = value;
555 +  int found;
556 +  char **string_field;
557 +  FIX_UNUSED (field);
558 +
559 +  stop_char = 0;
560 +  found = 0;
561 +
562 +  if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
563 +    {
564 +      if (short_opt != '-')
565 +        fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n",
566 +               package_name, long_opt, short_opt,
567 +               (additional_error ? additional_error : ""));
568 +      else
569 +        fprintf (stderr, "%s: `--%s' option given more than once%s\n",
570 +               package_name, long_opt,
571 +               (additional_error ? additional_error : ""));
572 +      return 1; /* failure */
573 +    }
574 +
575 +  FIX_UNUSED (default_value);
576 +    
577 +  if (field_given && *field_given && ! override)
578 +    return 0;
579 +  if (prev_given)
580 +    (*prev_given)++;
581 +  if (field_given)
582 +    (*field_given)++;
583 +  if (possible_values)
584 +    val = possible_values[found];
585 +
586 +  switch(arg_type) {
587 +  case ARG_INT:
588 +    if (val) *((int *)field) = strtol (val, &stop_char, 0);
589 +    break;
590 +  case ARG_STRING:
591 +    if (val) {
592 +      string_field = (char **)field;
593 +      if (!no_free && *string_field)
594 +        free (*string_field); /* free previous string */
595 +      *string_field = gengetopt_strdup (val);
596 +    }
597 +    break;
598 +  default:
599 +    break;
600 +  };
601 +
602 +  /* check numeric conversion */
603 +  switch(arg_type) {
604 +  case ARG_INT:
605 +    if (val && !(stop_char && *stop_char == '\0')) {
606 +      fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
607 +      return 1; /* failure */
608 +    }
609 +    break;
610 +  default:
611 +    ;
612 +  };
613 +
614 +  /* store the original value */
615 +  switch(arg_type) {
616 +  case ARG_NO:
617 +    break;
618 +  default:
619 +    if (value && orig_field) {
620 +      if (no_free) {
621 +        *orig_field = value;
622 +      } else {
623 +        if (*orig_field)
624 +          free (*orig_field); /* free previous string */
625 +        *orig_field = gengetopt_strdup (value);
626 +      }
627 +    }
628 +  };
629 +
630 +  return 0; /* OK */
631 + }
632 +
633 +
634 + int
635 + cmdline_parser_internal (
636 +  int argc, char **argv, struct gengetopt_args_info *args_info,
637 +                        struct cmdline_parser_params *params, const char *additional_error)
638 + {
639 +  int c;        /* Character of the parsed option.  */
640 +
641 +  int error = 0;
642 +  struct gengetopt_args_info local_args_info;
643 +  
644 +  int override;
645 +  int initialize;
646 +  int check_required;
647 +  int check_ambiguity;
648 +  
649 +  package_name = argv[0];
650 +  
651 +  override = params->override;
652 +  initialize = params->initialize;
653 +  check_required = params->check_required;
654 +  check_ambiguity = params->check_ambiguity;
655 +
656 +  if (initialize)
657 +    cmdline_parser_init (args_info);
658 +
659 +  cmdline_parser_init (&local_args_info);
660 +
661    optarg = 0;
662 <  optind = 1;
663 <  opterr = 1;
662 >  optind = 0;
663 >  opterr = params->print_errors;
664    optopt = '?';
665  
666    while (1)
667      {
668        int option_index = 0;
100      char *stop_char;
669  
670        static struct option long_options[] = {
671          { "help",       0, NULL, 'h' },
# Line 106 | Line 674 | cmdline_parser (int argc, char * const *argv, struct g
674          { "output",     1, NULL, 'o' },
675          { "sele1",      1, NULL, 0 },
676          { "sele2",      1, NULL, 0 },
677 +        { "order",      1, NULL, 0 },
678 +        { "nzbins",     1, NULL, 'z' },
679 +        { "memory",     1, NULL, 'm' },
680 +        { "selecorr",   0, NULL, 's' },
681          { "rcorr",      0, NULL, 'r' },
682          { "vcorr",      0, NULL, 'v' },
683 +        { "vcorrZ",     0, NULL, 0 },
684 +        { "vcorrR",     0, NULL, 0 },
685          { "dcorr",      0, NULL, 'd' },
686 <        { NULL, 0, NULL, 0 }
686 >        { "lcorr",      0, NULL, 'l' },
687 >        { "lcorrZ",     0, NULL, 0 },
688 >        { "cohZ",       0, NULL, 0 },
689 >        { "sdcorr",     0, NULL, 'M' },
690 >        { "r_rcorr",    0, NULL, 0 },
691 >        { "thetacorr",  0, NULL, 0 },
692 >        { "drcorr",     0, NULL, 0 },
693 >        { "helfandEcorr",       0, NULL, 0 },
694 >        { "momentum",   0, NULL, 'p' },
695 >        { "stresscorr", 0, NULL, 0 },
696 >        { "bondcorr",   0, NULL, 'b' },
697 >        { "freqfluccorr",       0, NULL, 'f' },
698 >        { 0,  0, 0, 0 }
699        };
700  
701 <      stop_char = 0;
116 <      c = getopt_long (argc, argv, "hVi:o:rvd", long_options, &option_index);
701 >      c = getopt_long (argc, argv, "hVi:o:z:m:srvdlMpbf", long_options, &option_index);
702  
703        if (c == -1) break;       /* Exit from `while (1)' loop.  */
704  
705        switch (c)
706          {
707          case 'h':       /* Print help and exit.  */
123          clear_args ();
708            cmdline_parser_print_help ();
709 +          cmdline_parser_free (&local_args_info);
710            exit (EXIT_SUCCESS);
711  
712          case 'V':       /* Print version and exit.  */
128          clear_args ();
713            cmdline_parser_print_version ();
714 +          cmdline_parser_free (&local_args_info);
715            exit (EXIT_SUCCESS);
716  
717          case 'i':       /* input dump file.  */
718 <          if (args_info->input_given)
719 <            {
720 <              fprintf (stderr, "%s: `--input' (`-i') option given more than once\n", CMDLINE_PARSER_PACKAGE);
721 <              clear_args ();
722 <              exit (EXIT_FAILURE);
723 <            }
724 <          args_info->input_given = 1;
725 <          args_info->input_arg = gengetopt_strdup (optarg);
718 >        
719 >        
720 >          if (update_arg( (void *)&(args_info->input_arg),
721 >               &(args_info->input_orig), &(args_info->input_given),
722 >              &(local_args_info.input_given), optarg, 0, 0, ARG_STRING,
723 >              check_ambiguity, override, 0, 0,
724 >              "input", 'i',
725 >              additional_error))
726 >            goto failure;
727 >        
728            break;
142
729          case 'o':       /* output file name.  */
730 <          if (args_info->output_given)
731 <            {
732 <              fprintf (stderr, "%s: `--output' (`-o') option given more than once\n", CMDLINE_PARSER_PACKAGE);
733 <              clear_args ();
734 <              exit (EXIT_FAILURE);
735 <            }
736 <          args_info->output_given = 1;
737 <          args_info->output_arg = gengetopt_strdup (optarg);
730 >        
731 >        
732 >          if (update_arg( (void *)&(args_info->output_arg),
733 >               &(args_info->output_orig), &(args_info->output_given),
734 >              &(local_args_info.output_given), optarg, 0, 0, ARG_STRING,
735 >              check_ambiguity, override, 0, 0,
736 >              "output", 'o',
737 >              additional_error))
738 >            goto failure;
739 >        
740            break;
741 <
741 >        case 'z':       /* Number of Z bins.  */
742 >        
743 >        
744 >          if (update_arg( (void *)&(args_info->nzbins_arg),
745 >               &(args_info->nzbins_orig), &(args_info->nzbins_given),
746 >              &(local_args_info.nzbins_given), optarg, 0, "100", ARG_INT,
747 >              check_ambiguity, override, 0, 0,
748 >              "nzbins", 'z',
749 >              additional_error))
750 >            goto failure;
751 >        
752 >          break;
753 >        case 'm':       /* Available memory (defaults to 2G).  */
754 >        
755 >        
756 >          if (update_arg( (void *)&(args_info->memory_arg),
757 >               &(args_info->memory_orig), &(args_info->memory_given),
758 >              &(local_args_info.memory_given), optarg, 0, "2G", ARG_STRING,
759 >              check_ambiguity, override, 0, 0,
760 >              "memory", 'm',
761 >              additional_error))
762 >            goto failure;
763 >        
764 >          break;
765 >        case 's':       /* selection correlation function.  */
766 >        
767 >          if (args_info->dynamicProps_group_counter && override)
768 >            reset_group_dynamicProps (args_info);
769 >          args_info->dynamicProps_group_counter += 1;
770 >        
771 >          if (update_arg( 0 ,
772 >               0 , &(args_info->selecorr_given),
773 >              &(local_args_info.selecorr_given), optarg, 0, 0, ARG_NO,
774 >              check_ambiguity, override, 0, 0,
775 >              "selecorr", 's',
776 >              additional_error))
777 >            goto failure;
778 >        
779 >          break;
780          case 'r':       /* rmsd.  */
781 <          if (args_info->rcorr_given)
782 <            {
783 <              fprintf (stderr, "%s: `--rcorr' (`-r') option given more than once\n", CMDLINE_PARSER_PACKAGE);
784 <              clear_args ();
785 <              exit (EXIT_FAILURE);
786 <            }
787 <          args_info->rcorr_given = 1;
788 <          dynamicProps_group_counter += 1;
789 <          break;
790 <
781 >        
782 >          if (args_info->dynamicProps_group_counter && override)
783 >            reset_group_dynamicProps (args_info);
784 >          args_info->dynamicProps_group_counter += 1;
785 >        
786 >          if (update_arg( 0 ,
787 >               0 , &(args_info->rcorr_given),
788 >              &(local_args_info.rcorr_given), optarg, 0, 0, ARG_NO,
789 >              check_ambiguity, override, 0, 0,
790 >              "rcorr", 'r',
791 >              additional_error))
792 >            goto failure;
793 >        
794 >          break;
795          case 'v':       /* velocity correlation function.  */
796 <          if (args_info->vcorr_given)
797 <            {
798 <              fprintf (stderr, "%s: `--vcorr' (`-v') option given more than once\n", CMDLINE_PARSER_PACKAGE);
799 <              clear_args ();
800 <              exit (EXIT_FAILURE);
801 <            }
802 <          args_info->vcorr_given = 1;
803 <          dynamicProps_group_counter += 1;
804 <          break;
805 <
796 >        
797 >          if (args_info->dynamicProps_group_counter && override)
798 >            reset_group_dynamicProps (args_info);
799 >          args_info->dynamicProps_group_counter += 1;
800 >        
801 >          if (update_arg( 0 ,
802 >               0 , &(args_info->vcorr_given),
803 >              &(local_args_info.vcorr_given), optarg, 0, 0, ARG_NO,
804 >              check_ambiguity, override, 0, 0,
805 >              "vcorr", 'v',
806 >              additional_error))
807 >            goto failure;
808 >        
809 >          break;
810          case 'd':       /* dipole correlation function.  */
811 <          if (args_info->dcorr_given)
812 <            {
813 <              fprintf (stderr, "%s: `--dcorr' (`-d') option given more than once\n", CMDLINE_PARSER_PACKAGE);
814 <              clear_args ();
815 <              exit (EXIT_FAILURE);
816 <            }
817 <          args_info->dcorr_given = 1;
818 <          dynamicProps_group_counter += 1;
819 <          break;
820 <
811 >        
812 >          if (args_info->dynamicProps_group_counter && override)
813 >            reset_group_dynamicProps (args_info);
814 >          args_info->dynamicProps_group_counter += 1;
815 >        
816 >          if (update_arg( 0 ,
817 >               0 , &(args_info->dcorr_given),
818 >              &(local_args_info.dcorr_given), optarg, 0, 0, ARG_NO,
819 >              check_ambiguity, override, 0, 0,
820 >              "dcorr", 'd',
821 >              additional_error))
822 >            goto failure;
823 >        
824 >          break;
825 >        case 'l':       /* Lengendre correlation function.  */
826 >        
827 >          if (args_info->dynamicProps_group_counter && override)
828 >            reset_group_dynamicProps (args_info);
829 >          args_info->dynamicProps_group_counter += 1;
830 >        
831 >          if (update_arg( 0 ,
832 >               0 , &(args_info->lcorr_given),
833 >              &(local_args_info.lcorr_given), optarg, 0, 0, ARG_NO,
834 >              check_ambiguity, override, 0, 0,
835 >              "lcorr", 'l',
836 >              additional_error))
837 >            goto failure;
838 >        
839 >          break;
840 >        case 'M':       /* System dipole correlation function.  */
841 >        
842 >          if (args_info->dynamicProps_group_counter && override)
843 >            reset_group_dynamicProps (args_info);
844 >          args_info->dynamicProps_group_counter += 1;
845 >        
846 >          if (update_arg( 0 ,
847 >               0 , &(args_info->sdcorr_given),
848 >              &(local_args_info.sdcorr_given), optarg, 0, 0, ARG_NO,
849 >              check_ambiguity, override, 0, 0,
850 >              "sdcorr", 'M',
851 >              additional_error))
852 >            goto failure;
853 >        
854 >          break;
855 >        case 'p':       /* Helfand momentum for viscosity.  */
856 >        
857 >          if (args_info->dynamicProps_group_counter && override)
858 >            reset_group_dynamicProps (args_info);
859 >          args_info->dynamicProps_group_counter += 1;
860 >        
861 >          if (update_arg( 0 ,
862 >               0 , &(args_info->momentum_given),
863 >              &(local_args_info.momentum_given), optarg, 0, 0, ARG_NO,
864 >              check_ambiguity, override, 0, 0,
865 >              "momentum", 'p',
866 >              additional_error))
867 >            goto failure;
868 >        
869 >          break;
870 >        case 'b':       /* Bond extension correlation function.  */
871 >        
872 >          if (args_info->dynamicProps_group_counter && override)
873 >            reset_group_dynamicProps (args_info);
874 >          args_info->dynamicProps_group_counter += 1;
875 >        
876 >          if (update_arg( 0 ,
877 >               0 , &(args_info->bondcorr_given),
878 >              &(local_args_info.bondcorr_given), optarg, 0, 0, ARG_NO,
879 >              check_ambiguity, override, 0, 0,
880 >              "bondcorr", 'b',
881 >              additional_error))
882 >            goto failure;
883 >        
884 >          break;
885 >        case 'f':       /* Frequency Fluctuation correlation function.  */
886 >        
887 >          if (args_info->dynamicProps_group_counter && override)
888 >            reset_group_dynamicProps (args_info);
889 >          args_info->dynamicProps_group_counter += 1;
890 >        
891 >          if (update_arg( 0 ,
892 >               0 , &(args_info->freqfluccorr_given),
893 >              &(local_args_info.freqfluccorr_given), optarg, 0, 0, ARG_NO,
894 >              check_ambiguity, override, 0, 0,
895 >              "freqfluccorr", 'f',
896 >              additional_error))
897 >            goto failure;
898 >        
899 >          break;
900  
901          case 0: /* Long option with no short option */
902            /* select first stuntdouble set.  */
903            if (strcmp (long_options[option_index].name, "sele1") == 0)
904 <            {
192 <              if (args_info->sele1_given)
193 <                {
194 <                  fprintf (stderr, "%s: `--sele1' option given more than once\n", CMDLINE_PARSER_PACKAGE);
195 <                  clear_args ();
196 <                  exit (EXIT_FAILURE);
197 <                }
198 <              args_info->sele1_given = 1;
199 <              args_info->sele1_arg = gengetopt_strdup (optarg);
200 <              break;
201 <            }
904 >          {
905            
906 +          
907 +            if (update_arg( (void *)&(args_info->sele1_arg),
908 +                 &(args_info->sele1_orig), &(args_info->sele1_given),
909 +                &(local_args_info.sele1_given), optarg, 0, 0, ARG_STRING,
910 +                check_ambiguity, override, 0, 0,
911 +                "sele1", '-',
912 +                additional_error))
913 +              goto failure;
914 +          
915 +          }
916            /* select second stuntdouble set (if sele2 is not set, use script from sele1).  */
917            else if (strcmp (long_options[option_index].name, "sele2") == 0)
918 <            {
206 <              if (args_info->sele2_given)
207 <                {
208 <                  fprintf (stderr, "%s: `--sele2' option given more than once\n", CMDLINE_PARSER_PACKAGE);
209 <                  clear_args ();
210 <                  exit (EXIT_FAILURE);
211 <                }
212 <              args_info->sele2_given = 1;
213 <              args_info->sele2_arg = gengetopt_strdup (optarg);
214 <              break;
215 <            }
918 >          {
919            
920 <
920 >          
921 >            if (update_arg( (void *)&(args_info->sele2_arg),
922 >                 &(args_info->sele2_orig), &(args_info->sele2_given),
923 >                &(local_args_info.sele2_given), optarg, 0, 0, ARG_STRING,
924 >                check_ambiguity, override, 0, 0,
925 >                "sele2", '-',
926 >                additional_error))
927 >              goto failure;
928 >          
929 >          }
930 >          /* Lengendre Polynomial Order.  */
931 >          else if (strcmp (long_options[option_index].name, "order") == 0)
932 >          {
933 >          
934 >          
935 >            if (update_arg( (void *)&(args_info->order_arg),
936 >                 &(args_info->order_orig), &(args_info->order_given),
937 >                &(local_args_info.order_given), optarg, 0, 0, ARG_INT,
938 >                check_ambiguity, override, 0, 0,
939 >                "order", '-',
940 >                additional_error))
941 >              goto failure;
942 >          
943 >          }
944 >          /* velocity correlation function along z-axis.  */
945 >          else if (strcmp (long_options[option_index].name, "vcorrZ") == 0)
946 >          {
947 >          
948 >            if (args_info->dynamicProps_group_counter && override)
949 >              reset_group_dynamicProps (args_info);
950 >            args_info->dynamicProps_group_counter += 1;
951 >          
952 >            if (update_arg( 0 ,
953 >                 0 , &(args_info->vcorrZ_given),
954 >                &(local_args_info.vcorrZ_given), optarg, 0, 0, ARG_NO,
955 >                check_ambiguity, override, 0, 0,
956 >                "vcorrZ", '-',
957 >                additional_error))
958 >              goto failure;
959 >          
960 >          }
961 >          /* velocity correlation function projected radially.  */
962 >          else if (strcmp (long_options[option_index].name, "vcorrR") == 0)
963 >          {
964 >          
965 >            if (args_info->dynamicProps_group_counter && override)
966 >              reset_group_dynamicProps (args_info);
967 >            args_info->dynamicProps_group_counter += 1;
968 >          
969 >            if (update_arg( 0 ,
970 >                 0 , &(args_info->vcorrR_given),
971 >                &(local_args_info.vcorrR_given), optarg, 0, 0, ARG_NO,
972 >                check_ambiguity, override, 0, 0,
973 >                "vcorrR", '-',
974 >                additional_error))
975 >              goto failure;
976 >          
977 >          }
978 >          /* Lengendre correlation function binned by Z.  */
979 >          else if (strcmp (long_options[option_index].name, "lcorrZ") == 0)
980 >          {
981 >          
982 >            if (args_info->dynamicProps_group_counter && override)
983 >              reset_group_dynamicProps (args_info);
984 >            args_info->dynamicProps_group_counter += 1;
985 >          
986 >            if (update_arg( 0 ,
987 >                 0 , &(args_info->lcorrZ_given),
988 >                &(local_args_info.lcorrZ_given), optarg, 0, 0, ARG_NO,
989 >                check_ambiguity, override, 0, 0,
990 >                "lcorrZ", '-',
991 >                additional_error))
992 >              goto failure;
993 >          
994 >          }
995 >          /* Lengendre correlation function for OH bond vectors binned by Z.  */
996 >          else if (strcmp (long_options[option_index].name, "cohZ") == 0)
997 >          {
998 >          
999 >            if (args_info->dynamicProps_group_counter && override)
1000 >              reset_group_dynamicProps (args_info);
1001 >            args_info->dynamicProps_group_counter += 1;
1002 >          
1003 >            if (update_arg( 0 ,
1004 >                 0 , &(args_info->cohZ_given),
1005 >                &(local_args_info.cohZ_given), optarg, 0, 0, ARG_NO,
1006 >                check_ambiguity, override, 0, 0,
1007 >                "cohZ", '-',
1008 >                additional_error))
1009 >              goto failure;
1010 >          
1011 >          }
1012 >          /* Radial rmsd.  */
1013 >          else if (strcmp (long_options[option_index].name, "r_rcorr") == 0)
1014 >          {
1015 >          
1016 >            if (args_info->dynamicProps_group_counter && override)
1017 >              reset_group_dynamicProps (args_info);
1018 >            args_info->dynamicProps_group_counter += 1;
1019 >          
1020 >            if (update_arg( 0 ,
1021 >                 0 , &(args_info->r_rcorr_given),
1022 >                &(local_args_info.r_rcorr_given), optarg, 0, 0, ARG_NO,
1023 >                check_ambiguity, override, 0, 0,
1024 >                "r_rcorr", '-',
1025 >                additional_error))
1026 >              goto failure;
1027 >          
1028 >          }
1029 >          /* Angular rmsd.  */
1030 >          else if (strcmp (long_options[option_index].name, "thetacorr") == 0)
1031 >          {
1032 >          
1033 >            if (args_info->dynamicProps_group_counter && override)
1034 >              reset_group_dynamicProps (args_info);
1035 >            args_info->dynamicProps_group_counter += 1;
1036 >          
1037 >            if (update_arg( 0 ,
1038 >                 0 , &(args_info->thetacorr_given),
1039 >                &(local_args_info.thetacorr_given), optarg, 0, 0, ARG_NO,
1040 >                check_ambiguity, override, 0, 0,
1041 >                "thetacorr", '-',
1042 >                additional_error))
1043 >              goto failure;
1044 >          
1045 >          }
1046 >          /* Directional rmsd for particles with unit vectors.  */
1047 >          else if (strcmp (long_options[option_index].name, "drcorr") == 0)
1048 >          {
1049 >          
1050 >            if (args_info->dynamicProps_group_counter && override)
1051 >              reset_group_dynamicProps (args_info);
1052 >            args_info->dynamicProps_group_counter += 1;
1053 >          
1054 >            if (update_arg( 0 ,
1055 >                 0 , &(args_info->drcorr_given),
1056 >                &(local_args_info.drcorr_given), optarg, 0, 0, ARG_NO,
1057 >                check_ambiguity, override, 0, 0,
1058 >                "drcorr", '-',
1059 >                additional_error))
1060 >              goto failure;
1061 >          
1062 >          }
1063 >          /* Helfand moment for thermal conductvity.  */
1064 >          else if (strcmp (long_options[option_index].name, "helfandEcorr") == 0)
1065 >          {
1066 >          
1067 >            if (args_info->dynamicProps_group_counter && override)
1068 >              reset_group_dynamicProps (args_info);
1069 >            args_info->dynamicProps_group_counter += 1;
1070 >          
1071 >            if (update_arg( 0 ,
1072 >                 0 , &(args_info->helfandEcorr_given),
1073 >                &(local_args_info.helfandEcorr_given), optarg, 0, 0, ARG_NO,
1074 >                check_ambiguity, override, 0, 0,
1075 >                "helfandEcorr", '-',
1076 >                additional_error))
1077 >              goto failure;
1078 >          
1079 >          }
1080 >          /* Stress tensor correlation function.  */
1081 >          else if (strcmp (long_options[option_index].name, "stresscorr") == 0)
1082 >          {
1083 >          
1084 >            if (args_info->dynamicProps_group_counter && override)
1085 >              reset_group_dynamicProps (args_info);
1086 >            args_info->dynamicProps_group_counter += 1;
1087 >          
1088 >            if (update_arg( 0 ,
1089 >                 0 , &(args_info->stresscorr_given),
1090 >                &(local_args_info.stresscorr_given), optarg, 0, 0, ARG_NO,
1091 >                check_ambiguity, override, 0, 0,
1092 >                "stresscorr", '-',
1093 >                additional_error))
1094 >              goto failure;
1095 >          
1096 >          }
1097 >          
1098 >          break;
1099          case '?':       /* Invalid option.  */
1100            /* `getopt_long' already printed an error message.  */
1101 <          exit (EXIT_FAILURE);
1101 >          goto failure;
1102  
1103          default:        /* bug: option not considered.  */
1104 <          fprintf (stderr, "%s: option unknown: %c\n", CMDLINE_PARSER_PACKAGE, c);
1104 >          fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
1105            abort ();
1106          } /* switch */
1107      } /* while */
1108  
1109 <  if ( dynamicProps_group_counter != 1)
1109 >  if (args_info->dynamicProps_group_counter > 1)
1110      {
1111 <      fprintf (stderr, "%s: %d options of group dynamicProps were given. One is required\n", CMDLINE_PARSER_PACKAGE, dynamicProps_group_counter);
1112 <      missing_required_options = 1;
1111 >      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 : ""));
1112 >      error = 1;
1113      }
1114    
1115  
1116 <  if (! args_info->input_given)
1116 >
1117 >  if (check_required)
1118      {
1119 <      fprintf (stderr, "%s: '--input' ('-i') option required\n", CMDLINE_PARSER_PACKAGE);
238 <      missing_required_options = 1;
1119 >      error += cmdline_parser_required2 (args_info, argv[0], additional_error);
1120      }
240  if ( missing_required_options )
241    exit (EXIT_FAILURE);
1121  
1122 +  cmdline_parser_release (&local_args_info);
1123 +
1124 +  if ( error )
1125 +    return (EXIT_FAILURE);
1126 +
1127 +  if (optind < argc)
1128 +    {
1129 +      int i = 0 ;
1130 +      int found_prog_name = 0;
1131 +      /* whether program name, i.e., argv[0], is in the remaining args
1132 +         (this may happen with some implementations of getopt,
1133 +          but surely not with the one included by gengetopt) */
1134 +
1135 +      i = optind;
1136 +      while (i < argc)
1137 +        if (argv[i++] == argv[0]) {
1138 +          found_prog_name = 1;
1139 +          break;
1140 +        }
1141 +      i = 0;
1142 +
1143 +      args_info->inputs_num = argc - optind - found_prog_name;
1144 +      args_info->inputs =
1145 +        (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ;
1146 +      while (optind < argc)
1147 +        if (argv[optind++] != argv[0])
1148 +          args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind-1]) ;
1149 +    }
1150 +
1151    return 0;
1152 +
1153 + failure:
1154 +  
1155 +  cmdline_parser_release (&local_args_info);
1156 +  return (EXIT_FAILURE);
1157   }

Comparing:
trunk/src/applications/dynamicProps/DynamicPropsCmd.c (property svn:keywords), Revision 507 by gezelter, Fri Apr 15 22:04:00 2005 UTC vs.
trunk/src/applications/dynamicProps/DynamicPropsCmd.cpp (property svn:keywords), Revision 2024 by gezelter, Thu Oct 16 19:13:51 2014 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines