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 1183 by xsun, Tue Oct 2 12:05:25 2007 UTC vs.
trunk/src/applications/dynamicProps/DynamicPropsCmd.cpp (file contents), Revision 1879 by gezelter, Sun Jun 16 15:15:42 2013 UTC

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

Comparing:
trunk/src/applications/dynamicProps/DynamicPropsCmd.c (property svn:keywords), Revision 1183 by xsun, Tue Oct 2 12:05:25 2007 UTC vs.
trunk/src/applications/dynamicProps/DynamicPropsCmd.cpp (property svn:keywords), Revision 1879 by gezelter, Sun Jun 16 15:15:42 2013 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines