# | Line 1 | Line 1 | |
---|---|---|
1 | /* | |
2 | < | File autogenerated by gengetopt version 2.11 |
2 | > | File autogenerated by gengetopt version 2.14 |
3 | generated with the following command: | |
4 | < | /home/maul/gezelter/tim/bin/gengetopt -F DynamicPropsCmd |
4 | > | gengetopt -i DynamicProps.ggo -F DynamicPropsCmd |
5 | ||
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 | – | |
12 | – | #include <stdio.h> |
13 | – | #include <stdlib.h> |
14 | – | #include <string.h> |
15 | – | |
11 | /* If we use autoconf. */ | |
12 | #ifdef HAVE_CONFIG_H | |
13 | #include "config.h" | |
14 | #endif | |
15 | ||
16 | + | #include <stdio.h> |
17 | + | #include <stdlib.h> |
18 | + | #include <string.h> |
19 | + | |
20 | #include "getopt.h" | |
21 | ||
22 | #include "DynamicPropsCmd.h" | |
23 | ||
24 | + | static |
25 | + | void clear_given (struct gengetopt_args_info *args_info); |
26 | + | static |
27 | + | void clear_args (struct gengetopt_args_info *args_info); |
28 | + | |
29 | + | static int |
30 | + | 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); |
31 | + | |
32 | + | static int |
33 | + | cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error); |
34 | + | |
35 | + | static char * |
36 | + | gengetopt_strdup (const char *s); |
37 | + | |
38 | + | static |
39 | + | void clear_given (struct gengetopt_args_info *args_info) |
40 | + | { |
41 | + | args_info->help_given = 0 ; |
42 | + | args_info->version_given = 0 ; |
43 | + | args_info->input_given = 0 ; |
44 | + | args_info->output_given = 0 ; |
45 | + | args_info->sele1_given = 0 ; |
46 | + | args_info->sele2_given = 0 ; |
47 | + | args_info->order_given = 0 ; |
48 | + | args_info->rcorr_given = 0 ; |
49 | + | args_info->vcorr_given = 0 ; |
50 | + | args_info->dcorr_given = 0 ; |
51 | + | args_info->lcorr_given = 0 ; |
52 | + | args_info->r_rcorr_given = 0 ; |
53 | + | args_info->thetacorr_given = 0 ; |
54 | + | args_info->drcorr_given = 0 ; |
55 | + | args_info->helfandEcorr_given = 0 ; |
56 | + | args_info->dynamicProps_group_counter = 0 ; |
57 | + | } |
58 | + | |
59 | + | static |
60 | + | void clear_args (struct gengetopt_args_info *args_info) |
61 | + | { |
62 | + | args_info->input_arg = NULL; |
63 | + | args_info->input_orig = NULL; |
64 | + | args_info->output_arg = NULL; |
65 | + | args_info->output_orig = NULL; |
66 | + | args_info->sele1_arg = NULL; |
67 | + | args_info->sele1_orig = NULL; |
68 | + | args_info->sele2_arg = NULL; |
69 | + | args_info->sele2_orig = NULL; |
70 | + | args_info->order_orig = NULL; |
71 | + | |
72 | + | } |
73 | + | |
74 | void | |
75 | cmdline_parser_print_version (void) | |
76 | { | |
# | Line 32 | Line 81 | cmdline_parser_print_help (void) | |
81 | cmdline_parser_print_help (void) | |
82 | { | |
83 | cmdline_parser_print_version (); | |
84 | < | printf("\n" |
85 | < | "Usage: %s [OPTIONS]...\n", CMDLINE_PARSER_PACKAGE); |
86 | < | printf("\n"); |
87 | < | printf(" -h, --help Print help and exit\n"); |
88 | < | printf(" -V, --version Print version and exit\n"); |
89 | < | printf(" -i, --input=filename input dump file\n"); |
90 | < | printf(" -o, --output=filename output file name\n"); |
91 | < | printf(" --sele1=selection script select first stuntdouble set\n"); |
92 | < | printf(" --sele2=selection script select second stuntdouble set (if sele2 is not \n set, use script from sele1)\n"); |
93 | < | printf("\n"); |
94 | < | printf(" Group: dynamicProps an option of this group is required\n"); |
95 | < | printf(" -r, --rcorr rmsd\n"); |
96 | < | printf(" -v, --vcorr velocity correlation function\n"); |
97 | < | printf(" -d, --dcorr dipole correlation function\n"); |
84 | > | printf("\nUsage: DynamicProps [OPTIONS]...\n\n"); |
85 | > | printf("%s\n"," -h, --help Print help and exit"); |
86 | > | printf("%s\n"," -V, --version Print version and exit"); |
87 | > | printf("%s\n"," -i, --input=filename input dump file"); |
88 | > | printf("%s\n"," -o, --output=filename output file name"); |
89 | > | printf("%s\n"," --sele1=selection script select first stuntdouble set"); |
90 | > | printf("%s\n"," --sele2=selection script select second stuntdouble set (if sele2 is not \n set, use script from sele1)"); |
91 | > | printf("%s\n"," --order=INT Lengendre Polynomial Order"); |
92 | > | printf("%s\n","\n Group: dynamicProps\n an option of this group is required"); |
93 | > | printf("%s\n"," -r, --rcorr rmsd"); |
94 | > | printf("%s\n"," -v, --vcorr velocity correlation function"); |
95 | > | printf("%s\n"," -d, --dcorr dipole correlation function"); |
96 | > | printf("%s\n"," -l, --lcorr Lengendre correlation function"); |
97 | > | printf("%s\n"," --r_rcorr Radial rmsd"); |
98 | > | printf("%s\n"," --thetacorr Angular rmsd"); |
99 | > | printf("%s\n"," --drcorr Directional rmsd for particles with unit \n vectors"); |
100 | > | printf("%s\n"," --helfandEcorr Helfand moment for thermal conductvity"); |
101 | > | |
102 | } | |
103 | ||
104 | + | void |
105 | + | cmdline_parser_init (struct gengetopt_args_info *args_info) |
106 | + | { |
107 | + | clear_given (args_info); |
108 | + | clear_args (args_info); |
109 | + | } |
110 | ||
111 | < | static char *gengetopt_strdup (const char *s); |
111 | > | static void |
112 | > | cmdline_parser_release (struct gengetopt_args_info *args_info) |
113 | > | { |
114 | > | |
115 | > | if (args_info->input_arg) |
116 | > | { |
117 | > | free (args_info->input_arg); /* free previous argument */ |
118 | > | args_info->input_arg = 0; |
119 | > | } |
120 | > | if (args_info->input_orig) |
121 | > | { |
122 | > | free (args_info->input_orig); /* free previous argument */ |
123 | > | args_info->input_orig = 0; |
124 | > | } |
125 | > | if (args_info->output_arg) |
126 | > | { |
127 | > | free (args_info->output_arg); /* free previous argument */ |
128 | > | args_info->output_arg = 0; |
129 | > | } |
130 | > | if (args_info->output_orig) |
131 | > | { |
132 | > | free (args_info->output_orig); /* free previous argument */ |
133 | > | args_info->output_orig = 0; |
134 | > | } |
135 | > | if (args_info->sele1_arg) |
136 | > | { |
137 | > | free (args_info->sele1_arg); /* free previous argument */ |
138 | > | args_info->sele1_arg = 0; |
139 | > | } |
140 | > | if (args_info->sele1_orig) |
141 | > | { |
142 | > | free (args_info->sele1_orig); /* free previous argument */ |
143 | > | args_info->sele1_orig = 0; |
144 | > | } |
145 | > | if (args_info->sele2_arg) |
146 | > | { |
147 | > | free (args_info->sele2_arg); /* free previous argument */ |
148 | > | args_info->sele2_arg = 0; |
149 | > | } |
150 | > | if (args_info->sele2_orig) |
151 | > | { |
152 | > | free (args_info->sele2_orig); /* free previous argument */ |
153 | > | args_info->sele2_orig = 0; |
154 | > | } |
155 | > | if (args_info->order_orig) |
156 | > | { |
157 | > | free (args_info->order_orig); /* free previous argument */ |
158 | > | args_info->order_orig = 0; |
159 | > | } |
160 | > | |
161 | > | clear_given (args_info); |
162 | > | } |
163 | ||
164 | + | int |
165 | + | cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info) |
166 | + | { |
167 | + | FILE *outfile; |
168 | + | int i = 0; |
169 | + | |
170 | + | outfile = fopen(filename, "w"); |
171 | + | |
172 | + | if (!outfile) |
173 | + | { |
174 | + | fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename); |
175 | + | return EXIT_FAILURE; |
176 | + | } |
177 | + | |
178 | + | if (args_info->help_given) { |
179 | + | fprintf(outfile, "%s\n", "help"); |
180 | + | } |
181 | + | if (args_info->version_given) { |
182 | + | fprintf(outfile, "%s\n", "version"); |
183 | + | } |
184 | + | if (args_info->input_given) { |
185 | + | if (args_info->input_orig) { |
186 | + | fprintf(outfile, "%s=\"%s\"\n", "input", args_info->input_orig); |
187 | + | } else { |
188 | + | fprintf(outfile, "%s\n", "input"); |
189 | + | } |
190 | + | } |
191 | + | if (args_info->output_given) { |
192 | + | if (args_info->output_orig) { |
193 | + | fprintf(outfile, "%s=\"%s\"\n", "output", args_info->output_orig); |
194 | + | } else { |
195 | + | fprintf(outfile, "%s\n", "output"); |
196 | + | } |
197 | + | } |
198 | + | if (args_info->sele1_given) { |
199 | + | if (args_info->sele1_orig) { |
200 | + | fprintf(outfile, "%s=\"%s\"\n", "sele1", args_info->sele1_orig); |
201 | + | } else { |
202 | + | fprintf(outfile, "%s\n", "sele1"); |
203 | + | } |
204 | + | } |
205 | + | if (args_info->sele2_given) { |
206 | + | if (args_info->sele2_orig) { |
207 | + | fprintf(outfile, "%s=\"%s\"\n", "sele2", args_info->sele2_orig); |
208 | + | } else { |
209 | + | fprintf(outfile, "%s\n", "sele2"); |
210 | + | } |
211 | + | } |
212 | + | if (args_info->order_given) { |
213 | + | if (args_info->order_orig) { |
214 | + | fprintf(outfile, "%s=\"%s\"\n", "order", args_info->order_orig); |
215 | + | } else { |
216 | + | fprintf(outfile, "%s\n", "order"); |
217 | + | } |
218 | + | } |
219 | + | if (args_info->rcorr_given) { |
220 | + | fprintf(outfile, "%s\n", "rcorr"); |
221 | + | } |
222 | + | if (args_info->vcorr_given) { |
223 | + | fprintf(outfile, "%s\n", "vcorr"); |
224 | + | } |
225 | + | if (args_info->dcorr_given) { |
226 | + | fprintf(outfile, "%s\n", "dcorr"); |
227 | + | } |
228 | + | if (args_info->lcorr_given) { |
229 | + | fprintf(outfile, "%s\n", "lcorr"); |
230 | + | } |
231 | + | if (args_info->r_rcorr_given) { |
232 | + | fprintf(outfile, "%s\n", "r_rcorr"); |
233 | + | } |
234 | + | if (args_info->thetacorr_given) { |
235 | + | fprintf(outfile, "%s\n", "thetacorr"); |
236 | + | } |
237 | + | if (args_info->drcorr_given) { |
238 | + | fprintf(outfile, "%s\n", "drcorr"); |
239 | + | } |
240 | + | if (args_info->helfandEcorr_given) { |
241 | + | fprintf(outfile, "%s\n", "helfandEcorr"); |
242 | + | } |
243 | + | |
244 | + | fclose (outfile); |
245 | + | |
246 | + | i = EXIT_SUCCESS; |
247 | + | return i; |
248 | + | } |
249 | + | |
250 | + | void |
251 | + | cmdline_parser_free (struct gengetopt_args_info *args_info) |
252 | + | { |
253 | + | cmdline_parser_release (args_info); |
254 | + | } |
255 | + | |
256 | + | |
257 | /* gengetopt_strdup() */ | |
258 | /* strdup.c replacement of strdup, which is not standard */ | |
259 | char * | |
260 | gengetopt_strdup (const char *s) | |
261 | { | |
262 | < | char *result = (char*)malloc(strlen(s) + 1); |
262 | > | char *result = NULL; |
263 | > | if (!s) |
264 | > | return result; |
265 | > | |
266 | > | result = (char*)malloc(strlen(s) + 1); |
267 | if (result == (char*)0) | |
268 | return (char*)0; | |
269 | strcpy(result, s); | |
270 | return result; | |
271 | } | |
272 | ||
273 | < | int |
274 | < | cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info) |
273 | > | static void |
274 | > | reset_group_dynamicProps(struct gengetopt_args_info *args_info); |
275 | > | |
276 | > | static void |
277 | > | reset_group_dynamicProps(struct gengetopt_args_info *args_info) |
278 | { | |
279 | < | int c; /* Character of the parsed option. */ |
280 | < | int missing_required_options = 0; |
71 | < | int dynamicProps_group_counter = 0; |
279 | > | if (! args_info->dynamicProps_group_counter) |
280 | > | return; |
281 | ||
73 | – | |
74 | – | args_info->help_given = 0 ; |
75 | – | args_info->version_given = 0 ; |
76 | – | args_info->input_given = 0 ; |
77 | – | args_info->output_given = 0 ; |
78 | – | args_info->sele1_given = 0 ; |
79 | – | args_info->sele2_given = 0 ; |
282 | args_info->rcorr_given = 0 ; | |
283 | args_info->vcorr_given = 0 ; | |
284 | args_info->dcorr_given = 0 ; | |
285 | < | #define clear_args() { \ |
286 | < | args_info->input_arg = NULL; \ |
287 | < | args_info->output_arg = NULL; \ |
288 | < | args_info->sele1_arg = NULL; \ |
289 | < | args_info->sele2_arg = NULL; \ |
88 | < | } |
285 | > | args_info->lcorr_given = 0 ; |
286 | > | args_info->r_rcorr_given = 0 ; |
287 | > | args_info->thetacorr_given = 0 ; |
288 | > | args_info->drcorr_given = 0 ; |
289 | > | args_info->helfandEcorr_given = 0 ; |
290 | ||
291 | < | clear_args(); |
291 | > | args_info->dynamicProps_group_counter = 0; |
292 | > | } |
293 | ||
294 | + | int |
295 | + | cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info) |
296 | + | { |
297 | + | return cmdline_parser2 (argc, argv, args_info, 0, 1, 1); |
298 | + | } |
299 | + | |
300 | + | int |
301 | + | cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) |
302 | + | { |
303 | + | int result; |
304 | + | |
305 | + | result = cmdline_parser_internal (argc, argv, args_info, override, initialize, check_required, NULL); |
306 | + | |
307 | + | if (result == EXIT_FAILURE) |
308 | + | { |
309 | + | cmdline_parser_free (args_info); |
310 | + | exit (EXIT_FAILURE); |
311 | + | } |
312 | + | |
313 | + | return result; |
314 | + | } |
315 | + | |
316 | + | int |
317 | + | cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name) |
318 | + | { |
319 | + | int result = EXIT_SUCCESS; |
320 | + | |
321 | + | if (cmdline_parser_required2(args_info, prog_name, NULL) > 0) |
322 | + | result = EXIT_FAILURE; |
323 | + | |
324 | + | if (result == EXIT_FAILURE) |
325 | + | { |
326 | + | cmdline_parser_free (args_info); |
327 | + | exit (EXIT_FAILURE); |
328 | + | } |
329 | + | |
330 | + | return result; |
331 | + | } |
332 | + | |
333 | + | int |
334 | + | cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error) |
335 | + | { |
336 | + | int error = 0; |
337 | + | |
338 | + | if (! args_info->input_given) |
339 | + | { |
340 | + | fprintf (stderr, "%s: '--input' ('-i') option required%s\n", prog_name, (additional_error ? additional_error : "")); |
341 | + | error = 1; |
342 | + | } |
343 | + | if (args_info->dynamicProps_group_counter == 0) |
344 | + | { |
345 | + | fprintf (stderr, "%s: %d options of group dynamicProps were given. One is required.%s\n", prog_name, args_info->dynamicProps_group_counter, (additional_error ? additional_error : "")); |
346 | + | error = 1; |
347 | + | } |
348 | + | |
349 | + | |
350 | + | return error; |
351 | + | } |
352 | + | |
353 | + | int |
354 | + | 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) |
355 | + | { |
356 | + | int c; /* Character of the parsed option. */ |
357 | + | |
358 | + | int error = 0; |
359 | + | struct gengetopt_args_info local_args_info; |
360 | + | |
361 | + | if (initialize) |
362 | + | cmdline_parser_init (args_info); |
363 | + | |
364 | + | cmdline_parser_init (&local_args_info); |
365 | + | |
366 | optarg = 0; | |
367 | optind = 1; | |
368 | opterr = 1; | |
# | Line 106 | Line 380 | cmdline_parser (int argc, char * const *argv, struct g | |
380 | { "output", 1, NULL, 'o' }, | |
381 | { "sele1", 1, NULL, 0 }, | |
382 | { "sele2", 1, NULL, 0 }, | |
383 | + | { "order", 1, NULL, 0 }, |
384 | { "rcorr", 0, NULL, 'r' }, | |
385 | { "vcorr", 0, NULL, 'v' }, | |
386 | { "dcorr", 0, NULL, 'd' }, | |
387 | + | { "lcorr", 0, NULL, 'l' }, |
388 | + | { "r_rcorr", 0, NULL, 0 }, |
389 | + | { "thetacorr", 0, NULL, 0 }, |
390 | + | { "drcorr", 0, NULL, 0 }, |
391 | + | { "helfandEcorr", 0, NULL, 0 }, |
392 | { NULL, 0, NULL, 0 } | |
393 | }; | |
394 | ||
395 | stop_char = 0; | |
396 | < | c = getopt_long (argc, argv, "hVi:o:rvd", long_options, &option_index); |
396 | > | c = getopt_long (argc, argv, "hVi:o:rvdl", long_options, &option_index); |
397 | ||
398 | if (c == -1) break; /* Exit from `while (1)' loop. */ | |
399 | ||
400 | switch (c) | |
401 | { | |
402 | case 'h': /* Print help and exit. */ | |
123 | – | clear_args (); |
403 | cmdline_parser_print_help (); | |
404 | + | cmdline_parser_free (&local_args_info); |
405 | exit (EXIT_SUCCESS); | |
406 | ||
407 | case 'V': /* Print version and exit. */ | |
128 | – | clear_args (); |
408 | cmdline_parser_print_version (); | |
409 | + | cmdline_parser_free (&local_args_info); |
410 | exit (EXIT_SUCCESS); | |
411 | ||
412 | case 'i': /* input dump file. */ | |
413 | < | if (args_info->input_given) |
413 | > | if (local_args_info.input_given) |
414 | { | |
415 | < | fprintf (stderr, "%s: `--input' (`-i') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
416 | < | clear_args (); |
137 | < | exit (EXIT_FAILURE); |
415 | > | fprintf (stderr, "%s: `--input' (`-i') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
416 | > | goto failure; |
417 | } | |
418 | + | if (args_info->input_given && ! override) |
419 | + | continue; |
420 | + | local_args_info.input_given = 1; |
421 | args_info->input_given = 1; | |
422 | + | if (args_info->input_arg) |
423 | + | free (args_info->input_arg); /* free previous string */ |
424 | args_info->input_arg = gengetopt_strdup (optarg); | |
425 | + | if (args_info->input_orig) |
426 | + | free (args_info->input_orig); /* free previous string */ |
427 | + | args_info->input_orig = gengetopt_strdup (optarg); |
428 | break; | |
429 | ||
430 | case 'o': /* output file name. */ | |
431 | < | if (args_info->output_given) |
431 | > | if (local_args_info.output_given) |
432 | { | |
433 | < | fprintf (stderr, "%s: `--output' (`-o') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
434 | < | clear_args (); |
148 | < | exit (EXIT_FAILURE); |
433 | > | fprintf (stderr, "%s: `--output' (`-o') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
434 | > | goto failure; |
435 | } | |
436 | + | if (args_info->output_given && ! override) |
437 | + | continue; |
438 | + | local_args_info.output_given = 1; |
439 | args_info->output_given = 1; | |
440 | + | if (args_info->output_arg) |
441 | + | free (args_info->output_arg); /* free previous string */ |
442 | args_info->output_arg = gengetopt_strdup (optarg); | |
443 | + | if (args_info->output_orig) |
444 | + | free (args_info->output_orig); /* free previous string */ |
445 | + | args_info->output_orig = gengetopt_strdup (optarg); |
446 | break; | |
447 | ||
448 | case 'r': /* rmsd. */ | |
449 | < | if (args_info->rcorr_given) |
449 | > | if (local_args_info.rcorr_given) |
450 | { | |
451 | < | fprintf (stderr, "%s: `--rcorr' (`-r') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
452 | < | clear_args (); |
159 | < | exit (EXIT_FAILURE); |
451 | > | fprintf (stderr, "%s: `--rcorr' (`-r') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
452 | > | goto failure; |
453 | } | |
454 | + | if (args_info->rcorr_given && ! override) |
455 | + | continue; |
456 | + | local_args_info.rcorr_given = 1; |
457 | args_info->rcorr_given = 1; | |
458 | < | dynamicProps_group_counter += 1; |
459 | < | break; |
458 | > | if (args_info->dynamicProps_group_counter && override) |
459 | > | reset_group_dynamicProps (args_info); |
460 | > | args_info->dynamicProps_group_counter += 1; |
461 | > | break; |
462 | ||
463 | case 'v': /* velocity correlation function. */ | |
464 | < | if (args_info->vcorr_given) |
464 | > | if (local_args_info.vcorr_given) |
465 | { | |
466 | < | fprintf (stderr, "%s: `--vcorr' (`-v') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
467 | < | clear_args (); |
170 | < | exit (EXIT_FAILURE); |
466 | > | fprintf (stderr, "%s: `--vcorr' (`-v') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
467 | > | goto failure; |
468 | } | |
469 | + | if (args_info->vcorr_given && ! override) |
470 | + | continue; |
471 | + | local_args_info.vcorr_given = 1; |
472 | args_info->vcorr_given = 1; | |
473 | < | dynamicProps_group_counter += 1; |
474 | < | break; |
473 | > | if (args_info->dynamicProps_group_counter && override) |
474 | > | reset_group_dynamicProps (args_info); |
475 | > | args_info->dynamicProps_group_counter += 1; |
476 | > | break; |
477 | ||
478 | case 'd': /* dipole correlation function. */ | |
479 | < | if (args_info->dcorr_given) |
479 | > | if (local_args_info.dcorr_given) |
480 | { | |
481 | < | fprintf (stderr, "%s: `--dcorr' (`-d') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
482 | < | clear_args (); |
181 | < | exit (EXIT_FAILURE); |
481 | > | fprintf (stderr, "%s: `--dcorr' (`-d') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
482 | > | goto failure; |
483 | } | |
484 | + | if (args_info->dcorr_given && ! override) |
485 | + | continue; |
486 | + | local_args_info.dcorr_given = 1; |
487 | args_info->dcorr_given = 1; | |
488 | < | dynamicProps_group_counter += 1; |
489 | < | break; |
488 | > | if (args_info->dynamicProps_group_counter && override) |
489 | > | reset_group_dynamicProps (args_info); |
490 | > | args_info->dynamicProps_group_counter += 1; |
491 | > | break; |
492 | ||
493 | + | case 'l': /* Lengendre correlation function. */ |
494 | + | if (local_args_info.lcorr_given) |
495 | + | { |
496 | + | fprintf (stderr, "%s: `--lcorr' (`-l') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
497 | + | goto failure; |
498 | + | } |
499 | + | if (args_info->lcorr_given && ! override) |
500 | + | continue; |
501 | + | local_args_info.lcorr_given = 1; |
502 | + | args_info->lcorr_given = 1; |
503 | + | if (args_info->dynamicProps_group_counter && override) |
504 | + | reset_group_dynamicProps (args_info); |
505 | + | args_info->dynamicProps_group_counter += 1; |
506 | + | break; |
507 | ||
508 | + | |
509 | case 0: /* Long option with no short option */ | |
510 | /* select first stuntdouble set. */ | |
511 | if (strcmp (long_options[option_index].name, "sele1") == 0) | |
512 | < | { |
513 | < | if (args_info->sele1_given) |
514 | < | { |
515 | < | fprintf (stderr, "%s: `--sele1' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
516 | < | clear_args (); |
517 | < | exit (EXIT_FAILURE); |
518 | < | } |
519 | < | args_info->sele1_given = 1; |
520 | < | args_info->sele1_arg = gengetopt_strdup (optarg); |
521 | < | break; |
522 | < | } |
523 | < | |
512 | > | { |
513 | > | if (local_args_info.sele1_given) |
514 | > | { |
515 | > | fprintf (stderr, "%s: `--sele1' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
516 | > | goto failure; |
517 | > | } |
518 | > | if (args_info->sele1_given && ! override) |
519 | > | continue; |
520 | > | local_args_info.sele1_given = 1; |
521 | > | args_info->sele1_given = 1; |
522 | > | if (args_info->sele1_arg) |
523 | > | free (args_info->sele1_arg); /* free previous string */ |
524 | > | args_info->sele1_arg = gengetopt_strdup (optarg); |
525 | > | if (args_info->sele1_orig) |
526 | > | free (args_info->sele1_orig); /* free previous string */ |
527 | > | args_info->sele1_orig = gengetopt_strdup (optarg); |
528 | > | } |
529 | /* select second stuntdouble set (if sele2 is not set, use script from sele1). */ | |
530 | else if (strcmp (long_options[option_index].name, "sele2") == 0) | |
531 | < | { |
532 | < | if (args_info->sele2_given) |
533 | < | { |
534 | < | fprintf (stderr, "%s: `--sele2' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
535 | < | clear_args (); |
536 | < | exit (EXIT_FAILURE); |
537 | < | } |
538 | < | args_info->sele2_given = 1; |
539 | < | args_info->sele2_arg = gengetopt_strdup (optarg); |
540 | < | break; |
541 | < | } |
531 | > | { |
532 | > | if (local_args_info.sele2_given) |
533 | > | { |
534 | > | fprintf (stderr, "%s: `--sele2' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
535 | > | goto failure; |
536 | > | } |
537 | > | if (args_info->sele2_given && ! override) |
538 | > | continue; |
539 | > | local_args_info.sele2_given = 1; |
540 | > | args_info->sele2_given = 1; |
541 | > | if (args_info->sele2_arg) |
542 | > | free (args_info->sele2_arg); /* free previous string */ |
543 | > | args_info->sele2_arg = gengetopt_strdup (optarg); |
544 | > | if (args_info->sele2_orig) |
545 | > | free (args_info->sele2_orig); /* free previous string */ |
546 | > | args_info->sele2_orig = gengetopt_strdup (optarg); |
547 | > | } |
548 | > | /* Lengendre Polynomial Order. */ |
549 | > | else if (strcmp (long_options[option_index].name, "order") == 0) |
550 | > | { |
551 | > | if (local_args_info.order_given) |
552 | > | { |
553 | > | fprintf (stderr, "%s: `--order' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
554 | > | goto failure; |
555 | > | } |
556 | > | if (args_info->order_given && ! override) |
557 | > | continue; |
558 | > | local_args_info.order_given = 1; |
559 | > | args_info->order_given = 1; |
560 | > | args_info->order_arg = strtol (optarg,&stop_char,0); |
561 | > | if (args_info->order_orig) |
562 | > | free (args_info->order_orig); /* free previous string */ |
563 | > | args_info->order_orig = gengetopt_strdup (optarg); |
564 | > | } |
565 | > | /* Radial rmsd. */ |
566 | > | else if (strcmp (long_options[option_index].name, "r_rcorr") == 0) |
567 | > | { |
568 | > | if (local_args_info.r_rcorr_given) |
569 | > | { |
570 | > | fprintf (stderr, "%s: `--r_rcorr' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
571 | > | goto failure; |
572 | > | } |
573 | > | if (args_info->r_rcorr_given && ! override) |
574 | > | continue; |
575 | > | local_args_info.r_rcorr_given = 1; |
576 | > | args_info->r_rcorr_given = 1; |
577 | > | if (args_info->dynamicProps_group_counter && override) |
578 | > | reset_group_dynamicProps (args_info); |
579 | > | args_info->dynamicProps_group_counter += 1; |
580 | > | break; |
581 | > | } |
582 | > | /* Angular rmsd. */ |
583 | > | else if (strcmp (long_options[option_index].name, "thetacorr") == 0) |
584 | > | { |
585 | > | if (local_args_info.thetacorr_given) |
586 | > | { |
587 | > | fprintf (stderr, "%s: `--thetacorr' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
588 | > | goto failure; |
589 | > | } |
590 | > | if (args_info->thetacorr_given && ! override) |
591 | > | continue; |
592 | > | local_args_info.thetacorr_given = 1; |
593 | > | args_info->thetacorr_given = 1; |
594 | > | if (args_info->dynamicProps_group_counter && override) |
595 | > | reset_group_dynamicProps (args_info); |
596 | > | args_info->dynamicProps_group_counter += 1; |
597 | > | break; |
598 | > | } |
599 | > | /* Directional rmsd for particles with unit vectors. */ |
600 | > | else if (strcmp (long_options[option_index].name, "drcorr") == 0) |
601 | > | { |
602 | > | if (local_args_info.drcorr_given) |
603 | > | { |
604 | > | fprintf (stderr, "%s: `--drcorr' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
605 | > | goto failure; |
606 | > | } |
607 | > | if (args_info->drcorr_given && ! override) |
608 | > | continue; |
609 | > | local_args_info.drcorr_given = 1; |
610 | > | args_info->drcorr_given = 1; |
611 | > | if (args_info->dynamicProps_group_counter && override) |
612 | > | reset_group_dynamicProps (args_info); |
613 | > | args_info->dynamicProps_group_counter += 1; |
614 | > | break; |
615 | > | } |
616 | > | /* Helfand moment for thermal conductvity. */ |
617 | > | else if (strcmp (long_options[option_index].name, "helfandEcorr") == 0) |
618 | > | { |
619 | > | if (local_args_info.helfandEcorr_given) |
620 | > | { |
621 | > | fprintf (stderr, "%s: `--helfandEcorr' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
622 | > | goto failure; |
623 | > | } |
624 | > | if (args_info->helfandEcorr_given && ! override) |
625 | > | continue; |
626 | > | local_args_info.helfandEcorr_given = 1; |
627 | > | args_info->helfandEcorr_given = 1; |
628 | > | if (args_info->dynamicProps_group_counter && override) |
629 | > | reset_group_dynamicProps (args_info); |
630 | > | args_info->dynamicProps_group_counter += 1; |
631 | > | break; |
632 | > | } |
633 | ||
634 | < | |
634 | > | break; |
635 | case '?': /* Invalid option. */ | |
636 | /* `getopt_long' already printed an error message. */ | |
637 | < | exit (EXIT_FAILURE); |
637 | > | goto failure; |
638 | ||
639 | default: /* bug: option not considered. */ | |
640 | < | fprintf (stderr, "%s: option unknown: %c\n", CMDLINE_PARSER_PACKAGE, c); |
640 | > | fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : "")); |
641 | abort (); | |
642 | } /* switch */ | |
643 | } /* while */ | |
644 | ||
645 | < | if ( dynamicProps_group_counter != 1) |
645 | > | if (args_info->dynamicProps_group_counter > 1) |
646 | { | |
647 | < | fprintf (stderr, "%s: %d options of group dynamicProps were given. One is required\n", CMDLINE_PARSER_PACKAGE, dynamicProps_group_counter); |
648 | < | missing_required_options = 1; |
647 | > | fprintf (stderr, "%s: %d options of group dynamicProps were given. One is required.%s\n", argv[0], args_info->dynamicProps_group_counter, (additional_error ? additional_error : "")); |
648 | > | error = 1; |
649 | } | |
650 | ||
651 | ||
652 | < | if (! args_info->input_given) |
652 | > | |
653 | > | if (check_required) |
654 | { | |
655 | < | fprintf (stderr, "%s: '--input' ('-i') option required\n", CMDLINE_PARSER_PACKAGE); |
238 | < | missing_required_options = 1; |
655 | > | error += cmdline_parser_required2 (args_info, argv[0], additional_error); |
656 | } | |
240 | – | if ( missing_required_options ) |
241 | – | exit (EXIT_FAILURE); |
657 | ||
658 | + | cmdline_parser_release (&local_args_info); |
659 | + | |
660 | + | if ( error ) |
661 | + | return (EXIT_FAILURE); |
662 | + | |
663 | return 0; | |
664 | + | |
665 | + | failure: |
666 | + | |
667 | + | cmdline_parser_release (&local_args_info); |
668 | + | return (EXIT_FAILURE); |
669 | } |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |