# | Line 1 | Line 1 | |
---|---|---|
1 | /* | |
2 | < | File autogenerated by gengetopt version 2.11 |
2 | > | File autogenerated by gengetopt version 2.16 |
3 | generated with the following command: | |
4 | < | /home/maul/gezelter/tim/bin/gengetopt -F StaticPropsCmd |
4 | > | gengetopt -F StaticPropsCmd |
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 "StaticPropsCmd.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->step_given = 0 ; |
46 | + | args_info->nrbins_given = 0 ; |
47 | + | args_info->nbins_x_given = 0 ; |
48 | + | args_info->nbins_y_given = 0 ; |
49 | + | args_info->nanglebins_given = 0 ; |
50 | + | args_info->length_given = 0 ; |
51 | + | args_info->zoffset_given = 0 ; |
52 | + | args_info->sele1_given = 0 ; |
53 | + | args_info->sele2_given = 0 ; |
54 | + | args_info->sele3_given = 0 ; |
55 | + | args_info->refsele_given = 0 ; |
56 | + | args_info->molname_given = 0 ; |
57 | + | args_info->begin_given = 0 ; |
58 | + | args_info->end_given = 0 ; |
59 | + | args_info->gofr_given = 0 ; |
60 | + | args_info->r_theta_given = 0 ; |
61 | + | args_info->r_omega_given = 0 ; |
62 | + | args_info->theta_omega_given = 0 ; |
63 | + | args_info->gxyz_given = 0 ; |
64 | + | args_info->p2_given = 0 ; |
65 | + | args_info->rp2_given = 0 ; |
66 | + | args_info->scd_given = 0 ; |
67 | + | args_info->density_given = 0 ; |
68 | + | args_info->slab_density_given = 0 ; |
69 | + | args_info->hxy_given = 0 ; |
70 | + | args_info->staticProps_group_counter = 0 ; |
71 | + | } |
72 | + | |
73 | + | static |
74 | + | void clear_args (struct gengetopt_args_info *args_info) |
75 | + | { |
76 | + | args_info->input_arg = NULL; |
77 | + | args_info->input_orig = NULL; |
78 | + | args_info->output_arg = NULL; |
79 | + | args_info->output_orig = NULL; |
80 | + | args_info->step_arg = 1; |
81 | + | args_info->step_orig = NULL; |
82 | + | args_info->nrbins_arg = 100; |
83 | + | args_info->nrbins_orig = NULL; |
84 | + | args_info->nbins_x_arg = 100; |
85 | + | args_info->nbins_x_orig = NULL; |
86 | + | args_info->nbins_y_arg = 100; |
87 | + | args_info->nbins_y_orig = NULL; |
88 | + | args_info->nanglebins_arg = 50; |
89 | + | args_info->nanglebins_orig = NULL; |
90 | + | args_info->length_orig = NULL; |
91 | + | args_info->zoffset_arg = 0; |
92 | + | args_info->zoffset_orig = NULL; |
93 | + | args_info->sele1_arg = NULL; |
94 | + | args_info->sele1_orig = NULL; |
95 | + | args_info->sele2_arg = NULL; |
96 | + | args_info->sele2_orig = NULL; |
97 | + | args_info->sele3_arg = NULL; |
98 | + | args_info->sele3_orig = NULL; |
99 | + | args_info->refsele_arg = NULL; |
100 | + | args_info->refsele_orig = NULL; |
101 | + | args_info->molname_arg = NULL; |
102 | + | args_info->molname_orig = NULL; |
103 | + | args_info->begin_orig = NULL; |
104 | + | args_info->end_orig = NULL; |
105 | + | |
106 | + | } |
107 | + | |
108 | void | |
109 | cmdline_parser_print_version (void) | |
110 | { | |
# | Line 32 | Line 115 | cmdline_parser_print_help (void) | |
115 | cmdline_parser_print_help (void) | |
116 | { | |
117 | cmdline_parser_print_version (); | |
118 | < | printf("\n" |
119 | < | "Usage: %s [OPTIONS]...\n", CMDLINE_PARSER_PACKAGE); |
120 | < | printf("\n"); |
121 | < | printf(" -h, --help Print help and exit\n"); |
122 | < | printf(" -V, --version Print version and exit\n"); |
123 | < | printf(" -i, --input=filename input dump file\n"); |
124 | < | printf(" -o, --output=filename output file name\n"); |
125 | < | printf(" -n, --step=INT process every n frame (default=`1')\n"); |
126 | < | printf(" -r, --nrbins=INT number of bins for distance (default=`100')\n"); |
127 | < | printf(" -a, --nanglebins=INT number of bins for cos(angle) (default=\n `50')\n"); |
128 | < | printf(" -l, --length=DOUBLE maximum length (Defaults to 1/2 smallest \n length of first frame)\n"); |
129 | < | printf(" --sele1=selection script select first stuntdouble set\n"); |
130 | < | printf(" --sele2=selection script select second stuntdouble set\n"); |
131 | < | printf(" --refsele=selection script select reference (use and only use with \n --gxyz)\n"); |
132 | < | printf("\n"); |
133 | < | printf(" Group: staticProps an option of this group is required\n"); |
134 | < | printf(" --gofr g(r)\n"); |
135 | < | printf(" --r_theta g(r, cos(theta))\n"); |
136 | < | printf(" --r_omega g(r, cos(omega))\n"); |
137 | < | printf(" --theta_omega g(cos(theta), cos(omega))\n"); |
138 | < | printf(" --gxyz g(x, y, z)\n"); |
118 | > | printf("\nUsage: StaticProps [OPTIONS]...\n\n"); |
119 | > | printf("%s\n"," -h, --help Print help and exit"); |
120 | > | printf("%s\n"," -V, --version Print version and exit"); |
121 | > | printf("%s\n"," -i, --input=filename input dump file"); |
122 | > | printf("%s\n"," -o, --output=filename output file name"); |
123 | > | printf("%s\n"," -n, --step=INT process every n frame (default=`1')"); |
124 | > | printf("%s\n"," -r, --nrbins=INT number of bins for distance (default=`100')"); |
125 | > | printf("%s\n"," -x, --nbins_x=INT number of bins in x axis (default=`100')"); |
126 | > | printf("%s\n"," -y, --nbins_y=INT number of bins in y axis (default=`100')"); |
127 | > | printf("%s\n"," -a, --nanglebins=INT number of bins for cos(angle) (default=`50')"); |
128 | > | printf("%s\n"," -l, --length=DOUBLE maximum length (Defaults to 1/2 smallest length \n of first frame)"); |
129 | > | printf("%s\n"," -z, --zoffset=DOUBLE Where to set the zero for the slab_density \n calculation (default=`0')"); |
130 | > | printf("%s\n"," --sele1=selection script select the first stuntdouble set"); |
131 | > | printf("%s\n"," --sele2=selection script select the second stuntdouble set"); |
132 | > | printf("%s\n"," --sele3=selection script select the third stuntdouble set"); |
133 | > | printf("%s\n"," --refsele=selection script\n select reference (use and only use with --gxyz)"); |
134 | > | printf("%s\n"," --molname=STRING molecule name"); |
135 | > | printf("%s\n"," --begin=INT begin interanl index"); |
136 | > | printf("%s\n"," --end=INT end internal index"); |
137 | > | printf("%s\n","\n Group: staticProps\n an option of this group is required"); |
138 | > | printf("%s\n"," --gofr g(r)"); |
139 | > | printf("%s\n"," --r_theta g(r, cos(theta))"); |
140 | > | printf("%s\n"," --r_omega g(r, cos(omega))"); |
141 | > | printf("%s\n"," --theta_omega g(cos(theta), cos(omega))"); |
142 | > | printf("%s\n"," --gxyz g(x, y, z)"); |
143 | > | printf("%s\n"," --p2 p2 order parameter (--sele1 and --sele2 must be \n specified)"); |
144 | > | printf("%s\n"," --rp2 rp2 order parameter (--sele1 and --sele2 must \n be specified)"); |
145 | > | printf("%s\n"," --scd scd order parameter(either --sele1, --sele2, \n --sele3 are specified or --molname, --begin, \n --end are specified)"); |
146 | > | printf("%s\n"," --density density plot (--sele1 must be specified)"); |
147 | > | printf("%s\n"," --slab_density slab density (--sele1 must be specified)"); |
148 | > | printf("%s\n"," --hxy hxy (--sele1 must be specified)"); |
149 | > | |
150 | } | |
151 | ||
152 | + | void |
153 | + | cmdline_parser_init (struct gengetopt_args_info *args_info) |
154 | + | { |
155 | + | clear_given (args_info); |
156 | + | clear_args (args_info); |
157 | + | } |
158 | ||
159 | < | static char *gengetopt_strdup (const char *s); |
159 | > | static void |
160 | > | cmdline_parser_release (struct gengetopt_args_info *args_info) |
161 | > | { |
162 | > | |
163 | > | if (args_info->input_arg) |
164 | > | { |
165 | > | free (args_info->input_arg); /* free previous argument */ |
166 | > | args_info->input_arg = 0; |
167 | > | } |
168 | > | if (args_info->input_orig) |
169 | > | { |
170 | > | free (args_info->input_orig); /* free previous argument */ |
171 | > | args_info->input_orig = 0; |
172 | > | } |
173 | > | if (args_info->output_arg) |
174 | > | { |
175 | > | free (args_info->output_arg); /* free previous argument */ |
176 | > | args_info->output_arg = 0; |
177 | > | } |
178 | > | if (args_info->output_orig) |
179 | > | { |
180 | > | free (args_info->output_orig); /* free previous argument */ |
181 | > | args_info->output_orig = 0; |
182 | > | } |
183 | > | if (args_info->step_orig) |
184 | > | { |
185 | > | free (args_info->step_orig); /* free previous argument */ |
186 | > | args_info->step_orig = 0; |
187 | > | } |
188 | > | if (args_info->nrbins_orig) |
189 | > | { |
190 | > | free (args_info->nrbins_orig); /* free previous argument */ |
191 | > | args_info->nrbins_orig = 0; |
192 | > | } |
193 | > | if (args_info->nbins_x_orig) |
194 | > | { |
195 | > | free (args_info->nbins_x_orig); /* free previous argument */ |
196 | > | args_info->nbins_x_orig = 0; |
197 | > | } |
198 | > | if (args_info->nbins_y_orig) |
199 | > | { |
200 | > | free (args_info->nbins_y_orig); /* free previous argument */ |
201 | > | args_info->nbins_y_orig = 0; |
202 | > | } |
203 | > | if (args_info->nanglebins_orig) |
204 | > | { |
205 | > | free (args_info->nanglebins_orig); /* free previous argument */ |
206 | > | args_info->nanglebins_orig = 0; |
207 | > | } |
208 | > | if (args_info->length_orig) |
209 | > | { |
210 | > | free (args_info->length_orig); /* free previous argument */ |
211 | > | args_info->length_orig = 0; |
212 | > | } |
213 | > | if (args_info->zoffset_orig) |
214 | > | { |
215 | > | free (args_info->zoffset_orig); /* free previous argument */ |
216 | > | args_info->zoffset_orig = 0; |
217 | > | } |
218 | > | if (args_info->sele1_arg) |
219 | > | { |
220 | > | free (args_info->sele1_arg); /* free previous argument */ |
221 | > | args_info->sele1_arg = 0; |
222 | > | } |
223 | > | if (args_info->sele1_orig) |
224 | > | { |
225 | > | free (args_info->sele1_orig); /* free previous argument */ |
226 | > | args_info->sele1_orig = 0; |
227 | > | } |
228 | > | if (args_info->sele2_arg) |
229 | > | { |
230 | > | free (args_info->sele2_arg); /* free previous argument */ |
231 | > | args_info->sele2_arg = 0; |
232 | > | } |
233 | > | if (args_info->sele2_orig) |
234 | > | { |
235 | > | free (args_info->sele2_orig); /* free previous argument */ |
236 | > | args_info->sele2_orig = 0; |
237 | > | } |
238 | > | if (args_info->sele3_arg) |
239 | > | { |
240 | > | free (args_info->sele3_arg); /* free previous argument */ |
241 | > | args_info->sele3_arg = 0; |
242 | > | } |
243 | > | if (args_info->sele3_orig) |
244 | > | { |
245 | > | free (args_info->sele3_orig); /* free previous argument */ |
246 | > | args_info->sele3_orig = 0; |
247 | > | } |
248 | > | if (args_info->refsele_arg) |
249 | > | { |
250 | > | free (args_info->refsele_arg); /* free previous argument */ |
251 | > | args_info->refsele_arg = 0; |
252 | > | } |
253 | > | if (args_info->refsele_orig) |
254 | > | { |
255 | > | free (args_info->refsele_orig); /* free previous argument */ |
256 | > | args_info->refsele_orig = 0; |
257 | > | } |
258 | > | if (args_info->molname_arg) |
259 | > | { |
260 | > | free (args_info->molname_arg); /* free previous argument */ |
261 | > | args_info->molname_arg = 0; |
262 | > | } |
263 | > | if (args_info->molname_orig) |
264 | > | { |
265 | > | free (args_info->molname_orig); /* free previous argument */ |
266 | > | args_info->molname_orig = 0; |
267 | > | } |
268 | > | if (args_info->begin_orig) |
269 | > | { |
270 | > | free (args_info->begin_orig); /* free previous argument */ |
271 | > | args_info->begin_orig = 0; |
272 | > | } |
273 | > | if (args_info->end_orig) |
274 | > | { |
275 | > | free (args_info->end_orig); /* free previous argument */ |
276 | > | args_info->end_orig = 0; |
277 | > | } |
278 | > | |
279 | > | clear_given (args_info); |
280 | > | } |
281 | > | |
282 | > | int |
283 | > | cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info) |
284 | > | { |
285 | > | FILE *outfile; |
286 | > | int i = 0; |
287 | > | |
288 | > | outfile = fopen(filename, "w"); |
289 | > | |
290 | > | if (!outfile) |
291 | > | { |
292 | > | fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename); |
293 | > | return EXIT_FAILURE; |
294 | > | } |
295 | > | |
296 | > | if (args_info->help_given) { |
297 | > | fprintf(outfile, "%s\n", "help"); |
298 | > | } |
299 | > | if (args_info->version_given) { |
300 | > | fprintf(outfile, "%s\n", "version"); |
301 | > | } |
302 | > | if (args_info->input_given) { |
303 | > | if (args_info->input_orig) { |
304 | > | fprintf(outfile, "%s=\"%s\"\n", "input", args_info->input_orig); |
305 | > | } else { |
306 | > | fprintf(outfile, "%s\n", "input"); |
307 | > | } |
308 | > | } |
309 | > | if (args_info->output_given) { |
310 | > | if (args_info->output_orig) { |
311 | > | fprintf(outfile, "%s=\"%s\"\n", "output", args_info->output_orig); |
312 | > | } else { |
313 | > | fprintf(outfile, "%s\n", "output"); |
314 | > | } |
315 | > | } |
316 | > | if (args_info->step_given) { |
317 | > | if (args_info->step_orig) { |
318 | > | fprintf(outfile, "%s=\"%s\"\n", "step", args_info->step_orig); |
319 | > | } else { |
320 | > | fprintf(outfile, "%s\n", "step"); |
321 | > | } |
322 | > | } |
323 | > | if (args_info->nrbins_given) { |
324 | > | if (args_info->nrbins_orig) { |
325 | > | fprintf(outfile, "%s=\"%s\"\n", "nrbins", args_info->nrbins_orig); |
326 | > | } else { |
327 | > | fprintf(outfile, "%s\n", "nrbins"); |
328 | > | } |
329 | > | } |
330 | > | if (args_info->nbins_x_given) { |
331 | > | if (args_info->nbins_x_orig) { |
332 | > | fprintf(outfile, "%s=\"%s\"\n", "nbins_x", args_info->nbins_x_orig); |
333 | > | } else { |
334 | > | fprintf(outfile, "%s\n", "nbins_x"); |
335 | > | } |
336 | > | } |
337 | > | if (args_info->nbins_y_given) { |
338 | > | if (args_info->nbins_y_orig) { |
339 | > | fprintf(outfile, "%s=\"%s\"\n", "nbins_y", args_info->nbins_y_orig); |
340 | > | } else { |
341 | > | fprintf(outfile, "%s\n", "nbins_y"); |
342 | > | } |
343 | > | } |
344 | > | if (args_info->nanglebins_given) { |
345 | > | if (args_info->nanglebins_orig) { |
346 | > | fprintf(outfile, "%s=\"%s\"\n", "nanglebins", args_info->nanglebins_orig); |
347 | > | } else { |
348 | > | fprintf(outfile, "%s\n", "nanglebins"); |
349 | > | } |
350 | > | } |
351 | > | if (args_info->length_given) { |
352 | > | if (args_info->length_orig) { |
353 | > | fprintf(outfile, "%s=\"%s\"\n", "length", args_info->length_orig); |
354 | > | } else { |
355 | > | fprintf(outfile, "%s\n", "length"); |
356 | > | } |
357 | > | } |
358 | > | if (args_info->zoffset_given) { |
359 | > | if (args_info->zoffset_orig) { |
360 | > | fprintf(outfile, "%s=\"%s\"\n", "zoffset", args_info->zoffset_orig); |
361 | > | } else { |
362 | > | fprintf(outfile, "%s\n", "zoffset"); |
363 | > | } |
364 | > | } |
365 | > | if (args_info->sele1_given) { |
366 | > | if (args_info->sele1_orig) { |
367 | > | fprintf(outfile, "%s=\"%s\"\n", "sele1", args_info->sele1_orig); |
368 | > | } else { |
369 | > | fprintf(outfile, "%s\n", "sele1"); |
370 | > | } |
371 | > | } |
372 | > | if (args_info->sele2_given) { |
373 | > | if (args_info->sele2_orig) { |
374 | > | fprintf(outfile, "%s=\"%s\"\n", "sele2", args_info->sele2_orig); |
375 | > | } else { |
376 | > | fprintf(outfile, "%s\n", "sele2"); |
377 | > | } |
378 | > | } |
379 | > | if (args_info->sele3_given) { |
380 | > | if (args_info->sele3_orig) { |
381 | > | fprintf(outfile, "%s=\"%s\"\n", "sele3", args_info->sele3_orig); |
382 | > | } else { |
383 | > | fprintf(outfile, "%s\n", "sele3"); |
384 | > | } |
385 | > | } |
386 | > | if (args_info->refsele_given) { |
387 | > | if (args_info->refsele_orig) { |
388 | > | fprintf(outfile, "%s=\"%s\"\n", "refsele", args_info->refsele_orig); |
389 | > | } else { |
390 | > | fprintf(outfile, "%s\n", "refsele"); |
391 | > | } |
392 | > | } |
393 | > | if (args_info->molname_given) { |
394 | > | if (args_info->molname_orig) { |
395 | > | fprintf(outfile, "%s=\"%s\"\n", "molname", args_info->molname_orig); |
396 | > | } else { |
397 | > | fprintf(outfile, "%s\n", "molname"); |
398 | > | } |
399 | > | } |
400 | > | if (args_info->begin_given) { |
401 | > | if (args_info->begin_orig) { |
402 | > | fprintf(outfile, "%s=\"%s\"\n", "begin", args_info->begin_orig); |
403 | > | } else { |
404 | > | fprintf(outfile, "%s\n", "begin"); |
405 | > | } |
406 | > | } |
407 | > | if (args_info->end_given) { |
408 | > | if (args_info->end_orig) { |
409 | > | fprintf(outfile, "%s=\"%s\"\n", "end", args_info->end_orig); |
410 | > | } else { |
411 | > | fprintf(outfile, "%s\n", "end"); |
412 | > | } |
413 | > | } |
414 | > | if (args_info->gofr_given) { |
415 | > | fprintf(outfile, "%s\n", "gofr"); |
416 | > | } |
417 | > | if (args_info->r_theta_given) { |
418 | > | fprintf(outfile, "%s\n", "r_theta"); |
419 | > | } |
420 | > | if (args_info->r_omega_given) { |
421 | > | fprintf(outfile, "%s\n", "r_omega"); |
422 | > | } |
423 | > | if (args_info->theta_omega_given) { |
424 | > | fprintf(outfile, "%s\n", "theta_omega"); |
425 | > | } |
426 | > | if (args_info->gxyz_given) { |
427 | > | fprintf(outfile, "%s\n", "gxyz"); |
428 | > | } |
429 | > | if (args_info->p2_given) { |
430 | > | fprintf(outfile, "%s\n", "p2"); |
431 | > | } |
432 | > | if (args_info->rp2_given) { |
433 | > | fprintf(outfile, "%s\n", "rp2"); |
434 | > | } |
435 | > | if (args_info->scd_given) { |
436 | > | fprintf(outfile, "%s\n", "scd"); |
437 | > | } |
438 | > | if (args_info->density_given) { |
439 | > | fprintf(outfile, "%s\n", "density"); |
440 | > | } |
441 | > | if (args_info->slab_density_given) { |
442 | > | fprintf(outfile, "%s\n", "slab_density"); |
443 | > | } |
444 | > | if (args_info->hxy_given) { |
445 | > | fprintf(outfile, "%s\n", "hxy"); |
446 | > | } |
447 | > | |
448 | > | fclose (outfile); |
449 | ||
450 | + | i = EXIT_SUCCESS; |
451 | + | return i; |
452 | + | } |
453 | + | |
454 | + | void |
455 | + | cmdline_parser_free (struct gengetopt_args_info *args_info) |
456 | + | { |
457 | + | cmdline_parser_release (args_info); |
458 | + | } |
459 | + | |
460 | + | |
461 | /* gengetopt_strdup() */ | |
462 | /* strdup.c replacement of strdup, which is not standard */ | |
463 | char * | |
464 | gengetopt_strdup (const char *s) | |
465 | { | |
466 | < | char *result = (char*)malloc(strlen(s) + 1); |
466 | > | char *result = NULL; |
467 | > | if (!s) |
468 | > | return result; |
469 | > | |
470 | > | result = (char*)malloc(strlen(s) + 1); |
471 | if (result == (char*)0) | |
472 | return (char*)0; | |
473 | strcpy(result, s); | |
474 | return result; | |
475 | } | |
476 | ||
477 | < | int |
478 | < | cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info) |
477 | > | static void |
478 | > | reset_group_staticProps(struct gengetopt_args_info *args_info); |
479 | > | |
480 | > | static void |
481 | > | reset_group_staticProps(struct gengetopt_args_info *args_info) |
482 | { | |
483 | < | int c; /* Character of the parsed option. */ |
484 | < | int missing_required_options = 0; |
78 | < | int staticProps_group_counter = 0; |
483 | > | if (! args_info->staticProps_group_counter) |
484 | > | return; |
485 | ||
80 | – | |
81 | – | args_info->help_given = 0 ; |
82 | – | args_info->version_given = 0 ; |
83 | – | args_info->input_given = 0 ; |
84 | – | args_info->output_given = 0 ; |
85 | – | args_info->step_given = 0 ; |
86 | – | args_info->nrbins_given = 0 ; |
87 | – | args_info->nanglebins_given = 0 ; |
88 | – | args_info->length_given = 0 ; |
89 | – | args_info->sele1_given = 0 ; |
90 | – | args_info->sele2_given = 0 ; |
91 | – | args_info->refsele_given = 0 ; |
486 | args_info->gofr_given = 0 ; | |
487 | args_info->r_theta_given = 0 ; | |
488 | args_info->r_omega_given = 0 ; | |
489 | args_info->theta_omega_given = 0 ; | |
490 | args_info->gxyz_given = 0 ; | |
491 | < | #define clear_args() { \ |
492 | < | args_info->input_arg = NULL; \ |
493 | < | args_info->output_arg = NULL; \ |
494 | < | args_info->step_arg = 1 ; \ |
495 | < | args_info->nrbins_arg = 100 ; \ |
496 | < | args_info->nanglebins_arg = 50 ; \ |
103 | < | args_info->sele1_arg = NULL; \ |
104 | < | args_info->sele2_arg = NULL; \ |
105 | < | args_info->refsele_arg = NULL; \ |
106 | < | } |
491 | > | args_info->p2_given = 0 ; |
492 | > | args_info->rp2_given = 0 ; |
493 | > | args_info->scd_given = 0 ; |
494 | > | args_info->density_given = 0 ; |
495 | > | args_info->slab_density_given = 0 ; |
496 | > | args_info->hxy_given = 0 ; |
497 | ||
498 | < | clear_args(); |
498 | > | args_info->staticProps_group_counter = 0; |
499 | > | } |
500 | ||
501 | + | int |
502 | + | cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info) |
503 | + | { |
504 | + | return cmdline_parser2 (argc, argv, args_info, 0, 1, 1); |
505 | + | } |
506 | + | |
507 | + | int |
508 | + | cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) |
509 | + | { |
510 | + | int result; |
511 | + | |
512 | + | result = cmdline_parser_internal (argc, argv, args_info, override, initialize, check_required, NULL); |
513 | + | |
514 | + | if (result == EXIT_FAILURE) |
515 | + | { |
516 | + | cmdline_parser_free (args_info); |
517 | + | exit (EXIT_FAILURE); |
518 | + | } |
519 | + | |
520 | + | return result; |
521 | + | } |
522 | + | |
523 | + | int |
524 | + | cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name) |
525 | + | { |
526 | + | int result = EXIT_SUCCESS; |
527 | + | |
528 | + | if (cmdline_parser_required2(args_info, prog_name, NULL) > 0) |
529 | + | result = EXIT_FAILURE; |
530 | + | |
531 | + | if (result == EXIT_FAILURE) |
532 | + | { |
533 | + | cmdline_parser_free (args_info); |
534 | + | exit (EXIT_FAILURE); |
535 | + | } |
536 | + | |
537 | + | return result; |
538 | + | } |
539 | + | |
540 | + | int |
541 | + | cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error) |
542 | + | { |
543 | + | int error = 0; |
544 | + | |
545 | + | if (! args_info->input_given) |
546 | + | { |
547 | + | fprintf (stderr, "%s: '--input' ('-i') option required%s\n", prog_name, (additional_error ? additional_error : "")); |
548 | + | error = 1; |
549 | + | } |
550 | + | if (args_info->staticProps_group_counter == 0) |
551 | + | { |
552 | + | fprintf (stderr, "%s: %d options of group staticProps were given. One is required.%s\n", prog_name, args_info->staticProps_group_counter, (additional_error ? additional_error : "")); |
553 | + | error = 1; |
554 | + | } |
555 | + | |
556 | + | |
557 | + | return error; |
558 | + | } |
559 | + | |
560 | + | int |
561 | + | 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) |
562 | + | { |
563 | + | int c; /* Character of the parsed option. */ |
564 | + | |
565 | + | int error = 0; |
566 | + | struct gengetopt_args_info local_args_info; |
567 | + | |
568 | + | if (initialize) |
569 | + | cmdline_parser_init (args_info); |
570 | + | |
571 | + | cmdline_parser_init (&local_args_info); |
572 | + | |
573 | optarg = 0; | |
574 | < | optind = 1; |
574 | > | optind = 0; |
575 | opterr = 1; | |
576 | optopt = '?'; | |
577 | ||
# | Line 124 | Line 587 | cmdline_parser (int argc, char * const *argv, struct g | |
587 | { "output", 1, NULL, 'o' }, | |
588 | { "step", 1, NULL, 'n' }, | |
589 | { "nrbins", 1, NULL, 'r' }, | |
590 | + | { "nbins_x", 1, NULL, 'x' }, |
591 | + | { "nbins_y", 1, NULL, 'y' }, |
592 | { "nanglebins", 1, NULL, 'a' }, | |
593 | { "length", 1, NULL, 'l' }, | |
594 | + | { "zoffset", 1, NULL, 'z' }, |
595 | { "sele1", 1, NULL, 0 }, | |
596 | { "sele2", 1, NULL, 0 }, | |
597 | + | { "sele3", 1, NULL, 0 }, |
598 | { "refsele", 1, NULL, 0 }, | |
599 | + | { "molname", 1, NULL, 0 }, |
600 | + | { "begin", 1, NULL, 0 }, |
601 | + | { "end", 1, NULL, 0 }, |
602 | { "gofr", 0, NULL, 0 }, | |
603 | { "r_theta", 0, NULL, 0 }, | |
604 | { "r_omega", 0, NULL, 0 }, | |
605 | { "theta_omega", 0, NULL, 0 }, | |
606 | { "gxyz", 0, NULL, 0 }, | |
607 | + | { "p2", 0, NULL, 0 }, |
608 | + | { "rp2", 0, NULL, 0 }, |
609 | + | { "scd", 0, NULL, 0 }, |
610 | + | { "density", 0, NULL, 0 }, |
611 | + | { "slab_density", 0, NULL, 0 }, |
612 | + | { "hxy", 0, NULL, 0 }, |
613 | { NULL, 0, NULL, 0 } | |
614 | }; | |
615 | ||
616 | stop_char = 0; | |
617 | < | c = getopt_long (argc, argv, "hVi:o:n:r:a:l:", long_options, &option_index); |
617 | > | c = getopt_long (argc, argv, "hVi:o:n:r:x:y:a:l:z:", long_options, &option_index); |
618 | ||
619 | if (c == -1) break; /* Exit from `while (1)' loop. */ | |
620 | ||
621 | switch (c) | |
622 | { | |
623 | case 'h': /* Print help and exit. */ | |
148 | – | clear_args (); |
624 | cmdline_parser_print_help (); | |
625 | + | cmdline_parser_free (&local_args_info); |
626 | exit (EXIT_SUCCESS); | |
627 | ||
628 | case 'V': /* Print version and exit. */ | |
153 | – | clear_args (); |
629 | cmdline_parser_print_version (); | |
630 | + | cmdline_parser_free (&local_args_info); |
631 | exit (EXIT_SUCCESS); | |
632 | ||
633 | case 'i': /* input dump file. */ | |
634 | < | if (args_info->input_given) |
634 | > | if (local_args_info.input_given) |
635 | { | |
636 | < | fprintf (stderr, "%s: `--input' (`-i') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
637 | < | clear_args (); |
162 | < | exit (EXIT_FAILURE); |
636 | > | fprintf (stderr, "%s: `--input' (`-i') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
637 | > | goto failure; |
638 | } | |
639 | + | if (args_info->input_given && ! override) |
640 | + | continue; |
641 | + | local_args_info.input_given = 1; |
642 | args_info->input_given = 1; | |
643 | + | if (args_info->input_arg) |
644 | + | free (args_info->input_arg); /* free previous string */ |
645 | args_info->input_arg = gengetopt_strdup (optarg); | |
646 | + | if (args_info->input_orig) |
647 | + | free (args_info->input_orig); /* free previous string */ |
648 | + | args_info->input_orig = gengetopt_strdup (optarg); |
649 | break; | |
650 | ||
651 | case 'o': /* output file name. */ | |
652 | < | if (args_info->output_given) |
652 | > | if (local_args_info.output_given) |
653 | { | |
654 | < | fprintf (stderr, "%s: `--output' (`-o') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
655 | < | clear_args (); |
173 | < | exit (EXIT_FAILURE); |
654 | > | fprintf (stderr, "%s: `--output' (`-o') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
655 | > | goto failure; |
656 | } | |
657 | + | if (args_info->output_given && ! override) |
658 | + | continue; |
659 | + | local_args_info.output_given = 1; |
660 | args_info->output_given = 1; | |
661 | + | if (args_info->output_arg) |
662 | + | free (args_info->output_arg); /* free previous string */ |
663 | args_info->output_arg = gengetopt_strdup (optarg); | |
664 | + | if (args_info->output_orig) |
665 | + | free (args_info->output_orig); /* free previous string */ |
666 | + | args_info->output_orig = gengetopt_strdup (optarg); |
667 | break; | |
668 | ||
669 | case 'n': /* process every n frame. */ | |
670 | < | if (args_info->step_given) |
670 | > | if (local_args_info.step_given) |
671 | { | |
672 | < | fprintf (stderr, "%s: `--step' (`-n') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
673 | < | clear_args (); |
184 | < | exit (EXIT_FAILURE); |
672 | > | fprintf (stderr, "%s: `--step' (`-n') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
673 | > | goto failure; |
674 | } | |
675 | < | args_info->step_given = 1; |
676 | < | args_info->step_arg = strtol (optarg,&stop_char,0); |
675 | > | if (args_info->step_given && ! override) |
676 | > | continue; |
677 | > | local_args_info.step_given = 1; |
678 | > | args_info->step_given = 1; |
679 | > | args_info->step_arg = strtol (optarg, &stop_char, 0); |
680 | > | if (!(stop_char && *stop_char == '\0')) { |
681 | > | fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); |
682 | > | goto failure; |
683 | > | } |
684 | > | if (args_info->step_orig) |
685 | > | free (args_info->step_orig); /* free previous string */ |
686 | > | args_info->step_orig = gengetopt_strdup (optarg); |
687 | break; | |
688 | ||
689 | case 'r': /* number of bins for distance. */ | |
690 | < | if (args_info->nrbins_given) |
690 | > | if (local_args_info.nrbins_given) |
691 | { | |
692 | < | fprintf (stderr, "%s: `--nrbins' (`-r') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
693 | < | clear_args (); |
195 | < | exit (EXIT_FAILURE); |
692 | > | fprintf (stderr, "%s: `--nrbins' (`-r') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
693 | > | goto failure; |
694 | } | |
695 | + | if (args_info->nrbins_given && ! override) |
696 | + | continue; |
697 | + | local_args_info.nrbins_given = 1; |
698 | args_info->nrbins_given = 1; | |
699 | < | args_info->nrbins_arg = strtol (optarg,&stop_char,0); |
699 | > | args_info->nrbins_arg = strtol (optarg, &stop_char, 0); |
700 | > | if (!(stop_char && *stop_char == '\0')) { |
701 | > | fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); |
702 | > | goto failure; |
703 | > | } |
704 | > | if (args_info->nrbins_orig) |
705 | > | free (args_info->nrbins_orig); /* free previous string */ |
706 | > | args_info->nrbins_orig = gengetopt_strdup (optarg); |
707 | break; | |
708 | ||
709 | + | case 'x': /* number of bins in x axis. */ |
710 | + | if (local_args_info.nbins_x_given) |
711 | + | { |
712 | + | fprintf (stderr, "%s: `--nbins_x' (`-x') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
713 | + | goto failure; |
714 | + | } |
715 | + | if (args_info->nbins_x_given && ! override) |
716 | + | continue; |
717 | + | local_args_info.nbins_x_given = 1; |
718 | + | args_info->nbins_x_given = 1; |
719 | + | args_info->nbins_x_arg = strtol (optarg, &stop_char, 0); |
720 | + | if (!(stop_char && *stop_char == '\0')) { |
721 | + | fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); |
722 | + | goto failure; |
723 | + | } |
724 | + | if (args_info->nbins_x_orig) |
725 | + | free (args_info->nbins_x_orig); /* free previous string */ |
726 | + | args_info->nbins_x_orig = gengetopt_strdup (optarg); |
727 | + | break; |
728 | + | |
729 | + | case 'y': /* number of bins in y axis. */ |
730 | + | if (local_args_info.nbins_y_given) |
731 | + | { |
732 | + | fprintf (stderr, "%s: `--nbins_y' (`-y') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
733 | + | goto failure; |
734 | + | } |
735 | + | if (args_info->nbins_y_given && ! override) |
736 | + | continue; |
737 | + | local_args_info.nbins_y_given = 1; |
738 | + | args_info->nbins_y_given = 1; |
739 | + | args_info->nbins_y_arg = strtol (optarg, &stop_char, 0); |
740 | + | if (!(stop_char && *stop_char == '\0')) { |
741 | + | fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); |
742 | + | goto failure; |
743 | + | } |
744 | + | if (args_info->nbins_y_orig) |
745 | + | free (args_info->nbins_y_orig); /* free previous string */ |
746 | + | args_info->nbins_y_orig = gengetopt_strdup (optarg); |
747 | + | break; |
748 | + | |
749 | case 'a': /* number of bins for cos(angle). */ | |
750 | < | if (args_info->nanglebins_given) |
750 | > | if (local_args_info.nanglebins_given) |
751 | { | |
752 | < | fprintf (stderr, "%s: `--nanglebins' (`-a') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
753 | < | clear_args (); |
206 | < | exit (EXIT_FAILURE); |
752 | > | fprintf (stderr, "%s: `--nanglebins' (`-a') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
753 | > | goto failure; |
754 | } | |
755 | + | if (args_info->nanglebins_given && ! override) |
756 | + | continue; |
757 | + | local_args_info.nanglebins_given = 1; |
758 | args_info->nanglebins_given = 1; | |
759 | < | args_info->nanglebins_arg = strtol (optarg,&stop_char,0); |
759 | > | args_info->nanglebins_arg = strtol (optarg, &stop_char, 0); |
760 | > | if (!(stop_char && *stop_char == '\0')) { |
761 | > | fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); |
762 | > | goto failure; |
763 | > | } |
764 | > | if (args_info->nanglebins_orig) |
765 | > | free (args_info->nanglebins_orig); /* free previous string */ |
766 | > | args_info->nanglebins_orig = gengetopt_strdup (optarg); |
767 | break; | |
768 | ||
769 | case 'l': /* maximum length (Defaults to 1/2 smallest length of first frame). */ | |
770 | < | if (args_info->length_given) |
770 | > | if (local_args_info.length_given) |
771 | { | |
772 | < | fprintf (stderr, "%s: `--length' (`-l') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
773 | < | clear_args (); |
217 | < | exit (EXIT_FAILURE); |
772 | > | fprintf (stderr, "%s: `--length' (`-l') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
773 | > | goto failure; |
774 | } | |
775 | + | if (args_info->length_given && ! override) |
776 | + | continue; |
777 | + | local_args_info.length_given = 1; |
778 | args_info->length_given = 1; | |
779 | < | args_info->length_arg = strtod (optarg, NULL); |
779 | > | args_info->length_arg = strtod (optarg, &stop_char); |
780 | > | if (!(stop_char && *stop_char == '\0')) { |
781 | > | fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); |
782 | > | goto failure; |
783 | > | } |
784 | > | if (args_info->length_orig) |
785 | > | free (args_info->length_orig); /* free previous string */ |
786 | > | args_info->length_orig = gengetopt_strdup (optarg); |
787 | break; | |
788 | ||
789 | + | case 'z': /* Where to set the zero for the slab_density calculation. */ |
790 | + | if (local_args_info.zoffset_given) |
791 | + | { |
792 | + | fprintf (stderr, "%s: `--zoffset' (`-z') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
793 | + | goto failure; |
794 | + | } |
795 | + | if (args_info->zoffset_given && ! override) |
796 | + | continue; |
797 | + | local_args_info.zoffset_given = 1; |
798 | + | args_info->zoffset_given = 1; |
799 | + | args_info->zoffset_arg = strtod (optarg, &stop_char); |
800 | + | if (!(stop_char && *stop_char == '\0')) { |
801 | + | fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); |
802 | + | goto failure; |
803 | + | } |
804 | + | if (args_info->zoffset_orig) |
805 | + | free (args_info->zoffset_orig); /* free previous string */ |
806 | + | args_info->zoffset_orig = gengetopt_strdup (optarg); |
807 | + | break; |
808 | ||
809 | + | |
810 | case 0: /* Long option with no short option */ | |
811 | < | /* select first stuntdouble set. */ |
811 | > | /* select the first stuntdouble set. */ |
812 | if (strcmp (long_options[option_index].name, "sele1") == 0) | |
813 | < | { |
814 | < | if (args_info->sele1_given) |
815 | < | { |
816 | < | fprintf (stderr, "%s: `--sele1' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
817 | < | clear_args (); |
818 | < | exit (EXIT_FAILURE); |
819 | < | } |
820 | < | args_info->sele1_given = 1; |
821 | < | args_info->sele1_arg = gengetopt_strdup (optarg); |
822 | < | break; |
823 | < | } |
824 | < | |
825 | < | /* select second stuntdouble set. */ |
813 | > | { |
814 | > | if (local_args_info.sele1_given) |
815 | > | { |
816 | > | fprintf (stderr, "%s: `--sele1' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
817 | > | goto failure; |
818 | > | } |
819 | > | if (args_info->sele1_given && ! override) |
820 | > | continue; |
821 | > | local_args_info.sele1_given = 1; |
822 | > | args_info->sele1_given = 1; |
823 | > | if (args_info->sele1_arg) |
824 | > | free (args_info->sele1_arg); /* free previous string */ |
825 | > | args_info->sele1_arg = gengetopt_strdup (optarg); |
826 | > | if (args_info->sele1_orig) |
827 | > | free (args_info->sele1_orig); /* free previous string */ |
828 | > | args_info->sele1_orig = gengetopt_strdup (optarg); |
829 | > | } |
830 | > | /* select the second stuntdouble set. */ |
831 | else if (strcmp (long_options[option_index].name, "sele2") == 0) | |
832 | < | { |
833 | < | if (args_info->sele2_given) |
834 | < | { |
835 | < | fprintf (stderr, "%s: `--sele2' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
836 | < | clear_args (); |
837 | < | exit (EXIT_FAILURE); |
838 | < | } |
839 | < | args_info->sele2_given = 1; |
840 | < | args_info->sele2_arg = gengetopt_strdup (optarg); |
841 | < | break; |
842 | < | } |
843 | < | |
832 | > | { |
833 | > | if (local_args_info.sele2_given) |
834 | > | { |
835 | > | fprintf (stderr, "%s: `--sele2' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
836 | > | goto failure; |
837 | > | } |
838 | > | if (args_info->sele2_given && ! override) |
839 | > | continue; |
840 | > | local_args_info.sele2_given = 1; |
841 | > | args_info->sele2_given = 1; |
842 | > | if (args_info->sele2_arg) |
843 | > | free (args_info->sele2_arg); /* free previous string */ |
844 | > | args_info->sele2_arg = gengetopt_strdup (optarg); |
845 | > | if (args_info->sele2_orig) |
846 | > | free (args_info->sele2_orig); /* free previous string */ |
847 | > | args_info->sele2_orig = gengetopt_strdup (optarg); |
848 | > | } |
849 | > | /* select the third stuntdouble set. */ |
850 | > | else if (strcmp (long_options[option_index].name, "sele3") == 0) |
851 | > | { |
852 | > | if (local_args_info.sele3_given) |
853 | > | { |
854 | > | fprintf (stderr, "%s: `--sele3' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
855 | > | goto failure; |
856 | > | } |
857 | > | if (args_info->sele3_given && ! override) |
858 | > | continue; |
859 | > | local_args_info.sele3_given = 1; |
860 | > | args_info->sele3_given = 1; |
861 | > | if (args_info->sele3_arg) |
862 | > | free (args_info->sele3_arg); /* free previous string */ |
863 | > | args_info->sele3_arg = gengetopt_strdup (optarg); |
864 | > | if (args_info->sele3_orig) |
865 | > | free (args_info->sele3_orig); /* free previous string */ |
866 | > | args_info->sele3_orig = gengetopt_strdup (optarg); |
867 | > | } |
868 | /* select reference (use and only use with --gxyz). */ | |
869 | else if (strcmp (long_options[option_index].name, "refsele") == 0) | |
870 | < | { |
871 | < | if (args_info->refsele_given) |
872 | < | { |
873 | < | fprintf (stderr, "%s: `--refsele' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
874 | < | clear_args (); |
875 | < | exit (EXIT_FAILURE); |
876 | < | } |
877 | < | args_info->refsele_given = 1; |
878 | < | args_info->refsele_arg = gengetopt_strdup (optarg); |
879 | < | break; |
880 | < | } |
881 | < | |
882 | < | /* g(r). */ |
883 | < | else if (strcmp (long_options[option_index].name, "gofr") == 0) |
884 | < | { |
885 | < | if (args_info->gofr_given) |
886 | < | { |
887 | < | fprintf (stderr, "%s: `--gofr' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
888 | < | clear_args (); |
889 | < | exit (EXIT_FAILURE); |
890 | < | } |
891 | < | args_info->gofr_given = 1; staticProps_group_counter += 1; |
892 | < | |
893 | < | break; |
894 | < | } |
895 | < | |
896 | < | /* g(r, cos(theta)). */ |
897 | < | else if (strcmp (long_options[option_index].name, "r_theta") == 0) |
898 | < | { |
899 | < | if (args_info->r_theta_given) |
900 | < | { |
901 | < | fprintf (stderr, "%s: `--r_theta' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
902 | < | clear_args (); |
903 | < | exit (EXIT_FAILURE); |
904 | < | } |
905 | < | args_info->r_theta_given = 1; staticProps_group_counter += 1; |
906 | < | |
907 | < | break; |
908 | < | } |
909 | < | |
910 | < | /* g(r, cos(omega)). */ |
911 | < | else if (strcmp (long_options[option_index].name, "r_omega") == 0) |
912 | < | { |
913 | < | if (args_info->r_omega_given) |
914 | < | { |
915 | < | fprintf (stderr, "%s: `--r_omega' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
916 | < | clear_args (); |
917 | < | exit (EXIT_FAILURE); |
918 | < | } |
919 | < | args_info->r_omega_given = 1; staticProps_group_counter += 1; |
920 | < | |
921 | < | break; |
922 | < | } |
923 | < | |
924 | < | /* g(cos(theta), cos(omega)). */ |
925 | < | else if (strcmp (long_options[option_index].name, "theta_omega") == 0) |
926 | < | { |
927 | < | if (args_info->theta_omega_given) |
928 | < | { |
929 | < | fprintf (stderr, "%s: `--theta_omega' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
930 | < | clear_args (); |
931 | < | exit (EXIT_FAILURE); |
932 | < | } |
933 | < | args_info->theta_omega_given = 1; staticProps_group_counter += 1; |
934 | < | |
935 | < | break; |
936 | < | } |
937 | < | |
870 | > | { |
871 | > | if (local_args_info.refsele_given) |
872 | > | { |
873 | > | fprintf (stderr, "%s: `--refsele' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
874 | > | goto failure; |
875 | > | } |
876 | > | if (args_info->refsele_given && ! override) |
877 | > | continue; |
878 | > | local_args_info.refsele_given = 1; |
879 | > | args_info->refsele_given = 1; |
880 | > | if (args_info->refsele_arg) |
881 | > | free (args_info->refsele_arg); /* free previous string */ |
882 | > | args_info->refsele_arg = gengetopt_strdup (optarg); |
883 | > | if (args_info->refsele_orig) |
884 | > | free (args_info->refsele_orig); /* free previous string */ |
885 | > | args_info->refsele_orig = gengetopt_strdup (optarg); |
886 | > | } |
887 | > | /* molecule name. */ |
888 | > | else if (strcmp (long_options[option_index].name, "molname") == 0) |
889 | > | { |
890 | > | if (local_args_info.molname_given) |
891 | > | { |
892 | > | fprintf (stderr, "%s: `--molname' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
893 | > | goto failure; |
894 | > | } |
895 | > | if (args_info->molname_given && ! override) |
896 | > | continue; |
897 | > | local_args_info.molname_given = 1; |
898 | > | args_info->molname_given = 1; |
899 | > | if (args_info->molname_arg) |
900 | > | free (args_info->molname_arg); /* free previous string */ |
901 | > | args_info->molname_arg = gengetopt_strdup (optarg); |
902 | > | if (args_info->molname_orig) |
903 | > | free (args_info->molname_orig); /* free previous string */ |
904 | > | args_info->molname_orig = gengetopt_strdup (optarg); |
905 | > | } |
906 | > | /* begin interanl index. */ |
907 | > | else if (strcmp (long_options[option_index].name, "begin") == 0) |
908 | > | { |
909 | > | if (local_args_info.begin_given) |
910 | > | { |
911 | > | fprintf (stderr, "%s: `--begin' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
912 | > | goto failure; |
913 | > | } |
914 | > | if (args_info->begin_given && ! override) |
915 | > | continue; |
916 | > | local_args_info.begin_given = 1; |
917 | > | args_info->begin_given = 1; |
918 | > | args_info->begin_arg = strtol (optarg, &stop_char, 0); |
919 | > | if (!(stop_char && *stop_char == '\0')) { |
920 | > | fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); |
921 | > | goto failure; |
922 | > | } |
923 | > | if (args_info->begin_orig) |
924 | > | free (args_info->begin_orig); /* free previous string */ |
925 | > | args_info->begin_orig = gengetopt_strdup (optarg); |
926 | > | } |
927 | > | /* end internal index. */ |
928 | > | else if (strcmp (long_options[option_index].name, "end") == 0) |
929 | > | { |
930 | > | if (local_args_info.end_given) |
931 | > | { |
932 | > | fprintf (stderr, "%s: `--end' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
933 | > | goto failure; |
934 | > | } |
935 | > | if (args_info->end_given && ! override) |
936 | > | continue; |
937 | > | local_args_info.end_given = 1; |
938 | > | args_info->end_given = 1; |
939 | > | args_info->end_arg = strtol (optarg, &stop_char, 0); |
940 | > | if (!(stop_char && *stop_char == '\0')) { |
941 | > | fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); |
942 | > | goto failure; |
943 | > | } |
944 | > | if (args_info->end_orig) |
945 | > | free (args_info->end_orig); /* free previous string */ |
946 | > | args_info->end_orig = gengetopt_strdup (optarg); |
947 | > | } |
948 | > | /* g(r). */ |
949 | > | else if (strcmp (long_options[option_index].name, "gofr") == 0) |
950 | > | { |
951 | > | if (local_args_info.gofr_given) |
952 | > | { |
953 | > | fprintf (stderr, "%s: `--gofr' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
954 | > | goto failure; |
955 | > | } |
956 | > | if (args_info->gofr_given && ! override) |
957 | > | continue; |
958 | > | local_args_info.gofr_given = 1; |
959 | > | args_info->gofr_given = 1; |
960 | > | if (args_info->staticProps_group_counter && override) |
961 | > | reset_group_staticProps (args_info); |
962 | > | args_info->staticProps_group_counter += 1; |
963 | > | break; |
964 | > | } |
965 | > | /* g(r, cos(theta)). */ |
966 | > | else if (strcmp (long_options[option_index].name, "r_theta") == 0) |
967 | > | { |
968 | > | if (local_args_info.r_theta_given) |
969 | > | { |
970 | > | fprintf (stderr, "%s: `--r_theta' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
971 | > | goto failure; |
972 | > | } |
973 | > | if (args_info->r_theta_given && ! override) |
974 | > | continue; |
975 | > | local_args_info.r_theta_given = 1; |
976 | > | args_info->r_theta_given = 1; |
977 | > | if (args_info->staticProps_group_counter && override) |
978 | > | reset_group_staticProps (args_info); |
979 | > | args_info->staticProps_group_counter += 1; |
980 | > | break; |
981 | > | } |
982 | > | /* g(r, cos(omega)). */ |
983 | > | else if (strcmp (long_options[option_index].name, "r_omega") == 0) |
984 | > | { |
985 | > | if (local_args_info.r_omega_given) |
986 | > | { |
987 | > | fprintf (stderr, "%s: `--r_omega' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
988 | > | goto failure; |
989 | > | } |
990 | > | if (args_info->r_omega_given && ! override) |
991 | > | continue; |
992 | > | local_args_info.r_omega_given = 1; |
993 | > | args_info->r_omega_given = 1; |
994 | > | if (args_info->staticProps_group_counter && override) |
995 | > | reset_group_staticProps (args_info); |
996 | > | args_info->staticProps_group_counter += 1; |
997 | > | break; |
998 | > | } |
999 | > | /* g(cos(theta), cos(omega)). */ |
1000 | > | else if (strcmp (long_options[option_index].name, "theta_omega") == 0) |
1001 | > | { |
1002 | > | if (local_args_info.theta_omega_given) |
1003 | > | { |
1004 | > | fprintf (stderr, "%s: `--theta_omega' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
1005 | > | goto failure; |
1006 | > | } |
1007 | > | if (args_info->theta_omega_given && ! override) |
1008 | > | continue; |
1009 | > | local_args_info.theta_omega_given = 1; |
1010 | > | args_info->theta_omega_given = 1; |
1011 | > | if (args_info->staticProps_group_counter && override) |
1012 | > | reset_group_staticProps (args_info); |
1013 | > | args_info->staticProps_group_counter += 1; |
1014 | > | break; |
1015 | > | } |
1016 | /* g(x, y, z). */ | |
1017 | else if (strcmp (long_options[option_index].name, "gxyz") == 0) | |
1018 | < | { |
1019 | < | if (args_info->gxyz_given) |
1020 | < | { |
1021 | < | fprintf (stderr, "%s: `--gxyz' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
1022 | < | clear_args (); |
1023 | < | exit (EXIT_FAILURE); |
1024 | < | } |
1025 | < | args_info->gxyz_given = 1; staticProps_group_counter += 1; |
1018 | > | { |
1019 | > | if (local_args_info.gxyz_given) |
1020 | > | { |
1021 | > | fprintf (stderr, "%s: `--gxyz' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
1022 | > | goto failure; |
1023 | > | } |
1024 | > | if (args_info->gxyz_given && ! override) |
1025 | > | continue; |
1026 | > | local_args_info.gxyz_given = 1; |
1027 | > | args_info->gxyz_given = 1; |
1028 | > | if (args_info->staticProps_group_counter && override) |
1029 | > | reset_group_staticProps (args_info); |
1030 | > | args_info->staticProps_group_counter += 1; |
1031 | > | break; |
1032 | > | } |
1033 | > | /* p2 order parameter (--sele1 and --sele2 must be specified). */ |
1034 | > | else if (strcmp (long_options[option_index].name, "p2") == 0) |
1035 | > | { |
1036 | > | if (local_args_info.p2_given) |
1037 | > | { |
1038 | > | fprintf (stderr, "%s: `--p2' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
1039 | > | goto failure; |
1040 | > | } |
1041 | > | if (args_info->p2_given && ! override) |
1042 | > | continue; |
1043 | > | local_args_info.p2_given = 1; |
1044 | > | args_info->p2_given = 1; |
1045 | > | if (args_info->staticProps_group_counter && override) |
1046 | > | reset_group_staticProps (args_info); |
1047 | > | args_info->staticProps_group_counter += 1; |
1048 | > | break; |
1049 | > | } |
1050 | > | /* rp2 order parameter (--sele1 and --sele2 must be specified). */ |
1051 | > | else if (strcmp (long_options[option_index].name, "rp2") == 0) |
1052 | > | { |
1053 | > | if (local_args_info.rp2_given) |
1054 | > | { |
1055 | > | fprintf (stderr, "%s: `--rp2' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
1056 | > | goto failure; |
1057 | > | } |
1058 | > | if (args_info->rp2_given && ! override) |
1059 | > | continue; |
1060 | > | local_args_info.rp2_given = 1; |
1061 | > | args_info->rp2_given = 1; |
1062 | > | if (args_info->staticProps_group_counter && override) |
1063 | > | reset_group_staticProps (args_info); |
1064 | > | args_info->staticProps_group_counter += 1; |
1065 | > | break; |
1066 | > | } |
1067 | > | /* scd order parameter(either --sele1, --sele2, --sele3 are specified or --molname, --begin, --end are specified). */ |
1068 | > | else if (strcmp (long_options[option_index].name, "scd") == 0) |
1069 | > | { |
1070 | > | if (local_args_info.scd_given) |
1071 | > | { |
1072 | > | fprintf (stderr, "%s: `--scd' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
1073 | > | goto failure; |
1074 | > | } |
1075 | > | if (args_info->scd_given && ! override) |
1076 | > | continue; |
1077 | > | local_args_info.scd_given = 1; |
1078 | > | args_info->scd_given = 1; |
1079 | > | if (args_info->staticProps_group_counter && override) |
1080 | > | reset_group_staticProps (args_info); |
1081 | > | args_info->staticProps_group_counter += 1; |
1082 | > | break; |
1083 | > | } |
1084 | > | /* density plot (--sele1 must be specified). */ |
1085 | > | else if (strcmp (long_options[option_index].name, "density") == 0) |
1086 | > | { |
1087 | > | if (local_args_info.density_given) |
1088 | > | { |
1089 | > | fprintf (stderr, "%s: `--density' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
1090 | > | goto failure; |
1091 | > | } |
1092 | > | if (args_info->density_given && ! override) |
1093 | > | continue; |
1094 | > | local_args_info.density_given = 1; |
1095 | > | args_info->density_given = 1; |
1096 | > | if (args_info->staticProps_group_counter && override) |
1097 | > | reset_group_staticProps (args_info); |
1098 | > | args_info->staticProps_group_counter += 1; |
1099 | > | break; |
1100 | > | } |
1101 | > | /* slab density (--sele1 must be specified). */ |
1102 | > | else if (strcmp (long_options[option_index].name, "slab_density") == 0) |
1103 | > | { |
1104 | > | if (local_args_info.slab_density_given) |
1105 | > | { |
1106 | > | fprintf (stderr, "%s: `--slab_density' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
1107 | > | goto failure; |
1108 | > | } |
1109 | > | if (args_info->slab_density_given && ! override) |
1110 | > | continue; |
1111 | > | local_args_info.slab_density_given = 1; |
1112 | > | args_info->slab_density_given = 1; |
1113 | > | if (args_info->staticProps_group_counter && override) |
1114 | > | reset_group_staticProps (args_info); |
1115 | > | args_info->staticProps_group_counter += 1; |
1116 | > | break; |
1117 | > | } |
1118 | > | /* hxy (--sele1 must be specified). */ |
1119 | > | else if (strcmp (long_options[option_index].name, "hxy") == 0) |
1120 | > | { |
1121 | > | if (local_args_info.hxy_given) |
1122 | > | { |
1123 | > | fprintf (stderr, "%s: `--hxy' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
1124 | > | goto failure; |
1125 | > | } |
1126 | > | if (args_info->hxy_given && ! override) |
1127 | > | continue; |
1128 | > | local_args_info.hxy_given = 1; |
1129 | > | args_info->hxy_given = 1; |
1130 | > | if (args_info->staticProps_group_counter && override) |
1131 | > | reset_group_staticProps (args_info); |
1132 | > | args_info->staticProps_group_counter += 1; |
1133 | > | break; |
1134 | > | } |
1135 | ||
1136 | < | break; |
335 | < | } |
336 | < | |
337 | < | |
1136 | > | break; |
1137 | case '?': /* Invalid option. */ | |
1138 | /* `getopt_long' already printed an error message. */ | |
1139 | < | exit (EXIT_FAILURE); |
1139 | > | goto failure; |
1140 | ||
1141 | default: /* bug: option not considered. */ | |
1142 | < | fprintf (stderr, "%s: option unknown: %c\n", CMDLINE_PARSER_PACKAGE, c); |
1142 | > | fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : "")); |
1143 | abort (); | |
1144 | } /* switch */ | |
1145 | } /* while */ | |
1146 | ||
1147 | < | if ( staticProps_group_counter != 1) |
1147 | > | if (args_info->staticProps_group_counter > 1) |
1148 | { | |
1149 | < | fprintf (stderr, "%s: %d options of group staticProps were given. One is required\n", CMDLINE_PARSER_PACKAGE, staticProps_group_counter); |
1150 | < | missing_required_options = 1; |
1149 | > | fprintf (stderr, "%s: %d options of group staticProps were given. One is required.%s\n", argv[0], args_info->staticProps_group_counter, (additional_error ? additional_error : "")); |
1150 | > | error = 1; |
1151 | } | |
1152 | ||
1153 | ||
1154 | < | if (! args_info->input_given) |
1154 | > | |
1155 | > | if (check_required) |
1156 | { | |
1157 | < | fprintf (stderr, "%s: '--input' ('-i') option required\n", CMDLINE_PARSER_PACKAGE); |
358 | < | missing_required_options = 1; |
1157 | > | error += cmdline_parser_required2 (args_info, argv[0], additional_error); |
1158 | } | |
360 | – | if ( missing_required_options ) |
361 | – | exit (EXIT_FAILURE); |
1159 | ||
1160 | + | cmdline_parser_release (&local_args_info); |
1161 | + | |
1162 | + | if ( error ) |
1163 | + | return (EXIT_FAILURE); |
1164 | + | |
1165 | return 0; | |
1166 | + | |
1167 | + | failure: |
1168 | + | |
1169 | + | cmdline_parser_release (&local_args_info); |
1170 | + | return (EXIT_FAILURE); |
1171 | } |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |