ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/applications/dynamicProps/DynamicPropsCmd.cpp
(Generate patch)

Comparing:
branches/development/src/applications/dynamicProps/DynamicPropsCmd.c (file contents), Revision 1465 by chuckv, Fri Jul 9 23:08:25 2010 UTC vs.
trunk/src/applications/dynamicProps/DynamicPropsCmd.cpp (file contents), Revision 1811 by gezelter, Fri Nov 16 15:12:21 2012 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines