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