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

Comparing:
trunk/src/applications/hydrodynamics/HydroCmd.c (file contents), Revision 938 by gezelter, Mon Apr 17 21:49:12 2006 UTC vs.
branches/development/src/applications/hydrodynamics/HydroCmd.c (file contents), Revision 1630 by gezelter, Wed Sep 14 21:40:12 2011 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 HydroCmd
4 >  gengetopt -F HydroCmd -u
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 "HydroCmd.h"
27  
28 + const char *gengetopt_args_info_purpose = "\n +-----------------------------------------------------------------------+\n |    ____                    __  ___ ____                               |\n |   / __ \\____  ___  ____   /  |/  // __ \\  The Open Molecular Dynamics |\n |  / / / / __ \\/ _ \\/ __ \\ / /|_/ // / / /  Engine (formerly OOPSE).    |\n | / /_/ / /_/ /  __/ / / // /  / // /_/ /                               |\n | \\____/ .___/\\___/_/ /_//_/  /_//_____/    Copyright 2004-2009 by the  |\n |     /_/                                   University of Notre Dame.   |\n |                                                                       |\n |                                           http://www.openmd.net       |\n |                                                                       |\n | OpenMD is an OpenScience project.  All source code is available for   |\n | any use whatsoever under a BSD-style license.                         |\n |                                                                       |\n | Support OpenScience!  If you use OpenMD or its source code in your    |\n | research, please cite the appropriate papers when you publish your    |\n | work.  Good starting points are:                                      |\n |                                                                       |\n | [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).              |\n | [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).           |\n | [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008).           |\n | [4]  Vardeman & Gezelter, in progress (2009).                         |\n +-----------------------------------------------------------------------+";
29 +
30 + const char *gengetopt_args_info_usage = "Usage: Hydro [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 MetaData (md) file",
38 +  "  -o, --output=STRING   output file prefix  (default=`hydro')",
39 +  "      --model=STRING    hydrodynamics model (supports RoughShell and BeadModel)",
40 +  "  -b, --beads           generate the beads only, hydrodynamics will be \n                          performed  (default=off)",
41 +    0
42 + };
43 +
44 + typedef enum {ARG_NO
45 +  , ARG_FLAG
46 +  , ARG_STRING
47 + } cmdline_parser_arg_type;
48 +
49   static
50   void clear_given (struct gengetopt_args_info *args_info);
51   static
52   void clear_args (struct gengetopt_args_info *args_info);
53  
54   static int
55 < 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);
55 > cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info,
56 >                        struct cmdline_parser_params *params, const char *additional_error);
57  
58   static int
59   cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error);
# Line 49 | Line 75 | void clear_args (struct gengetopt_args_info *args_info
75   static
76   void clear_args (struct gengetopt_args_info *args_info)
77   {
78 +  FIX_UNUSED (args_info);
79    args_info->input_arg = NULL;
80    args_info->input_orig = NULL;
81    args_info->output_arg = gengetopt_strdup ("hydro");
# Line 59 | Line 86 | void clear_args (struct gengetopt_args_info *args_info
86    
87   }
88  
89 + static
90 + void init_args_info(struct gengetopt_args_info *args_info)
91 + {
92 +
93 +
94 +  args_info->help_help = gengetopt_args_info_help[0] ;
95 +  args_info->version_help = gengetopt_args_info_help[1] ;
96 +  args_info->input_help = gengetopt_args_info_help[2] ;
97 +  args_info->output_help = gengetopt_args_info_help[3] ;
98 +  args_info->model_help = gengetopt_args_info_help[4] ;
99 +  args_info->beads_help = gengetopt_args_info_help[5] ;
100 +  
101 + }
102 +
103   void
104   cmdline_parser_print_version (void)
105   {
106 <  printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION);
106 >  printf ("%s %s\n",
107 >     (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE),
108 >     CMDLINE_PARSER_VERSION);
109   }
110  
111 + static void print_help_common(void) {
112 +  cmdline_parser_print_version ();
113 +
114 +  if (strlen(gengetopt_args_info_purpose) > 0)
115 +    printf("\n%s\n", gengetopt_args_info_purpose);
116 +
117 +  if (strlen(gengetopt_args_info_usage) > 0)
118 +    printf("\n%s\n", gengetopt_args_info_usage);
119 +
120 +  printf("\n");
121 +
122 +  if (strlen(gengetopt_args_info_description) > 0)
123 +    printf("%s\n\n", gengetopt_args_info_description);
124 + }
125 +
126   void
127   cmdline_parser_print_help (void)
128   {
129 <  cmdline_parser_print_version ();
130 <  printf("\nUsage: Hydro [OPTIONS]...\n\n");
131 <  printf("%s\n","  -h, --help            Print help and exit");
132 <  printf("%s\n","  -V, --version         Print version and exit");
75 <  printf("%s\n","  -i, --input=filename  input dump file");
76 <  printf("%s\n","  -o, --output=STRING   output file prefix  (default=`hydro')");
77 <  printf("%s\n","      --model=STRING    hydrodynamics model (support RoughShell and BeadModel)");
78 <  printf("%s\n","  -b, --beads           generate the beads only, hydrodynamics will be \n                          performed  (default=off)");
79 <  
129 >  int i = 0;
130 >  print_help_common();
131 >  while (gengetopt_args_info_help[i])
132 >    printf("%s\n", gengetopt_args_info_help[i++]);
133   }
134  
135   void
# Line 84 | Line 137 | cmdline_parser_init (struct gengetopt_args_info *args_
137   {
138    clear_given (args_info);
139    clear_args (args_info);
140 +  init_args_info (args_info);
141 +
142 +  args_info->inputs = 0;
143 +  args_info->inputs_num = 0;
144   }
145  
146 + void
147 + cmdline_parser_params_init(struct cmdline_parser_params *params)
148 + {
149 +  if (params)
150 +    {
151 +      params->override = 0;
152 +      params->initialize = 1;
153 +      params->check_required = 1;
154 +      params->check_ambiguity = 0;
155 +      params->print_errors = 1;
156 +    }
157 + }
158 +
159 + struct cmdline_parser_params *
160 + cmdline_parser_params_create(void)
161 + {
162 +  struct cmdline_parser_params *params =
163 +    (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params));
164 +  cmdline_parser_params_init(params);  
165 +  return params;
166 + }
167 +
168   static void
169 < cmdline_parser_release (struct gengetopt_args_info *args_info)
169 > free_string_field (char **s)
170   {
171 <  
93 <  if (args_info->input_arg)
171 >  if (*s)
172      {
173 <      free (args_info->input_arg); /* free previous argument */
174 <      args_info->input_arg = 0;
173 >      free (*s);
174 >      *s = 0;
175      }
176 <  if (args_info->input_orig)
177 <    {
178 <      free (args_info->input_orig); /* free previous argument */
179 <      args_info->input_orig = 0;
180 <    }
181 <  if (args_info->output_arg)
182 <    {
183 <      free (args_info->output_arg); /* free previous argument */
184 <      args_info->output_arg = 0;
185 <    }
186 <  if (args_info->output_orig)
187 <    {
188 <      free (args_info->output_orig); /* free previous argument */
189 <      args_info->output_orig = 0;
190 <    }
191 <  if (args_info->model_arg)
192 <    {
193 <      free (args_info->model_arg); /* free previous argument */
194 <      args_info->model_arg = 0;
195 <    }
196 <  if (args_info->model_orig)
176 > }
177 >
178 >
179 > static void
180 > cmdline_parser_release (struct gengetopt_args_info *args_info)
181 > {
182 >  unsigned int i;
183 >  free_string_field (&(args_info->input_arg));
184 >  free_string_field (&(args_info->input_orig));
185 >  free_string_field (&(args_info->output_arg));
186 >  free_string_field (&(args_info->output_orig));
187 >  free_string_field (&(args_info->model_arg));
188 >  free_string_field (&(args_info->model_orig));
189 >  
190 >  
191 >  for (i = 0; i < args_info->inputs_num; ++i)
192 >    free (args_info->inputs [i]);
193 >
194 >  if (args_info->inputs_num)
195 >    free (args_info->inputs);
196 >
197 >  clear_given (args_info);
198 > }
199 >
200 >
201 > static void
202 > write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
203 > {
204 >  FIX_UNUSED (values);
205 >  if (arg) {
206 >    fprintf(outfile, "%s=\"%s\"\n", opt, arg);
207 >  } else {
208 >    fprintf(outfile, "%s\n", opt);
209 >  }
210 > }
211 >
212 >
213 > int
214 > cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
215 > {
216 >  int i = 0;
217 >
218 >  if (!outfile)
219      {
220 <      free (args_info->model_orig); /* free previous argument */
221 <      args_info->model_orig = 0;
220 >      fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE);
221 >      return EXIT_FAILURE;
222      }
223 +
224 +  if (args_info->help_given)
225 +    write_into_file(outfile, "help", 0, 0 );
226 +  if (args_info->version_given)
227 +    write_into_file(outfile, "version", 0, 0 );
228 +  if (args_info->input_given)
229 +    write_into_file(outfile, "input", args_info->input_orig, 0);
230 +  if (args_info->output_given)
231 +    write_into_file(outfile, "output", args_info->output_orig, 0);
232 +  if (args_info->model_given)
233 +    write_into_file(outfile, "model", args_info->model_orig, 0);
234 +  if (args_info->beads_given)
235 +    write_into_file(outfile, "beads", 0, 0 );
236    
237 <  clear_given (args_info);
237 >
238 >  i = EXIT_SUCCESS;
239 >  return i;
240   }
241  
242   int
# Line 138 | Line 253 | cmdline_parser_file_save(const char *filename, struct
253        return EXIT_FAILURE;
254      }
255  
256 <  if (args_info->help_given) {
142 <    fprintf(outfile, "%s\n", "help");
143 <  }
144 <  if (args_info->version_given) {
145 <    fprintf(outfile, "%s\n", "version");
146 <  }
147 <  if (args_info->input_given) {
148 <    if (args_info->input_orig) {
149 <      fprintf(outfile, "%s=\"%s\"\n", "input", args_info->input_orig);
150 <    } else {
151 <      fprintf(outfile, "%s\n", "input");
152 <    }
153 <  }
154 <  if (args_info->output_given) {
155 <    if (args_info->output_orig) {
156 <      fprintf(outfile, "%s=\"%s\"\n", "output", args_info->output_orig);
157 <    } else {
158 <      fprintf(outfile, "%s\n", "output");
159 <    }
160 <  }
161 <  if (args_info->model_given) {
162 <    if (args_info->model_orig) {
163 <      fprintf(outfile, "%s=\"%s\"\n", "model", args_info->model_orig);
164 <    } else {
165 <      fprintf(outfile, "%s\n", "model");
166 <    }
167 <  }
168 <  if (args_info->beads_given) {
169 <    fprintf(outfile, "%s\n", "beads");
170 <  }
171 <  
256 >  i = cmdline_parser_dump(outfile, args_info);
257    fclose (outfile);
258  
174  i = EXIT_SUCCESS;
259    return i;
260   }
261  
# Line 181 | Line 265 | cmdline_parser_free (struct gengetopt_args_info *args_
265    cmdline_parser_release (args_info);
266   }
267  
268 <
185 < /* gengetopt_strdup() */
186 < /* strdup.c replacement of strdup, which is not standard */
268 > /** @brief replacement of strdup, which is not standard */
269   char *
270   gengetopt_strdup (const char *s)
271   {
272 <  char *result = NULL;
272 >  char *result = 0;
273    if (!s)
274      return result;
275  
# Line 199 | Line 281 | int
281   }
282  
283   int
284 < cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
284 > cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info)
285   {
286    return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
287   }
288  
289   int
290 < cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
290 > cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info,
291 >                   struct cmdline_parser_params *params)
292   {
293    int result;
294 +  result = cmdline_parser_internal (argc, argv, args_info, params, 0);
295  
296 <  result = cmdline_parser_internal (argc, argv, args_info, override, initialize, check_required, NULL);
296 >  if (result == EXIT_FAILURE)
297 >    {
298 >      cmdline_parser_free (args_info);
299 >      exit (EXIT_FAILURE);
300 >    }
301 >  
302 >  return result;
303 > }
304 >
305 > int
306 > cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
307 > {
308 >  int result;
309 >  struct cmdline_parser_params params;
310 >  
311 >  params.override = override;
312 >  params.initialize = initialize;
313 >  params.check_required = check_required;
314 >  params.check_ambiguity = 0;
315 >  params.print_errors = 1;
316 >
317 >  result = cmdline_parser_internal (argc, argv, args_info, &params, 0);
318  
319    if (result == EXIT_FAILURE)
320      {
# Line 225 | Line 330 | cmdline_parser_required (struct gengetopt_args_info *a
330   {
331    int result = EXIT_SUCCESS;
332  
333 <  if (cmdline_parser_required2(args_info, prog_name, NULL) > 0)
333 >  if (cmdline_parser_required2(args_info, prog_name, 0) > 0)
334      result = EXIT_FAILURE;
335  
336    if (result == EXIT_FAILURE)
# Line 241 | Line 346 | cmdline_parser_required2 (struct gengetopt_args_info *
346   cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error)
347   {
348    int error = 0;
349 +  FIX_UNUSED (additional_error);
350  
351 +  /* checks for required options */
352    if (! args_info->input_given)
353      {
354        fprintf (stderr, "%s: '--input' ('-i') option required%s\n", prog_name, (additional_error ? additional_error : ""));
355        error = 1;
356      }
357 +  
358    if (! args_info->model_given)
359      {
360        fprintf (stderr, "%s: '--model' option required%s\n", prog_name, (additional_error ? additional_error : ""));
361        error = 1;
362      }
363 +  
364 +  
365 +  /* checks for dependences among options */
366  
367    return error;
368   }
369  
370 +
371 + static char *package_name = 0;
372 +
373 + /**
374 + * @brief updates an option
375 + * @param field the generic pointer to the field to update
376 + * @param orig_field the pointer to the orig field
377 + * @param field_given the pointer to the number of occurrence of this option
378 + * @param prev_given the pointer to the number of occurrence already seen
379 + * @param value the argument for this option (if null no arg was specified)
380 + * @param possible_values the possible values for this option (if specified)
381 + * @param default_value the default value (in case the option only accepts fixed values)
382 + * @param arg_type the type of this option
383 + * @param check_ambiguity @see cmdline_parser_params.check_ambiguity
384 + * @param override @see cmdline_parser_params.override
385 + * @param no_free whether to free a possible previous value
386 + * @param multiple_option whether this is a multiple option
387 + * @param long_opt the corresponding long option
388 + * @param short_opt the corresponding short option (or '-' if none)
389 + * @param additional_error possible further error specification
390 + */
391 + static
392 + int update_arg(void *field, char **orig_field,
393 +               unsigned int *field_given, unsigned int *prev_given,
394 +               char *value, const char *possible_values[],
395 +               const char *default_value,
396 +               cmdline_parser_arg_type arg_type,
397 +               int check_ambiguity, int override,
398 +               int no_free, int multiple_option,
399 +               const char *long_opt, char short_opt,
400 +               const char *additional_error)
401 + {
402 +  char *stop_char = 0;
403 +  const char *val = value;
404 +  int found;
405 +  char **string_field;
406 +  FIX_UNUSED (field);
407 +
408 +  stop_char = 0;
409 +  found = 0;
410 +
411 +  if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
412 +    {
413 +      if (short_opt != '-')
414 +        fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n",
415 +               package_name, long_opt, short_opt,
416 +               (additional_error ? additional_error : ""));
417 +      else
418 +        fprintf (stderr, "%s: `--%s' option given more than once%s\n",
419 +               package_name, long_opt,
420 +               (additional_error ? additional_error : ""));
421 +      return 1; /* failure */
422 +    }
423 +
424 +  FIX_UNUSED (default_value);
425 +    
426 +  if (field_given && *field_given && ! override)
427 +    return 0;
428 +  if (prev_given)
429 +    (*prev_given)++;
430 +  if (field_given)
431 +    (*field_given)++;
432 +  if (possible_values)
433 +    val = possible_values[found];
434 +
435 +  switch(arg_type) {
436 +  case ARG_FLAG:
437 +    *((int *)field) = !*((int *)field);
438 +    break;
439 +  case ARG_STRING:
440 +    if (val) {
441 +      string_field = (char **)field;
442 +      if (!no_free && *string_field)
443 +        free (*string_field); /* free previous string */
444 +      *string_field = gengetopt_strdup (val);
445 +    }
446 +    break;
447 +  default:
448 +    break;
449 +  };
450 +
451 +
452 +  /* store the original value */
453 +  switch(arg_type) {
454 +  case ARG_NO:
455 +  case ARG_FLAG:
456 +    break;
457 +  default:
458 +    if (value && orig_field) {
459 +      if (no_free) {
460 +        *orig_field = value;
461 +      } else {
462 +        if (*orig_field)
463 +          free (*orig_field); /* free previous string */
464 +        *orig_field = gengetopt_strdup (value);
465 +      }
466 +    }
467 +  };
468 +
469 +  return 0; /* OK */
470 + }
471 +
472 +
473   int
474 < 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)
474 > cmdline_parser_internal (
475 >  int argc, char **argv, struct gengetopt_args_info *args_info,
476 >                        struct cmdline_parser_params *params, const char *additional_error)
477   {
478    int c;        /* Character of the parsed option.  */
479  
480    int error = 0;
481    struct gengetopt_args_info local_args_info;
482 +  
483 +  int override;
484 +  int initialize;
485 +  int check_required;
486 +  int check_ambiguity;
487 +  
488 +  package_name = argv[0];
489 +  
490 +  override = params->override;
491 +  initialize = params->initialize;
492 +  check_required = params->check_required;
493 +  check_ambiguity = params->check_ambiguity;
494  
495    if (initialize)
496      cmdline_parser_init (args_info);
497  
498    cmdline_parser_init (&local_args_info);
271  printf("\n%s\n", "\n+----------------------------------------------------------------------+ \n|    ____  ____  ____  _____ ______  The OpenSource, Object-oriented   | \n|   / __ \\/ __ \\/ __ \\/ ___// ____/  Parallel Simulation Engine.       | \n|  / / / / / / / /_/ /\\__ \\/ __/                                       | \n| / /_/ / /_/ / ____/___/ / /___     Copyright 2004-2006 by the        | \n| \\____/\\____/_/    /____/_____/     University of Notre Dame.         | \n|                                                                      | \n|                                    http://www.oopse.org              |\n|                                                                      | \n| OOPSE is an OpenScience project.  All source code is available for   |\n| any use subject to only one condition:                               | \n|                                                                      |\n| Any published work resulting from the use of this code must cite the | \n| following paper:       M. A. Meineke, C. F. Vardeman II, T. Lin,     | \n|                        C. J. Fennell, and J. D. Gezelter,            | \n|                        J. Comput. Chem. 26, pp. 252-271 (2005).      | \n+----------------------------------------------------------------------+");
499  
500    optarg = 0;
501    optind = 0;
502 <  opterr = 1;
502 >  opterr = params->print_errors;
503    optopt = '?';
504  
505    while (1)
506      {
507        int option_index = 0;
281      char *stop_char;
508  
509        static struct option long_options[] = {
510          { "help",       0, NULL, 'h' },
# Line 287 | Line 513 | cmdline_parser_internal (int argc, char * const *argv,
513          { "output",     1, NULL, 'o' },
514          { "model",      1, NULL, 0 },
515          { "beads",      0, NULL, 'b' },
516 <        { NULL, 0, NULL, 0 }
516 >        { 0,  0, 0, 0 }
517        };
518  
293      stop_char = 0;
519        c = getopt_long (argc, argv, "hVi:o:b", long_options, &option_index);
520  
521        if (c == -1) break;       /* Exit from `while (1)' loop.  */
# Line 307 | Line 532 | cmdline_parser_internal (int argc, char * const *argv,
532            cmdline_parser_free (&local_args_info);
533            exit (EXIT_SUCCESS);
534  
535 <        case 'i':       /* input dump file.  */
536 <          if (local_args_info.input_given)
537 <            {
538 <              fprintf (stderr, "%s: `--input' (`-i') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
539 <              goto failure;
540 <            }
541 <          if (args_info->input_given && ! override)
542 <            continue;
543 <          local_args_info.input_given = 1;
544 <          args_info->input_given = 1;
545 <          if (args_info->input_arg)
321 <            free (args_info->input_arg); /* free previous string */
322 <          args_info->input_arg = gengetopt_strdup (optarg);
323 <          if (args_info->input_orig)
324 <            free (args_info->input_orig); /* free previous string */
325 <          args_info->input_orig = gengetopt_strdup (optarg);
535 >        case 'i':       /* input MetaData (md) file.  */
536 >        
537 >        
538 >          if (update_arg( (void *)&(args_info->input_arg),
539 >               &(args_info->input_orig), &(args_info->input_given),
540 >              &(local_args_info.input_given), optarg, 0, 0, ARG_STRING,
541 >              check_ambiguity, override, 0, 0,
542 >              "input", 'i',
543 >              additional_error))
544 >            goto failure;
545 >        
546            break;
327
547          case 'o':       /* output file prefix.  */
548 <          if (local_args_info.output_given)
549 <            {
550 <              fprintf (stderr, "%s: `--output' (`-o') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
551 <              goto failure;
552 <            }
553 <          if (args_info->output_given && ! override)
554 <            continue;
555 <          local_args_info.output_given = 1;
556 <          args_info->output_given = 1;
557 <          if (args_info->output_arg)
339 <            free (args_info->output_arg); /* free previous string */
340 <          args_info->output_arg = gengetopt_strdup (optarg);
341 <          if (args_info->output_orig)
342 <            free (args_info->output_orig); /* free previous string */
343 <          args_info->output_orig = gengetopt_strdup (optarg);
548 >        
549 >        
550 >          if (update_arg( (void *)&(args_info->output_arg),
551 >               &(args_info->output_orig), &(args_info->output_given),
552 >              &(local_args_info.output_given), optarg, 0, "hydro", ARG_STRING,
553 >              check_ambiguity, override, 0, 0,
554 >              "output", 'o',
555 >              additional_error))
556 >            goto failure;
557 >        
558            break;
345
559          case 'b':       /* generate the beads only, hydrodynamics will be performed.  */
560 <          if (local_args_info.beads_given)
561 <            {
562 <              fprintf (stderr, "%s: `--beads' (`-b') option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
563 <              goto failure;
564 <            }
565 <          if (args_info->beads_given && ! override)
566 <            continue;
567 <          local_args_info.beads_given = 1;
355 <          args_info->beads_given = 1;
356 <          args_info->beads_flag = !(args_info->beads_flag);
560 >        
561 >        
562 >          if (update_arg((void *)&(args_info->beads_flag), 0, &(args_info->beads_given),
563 >              &(local_args_info.beads_given), optarg, 0, 0, ARG_FLAG,
564 >              check_ambiguity, override, 1, 0, "beads", 'b',
565 >              additional_error))
566 >            goto failure;
567 >        
568            break;
569  
359
570          case 0: /* Long option with no short option */
571 <          /* hydrodynamics model (support RoughShell and BeadModel).  */
571 >          /* hydrodynamics model (supports RoughShell and BeadModel).  */
572            if (strcmp (long_options[option_index].name, "model") == 0)
573            {
574 <            if (local_args_info.model_given)
575 <              {
576 <                fprintf (stderr, "%s: `--model' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
577 <                goto failure;
578 <              }
579 <            if (args_info->model_given && ! override)
580 <              continue;
581 <            local_args_info.model_given = 1;
582 <            args_info->model_given = 1;
583 <            if (args_info->model_arg)
374 <              free (args_info->model_arg); /* free previous string */
375 <            args_info->model_arg = gengetopt_strdup (optarg);
376 <            if (args_info->model_orig)
377 <              free (args_info->model_orig); /* free previous string */
378 <            args_info->model_orig = gengetopt_strdup (optarg);
574 >          
575 >          
576 >            if (update_arg( (void *)&(args_info->model_arg),
577 >                 &(args_info->model_orig), &(args_info->model_given),
578 >                &(local_args_info.model_given), optarg, 0, 0, ARG_STRING,
579 >                check_ambiguity, override, 0, 0,
580 >                "model", '-',
581 >                additional_error))
582 >              goto failure;
583 >          
584            }
585            
586            break;
# Line 399 | Line 604 | cmdline_parser_internal (int argc, char * const *argv,
604    cmdline_parser_release (&local_args_info);
605  
606    if ( error )
607 <    goto failure;
607 >    return (EXIT_FAILURE);
608  
609 +  if (optind < argc)
610 +    {
611 +      int i = 0 ;
612 +      int found_prog_name = 0;
613 +      /* whether program name, i.e., argv[0], is in the remaining args
614 +         (this may happen with some implementations of getopt,
615 +          but surely not with the one included by gengetopt) */
616 +
617 +      i = optind;
618 +      while (i < argc)
619 +        if (argv[i++] == argv[0]) {
620 +          found_prog_name = 1;
621 +          break;
622 +        }
623 +      i = 0;
624 +
625 +      args_info->inputs_num = argc - optind - found_prog_name;
626 +      args_info->inputs =
627 +        (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ;
628 +      while (optind < argc)
629 +        if (argv[optind++] != argv[0])
630 +          args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind-1]) ;
631 +    }
632 +
633    return 0;
634  
635   failure:
636    
408  cmdline_parser_print_help ();
637    cmdline_parser_release (&local_args_info);
638    return (EXIT_FAILURE);
639   }

Comparing:
trunk/src/applications/hydrodynamics/HydroCmd.c (property svn:keywords), Revision 938 by gezelter, Mon Apr 17 21:49:12 2006 UTC vs.
branches/development/src/applications/hydrodynamics/HydroCmd.c (property svn:keywords), Revision 1630 by gezelter, Wed Sep 14 21:40:12 2011 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines