1 |
tim |
320 |
/* |
2 |
|
|
File autogenerated by gengetopt version 2.11 |
3 |
|
|
generated with the following command: |
4 |
tim |
876 |
/home/maul/gezelter/tim/program/gengetopt-2.11/src/gengetopt -F DynamicPropsCmd |
5 |
tim |
320 |
|
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 |
|
|
#include "DynamicPropsCmd.h" |
24 |
|
|
|
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 |
tim |
876 |
"Usage: %s [OPTIONS]...\n", CMDLINE_PARSER_PACKAGE); |
37 |
tim |
320 |
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 |
|
|
printf(" --sele1=selection script select first stuntdouble set\n"); |
43 |
|
|
printf(" --sele2=selection script select second stuntdouble set (if sele2 is not \n set, use script from sele1)\n"); |
44 |
tim |
876 |
printf(" --order=INT Lengendre Polynomial Order\n"); |
45 |
tim |
320 |
printf("\n"); |
46 |
|
|
printf(" Group: dynamicProps an option of this group is required\n"); |
47 |
tim |
916 |
printf(" -m, --rmsd rmsd\n"); |
48 |
|
|
printf(" -r, --rcorr position correlation function\n"); |
49 |
tim |
320 |
printf(" -v, --vcorr velocity correlation function\n"); |
50 |
|
|
printf(" -d, --dcorr dipole correlation function\n"); |
51 |
tim |
876 |
printf(" -l, --lcorr Lengendre correlation function\n"); |
52 |
tim |
320 |
} |
53 |
|
|
|
54 |
|
|
|
55 |
|
|
static char *gengetopt_strdup (const char *s); |
56 |
|
|
|
57 |
|
|
/* gengetopt_strdup() */ |
58 |
|
|
/* strdup.c replacement of strdup, which is not standard */ |
59 |
|
|
char * |
60 |
|
|
gengetopt_strdup (const char *s) |
61 |
|
|
{ |
62 |
|
|
char *result = (char*)malloc(strlen(s) + 1); |
63 |
|
|
if (result == (char*)0) |
64 |
|
|
return (char*)0; |
65 |
|
|
strcpy(result, s); |
66 |
|
|
return result; |
67 |
|
|
} |
68 |
|
|
|
69 |
|
|
int |
70 |
|
|
cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info) |
71 |
|
|
{ |
72 |
|
|
int c; /* Character of the parsed option. */ |
73 |
|
|
int missing_required_options = 0; |
74 |
|
|
int dynamicProps_group_counter = 0; |
75 |
|
|
|
76 |
|
|
|
77 |
|
|
args_info->help_given = 0 ; |
78 |
|
|
args_info->version_given = 0 ; |
79 |
|
|
args_info->input_given = 0 ; |
80 |
|
|
args_info->output_given = 0 ; |
81 |
|
|
args_info->sele1_given = 0 ; |
82 |
|
|
args_info->sele2_given = 0 ; |
83 |
tim |
876 |
args_info->order_given = 0 ; |
84 |
tim |
916 |
args_info->rmsd_given = 0 ; |
85 |
tim |
320 |
args_info->rcorr_given = 0 ; |
86 |
|
|
args_info->vcorr_given = 0 ; |
87 |
|
|
args_info->dcorr_given = 0 ; |
88 |
tim |
876 |
args_info->lcorr_given = 0 ; |
89 |
|
|
#define clear_args() { \ |
90 |
|
|
args_info->input_arg = NULL; \ |
91 |
|
|
args_info->output_arg = NULL; \ |
92 |
|
|
args_info->sele1_arg = NULL; \ |
93 |
|
|
args_info->sele2_arg = NULL; \ |
94 |
|
|
} |
95 |
tim |
320 |
|
96 |
|
|
clear_args(); |
97 |
|
|
|
98 |
|
|
optarg = 0; |
99 |
|
|
optind = 1; |
100 |
|
|
opterr = 1; |
101 |
|
|
optopt = '?'; |
102 |
|
|
|
103 |
|
|
while (1) |
104 |
|
|
{ |
105 |
|
|
int option_index = 0; |
106 |
|
|
char *stop_char; |
107 |
|
|
|
108 |
|
|
static struct option long_options[] = { |
109 |
|
|
{ "help", 0, NULL, 'h' }, |
110 |
|
|
{ "version", 0, NULL, 'V' }, |
111 |
|
|
{ "input", 1, NULL, 'i' }, |
112 |
|
|
{ "output", 1, NULL, 'o' }, |
113 |
|
|
{ "sele1", 1, NULL, 0 }, |
114 |
|
|
{ "sele2", 1, NULL, 0 }, |
115 |
tim |
876 |
{ "order", 1, NULL, 0 }, |
116 |
tim |
916 |
{ "rmsd", 0, NULL, 'm' }, |
117 |
tim |
320 |
{ "rcorr", 0, NULL, 'r' }, |
118 |
|
|
{ "vcorr", 0, NULL, 'v' }, |
119 |
|
|
{ "dcorr", 0, NULL, 'd' }, |
120 |
tim |
876 |
{ "lcorr", 0, NULL, 'l' }, |
121 |
tim |
320 |
{ NULL, 0, NULL, 0 } |
122 |
|
|
}; |
123 |
|
|
|
124 |
|
|
stop_char = 0; |
125 |
tim |
916 |
c = getopt_long (argc, argv, "hVi:o:mrvdl", long_options, &option_index); |
126 |
tim |
320 |
|
127 |
|
|
if (c == -1) break; /* Exit from `while (1)' loop. */ |
128 |
|
|
|
129 |
|
|
switch (c) |
130 |
|
|
{ |
131 |
|
|
case 'h': /* Print help and exit. */ |
132 |
|
|
clear_args (); |
133 |
|
|
cmdline_parser_print_help (); |
134 |
|
|
exit (EXIT_SUCCESS); |
135 |
|
|
|
136 |
|
|
case 'V': /* Print version and exit. */ |
137 |
|
|
clear_args (); |
138 |
|
|
cmdline_parser_print_version (); |
139 |
|
|
exit (EXIT_SUCCESS); |
140 |
|
|
|
141 |
|
|
case 'i': /* input dump file. */ |
142 |
|
|
if (args_info->input_given) |
143 |
|
|
{ |
144 |
|
|
fprintf (stderr, "%s: `--input' (`-i') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
145 |
|
|
clear_args (); |
146 |
|
|
exit (EXIT_FAILURE); |
147 |
|
|
} |
148 |
|
|
args_info->input_given = 1; |
149 |
|
|
args_info->input_arg = gengetopt_strdup (optarg); |
150 |
|
|
break; |
151 |
|
|
|
152 |
|
|
case 'o': /* output file name. */ |
153 |
|
|
if (args_info->output_given) |
154 |
|
|
{ |
155 |
|
|
fprintf (stderr, "%s: `--output' (`-o') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
156 |
|
|
clear_args (); |
157 |
|
|
exit (EXIT_FAILURE); |
158 |
|
|
} |
159 |
|
|
args_info->output_given = 1; |
160 |
|
|
args_info->output_arg = gengetopt_strdup (optarg); |
161 |
|
|
break; |
162 |
|
|
|
163 |
tim |
916 |
case 'm': /* rmsd. */ |
164 |
|
|
if (args_info->rmsd_given) |
165 |
|
|
{ |
166 |
|
|
fprintf (stderr, "%s: `--rmsd' (`-m') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
167 |
|
|
clear_args (); |
168 |
|
|
exit (EXIT_FAILURE); |
169 |
|
|
} |
170 |
|
|
args_info->rmsd_given = 1; |
171 |
|
|
dynamicProps_group_counter += 1; |
172 |
|
|
break; |
173 |
|
|
|
174 |
|
|
case 'r': /* position correlation function. */ |
175 |
tim |
320 |
if (args_info->rcorr_given) |
176 |
|
|
{ |
177 |
|
|
fprintf (stderr, "%s: `--rcorr' (`-r') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
178 |
|
|
clear_args (); |
179 |
|
|
exit (EXIT_FAILURE); |
180 |
|
|
} |
181 |
|
|
args_info->rcorr_given = 1; |
182 |
|
|
dynamicProps_group_counter += 1; |
183 |
tim |
876 |
break; |
184 |
tim |
320 |
|
185 |
|
|
case 'v': /* velocity correlation function. */ |
186 |
|
|
if (args_info->vcorr_given) |
187 |
|
|
{ |
188 |
|
|
fprintf (stderr, "%s: `--vcorr' (`-v') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
189 |
|
|
clear_args (); |
190 |
|
|
exit (EXIT_FAILURE); |
191 |
|
|
} |
192 |
|
|
args_info->vcorr_given = 1; |
193 |
|
|
dynamicProps_group_counter += 1; |
194 |
tim |
876 |
break; |
195 |
tim |
320 |
|
196 |
|
|
case 'd': /* dipole correlation function. */ |
197 |
|
|
if (args_info->dcorr_given) |
198 |
|
|
{ |
199 |
|
|
fprintf (stderr, "%s: `--dcorr' (`-d') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
200 |
|
|
clear_args (); |
201 |
|
|
exit (EXIT_FAILURE); |
202 |
|
|
} |
203 |
|
|
args_info->dcorr_given = 1; |
204 |
|
|
dynamicProps_group_counter += 1; |
205 |
tim |
876 |
break; |
206 |
tim |
320 |
|
207 |
tim |
876 |
case 'l': /* Lengendre correlation function. */ |
208 |
|
|
if (args_info->lcorr_given) |
209 |
|
|
{ |
210 |
|
|
fprintf (stderr, "%s: `--lcorr' (`-l') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
211 |
|
|
clear_args (); |
212 |
|
|
exit (EXIT_FAILURE); |
213 |
|
|
} |
214 |
|
|
args_info->lcorr_given = 1; |
215 |
|
|
dynamicProps_group_counter += 1; |
216 |
|
|
break; |
217 |
tim |
320 |
|
218 |
tim |
876 |
|
219 |
tim |
320 |
case 0: /* Long option with no short option */ |
220 |
|
|
/* select first stuntdouble set. */ |
221 |
|
|
if (strcmp (long_options[option_index].name, "sele1") == 0) |
222 |
tim |
876 |
{ |
223 |
|
|
if (args_info->sele1_given) |
224 |
|
|
{ |
225 |
|
|
fprintf (stderr, "%s: `--sele1' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
226 |
|
|
clear_args (); |
227 |
|
|
exit (EXIT_FAILURE); |
228 |
|
|
} |
229 |
|
|
args_info->sele1_given = 1; |
230 |
|
|
args_info->sele1_arg = gengetopt_strdup (optarg); |
231 |
|
|
break; |
232 |
|
|
} |
233 |
tim |
320 |
|
234 |
|
|
/* select second stuntdouble set (if sele2 is not set, use script from sele1). */ |
235 |
|
|
else if (strcmp (long_options[option_index].name, "sele2") == 0) |
236 |
tim |
876 |
{ |
237 |
|
|
if (args_info->sele2_given) |
238 |
|
|
{ |
239 |
|
|
fprintf (stderr, "%s: `--sele2' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
240 |
|
|
clear_args (); |
241 |
|
|
exit (EXIT_FAILURE); |
242 |
|
|
} |
243 |
|
|
args_info->sele2_given = 1; |
244 |
|
|
args_info->sele2_arg = gengetopt_strdup (optarg); |
245 |
|
|
break; |
246 |
|
|
} |
247 |
tim |
320 |
|
248 |
tim |
876 |
/* Lengendre Polynomial Order. */ |
249 |
|
|
else if (strcmp (long_options[option_index].name, "order") == 0) |
250 |
|
|
{ |
251 |
|
|
if (args_info->order_given) |
252 |
|
|
{ |
253 |
|
|
fprintf (stderr, "%s: `--order' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
254 |
|
|
clear_args (); |
255 |
|
|
exit (EXIT_FAILURE); |
256 |
|
|
} |
257 |
|
|
args_info->order_given = 1; |
258 |
|
|
args_info->order_arg = strtol (optarg,&stop_char,0); |
259 |
|
|
break; |
260 |
|
|
} |
261 |
|
|
|
262 |
tim |
320 |
|
263 |
|
|
case '?': /* Invalid option. */ |
264 |
|
|
/* `getopt_long' already printed an error message. */ |
265 |
|
|
exit (EXIT_FAILURE); |
266 |
|
|
|
267 |
|
|
default: /* bug: option not considered. */ |
268 |
|
|
fprintf (stderr, "%s: option unknown: %c\n", CMDLINE_PARSER_PACKAGE, c); |
269 |
|
|
abort (); |
270 |
|
|
} /* switch */ |
271 |
|
|
} /* while */ |
272 |
|
|
|
273 |
|
|
if ( dynamicProps_group_counter != 1) |
274 |
|
|
{ |
275 |
|
|
fprintf (stderr, "%s: %d options of group dynamicProps were given. One is required\n", CMDLINE_PARSER_PACKAGE, dynamicProps_group_counter); |
276 |
|
|
missing_required_options = 1; |
277 |
|
|
} |
278 |
|
|
|
279 |
|
|
|
280 |
|
|
if (! args_info->input_given) |
281 |
|
|
{ |
282 |
|
|
fprintf (stderr, "%s: '--input' ('-i') option required\n", CMDLINE_PARSER_PACKAGE); |
283 |
|
|
missing_required_options = 1; |
284 |
|
|
} |
285 |
|
|
if ( missing_required_options ) |
286 |
|
|
exit (EXIT_FAILURE); |
287 |
|
|
|
288 |
|
|
return 0; |
289 |
|
|
} |