1 |
chuckv |
653 |
/* |
2 |
|
|
File autogenerated by gengetopt version 2.13 |
3 |
|
|
generated with the following command: |
4 |
|
|
gengetopt -u -F nanoparticleBuilderCmd |
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 |
|
|
/* 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 "nanoparticleBuilderCmd.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 |
|
|
struct ShellRadius_list |
36 |
|
|
{ |
37 |
|
|
double ShellRadius_arg; |
38 |
|
|
struct ShellRadius_list * next; |
39 |
|
|
}; |
40 |
|
|
|
41 |
|
|
struct molFraction_list |
42 |
|
|
{ |
43 |
|
|
double molFraction_arg; |
44 |
|
|
struct molFraction_list * next; |
45 |
|
|
}; |
46 |
|
|
|
47 |
|
|
struct vacancyRadius_list |
48 |
|
|
{ |
49 |
|
|
double vacancyRadius_arg; |
50 |
|
|
struct vacancyRadius_list * next; |
51 |
|
|
}; |
52 |
|
|
|
53 |
|
|
static char * |
54 |
|
|
gengetopt_strdup (const char *s); |
55 |
|
|
|
56 |
|
|
static |
57 |
|
|
void clear_given (struct gengetopt_args_info *args_info) |
58 |
|
|
{ |
59 |
|
|
args_info->help_given = 0 ; |
60 |
|
|
args_info->version_given = 0 ; |
61 |
|
|
args_info->output_given = 0 ; |
62 |
|
|
args_info->latticetype_given = 0 ; |
63 |
|
|
args_info->latticeCnst_given = 0 ; |
64 |
|
|
args_info->radius_given = 0 ; |
65 |
|
|
args_info->ShellRadius_given = 0 ; |
66 |
|
|
args_info->molFraction_given = 0 ; |
67 |
|
|
args_info->vacancyPCT_given = 0 ; |
68 |
|
|
args_info->vacancyRadius_given = 0 ; |
69 |
|
|
} |
70 |
|
|
|
71 |
|
|
static |
72 |
|
|
void clear_args (struct gengetopt_args_info *args_info) |
73 |
|
|
{ |
74 |
|
|
args_info->output_arg = NULL; |
75 |
|
|
args_info->latticetype_arg = gengetopt_strdup ("fcc"); |
76 |
|
|
args_info->ShellRadius_arg = NULL; |
77 |
|
|
args_info->molFraction_arg = NULL; |
78 |
|
|
args_info->vacancyRadius_arg = NULL; |
79 |
|
|
} |
80 |
|
|
|
81 |
|
|
void |
82 |
|
|
cmdline_parser_print_version (void) |
83 |
|
|
{ |
84 |
|
|
printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION); |
85 |
|
|
} |
86 |
|
|
|
87 |
|
|
void |
88 |
|
|
cmdline_parser_print_help (void) |
89 |
|
|
{ |
90 |
|
|
cmdline_parser_print_version (); |
91 |
|
|
printf("\n%s\n", "Builds spherical random or core-shell nanoparticles and outputs a xyz input \nfile"); |
92 |
|
|
printf("\nUsage: nanoparticleBuilder [OPTIONS]... [FILES]...\n\n"); |
93 |
|
|
printf("%s\n"," -h, --help Print help and exit"); |
94 |
|
|
printf("%s\n"," -V, --version Print version and exit"); |
95 |
|
|
printf("%s\n"," -o, --output=STRING Output file name"); |
96 |
|
|
printf("%s\n"," --latticetype=STRING Lattice type string. Valid types are fcc,hcp,bcc. \n (default=`fcc')"); |
97 |
|
|
printf("%s\n"," --latticeCnst=DOUBLE Lattice spacing in Angstroms for cubic lattice."); |
98 |
|
|
printf("%s\n"," --radius=DOUBLE Nanoparticle radius in Angstroms"); |
99 |
|
|
printf("%s\n"," --ShellRadius=DOUBLE Radius from the center of the particle to start a \n new shell in multi-component core-shell \n particle. Specified for each component > 1 in \n md file."); |
100 |
|
|
printf("%s\n"," --molFraction=DOUBLE (Default) Builds a multi-component random mixed \n nanoparticle. Mole Fraction must be specified \n for each componet > 1 in MD file."); |
101 |
|
|
printf("%s\n"," --vacancyPCT=DOUBLE Percentage of vacancies to build"); |
102 |
|
|
printf("%s\n"," --vacancyRadius=DOUBLE Radius arround core-shell where vacancies should \n be located."); |
103 |
|
|
|
104 |
|
|
} |
105 |
|
|
|
106 |
|
|
void |
107 |
|
|
cmdline_parser_init (struct gengetopt_args_info *args_info) |
108 |
|
|
{ |
109 |
|
|
clear_given (args_info); |
110 |
|
|
clear_args (args_info); |
111 |
|
|
|
112 |
|
|
args_info->inputs = NULL; |
113 |
|
|
args_info->inputs_num = 0; |
114 |
|
|
} |
115 |
|
|
|
116 |
|
|
void |
117 |
|
|
cmdline_parser_free (struct gengetopt_args_info *args_info) |
118 |
|
|
{ |
119 |
|
|
|
120 |
|
|
unsigned int i; |
121 |
|
|
if (args_info->output_arg) |
122 |
|
|
{ |
123 |
|
|
free (args_info->output_arg); /* free previous argument */ |
124 |
|
|
args_info->output_arg = 0; |
125 |
|
|
} |
126 |
|
|
if (args_info->latticetype_arg) |
127 |
|
|
{ |
128 |
|
|
free (args_info->latticetype_arg); /* free previous argument */ |
129 |
|
|
args_info->latticetype_arg = 0; |
130 |
|
|
} |
131 |
|
|
if (args_info->ShellRadius_arg) |
132 |
|
|
{ |
133 |
|
|
free (args_info->ShellRadius_arg); /* free previous argument */ |
134 |
|
|
args_info->ShellRadius_arg = 0; |
135 |
|
|
} |
136 |
|
|
if (args_info->molFraction_arg) |
137 |
|
|
{ |
138 |
|
|
free (args_info->molFraction_arg); /* free previous argument */ |
139 |
|
|
args_info->molFraction_arg = 0; |
140 |
|
|
} |
141 |
|
|
if (args_info->vacancyRadius_arg) |
142 |
|
|
{ |
143 |
|
|
free (args_info->vacancyRadius_arg); /* free previous argument */ |
144 |
|
|
args_info->vacancyRadius_arg = 0; |
145 |
|
|
} |
146 |
|
|
|
147 |
|
|
for (i = 0; i < args_info->inputs_num; ++i) |
148 |
|
|
free (args_info->inputs [i]); |
149 |
|
|
|
150 |
|
|
if (args_info->inputs_num) |
151 |
|
|
free (args_info->inputs); |
152 |
|
|
|
153 |
|
|
clear_given (args_info); |
154 |
|
|
} |
155 |
|
|
|
156 |
|
|
/* gengetopt_strdup() */ |
157 |
|
|
/* strdup.c replacement of strdup, which is not standard */ |
158 |
|
|
char * |
159 |
|
|
gengetopt_strdup (const char *s) |
160 |
|
|
{ |
161 |
|
|
char *result = NULL; |
162 |
|
|
if (!s) |
163 |
|
|
return result; |
164 |
|
|
|
165 |
|
|
result = (char*)malloc(strlen(s) + 1); |
166 |
|
|
if (result == (char*)0) |
167 |
|
|
return (char*)0; |
168 |
|
|
strcpy(result, s); |
169 |
|
|
return result; |
170 |
|
|
} |
171 |
|
|
|
172 |
|
|
static char * |
173 |
|
|
get_multiple_arg_token(const char *arg) |
174 |
|
|
{ |
175 |
|
|
char *tok, *ret; |
176 |
|
|
size_t len; |
177 |
|
|
|
178 |
|
|
if (!arg) |
179 |
|
|
return NULL; |
180 |
|
|
|
181 |
|
|
tok = strchr (arg, ','); |
182 |
|
|
|
183 |
|
|
if (tok) |
184 |
|
|
len = (size_t)(tok - arg + 1); |
185 |
|
|
else |
186 |
|
|
len = strlen (arg) + 1; |
187 |
|
|
|
188 |
|
|
ret = (char *) malloc (len); |
189 |
|
|
strncpy (ret, arg, len-1); |
190 |
|
|
ret[len-1] = '\0'; |
191 |
|
|
|
192 |
|
|
return ret; |
193 |
|
|
} |
194 |
|
|
|
195 |
|
|
static char * |
196 |
|
|
get_multiple_arg_token_next(const char *arg) |
197 |
|
|
{ |
198 |
|
|
char *tok; |
199 |
|
|
|
200 |
|
|
if (!arg) |
201 |
|
|
return NULL; |
202 |
|
|
|
203 |
|
|
tok = strchr (arg, ','); |
204 |
|
|
|
205 |
|
|
if (! tok || strlen(tok) == 1) |
206 |
|
|
return 0; |
207 |
|
|
|
208 |
|
|
return tok+1; |
209 |
|
|
} |
210 |
|
|
|
211 |
|
|
int |
212 |
|
|
cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info) |
213 |
|
|
{ |
214 |
|
|
return cmdline_parser2 (argc, argv, args_info, 0, 1, 1); |
215 |
|
|
} |
216 |
|
|
|
217 |
|
|
int |
218 |
|
|
cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) |
219 |
|
|
{ |
220 |
|
|
int result; |
221 |
|
|
|
222 |
|
|
result = cmdline_parser_internal (argc, argv, args_info, override, initialize, check_required, NULL); |
223 |
|
|
|
224 |
|
|
if (result == EXIT_FAILURE) |
225 |
|
|
{ |
226 |
|
|
cmdline_parser_free (args_info); |
227 |
|
|
exit (EXIT_FAILURE); |
228 |
|
|
} |
229 |
|
|
|
230 |
|
|
return result; |
231 |
|
|
} |
232 |
|
|
|
233 |
|
|
int |
234 |
|
|
cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name) |
235 |
|
|
{ |
236 |
|
|
int result = EXIT_SUCCESS; |
237 |
|
|
|
238 |
|
|
if (cmdline_parser_required2(args_info, prog_name, NULL) > 0) |
239 |
|
|
result = EXIT_FAILURE; |
240 |
|
|
|
241 |
|
|
if (result == EXIT_FAILURE) |
242 |
|
|
{ |
243 |
|
|
cmdline_parser_free (args_info); |
244 |
|
|
exit (EXIT_FAILURE); |
245 |
|
|
} |
246 |
|
|
|
247 |
|
|
return result; |
248 |
|
|
} |
249 |
|
|
|
250 |
|
|
int |
251 |
|
|
cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error) |
252 |
|
|
{ |
253 |
|
|
int error = 0; |
254 |
|
|
|
255 |
|
|
if (! args_info->latticeCnst_given) |
256 |
|
|
{ |
257 |
|
|
fprintf (stderr, "%s: '--latticeCnst' option required%s\n", prog_name, (additional_error ? additional_error : "")); |
258 |
|
|
error = 1; |
259 |
|
|
} |
260 |
|
|
if (! args_info->radius_given) |
261 |
|
|
{ |
262 |
|
|
fprintf (stderr, "%s: '--radius' option required%s\n", prog_name, (additional_error ? additional_error : "")); |
263 |
|
|
error = 1; |
264 |
|
|
} |
265 |
|
|
|
266 |
|
|
return error; |
267 |
|
|
} |
268 |
|
|
|
269 |
|
|
int |
270 |
|
|
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) |
271 |
|
|
{ |
272 |
|
|
int c; /* Character of the parsed option. */ |
273 |
|
|
char *multi_token, *multi_next; /* for multiple options */ |
274 |
|
|
|
275 |
|
|
int i; /* Counter */ |
276 |
|
|
|
277 |
|
|
struct ShellRadius_list * ShellRadius_list = NULL,* ShellRadius_new = NULL; |
278 |
|
|
struct molFraction_list * molFraction_list = NULL,* molFraction_new = NULL; |
279 |
|
|
struct vacancyRadius_list * vacancyRadius_list = NULL,* vacancyRadius_new = NULL; |
280 |
|
|
int error = 0; |
281 |
|
|
struct gengetopt_args_info local_args_info; |
282 |
|
|
|
283 |
|
|
if (initialize) |
284 |
|
|
cmdline_parser_init (args_info); |
285 |
|
|
|
286 |
|
|
cmdline_parser_init (&local_args_info); |
287 |
|
|
|
288 |
|
|
optarg = 0; |
289 |
|
|
optind = 1; |
290 |
|
|
opterr = 1; |
291 |
|
|
optopt = '?'; |
292 |
|
|
|
293 |
|
|
while (1) |
294 |
|
|
{ |
295 |
|
|
int option_index = 0; |
296 |
|
|
char *stop_char; |
297 |
|
|
|
298 |
|
|
static struct option long_options[] = { |
299 |
|
|
{ "help", 0, NULL, 'h' }, |
300 |
|
|
{ "version", 0, NULL, 'V' }, |
301 |
|
|
{ "output", 1, NULL, 'o' }, |
302 |
|
|
{ "latticetype", 1, NULL, 0 }, |
303 |
|
|
{ "latticeCnst", 1, NULL, 0 }, |
304 |
|
|
{ "radius", 1, NULL, 0 }, |
305 |
|
|
{ "ShellRadius", 1, NULL, 0 }, |
306 |
|
|
{ "molFraction", 1, NULL, 0 }, |
307 |
|
|
{ "vacancyPCT", 1, NULL, 0 }, |
308 |
|
|
{ "vacancyRadius", 1, NULL, 0 }, |
309 |
|
|
{ NULL, 0, NULL, 0 } |
310 |
|
|
}; |
311 |
|
|
|
312 |
|
|
stop_char = 0; |
313 |
|
|
c = getopt_long (argc, argv, "hVo:", long_options, &option_index); |
314 |
|
|
|
315 |
|
|
if (c == -1) break; /* Exit from `while (1)' loop. */ |
316 |
|
|
|
317 |
|
|
switch (c) |
318 |
|
|
{ |
319 |
|
|
case 'h': /* Print help and exit. */ |
320 |
|
|
cmdline_parser_print_help (); |
321 |
|
|
exit (EXIT_SUCCESS); |
322 |
|
|
|
323 |
|
|
case 'V': /* Print version and exit. */ |
324 |
|
|
cmdline_parser_print_version (); |
325 |
|
|
exit (EXIT_SUCCESS); |
326 |
|
|
|
327 |
|
|
case 'o': /* Output file name. */ |
328 |
|
|
if (local_args_info.output_given) |
329 |
|
|
{ |
330 |
|
|
fprintf (stderr, "%s: `--output' (`-o') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
331 |
|
|
goto failure; |
332 |
|
|
} |
333 |
|
|
if (args_info->output_given && ! override) |
334 |
|
|
continue; |
335 |
|
|
local_args_info.output_given = 1; |
336 |
|
|
args_info->output_given = 1; |
337 |
|
|
if (args_info->output_arg) |
338 |
|
|
free (args_info->output_arg); /* free previous string */ |
339 |
|
|
args_info->output_arg = gengetopt_strdup (optarg); |
340 |
|
|
break; |
341 |
|
|
|
342 |
|
|
|
343 |
|
|
case 0: /* Long option with no short option */ |
344 |
|
|
/* Lattice type string. Valid types are fcc,hcp,bcc.. */ |
345 |
|
|
if (strcmp (long_options[option_index].name, "latticetype") == 0) |
346 |
|
|
{ |
347 |
|
|
if (local_args_info.latticetype_given) |
348 |
|
|
{ |
349 |
|
|
fprintf (stderr, "%s: `--latticetype' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
350 |
|
|
goto failure; |
351 |
|
|
} |
352 |
|
|
if (args_info->latticetype_given && ! override) |
353 |
|
|
continue; |
354 |
|
|
local_args_info.latticetype_given = 1; |
355 |
|
|
args_info->latticetype_given = 1; |
356 |
|
|
if (args_info->latticetype_arg) |
357 |
|
|
free (args_info->latticetype_arg); /* free previous string */ |
358 |
|
|
args_info->latticetype_arg = gengetopt_strdup (optarg); |
359 |
|
|
} |
360 |
|
|
/* Lattice spacing in Angstroms for cubic lattice.. */ |
361 |
|
|
else if (strcmp (long_options[option_index].name, "latticeCnst") == 0) |
362 |
|
|
{ |
363 |
|
|
if (local_args_info.latticeCnst_given) |
364 |
|
|
{ |
365 |
|
|
fprintf (stderr, "%s: `--latticeCnst' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
366 |
|
|
goto failure; |
367 |
|
|
} |
368 |
|
|
if (args_info->latticeCnst_given && ! override) |
369 |
|
|
continue; |
370 |
|
|
local_args_info.latticeCnst_given = 1; |
371 |
|
|
args_info->latticeCnst_given = 1; |
372 |
|
|
args_info->latticeCnst_arg = strtod (optarg, NULL); |
373 |
|
|
} |
374 |
|
|
/* Nanoparticle radius in Angstroms. */ |
375 |
|
|
else if (strcmp (long_options[option_index].name, "radius") == 0) |
376 |
|
|
{ |
377 |
|
|
if (local_args_info.radius_given) |
378 |
|
|
{ |
379 |
|
|
fprintf (stderr, "%s: `--radius' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
380 |
|
|
goto failure; |
381 |
|
|
} |
382 |
|
|
if (args_info->radius_given && ! override) |
383 |
|
|
continue; |
384 |
|
|
local_args_info.radius_given = 1; |
385 |
|
|
args_info->radius_given = 1; |
386 |
|
|
args_info->radius_arg = strtod (optarg, NULL); |
387 |
|
|
} |
388 |
|
|
/* Radius from the center of the particle to start a new shell in multi-component core-shell particle. Specified for each component > 1 in md file.. */ |
389 |
|
|
else if (strcmp (long_options[option_index].name, "ShellRadius") == 0) |
390 |
|
|
{ |
391 |
|
|
local_args_info.ShellRadius_given++; |
392 |
|
|
|
393 |
|
|
multi_token = get_multiple_arg_token(optarg); |
394 |
|
|
multi_next = get_multiple_arg_token_next (optarg); |
395 |
|
|
|
396 |
|
|
while (1) |
397 |
|
|
{ |
398 |
|
|
ShellRadius_new = (struct ShellRadius_list *) malloc (sizeof (struct ShellRadius_list)); |
399 |
|
|
ShellRadius_new->next = ShellRadius_list; |
400 |
|
|
ShellRadius_list = ShellRadius_new; |
401 |
|
|
ShellRadius_new->ShellRadius_arg = strtod (multi_token, NULL); |
402 |
|
|
free (multi_token); |
403 |
|
|
|
404 |
|
|
if (multi_next) |
405 |
|
|
{ |
406 |
|
|
multi_token = get_multiple_arg_token(multi_next); |
407 |
|
|
multi_next = get_multiple_arg_token_next (multi_next); |
408 |
|
|
local_args_info.ShellRadius_given++; |
409 |
|
|
} |
410 |
|
|
else |
411 |
|
|
break; |
412 |
|
|
} |
413 |
|
|
break; |
414 |
|
|
} |
415 |
|
|
/* (Default) Builds a multi-component random mixed nanoparticle. Mole Fraction must be specified for each componet > 1 in MD file.. */ |
416 |
|
|
else if (strcmp (long_options[option_index].name, "molFraction") == 0) |
417 |
|
|
{ |
418 |
|
|
local_args_info.molFraction_given++; |
419 |
|
|
|
420 |
|
|
multi_token = get_multiple_arg_token(optarg); |
421 |
|
|
multi_next = get_multiple_arg_token_next (optarg); |
422 |
|
|
|
423 |
|
|
while (1) |
424 |
|
|
{ |
425 |
|
|
molFraction_new = (struct molFraction_list *) malloc (sizeof (struct molFraction_list)); |
426 |
|
|
molFraction_new->next = molFraction_list; |
427 |
|
|
molFraction_list = molFraction_new; |
428 |
|
|
molFraction_new->molFraction_arg = strtod (multi_token, NULL); |
429 |
|
|
free (multi_token); |
430 |
|
|
|
431 |
|
|
if (multi_next) |
432 |
|
|
{ |
433 |
|
|
multi_token = get_multiple_arg_token(multi_next); |
434 |
|
|
multi_next = get_multiple_arg_token_next (multi_next); |
435 |
|
|
local_args_info.molFraction_given++; |
436 |
|
|
} |
437 |
|
|
else |
438 |
|
|
break; |
439 |
|
|
} |
440 |
|
|
break; |
441 |
|
|
} |
442 |
|
|
/* Percentage of vacancies to build. */ |
443 |
|
|
else if (strcmp (long_options[option_index].name, "vacancyPCT") == 0) |
444 |
|
|
{ |
445 |
|
|
if (local_args_info.vacancyPCT_given) |
446 |
|
|
{ |
447 |
|
|
fprintf (stderr, "%s: `--vacancyPCT' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); |
448 |
|
|
goto failure; |
449 |
|
|
} |
450 |
|
|
if (args_info->vacancyPCT_given && ! override) |
451 |
|
|
continue; |
452 |
|
|
local_args_info.vacancyPCT_given = 1; |
453 |
|
|
args_info->vacancyPCT_given = 1; |
454 |
|
|
args_info->vacancyPCT_arg = strtod (optarg, NULL); |
455 |
|
|
} |
456 |
|
|
/* Radius arround core-shell where vacancies should be located.. */ |
457 |
|
|
else if (strcmp (long_options[option_index].name, "vacancyRadius") == 0) |
458 |
|
|
{ |
459 |
|
|
local_args_info.vacancyRadius_given++; |
460 |
|
|
|
461 |
|
|
multi_token = get_multiple_arg_token(optarg); |
462 |
|
|
multi_next = get_multiple_arg_token_next (optarg); |
463 |
|
|
|
464 |
|
|
while (1) |
465 |
|
|
{ |
466 |
|
|
vacancyRadius_new = (struct vacancyRadius_list *) malloc (sizeof (struct vacancyRadius_list)); |
467 |
|
|
vacancyRadius_new->next = vacancyRadius_list; |
468 |
|
|
vacancyRadius_list = vacancyRadius_new; |
469 |
|
|
vacancyRadius_new->vacancyRadius_arg = strtod (multi_token, NULL); |
470 |
|
|
free (multi_token); |
471 |
|
|
|
472 |
|
|
if (multi_next) |
473 |
|
|
{ |
474 |
|
|
multi_token = get_multiple_arg_token(multi_next); |
475 |
|
|
multi_next = get_multiple_arg_token_next (multi_next); |
476 |
|
|
local_args_info.vacancyRadius_given++; |
477 |
|
|
} |
478 |
|
|
else |
479 |
|
|
break; |
480 |
|
|
} |
481 |
|
|
break; |
482 |
|
|
} |
483 |
|
|
|
484 |
|
|
break; |
485 |
|
|
case '?': /* Invalid option. */ |
486 |
|
|
/* `getopt_long' already printed an error message. */ |
487 |
|
|
goto failure; |
488 |
|
|
|
489 |
|
|
default: /* bug: option not considered. */ |
490 |
|
|
fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : "")); |
491 |
|
|
abort (); |
492 |
|
|
} /* switch */ |
493 |
|
|
} /* while */ |
494 |
|
|
|
495 |
|
|
|
496 |
|
|
if (local_args_info.ShellRadius_given && ShellRadius_list) |
497 |
|
|
{ |
498 |
|
|
struct ShellRadius_list *tmp; |
499 |
|
|
args_info->ShellRadius_arg = (double *) realloc (args_info->ShellRadius_arg, (args_info->ShellRadius_given + local_args_info.ShellRadius_given) * sizeof (double)); |
500 |
|
|
for (i = (local_args_info.ShellRadius_given - 1); i >= 0; --i) |
501 |
|
|
{ |
502 |
|
|
tmp = ShellRadius_list; |
503 |
|
|
args_info->ShellRadius_arg [i + args_info->ShellRadius_given] = ShellRadius_list->ShellRadius_arg; |
504 |
|
|
ShellRadius_list = ShellRadius_list->next; |
505 |
|
|
free (tmp); |
506 |
|
|
} |
507 |
|
|
} |
508 |
|
|
|
509 |
|
|
if (local_args_info.molFraction_given && molFraction_list) |
510 |
|
|
{ |
511 |
|
|
struct molFraction_list *tmp; |
512 |
|
|
args_info->molFraction_arg = (double *) realloc (args_info->molFraction_arg, (args_info->molFraction_given + local_args_info.molFraction_given) * sizeof (double)); |
513 |
|
|
for (i = (local_args_info.molFraction_given - 1); i >= 0; --i) |
514 |
|
|
{ |
515 |
|
|
tmp = molFraction_list; |
516 |
|
|
args_info->molFraction_arg [i + args_info->molFraction_given] = molFraction_list->molFraction_arg; |
517 |
|
|
molFraction_list = molFraction_list->next; |
518 |
|
|
free (tmp); |
519 |
|
|
} |
520 |
|
|
} |
521 |
|
|
|
522 |
|
|
if (local_args_info.vacancyRadius_given && vacancyRadius_list) |
523 |
|
|
{ |
524 |
|
|
struct vacancyRadius_list *tmp; |
525 |
|
|
args_info->vacancyRadius_arg = (double *) realloc (args_info->vacancyRadius_arg, (args_info->vacancyRadius_given + local_args_info.vacancyRadius_given) * sizeof (double)); |
526 |
|
|
for (i = (local_args_info.vacancyRadius_given - 1); i >= 0; --i) |
527 |
|
|
{ |
528 |
|
|
tmp = vacancyRadius_list; |
529 |
|
|
args_info->vacancyRadius_arg [i + args_info->vacancyRadius_given] = vacancyRadius_list->vacancyRadius_arg; |
530 |
|
|
vacancyRadius_list = vacancyRadius_list->next; |
531 |
|
|
free (tmp); |
532 |
|
|
} |
533 |
|
|
} |
534 |
|
|
|
535 |
|
|
|
536 |
|
|
args_info->ShellRadius_given += local_args_info.ShellRadius_given; |
537 |
|
|
local_args_info.ShellRadius_given = 0; |
538 |
|
|
args_info->molFraction_given += local_args_info.molFraction_given; |
539 |
|
|
local_args_info.molFraction_given = 0; |
540 |
|
|
args_info->vacancyRadius_given += local_args_info.vacancyRadius_given; |
541 |
|
|
local_args_info.vacancyRadius_given = 0; |
542 |
|
|
|
543 |
|
|
if (check_required) |
544 |
|
|
{ |
545 |
|
|
error += cmdline_parser_required2 (args_info, argv[0], additional_error); |
546 |
|
|
} |
547 |
|
|
|
548 |
|
|
cmdline_parser_free (&local_args_info); |
549 |
|
|
|
550 |
|
|
if ( error ) |
551 |
|
|
return (EXIT_FAILURE); |
552 |
|
|
|
553 |
|
|
if (optind < argc) |
554 |
|
|
{ |
555 |
|
|
int i = 0 ; |
556 |
|
|
|
557 |
|
|
args_info->inputs_num = argc - optind ; |
558 |
|
|
args_info->inputs = |
559 |
|
|
(char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ; |
560 |
|
|
while (optind < argc) |
561 |
|
|
args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind++]) ; |
562 |
|
|
} |
563 |
|
|
|
564 |
|
|
return 0; |
565 |
|
|
|
566 |
|
|
failure: |
567 |
|
|
if (ShellRadius_list) |
568 |
|
|
{ |
569 |
|
|
struct ShellRadius_list *tmp; |
570 |
|
|
while (ShellRadius_list) |
571 |
|
|
{ |
572 |
|
|
tmp = ShellRadius_list; |
573 |
|
|
ShellRadius_list = ShellRadius_list->next; |
574 |
|
|
free (tmp); |
575 |
|
|
} |
576 |
|
|
} |
577 |
|
|
if (molFraction_list) |
578 |
|
|
{ |
579 |
|
|
struct molFraction_list *tmp; |
580 |
|
|
while (molFraction_list) |
581 |
|
|
{ |
582 |
|
|
tmp = molFraction_list; |
583 |
|
|
molFraction_list = molFraction_list->next; |
584 |
|
|
free (tmp); |
585 |
|
|
} |
586 |
|
|
} |
587 |
|
|
if (vacancyRadius_list) |
588 |
|
|
{ |
589 |
|
|
struct vacancyRadius_list *tmp; |
590 |
|
|
while (vacancyRadius_list) |
591 |
|
|
{ |
592 |
|
|
tmp = vacancyRadius_list; |
593 |
|
|
vacancyRadius_list = vacancyRadius_list->next; |
594 |
|
|
free (tmp); |
595 |
|
|
} |
596 |
|
|
} |
597 |
|
|
|
598 |
|
|
cmdline_parser_free (&local_args_info); |
599 |
|
|
return (EXIT_FAILURE); |
600 |
|
|
} |