ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/applications/dump2Xyz/Dump2XYZCmd.cpp
Revision: 1798
Committed: Thu Sep 13 14:10:11 2012 UTC (12 years, 8 months ago) by gezelter
File size: 29672 byte(s)
Log Message:
Merged trunk changes into the development branch

File Contents

# User Rev Content
1 tim 12 /*
2 gezelter 1630 File autogenerated by gengetopt version 2.22.4
3 tim 12 generated with the following command:
4 gezelter 1456 gengetopt -F Dump2XYZCmd -u
5 tim 12
6     The developers of gengetopt consider the fixed text that goes in all
7     gengetopt output files to be in the public domain:
8     we make no copyright claims on it.
9     */
10    
11 chuckv 1117 /* If we use autoconf. */
12     #ifdef HAVE_CONFIG_H
13     #include "config.h"
14     #endif
15 tim 12
16     #include <stdio.h>
17     #include <stdlib.h>
18     #include <string.h>
19    
20 gezelter 1630 #ifndef FIX_UNUSED
21     #define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */
22     #endif
23 tim 12
24 gezelter 1798 #ifdef WIN32
25     #include "utils/wingetopt.h"
26     #else
27 gezelter 1630 #include <getopt.h>
28 gezelter 1798 #endif
29 gezelter 1630
30 tim 291 #include "Dump2XYZCmd.h"
31 tim 12
32 gezelter 1456 const char *gengetopt_args_info_purpose = "";
33    
34     const char *gengetopt_args_info_usage = "Usage: Dump2XYZ [OPTIONS]... [FILES]...";
35    
36     const char *gengetopt_args_info_description = "";
37    
38     const char *gengetopt_args_info_help[] = {
39     " -h, --help Print help and exit",
40     " -V, --version Print version and exit",
41     " -i, --input=filename input dump file",
42     " -o, --output=filename output file name",
43     " -n, --frame=INT print every n frame (default=`1')",
44     " -w, --water skip the the waters (default=off)",
45     " -m, --periodicBox map to the periodic box (default=off)",
46     " -z, --zconstraint replace the atom types of zconstraint molecules \n (default=off)",
47     " -r, --rigidbody add a pseudo COM atom to rigidbody \n (default=off)",
48     " -t, --watertype replace the atom type of water model \n (default=on)",
49     " -s, --selection=selection script\n general selection syntax",
50     " --originsele=selection script\n select origin",
51     " --refsele=selection script\n select reference",
52     " --repeatX=INT The number of images to repeat in the x \n direction (default=`0')",
53     " --repeatY=INT The number of images to repeat in the y \n direction (default=`0')",
54     " --repeatZ=INT The number of images to repeat in the z \n direction (default=`0')",
55     " -b, --basetype Convert to base atom type (default=off)",
56     " -v, --velocities Print velocities in xyz file (default=off)",
57     " -f, --forces Print forces xyz file (default=off)",
58     " -u, --vectors Print vectors (dipoles, etc) in xyz file \n (default=off)",
59     " -c, --charges Print charges in xyz file (default=off)",
60     0
61     };
62    
63     typedef enum {ARG_NO
64     , ARG_FLAG
65     , ARG_STRING
66     , ARG_INT
67     } cmdline_parser_arg_type;
68    
69 chuckv 1117 static
70     void clear_given (struct gengetopt_args_info *args_info);
71     static
72     void clear_args (struct gengetopt_args_info *args_info);
73    
74     static int
75 gezelter 1630 cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info,
76 gezelter 1456 struct cmdline_parser_params *params, const char *additional_error);
77 chuckv 1117
78     static int
79     cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error);
80    
81     static char *
82     gengetopt_strdup (const char *s);
83    
84     static
85     void clear_given (struct gengetopt_args_info *args_info)
86     {
87     args_info->help_given = 0 ;
88     args_info->version_given = 0 ;
89     args_info->input_given = 0 ;
90     args_info->output_given = 0 ;
91     args_info->frame_given = 0 ;
92     args_info->water_given = 0 ;
93     args_info->periodicBox_given = 0 ;
94     args_info->zconstraint_given = 0 ;
95     args_info->rigidbody_given = 0 ;
96     args_info->watertype_given = 0 ;
97     args_info->selection_given = 0 ;
98     args_info->originsele_given = 0 ;
99     args_info->refsele_given = 0 ;
100     args_info->repeatX_given = 0 ;
101     args_info->repeatY_given = 0 ;
102     args_info->repeatZ_given = 0 ;
103     args_info->basetype_given = 0 ;
104 gezelter 1456 args_info->velocities_given = 0 ;
105     args_info->forces_given = 0 ;
106     args_info->vectors_given = 0 ;
107     args_info->charges_given = 0 ;
108 chuckv 1117 }
109    
110     static
111     void clear_args (struct gengetopt_args_info *args_info)
112     {
113 gezelter 1630 FIX_UNUSED (args_info);
114 chuckv 1117 args_info->input_arg = NULL;
115     args_info->input_orig = NULL;
116     args_info->output_arg = NULL;
117     args_info->output_orig = NULL;
118     args_info->frame_arg = 1;
119     args_info->frame_orig = NULL;
120     args_info->water_flag = 0;
121     args_info->periodicBox_flag = 0;
122     args_info->zconstraint_flag = 0;
123     args_info->rigidbody_flag = 0;
124     args_info->watertype_flag = 1;
125     args_info->selection_arg = NULL;
126     args_info->selection_orig = NULL;
127     args_info->originsele_arg = NULL;
128     args_info->originsele_orig = NULL;
129     args_info->refsele_arg = NULL;
130     args_info->refsele_orig = NULL;
131     args_info->repeatX_arg = 0;
132     args_info->repeatX_orig = NULL;
133     args_info->repeatY_arg = 0;
134     args_info->repeatY_orig = NULL;
135     args_info->repeatZ_arg = 0;
136     args_info->repeatZ_orig = NULL;
137     args_info->basetype_flag = 0;
138 gezelter 1456 args_info->velocities_flag = 0;
139     args_info->forces_flag = 0;
140     args_info->vectors_flag = 0;
141     args_info->charges_flag = 0;
142 chuckv 1117
143     }
144    
145 gezelter 1456 static
146     void init_args_info(struct gengetopt_args_info *args_info)
147     {
148    
149    
150     args_info->help_help = gengetopt_args_info_help[0] ;
151     args_info->version_help = gengetopt_args_info_help[1] ;
152     args_info->input_help = gengetopt_args_info_help[2] ;
153     args_info->output_help = gengetopt_args_info_help[3] ;
154     args_info->frame_help = gengetopt_args_info_help[4] ;
155     args_info->water_help = gengetopt_args_info_help[5] ;
156     args_info->periodicBox_help = gengetopt_args_info_help[6] ;
157     args_info->zconstraint_help = gengetopt_args_info_help[7] ;
158     args_info->rigidbody_help = gengetopt_args_info_help[8] ;
159     args_info->watertype_help = gengetopt_args_info_help[9] ;
160     args_info->selection_help = gengetopt_args_info_help[10] ;
161     args_info->originsele_help = gengetopt_args_info_help[11] ;
162     args_info->refsele_help = gengetopt_args_info_help[12] ;
163     args_info->repeatX_help = gengetopt_args_info_help[13] ;
164     args_info->repeatY_help = gengetopt_args_info_help[14] ;
165     args_info->repeatZ_help = gengetopt_args_info_help[15] ;
166     args_info->basetype_help = gengetopt_args_info_help[16] ;
167     args_info->velocities_help = gengetopt_args_info_help[17] ;
168     args_info->forces_help = gengetopt_args_info_help[18] ;
169     args_info->vectors_help = gengetopt_args_info_help[19] ;
170     args_info->charges_help = gengetopt_args_info_help[20] ;
171    
172     }
173    
174 tim 12 void
175     cmdline_parser_print_version (void)
176     {
177 gezelter 1630 printf ("%s %s\n",
178     (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE),
179     CMDLINE_PARSER_VERSION);
180 tim 12 }
181    
182 gezelter 1456 static void print_help_common(void) {
183     cmdline_parser_print_version ();
184    
185     if (strlen(gengetopt_args_info_purpose) > 0)
186     printf("\n%s\n", gengetopt_args_info_purpose);
187    
188     if (strlen(gengetopt_args_info_usage) > 0)
189     printf("\n%s\n", gengetopt_args_info_usage);
190    
191     printf("\n");
192    
193     if (strlen(gengetopt_args_info_description) > 0)
194 gezelter 1630 printf("%s\n\n", gengetopt_args_info_description);
195 gezelter 1456 }
196    
197 tim 12 void
198     cmdline_parser_print_help (void)
199     {
200 gezelter 1456 int i = 0;
201     print_help_common();
202     while (gengetopt_args_info_help[i])
203     printf("%s\n", gengetopt_args_info_help[i++]);
204 tim 12 }
205    
206 chuckv 1117 void
207     cmdline_parser_init (struct gengetopt_args_info *args_info)
208     {
209     clear_given (args_info);
210     clear_args (args_info);
211 gezelter 1456 init_args_info (args_info);
212    
213 gezelter 1630 args_info->inputs = 0;
214 gezelter 1456 args_info->inputs_num = 0;
215 chuckv 1117 }
216 tim 12
217 gezelter 1456 void
218     cmdline_parser_params_init(struct cmdline_parser_params *params)
219     {
220     if (params)
221     {
222     params->override = 0;
223     params->initialize = 1;
224     params->check_required = 1;
225     params->check_ambiguity = 0;
226     params->print_errors = 1;
227     }
228     }
229    
230     struct cmdline_parser_params *
231     cmdline_parser_params_create(void)
232     {
233     struct cmdline_parser_params *params =
234     (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params));
235     cmdline_parser_params_init(params);
236     return params;
237     }
238    
239 chuckv 1117 static void
240 gezelter 1456 free_string_field (char **s)
241     {
242     if (*s)
243     {
244     free (*s);
245     *s = 0;
246     }
247     }
248    
249    
250     static void
251 chuckv 1117 cmdline_parser_release (struct gengetopt_args_info *args_info)
252     {
253 gezelter 1456 unsigned int i;
254     free_string_field (&(args_info->input_arg));
255     free_string_field (&(args_info->input_orig));
256     free_string_field (&(args_info->output_arg));
257     free_string_field (&(args_info->output_orig));
258     free_string_field (&(args_info->frame_orig));
259     free_string_field (&(args_info->selection_arg));
260     free_string_field (&(args_info->selection_orig));
261     free_string_field (&(args_info->originsele_arg));
262     free_string_field (&(args_info->originsele_orig));
263     free_string_field (&(args_info->refsele_arg));
264     free_string_field (&(args_info->refsele_orig));
265     free_string_field (&(args_info->repeatX_orig));
266     free_string_field (&(args_info->repeatY_orig));
267     free_string_field (&(args_info->repeatZ_orig));
268 chuckv 1117
269 gezelter 1456
270     for (i = 0; i < args_info->inputs_num; ++i)
271     free (args_info->inputs [i]);
272    
273     if (args_info->inputs_num)
274     free (args_info->inputs);
275    
276     clear_given (args_info);
277     }
278    
279    
280     static void
281 gezelter 1630 write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
282 gezelter 1456 {
283 gezelter 1630 FIX_UNUSED (values);
284 gezelter 1456 if (arg) {
285     fprintf(outfile, "%s=\"%s\"\n", opt, arg);
286     } else {
287     fprintf(outfile, "%s\n", opt);
288     }
289     }
290    
291    
292     int
293     cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
294     {
295     int i = 0;
296    
297     if (!outfile)
298 chuckv 1117 {
299 gezelter 1456 fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE);
300     return EXIT_FAILURE;
301 chuckv 1117 }
302 gezelter 1456
303     if (args_info->help_given)
304     write_into_file(outfile, "help", 0, 0 );
305     if (args_info->version_given)
306     write_into_file(outfile, "version", 0, 0 );
307     if (args_info->input_given)
308     write_into_file(outfile, "input", args_info->input_orig, 0);
309     if (args_info->output_given)
310     write_into_file(outfile, "output", args_info->output_orig, 0);
311     if (args_info->frame_given)
312     write_into_file(outfile, "frame", args_info->frame_orig, 0);
313     if (args_info->water_given)
314     write_into_file(outfile, "water", 0, 0 );
315     if (args_info->periodicBox_given)
316     write_into_file(outfile, "periodicBox", 0, 0 );
317     if (args_info->zconstraint_given)
318     write_into_file(outfile, "zconstraint", 0, 0 );
319     if (args_info->rigidbody_given)
320     write_into_file(outfile, "rigidbody", 0, 0 );
321     if (args_info->watertype_given)
322     write_into_file(outfile, "watertype", 0, 0 );
323     if (args_info->selection_given)
324     write_into_file(outfile, "selection", args_info->selection_orig, 0);
325     if (args_info->originsele_given)
326     write_into_file(outfile, "originsele", args_info->originsele_orig, 0);
327     if (args_info->refsele_given)
328     write_into_file(outfile, "refsele", args_info->refsele_orig, 0);
329     if (args_info->repeatX_given)
330     write_into_file(outfile, "repeatX", args_info->repeatX_orig, 0);
331     if (args_info->repeatY_given)
332     write_into_file(outfile, "repeatY", args_info->repeatY_orig, 0);
333     if (args_info->repeatZ_given)
334     write_into_file(outfile, "repeatZ", args_info->repeatZ_orig, 0);
335     if (args_info->basetype_given)
336     write_into_file(outfile, "basetype", 0, 0 );
337     if (args_info->velocities_given)
338     write_into_file(outfile, "velocities", 0, 0 );
339     if (args_info->forces_given)
340     write_into_file(outfile, "forces", 0, 0 );
341     if (args_info->vectors_given)
342     write_into_file(outfile, "vectors", 0, 0 );
343     if (args_info->charges_given)
344     write_into_file(outfile, "charges", 0, 0 );
345 chuckv 1117
346 gezelter 1456
347     i = EXIT_SUCCESS;
348     return i;
349 chuckv 1117 }
350 tim 12
351 chuckv 1117 int
352     cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info)
353     {
354     FILE *outfile;
355     int i = 0;
356    
357     outfile = fopen(filename, "w");
358    
359     if (!outfile)
360     {
361     fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename);
362     return EXIT_FAILURE;
363     }
364    
365 gezelter 1456 i = cmdline_parser_dump(outfile, args_info);
366 chuckv 1117 fclose (outfile);
367    
368     return i;
369     }
370    
371     void
372     cmdline_parser_free (struct gengetopt_args_info *args_info)
373     {
374     cmdline_parser_release (args_info);
375     }
376    
377 gezelter 1456 /** @brief replacement of strdup, which is not standard */
378 tim 12 char *
379     gengetopt_strdup (const char *s)
380     {
381 gezelter 1630 char *result = 0;
382 chuckv 1117 if (!s)
383     return result;
384    
385     result = (char*)malloc(strlen(s) + 1);
386 tim 12 if (result == (char*)0)
387     return (char*)0;
388     strcpy(result, s);
389     return result;
390     }
391    
392     int
393 gezelter 1630 cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info)
394 tim 12 {
395 chuckv 1117 return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
396     }
397 tim 12
398 chuckv 1117 int
399 gezelter 1630 cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info,
400 gezelter 1456 struct cmdline_parser_params *params)
401     {
402     int result;
403 gezelter 1630 result = cmdline_parser_internal (argc, argv, args_info, params, 0);
404 gezelter 1456
405     if (result == EXIT_FAILURE)
406     {
407     cmdline_parser_free (args_info);
408     exit (EXIT_FAILURE);
409     }
410    
411     return result;
412     }
413    
414     int
415 gezelter 1630 cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
416 chuckv 1117 {
417     int result;
418 gezelter 1456 struct cmdline_parser_params params;
419    
420     params.override = override;
421     params.initialize = initialize;
422     params.check_required = check_required;
423     params.check_ambiguity = 0;
424     params.print_errors = 1;
425 chuckv 1117
426 gezelter 1630 result = cmdline_parser_internal (argc, argv, args_info, &params, 0);
427 chuckv 1117
428     if (result == EXIT_FAILURE)
429     {
430     cmdline_parser_free (args_info);
431     exit (EXIT_FAILURE);
432     }
433    
434     return result;
435 tim 543 }
436 tim 12
437 chuckv 1117 int
438     cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
439     {
440     int result = EXIT_SUCCESS;
441 tim 12
442 gezelter 1630 if (cmdline_parser_required2(args_info, prog_name, 0) > 0)
443 chuckv 1117 result = EXIT_FAILURE;
444    
445     if (result == EXIT_FAILURE)
446     {
447     cmdline_parser_free (args_info);
448     exit (EXIT_FAILURE);
449     }
450    
451     return result;
452     }
453    
454     int
455     cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error)
456     {
457     int error = 0;
458 gezelter 1630 FIX_UNUSED (additional_error);
459 chuckv 1117
460 gezelter 1456 /* checks for required options */
461 chuckv 1117 if (! args_info->input_given)
462     {
463     fprintf (stderr, "%s: '--input' ('-i') option required%s\n", prog_name, (additional_error ? additional_error : ""));
464     error = 1;
465     }
466 gezelter 1456
467    
468     /* checks for dependences among options */
469 chuckv 1117
470     return error;
471     }
472    
473 gezelter 1456
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 gezelter 1630 char *value, const char *possible_values[],
498     const char *default_value,
499 gezelter 1456 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 gezelter 1630 FIX_UNUSED (field);
510 gezelter 1456
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 gezelter 1630 FIX_UNUSED (default_value);
528 gezelter 1456
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_FLAG:
540     *((int *)field) = !*((int *)field);
541     break;
542     case ARG_INT:
543     if (val) *((int *)field) = strtol (val, &stop_char, 0);
544     break;
545     case ARG_STRING:
546     if (val) {
547     string_field = (char **)field;
548     if (!no_free && *string_field)
549     free (*string_field); /* free previous string */
550     *string_field = gengetopt_strdup (val);
551     }
552     break;
553     default:
554     break;
555     };
556    
557     /* check numeric conversion */
558     switch(arg_type) {
559     case ARG_INT:
560     if (val && !(stop_char && *stop_char == '\0')) {
561     fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
562     return 1; /* failure */
563     }
564     break;
565     default:
566     ;
567     };
568    
569     /* store the original value */
570     switch(arg_type) {
571     case ARG_NO:
572     case ARG_FLAG:
573     break;
574     default:
575     if (value && orig_field) {
576     if (no_free) {
577     *orig_field = value;
578     } else {
579     if (*orig_field)
580     free (*orig_field); /* free previous string */
581     *orig_field = gengetopt_strdup (value);
582     }
583     }
584     };
585    
586     return 0; /* OK */
587     }
588    
589    
590 chuckv 1117 int
591 gezelter 1630 cmdline_parser_internal (
592     int argc, char **argv, struct gengetopt_args_info *args_info,
593 gezelter 1456 struct cmdline_parser_params *params, const char *additional_error)
594 chuckv 1117 {
595     int c; /* Character of the parsed option. */
596    
597     int error = 0;
598     struct gengetopt_args_info local_args_info;
599 gezelter 1456
600     int override;
601     int initialize;
602     int check_required;
603     int check_ambiguity;
604    
605     package_name = argv[0];
606    
607     override = params->override;
608     initialize = params->initialize;
609     check_required = params->check_required;
610     check_ambiguity = params->check_ambiguity;
611 chuckv 1117
612     if (initialize)
613     cmdline_parser_init (args_info);
614    
615     cmdline_parser_init (&local_args_info);
616    
617 tim 12 optarg = 0;
618 gezelter 1456 optind = 0;
619     opterr = params->print_errors;
620 tim 12 optopt = '?';
621    
622     while (1)
623     {
624     int option_index = 0;
625    
626     static struct option long_options[] = {
627     { "help", 0, NULL, 'h' },
628     { "version", 0, NULL, 'V' },
629     { "input", 1, NULL, 'i' },
630     { "output", 1, NULL, 'o' },
631     { "frame", 1, NULL, 'n' },
632     { "water", 0, NULL, 'w' },
633     { "periodicBox", 0, NULL, 'm' },
634     { "zconstraint", 0, NULL, 'z' },
635     { "rigidbody", 0, NULL, 'r' },
636     { "watertype", 0, NULL, 't' },
637 tim 291 { "selection", 1, NULL, 's' },
638 tim 369 { "originsele", 1, NULL, 0 },
639     { "refsele", 1, NULL, 0 },
640 tim 12 { "repeatX", 1, NULL, 0 },
641     { "repeatY", 1, NULL, 0 },
642     { "repeatZ", 1, NULL, 0 },
643 tim 954 { "basetype", 0, NULL, 'b' },
644 gezelter 1456 { "velocities", 0, NULL, 'v' },
645     { "forces", 0, NULL, 'f' },
646     { "vectors", 0, NULL, 'u' },
647     { "charges", 0, NULL, 'c' },
648 gezelter 1630 { 0, 0, 0, 0 }
649 tim 12 };
650    
651 gezelter 1456 c = getopt_long (argc, argv, "hVi:o:n:wmzrts:bvfuc", long_options, &option_index);
652 tim 12
653     if (c == -1) break; /* Exit from `while (1)' loop. */
654    
655     switch (c)
656     {
657     case 'h': /* Print help and exit. */
658     cmdline_parser_print_help ();
659 chuckv 1117 cmdline_parser_free (&local_args_info);
660 tim 12 exit (EXIT_SUCCESS);
661    
662     case 'V': /* Print version and exit. */
663     cmdline_parser_print_version ();
664 chuckv 1117 cmdline_parser_free (&local_args_info);
665 tim 12 exit (EXIT_SUCCESS);
666    
667     case 'i': /* input dump file. */
668 gezelter 1456
669    
670     if (update_arg( (void *)&(args_info->input_arg),
671     &(args_info->input_orig), &(args_info->input_given),
672     &(local_args_info.input_given), optarg, 0, 0, ARG_STRING,
673     check_ambiguity, override, 0, 0,
674     "input", 'i',
675     additional_error))
676     goto failure;
677    
678 tim 12 break;
679     case 'o': /* output file name. */
680 gezelter 1456
681    
682     if (update_arg( (void *)&(args_info->output_arg),
683     &(args_info->output_orig), &(args_info->output_given),
684     &(local_args_info.output_given), optarg, 0, 0, ARG_STRING,
685     check_ambiguity, override, 0, 0,
686     "output", 'o',
687     additional_error))
688     goto failure;
689    
690 tim 12 break;
691     case 'n': /* print every n frame. */
692 gezelter 1456
693    
694     if (update_arg( (void *)&(args_info->frame_arg),
695     &(args_info->frame_orig), &(args_info->frame_given),
696     &(local_args_info.frame_given), optarg, 0, "1", ARG_INT,
697     check_ambiguity, override, 0, 0,
698     "frame", 'n',
699     additional_error))
700 chuckv 1117 goto failure;
701 gezelter 1456
702 tim 12 break;
703     case 'w': /* skip the the waters. */
704 gezelter 1456
705    
706     if (update_arg((void *)&(args_info->water_flag), 0, &(args_info->water_given),
707     &(local_args_info.water_given), optarg, 0, 0, ARG_FLAG,
708     check_ambiguity, override, 1, 0, "water", 'w',
709     additional_error))
710     goto failure;
711    
712 tim 12 break;
713     case 'm': /* map to the periodic box. */
714 gezelter 1456
715    
716     if (update_arg((void *)&(args_info->periodicBox_flag), 0, &(args_info->periodicBox_given),
717     &(local_args_info.periodicBox_given), optarg, 0, 0, ARG_FLAG,
718     check_ambiguity, override, 1, 0, "periodicBox", 'm',
719     additional_error))
720     goto failure;
721    
722 tim 12 break;
723     case 'z': /* replace the atom types of zconstraint molecules. */
724 gezelter 1456
725    
726     if (update_arg((void *)&(args_info->zconstraint_flag), 0, &(args_info->zconstraint_given),
727     &(local_args_info.zconstraint_given), optarg, 0, 0, ARG_FLAG,
728     check_ambiguity, override, 1, 0, "zconstraint", 'z',
729     additional_error))
730     goto failure;
731    
732 tim 12 break;
733     case 'r': /* add a pseudo COM atom to rigidbody. */
734 gezelter 1456
735    
736     if (update_arg((void *)&(args_info->rigidbody_flag), 0, &(args_info->rigidbody_given),
737     &(local_args_info.rigidbody_given), optarg, 0, 0, ARG_FLAG,
738     check_ambiguity, override, 1, 0, "rigidbody", 'r',
739     additional_error))
740     goto failure;
741    
742 tim 12 break;
743     case 't': /* replace the atom type of water model. */
744 gezelter 1456
745    
746     if (update_arg((void *)&(args_info->watertype_flag), 0, &(args_info->watertype_given),
747     &(local_args_info.watertype_given), optarg, 0, 0, ARG_FLAG,
748     check_ambiguity, override, 1, 0, "watertype", 't',
749     additional_error))
750     goto failure;
751    
752 tim 12 break;
753 tim 954 case 's': /* general selection syntax. */
754 gezelter 1456
755    
756     if (update_arg( (void *)&(args_info->selection_arg),
757     &(args_info->selection_orig), &(args_info->selection_given),
758     &(local_args_info.selection_given), optarg, 0, 0, ARG_STRING,
759     check_ambiguity, override, 0, 0,
760     "selection", 's',
761     additional_error))
762     goto failure;
763    
764 tim 543 break;
765 tim 954 case 'b': /* Convert to base atom type. */
766 gezelter 1456
767    
768     if (update_arg((void *)&(args_info->basetype_flag), 0, &(args_info->basetype_given),
769     &(local_args_info.basetype_given), optarg, 0, 0, ARG_FLAG,
770     check_ambiguity, override, 1, 0, "basetype", 'b',
771     additional_error))
772     goto failure;
773    
774 tim 291 break;
775 gezelter 1456 case 'v': /* Print velocities in xyz file. */
776    
777    
778     if (update_arg((void *)&(args_info->velocities_flag), 0, &(args_info->velocities_given),
779     &(local_args_info.velocities_given), optarg, 0, 0, ARG_FLAG,
780     check_ambiguity, override, 1, 0, "velocities", 'v',
781     additional_error))
782     goto failure;
783    
784     break;
785     case 'f': /* Print forces xyz file. */
786    
787    
788     if (update_arg((void *)&(args_info->forces_flag), 0, &(args_info->forces_given),
789     &(local_args_info.forces_given), optarg, 0, 0, ARG_FLAG,
790     check_ambiguity, override, 1, 0, "forces", 'f',
791     additional_error))
792     goto failure;
793    
794     break;
795     case 'u': /* Print vectors (dipoles, etc) in xyz file. */
796    
797    
798     if (update_arg((void *)&(args_info->vectors_flag), 0, &(args_info->vectors_given),
799     &(local_args_info.vectors_given), optarg, 0, 0, ARG_FLAG,
800     check_ambiguity, override, 1, 0, "vectors", 'u',
801     additional_error))
802     goto failure;
803    
804     break;
805     case 'c': /* Print charges in xyz file. */
806    
807    
808     if (update_arg((void *)&(args_info->charges_flag), 0, &(args_info->charges_given),
809     &(local_args_info.charges_given), optarg, 0, 0, ARG_FLAG,
810     check_ambiguity, override, 1, 0, "charges", 'c',
811     additional_error))
812     goto failure;
813    
814     break;
815 tim 12
816     case 0: /* Long option with no short option */
817 tim 369 /* select origin. */
818     if (strcmp (long_options[option_index].name, "originsele") == 0)
819 tim 543 {
820 gezelter 1456
821    
822     if (update_arg( (void *)&(args_info->originsele_arg),
823     &(args_info->originsele_orig), &(args_info->originsele_given),
824     &(local_args_info.originsele_given), optarg, 0, 0, ARG_STRING,
825     check_ambiguity, override, 0, 0,
826     "originsele", '-',
827     additional_error))
828     goto failure;
829    
830 tim 543 }
831 tim 369 /* select reference. */
832     else if (strcmp (long_options[option_index].name, "refsele") == 0)
833 tim 543 {
834 gezelter 1456
835    
836     if (update_arg( (void *)&(args_info->refsele_arg),
837     &(args_info->refsele_orig), &(args_info->refsele_given),
838     &(local_args_info.refsele_given), optarg, 0, 0, ARG_STRING,
839     check_ambiguity, override, 0, 0,
840     "refsele", '-',
841     additional_error))
842     goto failure;
843    
844 tim 543 }
845 tim 12 /* The number of images to repeat in the x direction. */
846 tim 369 else if (strcmp (long_options[option_index].name, "repeatX") == 0)
847 tim 543 {
848 gezelter 1456
849    
850     if (update_arg( (void *)&(args_info->repeatX_arg),
851     &(args_info->repeatX_orig), &(args_info->repeatX_given),
852     &(local_args_info.repeatX_given), optarg, 0, "0", ARG_INT,
853     check_ambiguity, override, 0, 0,
854     "repeatX", '-',
855     additional_error))
856 chuckv 1117 goto failure;
857 gezelter 1456
858 tim 543 }
859 tim 12 /* The number of images to repeat in the y direction. */
860     else if (strcmp (long_options[option_index].name, "repeatY") == 0)
861 tim 543 {
862 gezelter 1456
863    
864     if (update_arg( (void *)&(args_info->repeatY_arg),
865     &(args_info->repeatY_orig), &(args_info->repeatY_given),
866     &(local_args_info.repeatY_given), optarg, 0, "0", ARG_INT,
867     check_ambiguity, override, 0, 0,
868     "repeatY", '-',
869     additional_error))
870 chuckv 1117 goto failure;
871 gezelter 1456
872 tim 543 }
873 tim 12 /* The number of images to repeat in the z direction. */
874     else if (strcmp (long_options[option_index].name, "repeatZ") == 0)
875 tim 543 {
876 gezelter 1456
877    
878     if (update_arg( (void *)&(args_info->repeatZ_arg),
879     &(args_info->repeatZ_orig), &(args_info->repeatZ_given),
880     &(local_args_info.repeatZ_given), optarg, 0, "0", ARG_INT,
881     check_ambiguity, override, 0, 0,
882     "repeatZ", '-',
883     additional_error))
884 chuckv 1117 goto failure;
885 gezelter 1456
886 tim 543 }
887 tim 954
888 chuckv 1117 break;
889 tim 12 case '?': /* Invalid option. */
890     /* `getopt_long' already printed an error message. */
891 chuckv 1117 goto failure;
892 tim 12
893     default: /* bug: option not considered. */
894 chuckv 1117 fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
895 tim 12 abort ();
896     } /* switch */
897     } /* while */
898    
899    
900 chuckv 1117
901     if (check_required)
902 tim 12 {
903 chuckv 1117 error += cmdline_parser_required2 (args_info, argv[0], additional_error);
904 tim 12 }
905    
906 chuckv 1117 cmdline_parser_release (&local_args_info);
907    
908     if ( error )
909     return (EXIT_FAILURE);
910    
911 gezelter 1456 if (optind < argc)
912     {
913     int i = 0 ;
914     int found_prog_name = 0;
915     /* whether program name, i.e., argv[0], is in the remaining args
916     (this may happen with some implementations of getopt,
917     but surely not with the one included by gengetopt) */
918    
919     i = optind;
920     while (i < argc)
921     if (argv[i++] == argv[0]) {
922     found_prog_name = 1;
923     break;
924     }
925     i = 0;
926    
927     args_info->inputs_num = argc - optind - found_prog_name;
928     args_info->inputs =
929     (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ;
930     while (optind < argc)
931     if (argv[optind++] != argv[0])
932     args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind-1]) ;
933     }
934    
935 tim 12 return 0;
936 chuckv 1117
937     failure:
938    
939     cmdline_parser_release (&local_args_info);
940     return (EXIT_FAILURE);
941 tim 12 }

Properties

Name Value
svn:keywords Author Id Revision Date