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 1213 by xsun, Wed Jan 23 21:21:50 2008 UTC vs.
trunk/src/applications/dynamicProps/DynamicPropsCmd.cpp (file contents), Revision 1934 by gezelter, Mon Aug 26 14:15:09 2013 UTC

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

Comparing:
trunk/src/applications/dynamicProps/DynamicPropsCmd.c (property svn:keywords), Revision 1213 by xsun, Wed Jan 23 21:21:50 2008 UTC vs.
trunk/src/applications/dynamicProps/DynamicPropsCmd.cpp (property svn:keywords), Revision 1934 by gezelter, Mon Aug 26 14:15:09 2013 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines