1 |
|
/* |
2 |
< |
File autogenerated by gengetopt version 2.11 |
2 |
> |
File autogenerated by gengetopt version 2.15 |
3 |
|
generated with the following command: |
4 |
< |
gengetopt -i Dump2XYZ.ggo |
4 |
> |
gengetopt -i Dump2XYZ.ggo -F Dump2XYZCmd |
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 "Dump2XYZCmd.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->frame_given = 0 ; |
46 |
+ |
args_info->water_given = 0 ; |
47 |
+ |
args_info->periodicBox_given = 0 ; |
48 |
+ |
args_info->zconstraint_given = 0 ; |
49 |
+ |
args_info->rigidbody_given = 0 ; |
50 |
+ |
args_info->watertype_given = 0 ; |
51 |
+ |
args_info->selection_given = 0 ; |
52 |
+ |
args_info->originsele_given = 0 ; |
53 |
+ |
args_info->refsele_given = 0 ; |
54 |
+ |
args_info->repeatX_given = 0 ; |
55 |
+ |
args_info->repeatY_given = 0 ; |
56 |
+ |
args_info->repeatZ_given = 0 ; |
57 |
+ |
args_info->gb_given = 0 ; |
58 |
+ |
args_info->basetype_given = 0 ; |
59 |
+ |
args_info->printPosOnly_given = 0 ; |
60 |
+ |
} |
61 |
+ |
|
62 |
+ |
static |
63 |
+ |
void clear_args (struct gengetopt_args_info *args_info) |
64 |
+ |
{ |
65 |
+ |
args_info->input_arg = NULL; |
66 |
+ |
args_info->input_orig = NULL; |
67 |
+ |
args_info->output_arg = NULL; |
68 |
+ |
args_info->output_orig = NULL; |
69 |
+ |
args_info->frame_arg = 1; |
70 |
+ |
args_info->frame_orig = NULL; |
71 |
+ |
args_info->water_flag = 0; |
72 |
+ |
args_info->periodicBox_flag = 0; |
73 |
+ |
args_info->zconstraint_flag = 0; |
74 |
+ |
args_info->rigidbody_flag = 0; |
75 |
+ |
args_info->watertype_flag = 1; |
76 |
+ |
args_info->selection_arg = NULL; |
77 |
+ |
args_info->selection_orig = NULL; |
78 |
+ |
args_info->originsele_arg = NULL; |
79 |
+ |
args_info->originsele_orig = NULL; |
80 |
+ |
args_info->refsele_arg = NULL; |
81 |
+ |
args_info->refsele_orig = NULL; |
82 |
+ |
args_info->repeatX_arg = 0; |
83 |
+ |
args_info->repeatX_orig = NULL; |
84 |
+ |
args_info->repeatY_arg = 0; |
85 |
+ |
args_info->repeatY_orig = NULL; |
86 |
+ |
args_info->repeatZ_arg = 0; |
87 |
+ |
args_info->repeatZ_orig = NULL; |
88 |
+ |
args_info->gb_arg = NULL; |
89 |
+ |
args_info->gb_orig = NULL; |
90 |
+ |
args_info->basetype_flag = 0; |
91 |
+ |
args_info->printPosOnly_flag = 0; |
92 |
+ |
|
93 |
+ |
} |
94 |
+ |
|
95 |
|
void |
96 |
|
cmdline_parser_print_version (void) |
97 |
|
{ |
102 |
|
cmdline_parser_print_help (void) |
103 |
|
{ |
104 |
|
cmdline_parser_print_version (); |
105 |
< |
printf("\n" |
106 |
< |
"Usage: %s [OPTIONS]...\n", CMDLINE_PARSER_PACKAGE); |
107 |
< |
printf("\n"); |
108 |
< |
printf(" -h, --help Print help and exit\n"); |
109 |
< |
printf(" -V, --version Print version and exit\n"); |
110 |
< |
printf(" -i, --input=filename input dump file\n"); |
111 |
< |
printf(" -o, --output=filename output file name\n"); |
112 |
< |
printf(" -n, --frame=INT print every n frame (default=`1')\n"); |
113 |
< |
printf(" -d, --dipole print the dipole moments (default=off)\n"); |
114 |
< |
printf(" -w, --water skip the the waters (default=off)\n"); |
115 |
< |
printf(" -m, --periodicBox map to the periodic box (default=off)\n"); |
116 |
< |
printf(" -z, --zconstraint replace the atom types of zconstraint \n molecules (default=off)\n"); |
117 |
< |
printf(" -r, --rigidbody add a pseudo COM atom to rigidbody \n (default=off)\n"); |
118 |
< |
printf(" -t, --watertype replace the atom type of water model \n (default=on)\n"); |
119 |
< |
printf(" -g, --ignore=atomtype ignore the atom types\n"); |
120 |
< |
printf(" -s, --selection=selection script general selection syntax(now only support \n select atoms within a specified range)\n"); |
121 |
< |
printf(" --repeatX=INT The number of images to repeat in the x \n direction (default=`0')\n"); |
122 |
< |
printf(" --repeatY=INT The number of images to repeat in the y \n direction (default=`0')\n"); |
123 |
< |
printf(" --repeatZ=INT The number of images to repeat in the z \n direction (default=`0')\n"); |
105 |
> |
printf("\nUsage: Dump2XYZ [OPTIONS]...\n\n"); |
106 |
> |
printf("%s\n"," -h, --help Print help and exit"); |
107 |
> |
printf("%s\n"," -V, --version Print version and exit"); |
108 |
> |
printf("%s\n"," -i, --input=filename input dump file"); |
109 |
> |
printf("%s\n"," -o, --output=filename output file name"); |
110 |
> |
printf("%s\n"," -n, --frame=INT print every n frame (default=`1')"); |
111 |
> |
printf("%s\n"," -w, --water skip the the waters (default=off)"); |
112 |
> |
printf("%s\n"," -m, --periodicBox map to the periodic box (default=off)"); |
113 |
> |
printf("%s\n"," -z, --zconstraint replace the atom types of zconstraint molecules \n (default=off)"); |
114 |
> |
printf("%s\n"," -r, --rigidbody add a pseudo COM atom to rigidbody \n (default=off)"); |
115 |
> |
printf("%s\n"," -t, --watertype replace the atom type of water model \n (default=on)"); |
116 |
> |
printf("%s\n"," -s, --selection=selection script\n general selection syntax"); |
117 |
> |
printf("%s\n"," --originsele=selection script\n select origin"); |
118 |
> |
printf("%s\n"," --refsele=selection script\n select reference"); |
119 |
> |
printf("%s\n"," --repeatX=INT The number of images to repeat in the x \n direction (default=`0')"); |
120 |
> |
printf("%s\n"," --repeatY=INT The number of images to repeat in the y \n direction (default=`0')"); |
121 |
> |
printf("%s\n"," --repeatZ=INT The number of images to repeat in the z \n direction (default=`0')"); |
122 |
> |
printf("%s\n"," --gb=atomtype Replace the Gay-Berne atom with four linear \n atoms"); |
123 |
> |
printf("%s\n"," -b, --basetype Convert to base atom type (default=off)"); |
124 |
> |
printf("%s\n"," --printPosOnly Print only positions in xyz file (default=off)"); |
125 |
> |
|
126 |
|
} |
127 |
|
|
128 |
+ |
void |
129 |
+ |
cmdline_parser_init (struct gengetopt_args_info *args_info) |
130 |
+ |
{ |
131 |
+ |
clear_given (args_info); |
132 |
+ |
clear_args (args_info); |
133 |
+ |
} |
134 |
|
|
135 |
< |
static char *gengetopt_strdup (const char *s); |
135 |
> |
static void |
136 |
> |
cmdline_parser_release (struct gengetopt_args_info *args_info) |
137 |
> |
{ |
138 |
> |
|
139 |
> |
if (args_info->input_arg) |
140 |
> |
{ |
141 |
> |
free (args_info->input_arg); /* free previous argument */ |
142 |
> |
args_info->input_arg = 0; |
143 |
> |
} |
144 |
> |
if (args_info->input_orig) |
145 |
> |
{ |
146 |
> |
free (args_info->input_orig); /* free previous argument */ |
147 |
> |
args_info->input_orig = 0; |
148 |
> |
} |
149 |
> |
if (args_info->output_arg) |
150 |
> |
{ |
151 |
> |
free (args_info->output_arg); /* free previous argument */ |
152 |
> |
args_info->output_arg = 0; |
153 |
> |
} |
154 |
> |
if (args_info->output_orig) |
155 |
> |
{ |
156 |
> |
free (args_info->output_orig); /* free previous argument */ |
157 |
> |
args_info->output_orig = 0; |
158 |
> |
} |
159 |
> |
if (args_info->frame_orig) |
160 |
> |
{ |
161 |
> |
free (args_info->frame_orig); /* free previous argument */ |
162 |
> |
args_info->frame_orig = 0; |
163 |
> |
} |
164 |
> |
if (args_info->selection_arg) |
165 |
> |
{ |
166 |
> |
free (args_info->selection_arg); /* free previous argument */ |
167 |
> |
args_info->selection_arg = 0; |
168 |
> |
} |
169 |
> |
if (args_info->selection_orig) |
170 |
> |
{ |
171 |
> |
free (args_info->selection_orig); /* free previous argument */ |
172 |
> |
args_info->selection_orig = 0; |
173 |
> |
} |
174 |
> |
if (args_info->originsele_arg) |
175 |
> |
{ |
176 |
> |
free (args_info->originsele_arg); /* free previous argument */ |
177 |
> |
args_info->originsele_arg = 0; |
178 |
> |
} |
179 |
> |
if (args_info->originsele_orig) |
180 |
> |
{ |
181 |
> |
free (args_info->originsele_orig); /* free previous argument */ |
182 |
> |
args_info->originsele_orig = 0; |
183 |
> |
} |
184 |
> |
if (args_info->refsele_arg) |
185 |
> |
{ |
186 |
> |
free (args_info->refsele_arg); /* free previous argument */ |
187 |
> |
args_info->refsele_arg = 0; |
188 |
> |
} |
189 |
> |
if (args_info->refsele_orig) |
190 |
> |
{ |
191 |
> |
free (args_info->refsele_orig); /* free previous argument */ |
192 |
> |
args_info->refsele_orig = 0; |
193 |
> |
} |
194 |
> |
if (args_info->repeatX_orig) |
195 |
> |
{ |
196 |
> |
free (args_info->repeatX_orig); /* free previous argument */ |
197 |
> |
args_info->repeatX_orig = 0; |
198 |
> |
} |
199 |
> |
if (args_info->repeatY_orig) |
200 |
> |
{ |
201 |
> |
free (args_info->repeatY_orig); /* free previous argument */ |
202 |
> |
args_info->repeatY_orig = 0; |
203 |
> |
} |
204 |
> |
if (args_info->repeatZ_orig) |
205 |
> |
{ |
206 |
> |
free (args_info->repeatZ_orig); /* free previous argument */ |
207 |
> |
args_info->repeatZ_orig = 0; |
208 |
> |
} |
209 |
> |
if (args_info->gb_arg) |
210 |
> |
{ |
211 |
> |
free (args_info->gb_arg); /* free previous argument */ |
212 |
> |
args_info->gb_arg = 0; |
213 |
> |
} |
214 |
> |
if (args_info->gb_orig) |
215 |
> |
{ |
216 |
> |
free (args_info->gb_orig); /* free previous argument */ |
217 |
> |
args_info->gb_orig = 0; |
218 |
> |
} |
219 |
> |
|
220 |
> |
clear_given (args_info); |
221 |
> |
} |
222 |
|
|
223 |
+ |
int |
224 |
+ |
cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info) |
225 |
+ |
{ |
226 |
+ |
FILE *outfile; |
227 |
+ |
int i = 0; |
228 |
+ |
|
229 |
+ |
outfile = fopen(filename, "w"); |
230 |
+ |
|
231 |
+ |
if (!outfile) |
232 |
+ |
{ |
233 |
+ |
fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename); |
234 |
+ |
return EXIT_FAILURE; |
235 |
+ |
} |
236 |
+ |
|
237 |
+ |
if (args_info->help_given) { |
238 |
+ |
fprintf(outfile, "%s\n", "help"); |
239 |
+ |
} |
240 |
+ |
if (args_info->version_given) { |
241 |
+ |
fprintf(outfile, "%s\n", "version"); |
242 |
+ |
} |
243 |
+ |
if (args_info->input_given) { |
244 |
+ |
if (args_info->input_orig) { |
245 |
+ |
fprintf(outfile, "%s=\"%s\"\n", "input", args_info->input_orig); |
246 |
+ |
} else { |
247 |
+ |
fprintf(outfile, "%s\n", "input"); |
248 |
+ |
} |
249 |
+ |
} |
250 |
+ |
if (args_info->output_given) { |
251 |
+ |
if (args_info->output_orig) { |
252 |
+ |
fprintf(outfile, "%s=\"%s\"\n", "output", args_info->output_orig); |
253 |
+ |
} else { |
254 |
+ |
fprintf(outfile, "%s\n", "output"); |
255 |
+ |
} |
256 |
+ |
} |
257 |
+ |
if (args_info->frame_given) { |
258 |
+ |
if (args_info->frame_orig) { |
259 |
+ |
fprintf(outfile, "%s=\"%s\"\n", "frame", args_info->frame_orig); |
260 |
+ |
} else { |
261 |
+ |
fprintf(outfile, "%s\n", "frame"); |
262 |
+ |
} |
263 |
+ |
} |
264 |
+ |
if (args_info->water_given) { |
265 |
+ |
fprintf(outfile, "%s\n", "water"); |
266 |
+ |
} |
267 |
+ |
if (args_info->periodicBox_given) { |
268 |
+ |
fprintf(outfile, "%s\n", "periodicBox"); |
269 |
+ |
} |
270 |
+ |
if (args_info->zconstraint_given) { |
271 |
+ |
fprintf(outfile, "%s\n", "zconstraint"); |
272 |
+ |
} |
273 |
+ |
if (args_info->rigidbody_given) { |
274 |
+ |
fprintf(outfile, "%s\n", "rigidbody"); |
275 |
+ |
} |
276 |
+ |
if (args_info->watertype_given) { |
277 |
+ |
fprintf(outfile, "%s\n", "watertype"); |
278 |
+ |
} |
279 |
+ |
if (args_info->selection_given) { |
280 |
+ |
if (args_info->selection_orig) { |
281 |
+ |
fprintf(outfile, "%s=\"%s\"\n", "selection", args_info->selection_orig); |
282 |
+ |
} else { |
283 |
+ |
fprintf(outfile, "%s\n", "selection"); |
284 |
+ |
} |
285 |
+ |
} |
286 |
+ |
if (args_info->originsele_given) { |
287 |
+ |
if (args_info->originsele_orig) { |
288 |
+ |
fprintf(outfile, "%s=\"%s\"\n", "originsele", args_info->originsele_orig); |
289 |
+ |
} else { |
290 |
+ |
fprintf(outfile, "%s\n", "originsele"); |
291 |
+ |
} |
292 |
+ |
} |
293 |
+ |
if (args_info->refsele_given) { |
294 |
+ |
if (args_info->refsele_orig) { |
295 |
+ |
fprintf(outfile, "%s=\"%s\"\n", "refsele", args_info->refsele_orig); |
296 |
+ |
} else { |
297 |
+ |
fprintf(outfile, "%s\n", "refsele"); |
298 |
+ |
} |
299 |
+ |
} |
300 |
+ |
if (args_info->repeatX_given) { |
301 |
+ |
if (args_info->repeatX_orig) { |
302 |
+ |
fprintf(outfile, "%s=\"%s\"\n", "repeatX", args_info->repeatX_orig); |
303 |
+ |
} else { |
304 |
+ |
fprintf(outfile, "%s\n", "repeatX"); |
305 |
+ |
} |
306 |
+ |
} |
307 |
+ |
if (args_info->repeatY_given) { |
308 |
+ |
if (args_info->repeatY_orig) { |
309 |
+ |
fprintf(outfile, "%s=\"%s\"\n", "repeatY", args_info->repeatY_orig); |
310 |
+ |
} else { |
311 |
+ |
fprintf(outfile, "%s\n", "repeatY"); |
312 |
+ |
} |
313 |
+ |
} |
314 |
+ |
if (args_info->repeatZ_given) { |
315 |
+ |
if (args_info->repeatZ_orig) { |
316 |
+ |
fprintf(outfile, "%s=\"%s\"\n", "repeatZ", args_info->repeatZ_orig); |
317 |
+ |
} else { |
318 |
+ |
fprintf(outfile, "%s\n", "repeatZ"); |
319 |
+ |
} |
320 |
+ |
} |
321 |
+ |
if (args_info->gb_given) { |
322 |
+ |
if (args_info->gb_orig) { |
323 |
+ |
fprintf(outfile, "%s=\"%s\"\n", "gb", args_info->gb_orig); |
324 |
+ |
} else { |
325 |
+ |
fprintf(outfile, "%s\n", "gb"); |
326 |
+ |
} |
327 |
+ |
} |
328 |
+ |
if (args_info->basetype_given) { |
329 |
+ |
fprintf(outfile, "%s\n", "basetype"); |
330 |
+ |
} |
331 |
+ |
if (args_info->printPosOnly_given) { |
332 |
+ |
fprintf(outfile, "%s\n", "printPosOnly"); |
333 |
+ |
} |
334 |
+ |
|
335 |
+ |
fclose (outfile); |
336 |
+ |
|
337 |
+ |
i = EXIT_SUCCESS; |
338 |
+ |
return i; |
339 |
+ |
} |
340 |
+ |
|
341 |
+ |
void |
342 |
+ |
cmdline_parser_free (struct gengetopt_args_info *args_info) |
343 |
+ |
{ |
344 |
+ |
cmdline_parser_release (args_info); |
345 |
+ |
} |
346 |
+ |
|
347 |
+ |
|
348 |
|
/* gengetopt_strdup() */ |
349 |
|
/* strdup.c replacement of strdup, which is not standard */ |
350 |
|
char * |
351 |
|
gengetopt_strdup (const char *s) |
352 |
|
{ |
353 |
< |
char *result = (char*)malloc(strlen(s) + 1); |
353 |
> |
char *result = NULL; |
354 |
> |
if (!s) |
355 |
> |
return result; |
356 |
> |
|
357 |
> |
result = (char*)malloc(strlen(s) + 1); |
358 |
|
if (result == (char*)0) |
359 |
|
return (char*)0; |
360 |
|
strcpy(result, s); |
364 |
|
int |
365 |
|
cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info) |
366 |
|
{ |
367 |
< |
int c; /* Character of the parsed option. */ |
368 |
< |
int i; /* Counter */ |
369 |
< |
struct ignore_list |
370 |
< |
{ |
371 |
< |
char * ignore_arg; |
372 |
< |
struct ignore_list * next; |
373 |
< |
}; |
374 |
< |
struct ignore_list * ignore_list = NULL,* ignore_new = NULL; |
367 |
> |
return cmdline_parser2 (argc, argv, args_info, 0, 1, 1); |
368 |
> |
} |
369 |
> |
|
370 |
> |
int |
371 |
> |
cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) |
372 |
> |
{ |
373 |
> |
int result; |
374 |
> |
|
375 |
> |
result = cmdline_parser_internal (argc, argv, args_info, override, initialize, check_required, NULL); |
376 |
> |
|
377 |
> |
if (result == EXIT_FAILURE) |
378 |
> |
{ |
379 |
> |
cmdline_parser_free (args_info); |
380 |
> |
exit (EXIT_FAILURE); |
381 |
> |
} |
382 |
|
|
383 |
< |
int missing_required_options = 0; |
383 |
> |
return result; |
384 |
> |
} |
385 |
|
|
386 |
< |
args_info->help_given = 0 ; |
387 |
< |
args_info->version_given = 0 ; |
388 |
< |
args_info->input_given = 0 ; |
389 |
< |
args_info->output_given = 0 ; |
390 |
< |
args_info->frame_given = 0 ; |
391 |
< |
args_info->dipole_given = 0 ; |
392 |
< |
args_info->water_given = 0 ; |
393 |
< |
args_info->periodicBox_given = 0 ; |
394 |
< |
args_info->zconstraint_given = 0 ; |
395 |
< |
args_info->rigidbody_given = 0 ; |
396 |
< |
args_info->watertype_given = 0 ; |
397 |
< |
args_info->ignore_given = 0 ; |
398 |
< |
args_info->selection_given = 0 ; |
399 |
< |
args_info->repeatX_given = 0 ; |
400 |
< |
args_info->repeatY_given = 0 ; |
100 |
< |
args_info->repeatZ_given = 0 ; |
101 |
< |
#define clear_args() { \ |
102 |
< |
args_info->input_arg = NULL; \ |
103 |
< |
args_info->output_arg = NULL; \ |
104 |
< |
args_info->frame_arg = 1 ;\ |
105 |
< |
args_info->dipole_flag = 0;\ |
106 |
< |
args_info->water_flag = 0;\ |
107 |
< |
args_info->periodicBox_flag = 0;\ |
108 |
< |
args_info->zconstraint_flag = 0;\ |
109 |
< |
args_info->rigidbody_flag = 0;\ |
110 |
< |
args_info->watertype_flag = 1;\ |
111 |
< |
args_info->ignore_arg = NULL; \ |
112 |
< |
args_info->selection_arg = NULL; \ |
113 |
< |
args_info->repeatX_arg = 0 ;\ |
114 |
< |
args_info->repeatY_arg = 0 ;\ |
115 |
< |
args_info->repeatZ_arg = 0 ;\ |
386 |
> |
int |
387 |
> |
cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name) |
388 |
> |
{ |
389 |
> |
int result = EXIT_SUCCESS; |
390 |
> |
|
391 |
> |
if (cmdline_parser_required2(args_info, prog_name, NULL) > 0) |
392 |
> |
result = EXIT_FAILURE; |
393 |
> |
|
394 |
> |
if (result == EXIT_FAILURE) |
395 |
> |
{ |
396 |
> |
cmdline_parser_free (args_info); |
397 |
> |
exit (EXIT_FAILURE); |
398 |
> |
} |
399 |
> |
|
400 |
> |
return result; |
401 |
|
} |
402 |
|
|
403 |
< |
clear_args(); |
403 |
> |
int |
404 |
> |
cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error) |
405 |
> |
{ |
406 |
> |
int error = 0; |
407 |
|
|
408 |
+ |
if (! args_info->input_given) |
409 |
+ |
{ |
410 |
+ |
fprintf (stderr, "%s: '--input' ('-i') option required%s\n", prog_name, (additional_error ? additional_error : "")); |
411 |
+ |
error = 1; |
412 |
+ |
} |
413 |
+ |
|
414 |
+ |
return error; |
415 |
+ |
} |
416 |
+ |
|
417 |
+ |
int |
418 |
+ |
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) |
419 |
+ |
{ |
420 |
+ |
int c; /* Character of the parsed option. */ |
421 |
+ |
|
422 |
+ |
int error = 0; |
423 |
+ |
struct gengetopt_args_info local_args_info; |
424 |
+ |
|
425 |
+ |
if (initialize) |
426 |
+ |
cmdline_parser_init (args_info); |
427 |
+ |
|
428 |
+ |
cmdline_parser_init (&local_args_info); |
429 |
+ |
|
430 |
|
optarg = 0; |
431 |
|
optind = 1; |
432 |
|
opterr = 1; |
443 |
|
{ "input", 1, NULL, 'i' }, |
444 |
|
{ "output", 1, NULL, 'o' }, |
445 |
|
{ "frame", 1, NULL, 'n' }, |
136 |
– |
{ "dipole", 0, NULL, 'd' }, |
446 |
|
{ "water", 0, NULL, 'w' }, |
447 |
|
{ "periodicBox", 0, NULL, 'm' }, |
448 |
|
{ "zconstraint", 0, NULL, 'z' }, |
449 |
|
{ "rigidbody", 0, NULL, 'r' }, |
450 |
|
{ "watertype", 0, NULL, 't' }, |
142 |
– |
{ "ignore", 1, NULL, 'g' }, |
451 |
|
{ "selection", 1, NULL, 's' }, |
452 |
+ |
{ "originsele", 1, NULL, 0 }, |
453 |
+ |
{ "refsele", 1, NULL, 0 }, |
454 |
|
{ "repeatX", 1, NULL, 0 }, |
455 |
|
{ "repeatY", 1, NULL, 0 }, |
456 |
|
{ "repeatZ", 1, NULL, 0 }, |
457 |
+ |
{ "gb", 1, NULL, 0 }, |
458 |
+ |
{ "basetype", 0, NULL, 'b' }, |
459 |
+ |
{ "printPosOnly", 0, NULL, 0 }, |
460 |
|
{ NULL, 0, NULL, 0 } |
461 |
|
}; |
462 |
|
|
463 |
|
stop_char = 0; |
464 |
< |
c = getopt_long (argc, argv, "hVi:o:n:dwmzrtg:s:", long_options, &option_index); |
464 |
> |
c = getopt_long (argc, argv, "hVi:o:n:wmzrts:b", long_options, &option_index); |
465 |
|
|
466 |
|
if (c == -1) break; /* Exit from `while (1)' loop. */ |
467 |
|
|
468 |
|
switch (c) |
469 |
|
{ |
470 |
|
case 'h': /* Print help and exit. */ |
158 |
– |
clear_args (); |
471 |
|
cmdline_parser_print_help (); |
472 |
+ |
cmdline_parser_free (&local_args_info); |
473 |
|
exit (EXIT_SUCCESS); |
474 |
|
|
475 |
|
case 'V': /* Print version and exit. */ |
163 |
– |
clear_args (); |
476 |
|
cmdline_parser_print_version (); |
477 |
+ |
cmdline_parser_free (&local_args_info); |
478 |
|
exit (EXIT_SUCCESS); |
479 |
|
|
480 |
|
case 'i': /* input dump file. */ |
481 |
< |
if (args_info->input_given) |
481 |
> |
if (local_args_info.input_given) |
482 |
|
{ |
483 |
< |
fprintf (stderr, "%s: `--input' (`-i') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
484 |
< |
clear_args (); |
172 |
< |
exit (EXIT_FAILURE); |
483 |
> |
fprintf (stderr, "%s: `--input' (`-i') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
484 |
> |
goto failure; |
485 |
|
} |
486 |
+ |
if (args_info->input_given && ! override) |
487 |
+ |
continue; |
488 |
+ |
local_args_info.input_given = 1; |
489 |
|
args_info->input_given = 1; |
490 |
+ |
if (args_info->input_arg) |
491 |
+ |
free (args_info->input_arg); /* free previous string */ |
492 |
|
args_info->input_arg = gengetopt_strdup (optarg); |
493 |
+ |
if (args_info->input_orig) |
494 |
+ |
free (args_info->input_orig); /* free previous string */ |
495 |
+ |
args_info->input_orig = gengetopt_strdup (optarg); |
496 |
|
break; |
497 |
|
|
498 |
|
case 'o': /* output file name. */ |
499 |
< |
if (args_info->output_given) |
499 |
> |
if (local_args_info.output_given) |
500 |
|
{ |
501 |
< |
fprintf (stderr, "%s: `--output' (`-o') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
502 |
< |
clear_args (); |
183 |
< |
exit (EXIT_FAILURE); |
501 |
> |
fprintf (stderr, "%s: `--output' (`-o') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
502 |
> |
goto failure; |
503 |
|
} |
504 |
+ |
if (args_info->output_given && ! override) |
505 |
+ |
continue; |
506 |
+ |
local_args_info.output_given = 1; |
507 |
|
args_info->output_given = 1; |
508 |
+ |
if (args_info->output_arg) |
509 |
+ |
free (args_info->output_arg); /* free previous string */ |
510 |
|
args_info->output_arg = gengetopt_strdup (optarg); |
511 |
+ |
if (args_info->output_orig) |
512 |
+ |
free (args_info->output_orig); /* free previous string */ |
513 |
+ |
args_info->output_orig = gengetopt_strdup (optarg); |
514 |
|
break; |
515 |
|
|
516 |
|
case 'n': /* print every n frame. */ |
517 |
< |
if (args_info->frame_given) |
517 |
> |
if (local_args_info.frame_given) |
518 |
|
{ |
519 |
< |
fprintf (stderr, "%s: `--frame' (`-n') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
520 |
< |
clear_args (); |
194 |
< |
exit (EXIT_FAILURE); |
519 |
> |
fprintf (stderr, "%s: `--frame' (`-n') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
520 |
> |
goto failure; |
521 |
|
} |
522 |
+ |
if (args_info->frame_given && ! override) |
523 |
+ |
continue; |
524 |
+ |
local_args_info.frame_given = 1; |
525 |
|
args_info->frame_given = 1; |
526 |
< |
args_info->frame_arg = strtol (optarg,&stop_char,0); |
526 |
> |
args_info->frame_arg = strtol (optarg, &stop_char, 0); |
527 |
> |
if (!(stop_char && *stop_char == '\0')) { |
528 |
> |
fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); |
529 |
> |
goto failure; |
530 |
> |
} |
531 |
> |
if (args_info->frame_orig) |
532 |
> |
free (args_info->frame_orig); /* free previous string */ |
533 |
> |
args_info->frame_orig = gengetopt_strdup (optarg); |
534 |
|
break; |
535 |
|
|
200 |
– |
case 'd': /* print the dipole moments. */ |
201 |
– |
if (args_info->dipole_given) |
202 |
– |
{ |
203 |
– |
fprintf (stderr, "%s: `--dipole' (`-d') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
204 |
– |
clear_args (); |
205 |
– |
exit (EXIT_FAILURE); |
206 |
– |
} |
207 |
– |
args_info->dipole_given = 1; |
208 |
– |
args_info->dipole_flag = !(args_info->dipole_flag); |
209 |
– |
break; |
210 |
– |
|
536 |
|
case 'w': /* skip the the waters. */ |
537 |
< |
if (args_info->water_given) |
537 |
> |
if (local_args_info.water_given) |
538 |
|
{ |
539 |
< |
fprintf (stderr, "%s: `--water' (`-w') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
540 |
< |
clear_args (); |
216 |
< |
exit (EXIT_FAILURE); |
539 |
> |
fprintf (stderr, "%s: `--water' (`-w') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
540 |
> |
goto failure; |
541 |
|
} |
542 |
+ |
if (args_info->water_given && ! override) |
543 |
+ |
continue; |
544 |
+ |
local_args_info.water_given = 1; |
545 |
|
args_info->water_given = 1; |
546 |
|
args_info->water_flag = !(args_info->water_flag); |
547 |
|
break; |
548 |
|
|
549 |
|
case 'm': /* map to the periodic box. */ |
550 |
< |
if (args_info->periodicBox_given) |
550 |
> |
if (local_args_info.periodicBox_given) |
551 |
|
{ |
552 |
< |
fprintf (stderr, "%s: `--periodicBox' (`-m') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
553 |
< |
clear_args (); |
227 |
< |
exit (EXIT_FAILURE); |
552 |
> |
fprintf (stderr, "%s: `--periodicBox' (`-m') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
553 |
> |
goto failure; |
554 |
|
} |
555 |
+ |
if (args_info->periodicBox_given && ! override) |
556 |
+ |
continue; |
557 |
+ |
local_args_info.periodicBox_given = 1; |
558 |
|
args_info->periodicBox_given = 1; |
559 |
|
args_info->periodicBox_flag = !(args_info->periodicBox_flag); |
560 |
|
break; |
561 |
|
|
562 |
|
case 'z': /* replace the atom types of zconstraint molecules. */ |
563 |
< |
if (args_info->zconstraint_given) |
563 |
> |
if (local_args_info.zconstraint_given) |
564 |
|
{ |
565 |
< |
fprintf (stderr, "%s: `--zconstraint' (`-z') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
566 |
< |
clear_args (); |
238 |
< |
exit (EXIT_FAILURE); |
565 |
> |
fprintf (stderr, "%s: `--zconstraint' (`-z') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
566 |
> |
goto failure; |
567 |
|
} |
568 |
+ |
if (args_info->zconstraint_given && ! override) |
569 |
+ |
continue; |
570 |
+ |
local_args_info.zconstraint_given = 1; |
571 |
|
args_info->zconstraint_given = 1; |
572 |
|
args_info->zconstraint_flag = !(args_info->zconstraint_flag); |
573 |
|
break; |
574 |
|
|
575 |
|
case 'r': /* add a pseudo COM atom to rigidbody. */ |
576 |
< |
if (args_info->rigidbody_given) |
576 |
> |
if (local_args_info.rigidbody_given) |
577 |
|
{ |
578 |
< |
fprintf (stderr, "%s: `--rigidbody' (`-r') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
579 |
< |
clear_args (); |
249 |
< |
exit (EXIT_FAILURE); |
578 |
> |
fprintf (stderr, "%s: `--rigidbody' (`-r') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
579 |
> |
goto failure; |
580 |
|
} |
581 |
+ |
if (args_info->rigidbody_given && ! override) |
582 |
+ |
continue; |
583 |
+ |
local_args_info.rigidbody_given = 1; |
584 |
|
args_info->rigidbody_given = 1; |
585 |
|
args_info->rigidbody_flag = !(args_info->rigidbody_flag); |
586 |
|
break; |
587 |
|
|
588 |
|
case 't': /* replace the atom type of water model. */ |
589 |
< |
if (args_info->watertype_given) |
589 |
> |
if (local_args_info.watertype_given) |
590 |
|
{ |
591 |
< |
fprintf (stderr, "%s: `--watertype' (`-t') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
592 |
< |
clear_args (); |
260 |
< |
exit (EXIT_FAILURE); |
591 |
> |
fprintf (stderr, "%s: `--watertype' (`-t') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
592 |
> |
goto failure; |
593 |
|
} |
594 |
+ |
if (args_info->watertype_given && ! override) |
595 |
+ |
continue; |
596 |
+ |
local_args_info.watertype_given = 1; |
597 |
|
args_info->watertype_given = 1; |
598 |
|
args_info->watertype_flag = !(args_info->watertype_flag); |
599 |
|
break; |
600 |
|
|
601 |
< |
case 'g': /* ignore the atom types. */ |
602 |
< |
args_info->ignore_given++; |
268 |
< |
ignore_new = (struct ignore_list *) malloc (sizeof (struct ignore_list)); |
269 |
< |
ignore_new->next = ignore_list; |
270 |
< |
ignore_list = ignore_new; |
271 |
< |
ignore_new->ignore_arg = gengetopt_strdup (optarg); |
272 |
< |
break; |
273 |
< |
|
274 |
< |
case 's': /* general selection syntax(now only support select atoms within a specified range). */ |
275 |
< |
if (args_info->selection_given) |
601 |
> |
case 's': /* general selection syntax. */ |
602 |
> |
if (local_args_info.selection_given) |
603 |
|
{ |
604 |
< |
fprintf (stderr, "%s: `--selection' (`-s') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
605 |
< |
clear_args (); |
279 |
< |
exit (EXIT_FAILURE); |
604 |
> |
fprintf (stderr, "%s: `--selection' (`-s') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
605 |
> |
goto failure; |
606 |
|
} |
607 |
+ |
if (args_info->selection_given && ! override) |
608 |
+ |
continue; |
609 |
+ |
local_args_info.selection_given = 1; |
610 |
|
args_info->selection_given = 1; |
611 |
+ |
if (args_info->selection_arg) |
612 |
+ |
free (args_info->selection_arg); /* free previous string */ |
613 |
|
args_info->selection_arg = gengetopt_strdup (optarg); |
614 |
+ |
if (args_info->selection_orig) |
615 |
+ |
free (args_info->selection_orig); /* free previous string */ |
616 |
+ |
args_info->selection_orig = gengetopt_strdup (optarg); |
617 |
+ |
break; |
618 |
+ |
|
619 |
+ |
case 'b': /* Convert to base atom type. */ |
620 |
+ |
if (local_args_info.basetype_given) |
621 |
+ |
{ |
622 |
+ |
fprintf (stderr, "%s: `--basetype' (`-b') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
623 |
+ |
goto failure; |
624 |
+ |
} |
625 |
+ |
if (args_info->basetype_given && ! override) |
626 |
+ |
continue; |
627 |
+ |
local_args_info.basetype_given = 1; |
628 |
+ |
args_info->basetype_given = 1; |
629 |
+ |
args_info->basetype_flag = !(args_info->basetype_flag); |
630 |
|
break; |
631 |
|
|
632 |
|
|
633 |
|
case 0: /* Long option with no short option */ |
634 |
+ |
/* select origin. */ |
635 |
+ |
if (strcmp (long_options[option_index].name, "originsele") == 0) |
636 |
+ |
{ |
637 |
+ |
if (local_args_info.originsele_given) |
638 |
+ |
{ |
639 |
+ |
fprintf (stderr, "%s: `--originsele' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
640 |
+ |
goto failure; |
641 |
+ |
} |
642 |
+ |
if (args_info->originsele_given && ! override) |
643 |
+ |
continue; |
644 |
+ |
local_args_info.originsele_given = 1; |
645 |
+ |
args_info->originsele_given = 1; |
646 |
+ |
if (args_info->originsele_arg) |
647 |
+ |
free (args_info->originsele_arg); /* free previous string */ |
648 |
+ |
args_info->originsele_arg = gengetopt_strdup (optarg); |
649 |
+ |
if (args_info->originsele_orig) |
650 |
+ |
free (args_info->originsele_orig); /* free previous string */ |
651 |
+ |
args_info->originsele_orig = gengetopt_strdup (optarg); |
652 |
+ |
} |
653 |
+ |
/* select reference. */ |
654 |
+ |
else if (strcmp (long_options[option_index].name, "refsele") == 0) |
655 |
+ |
{ |
656 |
+ |
if (local_args_info.refsele_given) |
657 |
+ |
{ |
658 |
+ |
fprintf (stderr, "%s: `--refsele' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
659 |
+ |
goto failure; |
660 |
+ |
} |
661 |
+ |
if (args_info->refsele_given && ! override) |
662 |
+ |
continue; |
663 |
+ |
local_args_info.refsele_given = 1; |
664 |
+ |
args_info->refsele_given = 1; |
665 |
+ |
if (args_info->refsele_arg) |
666 |
+ |
free (args_info->refsele_arg); /* free previous string */ |
667 |
+ |
args_info->refsele_arg = gengetopt_strdup (optarg); |
668 |
+ |
if (args_info->refsele_orig) |
669 |
+ |
free (args_info->refsele_orig); /* free previous string */ |
670 |
+ |
args_info->refsele_orig = gengetopt_strdup (optarg); |
671 |
+ |
} |
672 |
|
/* The number of images to repeat in the x direction. */ |
673 |
< |
if (strcmp (long_options[option_index].name, "repeatX") == 0) |
673 |
> |
else if (strcmp (long_options[option_index].name, "repeatX") == 0) |
674 |
|
{ |
675 |
< |
if (args_info->repeatX_given) |
675 |
> |
if (local_args_info.repeatX_given) |
676 |
|
{ |
677 |
< |
fprintf (stderr, "%s: `--repeatX' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
678 |
< |
clear_args (); |
294 |
< |
exit (EXIT_FAILURE); |
677 |
> |
fprintf (stderr, "%s: `--repeatX' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
678 |
> |
goto failure; |
679 |
|
} |
680 |
+ |
if (args_info->repeatX_given && ! override) |
681 |
+ |
continue; |
682 |
+ |
local_args_info.repeatX_given = 1; |
683 |
|
args_info->repeatX_given = 1; |
684 |
< |
args_info->repeatX_arg = strtol (optarg,&stop_char,0); |
685 |
< |
break; |
684 |
> |
args_info->repeatX_arg = strtol (optarg, &stop_char, 0); |
685 |
> |
if (!(stop_char && *stop_char == '\0')) { |
686 |
> |
fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); |
687 |
> |
goto failure; |
688 |
> |
} |
689 |
> |
if (args_info->repeatX_orig) |
690 |
> |
free (args_info->repeatX_orig); /* free previous string */ |
691 |
> |
args_info->repeatX_orig = gengetopt_strdup (optarg); |
692 |
|
} |
300 |
– |
|
693 |
|
/* The number of images to repeat in the y direction. */ |
694 |
|
else if (strcmp (long_options[option_index].name, "repeatY") == 0) |
695 |
|
{ |
696 |
< |
if (args_info->repeatY_given) |
696 |
> |
if (local_args_info.repeatY_given) |
697 |
|
{ |
698 |
< |
fprintf (stderr, "%s: `--repeatY' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
699 |
< |
clear_args (); |
308 |
< |
exit (EXIT_FAILURE); |
698 |
> |
fprintf (stderr, "%s: `--repeatY' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
699 |
> |
goto failure; |
700 |
|
} |
701 |
+ |
if (args_info->repeatY_given && ! override) |
702 |
+ |
continue; |
703 |
+ |
local_args_info.repeatY_given = 1; |
704 |
|
args_info->repeatY_given = 1; |
705 |
< |
args_info->repeatY_arg = strtol (optarg,&stop_char,0); |
706 |
< |
break; |
705 |
> |
args_info->repeatY_arg = strtol (optarg, &stop_char, 0); |
706 |
> |
if (!(stop_char && *stop_char == '\0')) { |
707 |
> |
fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); |
708 |
> |
goto failure; |
709 |
> |
} |
710 |
> |
if (args_info->repeatY_orig) |
711 |
> |
free (args_info->repeatY_orig); /* free previous string */ |
712 |
> |
args_info->repeatY_orig = gengetopt_strdup (optarg); |
713 |
|
} |
314 |
– |
|
714 |
|
/* The number of images to repeat in the z direction. */ |
715 |
|
else if (strcmp (long_options[option_index].name, "repeatZ") == 0) |
716 |
|
{ |
717 |
< |
if (args_info->repeatZ_given) |
717 |
> |
if (local_args_info.repeatZ_given) |
718 |
|
{ |
719 |
< |
fprintf (stderr, "%s: `--repeatZ' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
720 |
< |
clear_args (); |
322 |
< |
exit (EXIT_FAILURE); |
719 |
> |
fprintf (stderr, "%s: `--repeatZ' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
720 |
> |
goto failure; |
721 |
|
} |
722 |
+ |
if (args_info->repeatZ_given && ! override) |
723 |
+ |
continue; |
724 |
+ |
local_args_info.repeatZ_given = 1; |
725 |
|
args_info->repeatZ_given = 1; |
726 |
< |
args_info->repeatZ_arg = strtol (optarg,&stop_char,0); |
727 |
< |
break; |
726 |
> |
args_info->repeatZ_arg = strtol (optarg, &stop_char, 0); |
727 |
> |
if (!(stop_char && *stop_char == '\0')) { |
728 |
> |
fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); |
729 |
> |
goto failure; |
730 |
> |
} |
731 |
> |
if (args_info->repeatZ_orig) |
732 |
> |
free (args_info->repeatZ_orig); /* free previous string */ |
733 |
> |
args_info->repeatZ_orig = gengetopt_strdup (optarg); |
734 |
|
} |
735 |
+ |
/* Replace the Gay-Berne atom with four linear atoms. */ |
736 |
+ |
else if (strcmp (long_options[option_index].name, "gb") == 0) |
737 |
+ |
{ |
738 |
+ |
if (local_args_info.gb_given) |
739 |
+ |
{ |
740 |
+ |
fprintf (stderr, "%s: `--gb' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
741 |
+ |
goto failure; |
742 |
+ |
} |
743 |
+ |
if (args_info->gb_given && ! override) |
744 |
+ |
continue; |
745 |
+ |
local_args_info.gb_given = 1; |
746 |
+ |
args_info->gb_given = 1; |
747 |
+ |
if (args_info->gb_arg) |
748 |
+ |
free (args_info->gb_arg); /* free previous string */ |
749 |
+ |
args_info->gb_arg = gengetopt_strdup (optarg); |
750 |
+ |
if (args_info->gb_orig) |
751 |
+ |
free (args_info->gb_orig); /* free previous string */ |
752 |
+ |
args_info->gb_orig = gengetopt_strdup (optarg); |
753 |
+ |
} |
754 |
+ |
/* Print only positions in xyz file. */ |
755 |
+ |
else if (strcmp (long_options[option_index].name, "printPosOnly") == 0) |
756 |
+ |
{ |
757 |
+ |
if (local_args_info.printPosOnly_given) |
758 |
+ |
{ |
759 |
+ |
fprintf (stderr, "%s: `--printPosOnly' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
760 |
+ |
goto failure; |
761 |
+ |
} |
762 |
+ |
if (args_info->printPosOnly_given && ! override) |
763 |
+ |
continue; |
764 |
+ |
local_args_info.printPosOnly_given = 1; |
765 |
+ |
args_info->printPosOnly_given = 1; |
766 |
+ |
args_info->printPosOnly_flag = !(args_info->printPosOnly_flag); |
767 |
+ |
} |
768 |
|
|
769 |
< |
|
769 |
> |
break; |
770 |
|
case '?': /* Invalid option. */ |
771 |
|
/* `getopt_long' already printed an error message. */ |
772 |
< |
exit (EXIT_FAILURE); |
772 |
> |
goto failure; |
773 |
|
|
774 |
|
default: /* bug: option not considered. */ |
775 |
< |
fprintf (stderr, "%s: option unknown: %c\n", CMDLINE_PARSER_PACKAGE, c); |
775 |
> |
fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : "")); |
776 |
|
abort (); |
777 |
|
} /* switch */ |
778 |
|
} /* while */ |
779 |
|
|
780 |
|
|
341 |
– |
if (! args_info->input_given) |
342 |
– |
{ |
343 |
– |
fprintf (stderr, "%s: '--input' ('-i') option required\n", CMDLINE_PARSER_PACKAGE); |
344 |
– |
missing_required_options = 1; |
345 |
– |
} |
346 |
– |
if ( missing_required_options ) |
347 |
– |
exit (EXIT_FAILURE); |
781 |
|
|
782 |
< |
if (args_info->ignore_given) |
782 |
> |
if (check_required) |
783 |
|
{ |
784 |
< |
args_info->ignore_arg = (char * *) malloc (args_info->ignore_given * sizeof (char *)); |
352 |
< |
for (i = 0; i < args_info->ignore_given; i++) |
353 |
< |
{ |
354 |
< |
args_info->ignore_arg [i] = ignore_list->ignore_arg; |
355 |
< |
ignore_list = ignore_list->next; |
356 |
< |
} |
784 |
> |
error += cmdline_parser_required2 (args_info, argv[0], additional_error); |
785 |
|
} |
786 |
< |
|
786 |
> |
|
787 |
> |
cmdline_parser_release (&local_args_info); |
788 |
> |
|
789 |
> |
if ( error ) |
790 |
> |
return (EXIT_FAILURE); |
791 |
> |
|
792 |
|
return 0; |
793 |
+ |
|
794 |
+ |
failure: |
795 |
+ |
|
796 |
+ |
cmdline_parser_release (&local_args_info); |
797 |
+ |
return (EXIT_FAILURE); |
798 |
|
} |