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 1112 by chuckv, Wed Jan 3 20:47:00 2007 UTC vs.
trunk/src/applications/dynamicProps/DynamicPropsCmd.cpp (file contents), Revision 1915 by gezelter, Mon Jul 29 17:55:17 2013 UTC

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

Comparing:
trunk/src/applications/dynamicProps/DynamicPropsCmd.c (property svn:keywords), Revision 1112 by chuckv, Wed Jan 3 20:47:00 2007 UTC vs.
trunk/src/applications/dynamicProps/DynamicPropsCmd.cpp (property svn:keywords), Revision 1915 by gezelter, Mon Jul 29 17:55:17 2013 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines