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

Comparing:
trunk/src/applications/hydrodynamics/HydroCmd.c (property svn:keywords), Revision 938 by gezelter, Mon Apr 17 21:49:12 2006 UTC vs.
trunk/src/applications/hydrodynamics/HydroCmd.cpp (property svn:keywords), Revision 1985 by gezelter, Tue Apr 15 21:26:45 2014 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines