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