ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-3.0/src/applications/staticProps/GofrCmd.c
Revision: 1990
Committed: Wed Feb 9 17:08:22 2005 UTC (19 years, 5 months ago) by tim
Content type: text/plain
File size: 6002 byte(s)
Log Message:
adding GofR

File Contents

# Content
1 /*
2 File autogenerated by gengetopt version 2.11
3 generated with the following command:
4 /home/maul/gezelter/tim/bin/gengetopt -F GofrCmd
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
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 "GofrCmd.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 "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 printf(" -n, --frame=INT print every n frame (default=`1')\n");
43 printf(" --sele1=selection script select first stuntdouble set\n");
44 printf(" --sele2=selection script select second stuntdouble set\n");
45 }
46
47
48 static char *gengetopt_strdup (const char *s);
49
50 /* gengetopt_strdup() */
51 /* strdup.c replacement of strdup, which is not standard */
52 char *
53 gengetopt_strdup (const char *s)
54 {
55 char *result = (char*)malloc(strlen(s) + 1);
56 if (result == (char*)0)
57 return (char*)0;
58 strcpy(result, s);
59 return result;
60 }
61
62 int
63 cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
64 {
65 int c; /* Character of the parsed option. */
66 int missing_required_options = 0;
67
68 args_info->help_given = 0 ;
69 args_info->version_given = 0 ;
70 args_info->input_given = 0 ;
71 args_info->output_given = 0 ;
72 args_info->frame_given = 0 ;
73 args_info->sele1_given = 0 ;
74 args_info->sele2_given = 0 ;
75 #define clear_args() { \
76 args_info->input_arg = NULL; \
77 args_info->output_arg = NULL; \
78 args_info->frame_arg = 1 ;\
79 args_info->sele1_arg = NULL; \
80 args_info->sele2_arg = NULL; \
81 }
82
83 clear_args();
84
85 optarg = 0;
86 optind = 1;
87 opterr = 1;
88 optopt = '?';
89
90 while (1)
91 {
92 int option_index = 0;
93 char *stop_char;
94
95 static struct option long_options[] = {
96 { "help", 0, NULL, 'h' },
97 { "version", 0, NULL, 'V' },
98 { "input", 1, NULL, 'i' },
99 { "output", 1, NULL, 'o' },
100 { "frame", 1, NULL, 'n' },
101 { "sele1", 1, NULL, 0 },
102 { "sele2", 1, NULL, 0 },
103 { NULL, 0, NULL, 0 }
104 };
105
106 stop_char = 0;
107 c = getopt_long (argc, argv, "hVi:o:n:", long_options, &option_index);
108
109 if (c == -1) break; /* Exit from `while (1)' loop. */
110
111 switch (c)
112 {
113 case 'h': /* Print help and exit. */
114 clear_args ();
115 cmdline_parser_print_help ();
116 exit (EXIT_SUCCESS);
117
118 case 'V': /* Print version and exit. */
119 clear_args ();
120 cmdline_parser_print_version ();
121 exit (EXIT_SUCCESS);
122
123 case 'i': /* input dump file. */
124 if (args_info->input_given)
125 {
126 fprintf (stderr, "%s: `--input' (`-i') option given more than once\n", CMDLINE_PARSER_PACKAGE);
127 clear_args ();
128 exit (EXIT_FAILURE);
129 }
130 args_info->input_given = 1;
131 args_info->input_arg = gengetopt_strdup (optarg);
132 break;
133
134 case 'o': /* output file name. */
135 if (args_info->output_given)
136 {
137 fprintf (stderr, "%s: `--output' (`-o') option given more than once\n", CMDLINE_PARSER_PACKAGE);
138 clear_args ();
139 exit (EXIT_FAILURE);
140 }
141 args_info->output_given = 1;
142 args_info->output_arg = gengetopt_strdup (optarg);
143 break;
144
145 case 'n': /* print every n frame. */
146 if (args_info->frame_given)
147 {
148 fprintf (stderr, "%s: `--frame' (`-n') option given more than once\n", CMDLINE_PARSER_PACKAGE);
149 clear_args ();
150 exit (EXIT_FAILURE);
151 }
152 args_info->frame_given = 1;
153 args_info->frame_arg = strtol (optarg,&stop_char,0);
154 break;
155
156
157 case 0: /* Long option with no short option */
158 /* select first stuntdouble set. */
159 if (strcmp (long_options[option_index].name, "sele1") == 0)
160 {
161 if (args_info->sele1_given)
162 {
163 fprintf (stderr, "%s: `--sele1' option given more than once\n", CMDLINE_PARSER_PACKAGE);
164 clear_args ();
165 exit (EXIT_FAILURE);
166 }
167 args_info->sele1_given = 1;
168 args_info->sele1_arg = gengetopt_strdup (optarg);
169 break;
170 }
171
172 /* select second stuntdouble set. */
173 else if (strcmp (long_options[option_index].name, "sele2") == 0)
174 {
175 if (args_info->sele2_given)
176 {
177 fprintf (stderr, "%s: `--sele2' option given more than once\n", CMDLINE_PARSER_PACKAGE);
178 clear_args ();
179 exit (EXIT_FAILURE);
180 }
181 args_info->sele2_given = 1;
182 args_info->sele2_arg = gengetopt_strdup (optarg);
183 break;
184 }
185
186
187 case '?': /* Invalid option. */
188 /* `getopt_long' already printed an error message. */
189 exit (EXIT_FAILURE);
190
191 default: /* bug: option not considered. */
192 fprintf (stderr, "%s: option unknown: %c\n", CMDLINE_PARSER_PACKAGE, c);
193 abort ();
194 } /* switch */
195 } /* while */
196
197
198 if (! args_info->input_given)
199 {
200 fprintf (stderr, "%s: '--input' ('-i') option required\n", CMDLINE_PARSER_PACKAGE);
201 missing_required_options = 1;
202 }
203 if ( missing_required_options )
204 exit (EXIT_FAILURE);
205
206 return 0;
207 }