ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-3.0/src/applications/staticProps/StaticPropsCmd.c
Revision: 2053
Committed: Fri Feb 18 23:07:32 2005 UTC (19 years, 4 months ago) by tim
Content type: text/plain
File size: 12282 byte(s)
Log Message:
adding LipidTransVisitor, GofXyz is working now

File Contents

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