1 |
tim |
310 |
/* |
2 |
|
|
File autogenerated by gengetopt version 2.11 |
3 |
|
|
generated with the following command: |
4 |
tim |
311 |
/home/maul/gezelter/tim/bin/gengetopt -F StaticPropsCmd |
5 |
tim |
310 |
|
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 |
|
|
|
16 |
|
|
/* If we use autoconf. */ |
17 |
|
|
#ifdef HAVE_CONFIG_H |
18 |
|
|
#include "config.h" |
19 |
|
|
#endif |
20 |
|
|
|
21 |
|
|
#include "getopt.h" |
22 |
|
|
|
23 |
tim |
311 |
#include "StaticPropsCmd.h" |
24 |
tim |
310 |
|
25 |
|
|
void |
26 |
|
|
cmdline_parser_print_version (void) |
27 |
|
|
{ |
28 |
|
|
printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION); |
29 |
|
|
} |
30 |
|
|
|
31 |
|
|
void |
32 |
|
|
cmdline_parser_print_help (void) |
33 |
|
|
{ |
34 |
|
|
cmdline_parser_print_version (); |
35 |
|
|
printf("\n" |
36 |
|
|
"Usage: %s [OPTIONS]...\n", CMDLINE_PARSER_PACKAGE); |
37 |
|
|
printf("\n"); |
38 |
|
|
printf(" -h, --help Print help and exit\n"); |
39 |
|
|
printf(" -V, --version Print version and exit\n"); |
40 |
|
|
printf(" -i, --input=filename input dump file\n"); |
41 |
|
|
printf(" -o, --output=filename output file name\n"); |
42 |
tim |
311 |
printf(" -n, --step=INT process every n frame (default=`1')\n"); |
43 |
|
|
printf(" -r, --nrbins=INT number of bins for distance (default=`50')\n"); |
44 |
tim |
310 |
printf(" -a, --nanglebins=INT number of bins for cos(angle) (default=`50')\n"); |
45 |
tim |
326 |
printf(" -l, --length=DOUBLE maximum length (Defaults to cutoff radius)\n"); |
46 |
tim |
310 |
printf(" --sele1=selection script select first stuntdouble set\n"); |
47 |
|
|
printf(" --sele2=selection script select second stuntdouble set\n"); |
48 |
|
|
printf("\n"); |
49 |
|
|
printf(" Group: staticProps an option of this group is required\n"); |
50 |
|
|
printf(" --gofr g(r)\n"); |
51 |
|
|
printf(" --r_theta g(r, cos(theta))\n"); |
52 |
|
|
printf(" --r_omega g(r, cos(omega))\n"); |
53 |
|
|
printf(" --theta_omega g(cos(theta), cos(omega))\n"); |
54 |
|
|
printf(" --xyz g(x, y, z)\n"); |
55 |
|
|
} |
56 |
|
|
|
57 |
|
|
|
58 |
|
|
static char *gengetopt_strdup (const char *s); |
59 |
|
|
|
60 |
|
|
/* gengetopt_strdup() */ |
61 |
|
|
/* strdup.c replacement of strdup, which is not standard */ |
62 |
|
|
char * |
63 |
|
|
gengetopt_strdup (const char *s) |
64 |
|
|
{ |
65 |
|
|
char *result = (char*)malloc(strlen(s) + 1); |
66 |
|
|
if (result == (char*)0) |
67 |
|
|
return (char*)0; |
68 |
|
|
strcpy(result, s); |
69 |
|
|
return result; |
70 |
|
|
} |
71 |
|
|
|
72 |
|
|
int |
73 |
|
|
cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info) |
74 |
|
|
{ |
75 |
|
|
int c; /* Character of the parsed option. */ |
76 |
|
|
int missing_required_options = 0; |
77 |
|
|
int staticProps_group_counter = 0; |
78 |
|
|
|
79 |
|
|
|
80 |
|
|
args_info->help_given = 0 ; |
81 |
|
|
args_info->version_given = 0 ; |
82 |
|
|
args_info->input_given = 0 ; |
83 |
|
|
args_info->output_given = 0 ; |
84 |
tim |
311 |
args_info->step_given = 0 ; |
85 |
|
|
args_info->nrbins_given = 0 ; |
86 |
tim |
310 |
args_info->nanglebins_given = 0 ; |
87 |
|
|
args_info->length_given = 0 ; |
88 |
|
|
args_info->sele1_given = 0 ; |
89 |
|
|
args_info->sele2_given = 0 ; |
90 |
|
|
args_info->gofr_given = 0 ; |
91 |
|
|
args_info->r_theta_given = 0 ; |
92 |
|
|
args_info->r_omega_given = 0 ; |
93 |
|
|
args_info->theta_omega_given = 0 ; |
94 |
|
|
args_info->xyz_given = 0 ; |
95 |
|
|
#define clear_args() { \ |
96 |
|
|
args_info->input_arg = NULL; \ |
97 |
|
|
args_info->output_arg = NULL; \ |
98 |
tim |
311 |
args_info->step_arg = 1 ;\ |
99 |
|
|
args_info->nrbins_arg = 50 ;\ |
100 |
tim |
310 |
args_info->nanglebins_arg = 50 ;\ |
101 |
|
|
args_info->sele1_arg = NULL; \ |
102 |
|
|
args_info->sele2_arg = NULL; \ |
103 |
|
|
} |
104 |
|
|
|
105 |
|
|
clear_args(); |
106 |
|
|
|
107 |
|
|
optarg = 0; |
108 |
|
|
optind = 1; |
109 |
|
|
opterr = 1; |
110 |
|
|
optopt = '?'; |
111 |
|
|
|
112 |
|
|
while (1) |
113 |
|
|
{ |
114 |
|
|
int option_index = 0; |
115 |
|
|
char *stop_char; |
116 |
|
|
|
117 |
|
|
static struct option long_options[] = { |
118 |
|
|
{ "help", 0, NULL, 'h' }, |
119 |
|
|
{ "version", 0, NULL, 'V' }, |
120 |
|
|
{ "input", 1, NULL, 'i' }, |
121 |
|
|
{ "output", 1, NULL, 'o' }, |
122 |
tim |
311 |
{ "step", 1, NULL, 'n' }, |
123 |
|
|
{ "nrbins", 1, NULL, 'r' }, |
124 |
tim |
310 |
{ "nanglebins", 1, NULL, 'a' }, |
125 |
|
|
{ "length", 1, NULL, 'l' }, |
126 |
|
|
{ "sele1", 1, NULL, 0 }, |
127 |
|
|
{ "sele2", 1, NULL, 0 }, |
128 |
|
|
{ "gofr", 0, NULL, 0 }, |
129 |
|
|
{ "r_theta", 0, NULL, 0 }, |
130 |
|
|
{ "r_omega", 0, NULL, 0 }, |
131 |
|
|
{ "theta_omega", 0, NULL, 0 }, |
132 |
|
|
{ "xyz", 0, NULL, 0 }, |
133 |
|
|
{ NULL, 0, NULL, 0 } |
134 |
|
|
}; |
135 |
|
|
|
136 |
|
|
stop_char = 0; |
137 |
tim |
311 |
c = getopt_long (argc, argv, "hVi:o:n:r:a:l:", long_options, &option_index); |
138 |
tim |
310 |
|
139 |
|
|
if (c == -1) break; /* Exit from `while (1)' loop. */ |
140 |
|
|
|
141 |
|
|
switch (c) |
142 |
|
|
{ |
143 |
|
|
case 'h': /* Print help and exit. */ |
144 |
|
|
clear_args (); |
145 |
|
|
cmdline_parser_print_help (); |
146 |
|
|
exit (EXIT_SUCCESS); |
147 |
|
|
|
148 |
|
|
case 'V': /* Print version and exit. */ |
149 |
|
|
clear_args (); |
150 |
|
|
cmdline_parser_print_version (); |
151 |
|
|
exit (EXIT_SUCCESS); |
152 |
|
|
|
153 |
|
|
case 'i': /* input dump file. */ |
154 |
|
|
if (args_info->input_given) |
155 |
|
|
{ |
156 |
|
|
fprintf (stderr, "%s: `--input' (`-i') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
157 |
|
|
clear_args (); |
158 |
|
|
exit (EXIT_FAILURE); |
159 |
|
|
} |
160 |
|
|
args_info->input_given = 1; |
161 |
|
|
args_info->input_arg = gengetopt_strdup (optarg); |
162 |
|
|
break; |
163 |
|
|
|
164 |
|
|
case 'o': /* output file name. */ |
165 |
|
|
if (args_info->output_given) |
166 |
|
|
{ |
167 |
|
|
fprintf (stderr, "%s: `--output' (`-o') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
168 |
|
|
clear_args (); |
169 |
|
|
exit (EXIT_FAILURE); |
170 |
|
|
} |
171 |
|
|
args_info->output_given = 1; |
172 |
|
|
args_info->output_arg = gengetopt_strdup (optarg); |
173 |
|
|
break; |
174 |
|
|
|
175 |
tim |
311 |
case 'n': /* process every n frame. */ |
176 |
|
|
if (args_info->step_given) |
177 |
tim |
310 |
{ |
178 |
tim |
311 |
fprintf (stderr, "%s: `--step' (`-n') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
179 |
tim |
310 |
clear_args (); |
180 |
|
|
exit (EXIT_FAILURE); |
181 |
|
|
} |
182 |
tim |
311 |
args_info->step_given = 1; |
183 |
|
|
args_info->step_arg = strtol (optarg,&stop_char,0); |
184 |
tim |
310 |
break; |
185 |
|
|
|
186 |
tim |
311 |
case 'r': /* number of bins for distance. */ |
187 |
|
|
if (args_info->nrbins_given) |
188 |
tim |
310 |
{ |
189 |
tim |
311 |
fprintf (stderr, "%s: `--nrbins' (`-r') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
190 |
tim |
310 |
clear_args (); |
191 |
|
|
exit (EXIT_FAILURE); |
192 |
|
|
} |
193 |
tim |
311 |
args_info->nrbins_given = 1; |
194 |
|
|
args_info->nrbins_arg = strtol (optarg,&stop_char,0); |
195 |
tim |
310 |
break; |
196 |
|
|
|
197 |
|
|
case 'a': /* number of bins for cos(angle). */ |
198 |
|
|
if (args_info->nanglebins_given) |
199 |
|
|
{ |
200 |
|
|
fprintf (stderr, "%s: `--nanglebins' (`-a') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
201 |
|
|
clear_args (); |
202 |
|
|
exit (EXIT_FAILURE); |
203 |
|
|
} |
204 |
|
|
args_info->nanglebins_given = 1; |
205 |
|
|
args_info->nanglebins_arg = strtol (optarg,&stop_char,0); |
206 |
|
|
break; |
207 |
|
|
|
208 |
tim |
326 |
case 'l': /* maximum length (Defaults to cutoff radius). */ |
209 |
tim |
310 |
if (args_info->length_given) |
210 |
|
|
{ |
211 |
|
|
fprintf (stderr, "%s: `--length' (`-l') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
212 |
|
|
clear_args (); |
213 |
|
|
exit (EXIT_FAILURE); |
214 |
|
|
} |
215 |
|
|
args_info->length_given = 1; |
216 |
|
|
args_info->length_arg = strtod (optarg, NULL); |
217 |
|
|
break; |
218 |
|
|
|
219 |
|
|
|
220 |
|
|
case 0: /* Long option with no short option */ |
221 |
|
|
/* select first stuntdouble set. */ |
222 |
|
|
if (strcmp (long_options[option_index].name, "sele1") == 0) |
223 |
|
|
{ |
224 |
|
|
if (args_info->sele1_given) |
225 |
|
|
{ |
226 |
|
|
fprintf (stderr, "%s: `--sele1' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
227 |
|
|
clear_args (); |
228 |
|
|
exit (EXIT_FAILURE); |
229 |
|
|
} |
230 |
|
|
args_info->sele1_given = 1; |
231 |
|
|
args_info->sele1_arg = gengetopt_strdup (optarg); |
232 |
|
|
break; |
233 |
|
|
} |
234 |
|
|
|
235 |
|
|
/* select second stuntdouble set. */ |
236 |
|
|
else if (strcmp (long_options[option_index].name, "sele2") == 0) |
237 |
|
|
{ |
238 |
|
|
if (args_info->sele2_given) |
239 |
|
|
{ |
240 |
|
|
fprintf (stderr, "%s: `--sele2' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
241 |
|
|
clear_args (); |
242 |
|
|
exit (EXIT_FAILURE); |
243 |
|
|
} |
244 |
|
|
args_info->sele2_given = 1; |
245 |
|
|
args_info->sele2_arg = gengetopt_strdup (optarg); |
246 |
|
|
break; |
247 |
|
|
} |
248 |
|
|
|
249 |
|
|
/* g(r). */ |
250 |
|
|
else if (strcmp (long_options[option_index].name, "gofr") == 0) |
251 |
|
|
{ |
252 |
|
|
if (args_info->gofr_given) |
253 |
|
|
{ |
254 |
|
|
fprintf (stderr, "%s: `--gofr' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
255 |
|
|
clear_args (); |
256 |
|
|
exit (EXIT_FAILURE); |
257 |
|
|
} |
258 |
|
|
args_info->gofr_given = 1; staticProps_group_counter += 1; |
259 |
|
|
|
260 |
|
|
break; |
261 |
|
|
} |
262 |
|
|
|
263 |
|
|
/* g(r, cos(theta)). */ |
264 |
|
|
else if (strcmp (long_options[option_index].name, "r_theta") == 0) |
265 |
|
|
{ |
266 |
|
|
if (args_info->r_theta_given) |
267 |
|
|
{ |
268 |
|
|
fprintf (stderr, "%s: `--r_theta' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
269 |
|
|
clear_args (); |
270 |
|
|
exit (EXIT_FAILURE); |
271 |
|
|
} |
272 |
|
|
args_info->r_theta_given = 1; staticProps_group_counter += 1; |
273 |
|
|
|
274 |
|
|
break; |
275 |
|
|
} |
276 |
|
|
|
277 |
|
|
/* g(r, cos(omega)). */ |
278 |
|
|
else if (strcmp (long_options[option_index].name, "r_omega") == 0) |
279 |
|
|
{ |
280 |
|
|
if (args_info->r_omega_given) |
281 |
|
|
{ |
282 |
|
|
fprintf (stderr, "%s: `--r_omega' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
283 |
|
|
clear_args (); |
284 |
|
|
exit (EXIT_FAILURE); |
285 |
|
|
} |
286 |
|
|
args_info->r_omega_given = 1; staticProps_group_counter += 1; |
287 |
|
|
|
288 |
|
|
break; |
289 |
|
|
} |
290 |
|
|
|
291 |
|
|
/* g(cos(theta), cos(omega)). */ |
292 |
|
|
else if (strcmp (long_options[option_index].name, "theta_omega") == 0) |
293 |
|
|
{ |
294 |
|
|
if (args_info->theta_omega_given) |
295 |
|
|
{ |
296 |
|
|
fprintf (stderr, "%s: `--theta_omega' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
297 |
|
|
clear_args (); |
298 |
|
|
exit (EXIT_FAILURE); |
299 |
|
|
} |
300 |
|
|
args_info->theta_omega_given = 1; staticProps_group_counter += 1; |
301 |
|
|
|
302 |
|
|
break; |
303 |
|
|
} |
304 |
|
|
|
305 |
|
|
/* g(x, y, z). */ |
306 |
|
|
else if (strcmp (long_options[option_index].name, "xyz") == 0) |
307 |
|
|
{ |
308 |
|
|
if (args_info->xyz_given) |
309 |
|
|
{ |
310 |
|
|
fprintf (stderr, "%s: `--xyz' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
311 |
|
|
clear_args (); |
312 |
|
|
exit (EXIT_FAILURE); |
313 |
|
|
} |
314 |
|
|
args_info->xyz_given = 1; staticProps_group_counter += 1; |
315 |
|
|
|
316 |
|
|
break; |
317 |
|
|
} |
318 |
|
|
|
319 |
|
|
|
320 |
|
|
case '?': /* Invalid option. */ |
321 |
|
|
/* `getopt_long' already printed an error message. */ |
322 |
|
|
exit (EXIT_FAILURE); |
323 |
|
|
|
324 |
|
|
default: /* bug: option not considered. */ |
325 |
|
|
fprintf (stderr, "%s: option unknown: %c\n", CMDLINE_PARSER_PACKAGE, c); |
326 |
|
|
abort (); |
327 |
|
|
} /* switch */ |
328 |
|
|
} /* while */ |
329 |
|
|
|
330 |
|
|
if ( staticProps_group_counter != 1) |
331 |
|
|
{ |
332 |
|
|
fprintf (stderr, "%s: %d options of group staticProps were given. One is required\n", CMDLINE_PARSER_PACKAGE, staticProps_group_counter); |
333 |
|
|
missing_required_options = 1; |
334 |
|
|
} |
335 |
|
|
|
336 |
|
|
|
337 |
|
|
if (! args_info->input_given) |
338 |
|
|
{ |
339 |
|
|
fprintf (stderr, "%s: '--input' ('-i') option required\n", CMDLINE_PARSER_PACKAGE); |
340 |
|
|
missing_required_options = 1; |
341 |
|
|
} |
342 |
|
|
if ( missing_required_options ) |
343 |
|
|
exit (EXIT_FAILURE); |
344 |
|
|
|
345 |
|
|
return 0; |
346 |
|
|
} |