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

Comparing:
trunk/src/applications/dynamicProps/DynamicPropsCmd.c (property svn:keywords), Revision 917 by tim, Fri Mar 24 17:29:07 2006 UTC vs.
trunk/src/applications/dynamicProps/DynamicPropsCmd.cpp (property svn:keywords), Revision 2003 by gezelter, Sun Jun 1 19:28:44 2014 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines