blob: a84e7e88a494243fd0116b3318e908c0c65185d8 [file] [log] [blame]
jjako52c24142002-12-16 13:33:51 +00001/*
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +01002 File autogenerated by gengetopt version 2.22.6
jjako52c24142002-12-16 13:33:51 +00003 generated with the following command:
jjakoa7cd2492003-04-11 09:40:12 +00004 gengetopt --conf-parser
jjako52c24142002-12-16 13:33:51 +00005
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
jjako52c24142002-12-16 13:33:51 +000011/* If we use autoconf. */
12#ifdef HAVE_CONFIG_H
13#include "config.h"
14#endif
jjako52c24142002-12-16 13:33:51 +000015
Harald Welte1b3e5772010-05-04 11:13:56 +020016#include <stdio.h>
17#include <stdlib.h>
18#include <string.h>
19
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +010020#ifndef FIX_UNUSED
21#define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */
22#endif
23
24#include <getopt.h>
jjako52c24142002-12-16 13:33:51 +000025
26#include "cmdline.h"
27
Harald Welte1b3e5772010-05-04 11:13:56 +020028const char *gengetopt_args_info_purpose = "";
jjako52c24142002-12-16 13:33:51 +000029
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +010030const char *gengetopt_args_info_usage = "Usage: " CMDLINE_PARSER_PACKAGE " [OPTIONS]...";
31
32const char *gengetopt_args_info_versiontext = "";
33
34const char *gengetopt_args_info_description = "";
jjako52c24142002-12-16 13:33:51 +000035
Harald Welte1b3e5772010-05-04 11:13:56 +020036const char *gengetopt_args_info_help[] = {
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +010037 " -h, --help Print help and exit",
38 " -V, --version Print version and exit",
39 " -f, --fg Run in foreground (default=off)",
40 " -d, --debug Run in debug mode (default=off)",
41 " -c, --conf=STRING Read configuration file (default=`/etc/ggsn.conf')",
42 " --pidfile=STRING Filename of process id file\n (default=`/var/run/ggsn.pid')",
43 " --statedir=STRING Directory of nonvolatile data\n (default=`/var/lib/ggsn/')",
44 " -l, --listen=STRING Local interface",
45 " -n, --net=STRING Network (default=`192.168.0.0/24')",
46 " --ipup=STRING Script to run after link-up",
47 " --ipdown=STRING Script to run after link-down",
48 " --dynip=STRING Dynamic IP address pool",
49 " --statip=STRING Static IP address pool",
50 " --pcodns1=STRING PCO DNS Server 1 (default=`0.0.0.0')",
51 " --pcodns2=STRING PCO DNS Server 2 (default=`0.0.0.0')",
52 " --timelimit=INT Exit after timelimit seconds (default=`0')",
53 " -a, --apn=STRING Access point name (default=`internet')",
54 " -q, --qos=INT Requested quality of service (default=`0x0b921f')",
55 0
Harald Welte1b3e5772010-05-04 11:13:56 +020056};
57
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +010058typedef enum {ARG_NO
59 , ARG_FLAG
60 , ARG_STRING
61 , ARG_INT
62} cmdline_parser_arg_type;
63
Harald Welte1b3e5772010-05-04 11:13:56 +020064static
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +010065void clear_given (struct gengetopt_args_info *args_info);
Harald Welte1b3e5772010-05-04 11:13:56 +020066static
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +010067void clear_args (struct gengetopt_args_info *args_info);
Harald Welte1b3e5772010-05-04 11:13:56 +020068
69static int
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +010070cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info,
71 struct cmdline_parser_params *params, const char *additional_error);
Harald Welte1b3e5772010-05-04 11:13:56 +020072
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +010073struct line_list
74{
75 char * string_arg;
76 struct line_list * next;
Harald Welte1b3e5772010-05-04 11:13:56 +020077};
78
79static struct line_list *cmd_line_list = 0;
80static struct line_list *cmd_line_list_tmp = 0;
81
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +010082static void
83free_cmd_list(void)
Harald Welte1b3e5772010-05-04 11:13:56 +020084{
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +010085 /* free the list of a previous call */
86 if (cmd_line_list)
87 {
88 while (cmd_line_list) {
89 cmd_line_list_tmp = cmd_line_list;
90 cmd_line_list = cmd_line_list->next;
91 free (cmd_line_list_tmp->string_arg);
92 free (cmd_line_list_tmp);
93 }
94 }
jjako52c24142002-12-16 13:33:51 +000095}
96
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +010097
98static char *
99gengetopt_strdup (const char *s);
jjako52c24142002-12-16 13:33:51 +0000100
Harald Welte1b3e5772010-05-04 11:13:56 +0200101static
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100102void clear_given (struct gengetopt_args_info *args_info)
jjako52c24142002-12-16 13:33:51 +0000103{
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100104 args_info->help_given = 0 ;
105 args_info->version_given = 0 ;
106 args_info->fg_given = 0 ;
107 args_info->debug_given = 0 ;
108 args_info->conf_given = 0 ;
109 args_info->pidfile_given = 0 ;
110 args_info->statedir_given = 0 ;
111 args_info->listen_given = 0 ;
112 args_info->net_given = 0 ;
113 args_info->ipup_given = 0 ;
114 args_info->ipdown_given = 0 ;
115 args_info->dynip_given = 0 ;
116 args_info->statip_given = 0 ;
117 args_info->pcodns1_given = 0 ;
118 args_info->pcodns2_given = 0 ;
119 args_info->timelimit_given = 0 ;
120 args_info->apn_given = 0 ;
121 args_info->qos_given = 0 ;
jjako52c24142002-12-16 13:33:51 +0000122}
123
Harald Welte1b3e5772010-05-04 11:13:56 +0200124static
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100125void clear_args (struct gengetopt_args_info *args_info)
Harald Welte1b3e5772010-05-04 11:13:56 +0200126{
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100127 FIX_UNUSED (args_info);
128 args_info->fg_flag = 0;
129 args_info->debug_flag = 0;
130 args_info->conf_arg = gengetopt_strdup ("/etc/ggsn.conf");
131 args_info->conf_orig = NULL;
132 args_info->pidfile_arg = gengetopt_strdup ("/var/run/ggsn.pid");
133 args_info->pidfile_orig = NULL;
134 args_info->statedir_arg = gengetopt_strdup ("/var/lib/ggsn/");
135 args_info->statedir_orig = NULL;
136 args_info->listen_arg = NULL;
137 args_info->listen_orig = NULL;
138 args_info->net_arg = gengetopt_strdup ("192.168.0.0/24");
139 args_info->net_orig = NULL;
140 args_info->ipup_arg = NULL;
141 args_info->ipup_orig = NULL;
142 args_info->ipdown_arg = NULL;
143 args_info->ipdown_orig = NULL;
144 args_info->dynip_arg = NULL;
145 args_info->dynip_orig = NULL;
146 args_info->statip_arg = NULL;
147 args_info->statip_orig = NULL;
148 args_info->pcodns1_arg = gengetopt_strdup ("0.0.0.0");
149 args_info->pcodns1_orig = NULL;
150 args_info->pcodns2_arg = gengetopt_strdup ("0.0.0.0");
151 args_info->pcodns2_orig = NULL;
152 args_info->timelimit_arg = 0;
153 args_info->timelimit_orig = NULL;
154 args_info->apn_arg = gengetopt_strdup ("internet");
155 args_info->apn_orig = NULL;
156 args_info->qos_arg = 0x0b921f;
157 args_info->qos_orig = NULL;
158
Harald Welte1b3e5772010-05-04 11:13:56 +0200159}
160
161static
162void init_args_info(struct gengetopt_args_info *args_info)
163{
Harald Weltebed35df2011-11-02 13:06:18 +0100164
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100165
166 args_info->help_help = gengetopt_args_info_help[0] ;
167 args_info->version_help = gengetopt_args_info_help[1] ;
168 args_info->fg_help = gengetopt_args_info_help[2] ;
169 args_info->debug_help = gengetopt_args_info_help[3] ;
170 args_info->conf_help = gengetopt_args_info_help[4] ;
171 args_info->pidfile_help = gengetopt_args_info_help[5] ;
172 args_info->statedir_help = gengetopt_args_info_help[6] ;
173 args_info->listen_help = gengetopt_args_info_help[7] ;
174 args_info->net_help = gengetopt_args_info_help[8] ;
175 args_info->ipup_help = gengetopt_args_info_help[9] ;
176 args_info->ipdown_help = gengetopt_args_info_help[10] ;
177 args_info->dynip_help = gengetopt_args_info_help[11] ;
178 args_info->statip_help = gengetopt_args_info_help[12] ;
179 args_info->pcodns1_help = gengetopt_args_info_help[13] ;
180 args_info->pcodns2_help = gengetopt_args_info_help[14] ;
181 args_info->timelimit_help = gengetopt_args_info_help[15] ;
182 args_info->apn_help = gengetopt_args_info_help[16] ;
183 args_info->qos_help = gengetopt_args_info_help[17] ;
184
Harald Welte1b3e5772010-05-04 11:13:56 +0200185}
186
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100187void
188cmdline_parser_print_version (void)
Harald Welte1b3e5772010-05-04 11:13:56 +0200189{
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100190 printf ("%s %s\n",
191 (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE),
192 CMDLINE_PARSER_VERSION);
193
194 if (strlen(gengetopt_args_info_versiontext) > 0)
195 printf("\n%s\n", gengetopt_args_info_versiontext);
Harald Welte1b3e5772010-05-04 11:13:56 +0200196}
197
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100198static void print_help_common(void) {
199 cmdline_parser_print_version ();
Harald Welte1b3e5772010-05-04 11:13:56 +0200200
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100201 if (strlen(gengetopt_args_info_purpose) > 0)
202 printf("\n%s\n", gengetopt_args_info_purpose);
Harald Welte1b3e5772010-05-04 11:13:56 +0200203
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100204 if (strlen(gengetopt_args_info_usage) > 0)
205 printf("\n%s\n", gengetopt_args_info_usage);
206
207 printf("\n");
208
209 if (strlen(gengetopt_args_info_description) > 0)
210 printf("%s\n\n", gengetopt_args_info_description);
Harald Welte1b3e5772010-05-04 11:13:56 +0200211}
212
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100213void
214cmdline_parser_print_help (void)
Harald Welte1b3e5772010-05-04 11:13:56 +0200215{
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100216 int i = 0;
217 print_help_common();
218 while (gengetopt_args_info_help[i])
219 printf("%s\n", gengetopt_args_info_help[i++]);
Harald Welte1b3e5772010-05-04 11:13:56 +0200220}
221
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100222void
223cmdline_parser_init (struct gengetopt_args_info *args_info)
224{
225 clear_given (args_info);
226 clear_args (args_info);
227 init_args_info (args_info);
228}
229
230void
231cmdline_parser_params_init(struct cmdline_parser_params *params)
232{
233 if (params)
234 {
235 params->override = 0;
236 params->initialize = 1;
237 params->check_required = 1;
238 params->check_ambiguity = 0;
239 params->print_errors = 1;
240 }
241}
242
243struct cmdline_parser_params *
244cmdline_parser_params_create(void)
245{
246 struct cmdline_parser_params *params =
247 (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params));
248 cmdline_parser_params_init(params);
249 return params;
250}
251
252static void
253free_string_field (char **s)
254{
255 if (*s)
256 {
257 free (*s);
258 *s = 0;
259 }
260}
261
262
263static void
264cmdline_parser_release (struct gengetopt_args_info *args_info)
Harald Welte1b3e5772010-05-04 11:13:56 +0200265{
Harald Weltebed35df2011-11-02 13:06:18 +0100266
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100267 free_string_field (&(args_info->conf_arg));
268 free_string_field (&(args_info->conf_orig));
269 free_string_field (&(args_info->pidfile_arg));
270 free_string_field (&(args_info->pidfile_orig));
271 free_string_field (&(args_info->statedir_arg));
272 free_string_field (&(args_info->statedir_orig));
273 free_string_field (&(args_info->listen_arg));
274 free_string_field (&(args_info->listen_orig));
275 free_string_field (&(args_info->net_arg));
276 free_string_field (&(args_info->net_orig));
277 free_string_field (&(args_info->ipup_arg));
278 free_string_field (&(args_info->ipup_orig));
279 free_string_field (&(args_info->ipdown_arg));
280 free_string_field (&(args_info->ipdown_orig));
281 free_string_field (&(args_info->dynip_arg));
282 free_string_field (&(args_info->dynip_orig));
283 free_string_field (&(args_info->statip_arg));
284 free_string_field (&(args_info->statip_orig));
285 free_string_field (&(args_info->pcodns1_arg));
286 free_string_field (&(args_info->pcodns1_orig));
287 free_string_field (&(args_info->pcodns2_arg));
288 free_string_field (&(args_info->pcodns2_orig));
289 free_string_field (&(args_info->timelimit_orig));
290 free_string_field (&(args_info->apn_arg));
291 free_string_field (&(args_info->apn_orig));
292 free_string_field (&(args_info->qos_orig));
293
294
Harald Weltebed35df2011-11-02 13:06:18 +0100295
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100296 clear_given (args_info);
297}
298
299
300static void
301write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
302{
303 FIX_UNUSED (values);
304 if (arg) {
305 fprintf(outfile, "%s=\"%s\"\n", opt, arg);
306 } else {
307 fprintf(outfile, "%s\n", opt);
308 }
309}
310
311
312int
313cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
314{
315 int i = 0;
316
317 if (!outfile)
318 {
319 fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE);
320 return EXIT_FAILURE;
321 }
322
323 if (args_info->help_given)
324 write_into_file(outfile, "help", 0, 0 );
325 if (args_info->version_given)
326 write_into_file(outfile, "version", 0, 0 );
327 if (args_info->fg_given)
328 write_into_file(outfile, "fg", 0, 0 );
329 if (args_info->debug_given)
330 write_into_file(outfile, "debug", 0, 0 );
331 if (args_info->conf_given)
332 write_into_file(outfile, "conf", args_info->conf_orig, 0);
333 if (args_info->pidfile_given)
334 write_into_file(outfile, "pidfile", args_info->pidfile_orig, 0);
335 if (args_info->statedir_given)
336 write_into_file(outfile, "statedir", args_info->statedir_orig, 0);
337 if (args_info->listen_given)
338 write_into_file(outfile, "listen", args_info->listen_orig, 0);
339 if (args_info->net_given)
340 write_into_file(outfile, "net", args_info->net_orig, 0);
341 if (args_info->ipup_given)
342 write_into_file(outfile, "ipup", args_info->ipup_orig, 0);
343 if (args_info->ipdown_given)
344 write_into_file(outfile, "ipdown", args_info->ipdown_orig, 0);
345 if (args_info->dynip_given)
346 write_into_file(outfile, "dynip", args_info->dynip_orig, 0);
347 if (args_info->statip_given)
348 write_into_file(outfile, "statip", args_info->statip_orig, 0);
349 if (args_info->pcodns1_given)
350 write_into_file(outfile, "pcodns1", args_info->pcodns1_orig, 0);
351 if (args_info->pcodns2_given)
352 write_into_file(outfile, "pcodns2", args_info->pcodns2_orig, 0);
353 if (args_info->timelimit_given)
354 write_into_file(outfile, "timelimit", args_info->timelimit_orig, 0);
355 if (args_info->apn_given)
356 write_into_file(outfile, "apn", args_info->apn_orig, 0);
357 if (args_info->qos_given)
358 write_into_file(outfile, "qos", args_info->qos_orig, 0);
359
360
361 i = EXIT_SUCCESS;
362 return i;
Harald Welte1b3e5772010-05-04 11:13:56 +0200363}
364
365int
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100366cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info)
Harald Welte1b3e5772010-05-04 11:13:56 +0200367{
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100368 FILE *outfile;
369 int i = 0;
Harald Welte1b3e5772010-05-04 11:13:56 +0200370
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100371 outfile = fopen(filename, "w");
Harald Welte1b3e5772010-05-04 11:13:56 +0200372
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100373 if (!outfile)
374 {
375 fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename);
376 return EXIT_FAILURE;
377 }
Harald Welte1b3e5772010-05-04 11:13:56 +0200378
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100379 i = cmdline_parser_dump(outfile, args_info);
380 fclose (outfile);
Harald Welte1b3e5772010-05-04 11:13:56 +0200381
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100382 return i;
Harald Welte1b3e5772010-05-04 11:13:56 +0200383}
384
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100385void
386cmdline_parser_free (struct gengetopt_args_info *args_info)
Harald Welte1b3e5772010-05-04 11:13:56 +0200387{
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100388 cmdline_parser_release (args_info);
Harald Welte1b3e5772010-05-04 11:13:56 +0200389}
390
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100391/** @brief replacement of strdup, which is not standard */
392char *
393gengetopt_strdup (const char *s)
Harald Welte1b3e5772010-05-04 11:13:56 +0200394{
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100395 char *result = 0;
396 if (!s)
397 return result;
Harald Welte1b3e5772010-05-04 11:13:56 +0200398
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100399 result = (char*)malloc(strlen(s) + 1);
400 if (result == (char*)0)
401 return (char*)0;
402 strcpy(result, s);
403 return result;
Harald Welte1b3e5772010-05-04 11:13:56 +0200404}
405
406int
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100407cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info)
Harald Welte1b3e5772010-05-04 11:13:56 +0200408{
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100409 return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
Harald Welte1b3e5772010-05-04 11:13:56 +0200410}
411
412int
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100413cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info,
414 struct cmdline_parser_params *params)
Harald Welte1b3e5772010-05-04 11:13:56 +0200415{
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100416 int result;
417 result = cmdline_parser_internal (argc, argv, args_info, params, 0);
Harald Welte1b3e5772010-05-04 11:13:56 +0200418
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100419 if (result == EXIT_FAILURE)
420 {
421 cmdline_parser_free (args_info);
422 exit (EXIT_FAILURE);
423 }
424
425 return result;
Harald Welte1b3e5772010-05-04 11:13:56 +0200426}
427
428int
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100429cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
Harald Welte1b3e5772010-05-04 11:13:56 +0200430{
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100431 int result;
432 struct cmdline_parser_params params;
433
434 params.override = override;
435 params.initialize = initialize;
436 params.check_required = check_required;
437 params.check_ambiguity = 0;
438 params.print_errors = 1;
439
440 result = cmdline_parser_internal (argc, argv, args_info, &params, 0);
441
442 if (result == EXIT_FAILURE)
443 {
444 cmdline_parser_free (args_info);
445 exit (EXIT_FAILURE);
446 }
447
448 return result;
Harald Welte1b3e5772010-05-04 11:13:56 +0200449}
450
451int
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100452cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
Harald Welte1b3e5772010-05-04 11:13:56 +0200453{
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100454 FIX_UNUSED (args_info);
455 FIX_UNUSED (prog_name);
456 return EXIT_SUCCESS;
457}
Harald Welte1b3e5772010-05-04 11:13:56 +0200458
Harald Welte1b3e5772010-05-04 11:13:56 +0200459
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100460static char *package_name = 0;
Harald Welte1b3e5772010-05-04 11:13:56 +0200461
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100462/**
463 * @brief updates an option
464 * @param field the generic pointer to the field to update
465 * @param orig_field the pointer to the orig field
466 * @param field_given the pointer to the number of occurrence of this option
467 * @param prev_given the pointer to the number of occurrence already seen
468 * @param value the argument for this option (if null no arg was specified)
469 * @param possible_values the possible values for this option (if specified)
470 * @param default_value the default value (in case the option only accepts fixed values)
471 * @param arg_type the type of this option
472 * @param check_ambiguity @see cmdline_parser_params.check_ambiguity
473 * @param override @see cmdline_parser_params.override
474 * @param no_free whether to free a possible previous value
475 * @param multiple_option whether this is a multiple option
476 * @param long_opt the corresponding long option
477 * @param short_opt the corresponding short option (or '-' if none)
478 * @param additional_error possible further error specification
479 */
480static
481int update_arg(void *field, char **orig_field,
482 unsigned int *field_given, unsigned int *prev_given,
483 char *value, const char *possible_values[],
484 const char *default_value,
485 cmdline_parser_arg_type arg_type,
486 int check_ambiguity, int override,
487 int no_free, int multiple_option,
488 const char *long_opt, char short_opt,
489 const char *additional_error)
490{
491 char *stop_char = 0;
492 const char *val = value;
493 int found;
494 char **string_field;
495 FIX_UNUSED (field);
jjako52c24142002-12-16 13:33:51 +0000496
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100497 stop_char = 0;
498 found = 0;
jjako52c24142002-12-16 13:33:51 +0000499
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100500 if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
501 {
502 if (short_opt != '-')
503 fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n",
504 package_name, long_opt, short_opt,
505 (additional_error ? additional_error : ""));
506 else
507 fprintf (stderr, "%s: `--%s' option given more than once%s\n",
508 package_name, long_opt,
509 (additional_error ? additional_error : ""));
510 return 1; /* failure */
511 }
Harald Welte1b3e5772010-05-04 11:13:56 +0200512
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100513 FIX_UNUSED (default_value);
514
515 if (field_given && *field_given && ! override)
516 return 0;
517 if (prev_given)
518 (*prev_given)++;
519 if (field_given)
520 (*field_given)++;
521 if (possible_values)
522 val = possible_values[found];
jjako52c24142002-12-16 13:33:51 +0000523
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100524 switch(arg_type) {
525 case ARG_FLAG:
526 *((int *)field) = !*((int *)field);
527 break;
528 case ARG_INT:
529 if (val) *((int *)field) = strtol (val, &stop_char, 0);
530 break;
531 case ARG_STRING:
532 if (val) {
533 string_field = (char **)field;
534 if (!no_free && *string_field)
535 free (*string_field); /* free previous string */
536 *string_field = gengetopt_strdup (val);
537 }
538 break;
539 default:
540 break;
541 };
jjako52c24142002-12-16 13:33:51 +0000542
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100543 /* check numeric conversion */
544 switch(arg_type) {
545 case ARG_INT:
546 if (val && !(stop_char && *stop_char == '\0')) {
547 fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
548 return 1; /* failure */
549 }
550 break;
551 default:
552 ;
553 };
jjako52c24142002-12-16 13:33:51 +0000554
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100555 /* store the original value */
556 switch(arg_type) {
557 case ARG_NO:
558 case ARG_FLAG:
559 break;
560 default:
561 if (value && orig_field) {
562 if (no_free) {
563 *orig_field = value;
564 } else {
565 if (*orig_field)
566 free (*orig_field); /* free previous string */
567 *orig_field = gengetopt_strdup (value);
568 }
569 }
570 };
jjako52c24142002-12-16 13:33:51 +0000571
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100572 return 0; /* OK */
573}
jjako52c24142002-12-16 13:33:51 +0000574
jjako52c24142002-12-16 13:33:51 +0000575
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100576int
577cmdline_parser_internal (
578 int argc, char **argv, struct gengetopt_args_info *args_info,
579 struct cmdline_parser_params *params, const char *additional_error)
580{
581 int c; /* Character of the parsed option. */
jjako52c24142002-12-16 13:33:51 +0000582
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100583 int error_occurred = 0;
584 struct gengetopt_args_info local_args_info;
585
586 int override;
587 int initialize;
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100588 int check_ambiguity;
589
590 package_name = argv[0];
591
592 override = params->override;
593 initialize = params->initialize;
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100594 check_ambiguity = params->check_ambiguity;
jjako52c24142002-12-16 13:33:51 +0000595
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100596 if (initialize)
597 cmdline_parser_init (args_info);
jjako52c24142002-12-16 13:33:51 +0000598
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100599 cmdline_parser_init (&local_args_info);
jjako52c24142002-12-16 13:33:51 +0000600
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100601 optarg = 0;
602 optind = 0;
603 opterr = params->print_errors;
604 optopt = '?';
jjako52c24142002-12-16 13:33:51 +0000605
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100606 while (1)
607 {
608 int option_index = 0;
jjako52c24142002-12-16 13:33:51 +0000609
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100610 static struct option long_options[] = {
611 { "help", 0, NULL, 'h' },
612 { "version", 0, NULL, 'V' },
613 { "fg", 0, NULL, 'f' },
614 { "debug", 0, NULL, 'd' },
615 { "conf", 1, NULL, 'c' },
616 { "pidfile", 1, NULL, 0 },
617 { "statedir", 1, NULL, 0 },
618 { "listen", 1, NULL, 'l' },
619 { "net", 1, NULL, 'n' },
620 { "ipup", 1, NULL, 0 },
621 { "ipdown", 1, NULL, 0 },
622 { "dynip", 1, NULL, 0 },
623 { "statip", 1, NULL, 0 },
624 { "pcodns1", 1, NULL, 0 },
625 { "pcodns2", 1, NULL, 0 },
626 { "timelimit", 1, NULL, 0 },
627 { "apn", 1, NULL, 'a' },
628 { "qos", 1, NULL, 'q' },
629 { 0, 0, 0, 0 }
630 };
jjako52c24142002-12-16 13:33:51 +0000631
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100632 c = getopt_long (argc, argv, "hVfdc:l:n:a:q:", long_options, &option_index);
jjako52c24142002-12-16 13:33:51 +0000633
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100634 if (c == -1) break; /* Exit from `while (1)' loop. */
jjako52c24142002-12-16 13:33:51 +0000635
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100636 switch (c)
637 {
638 case 'h': /* Print help and exit. */
639 cmdline_parser_print_help ();
640 cmdline_parser_free (&local_args_info);
641 exit (EXIT_SUCCESS);
jjako52c24142002-12-16 13:33:51 +0000642
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100643 case 'V': /* Print version and exit. */
644 cmdline_parser_print_version ();
645 cmdline_parser_free (&local_args_info);
646 exit (EXIT_SUCCESS);
Harald Welte1b3e5772010-05-04 11:13:56 +0200647
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100648 case 'f': /* Run in foreground. */
649
650
651 if (update_arg((void *)&(args_info->fg_flag), 0, &(args_info->fg_given),
652 &(local_args_info.fg_given), optarg, 0, 0, ARG_FLAG,
653 check_ambiguity, override, 1, 0, "fg", 'f',
654 additional_error))
655 goto failure;
656
657 break;
658 case 'd': /* Run in debug mode. */
659
660
661 if (update_arg((void *)&(args_info->debug_flag), 0, &(args_info->debug_given),
662 &(local_args_info.debug_given), optarg, 0, 0, ARG_FLAG,
663 check_ambiguity, override, 1, 0, "debug", 'd',
664 additional_error))
665 goto failure;
666
667 break;
668 case 'c': /* Read configuration file. */
669
670
671 if (update_arg( (void *)&(args_info->conf_arg),
672 &(args_info->conf_orig), &(args_info->conf_given),
673 &(local_args_info.conf_given), optarg, 0, "/etc/ggsn.conf", ARG_STRING,
674 check_ambiguity, override, 0, 0,
675 "conf", 'c',
676 additional_error))
677 goto failure;
678
679 break;
680 case 'l': /* Local interface. */
681
682
683 if (update_arg( (void *)&(args_info->listen_arg),
684 &(args_info->listen_orig), &(args_info->listen_given),
685 &(local_args_info.listen_given), optarg, 0, 0, ARG_STRING,
686 check_ambiguity, override, 0, 0,
687 "listen", 'l',
688 additional_error))
689 goto failure;
690
691 break;
692 case 'n': /* Network. */
693
694
695 if (update_arg( (void *)&(args_info->net_arg),
696 &(args_info->net_orig), &(args_info->net_given),
697 &(local_args_info.net_given), optarg, 0, "192.168.0.0/24", ARG_STRING,
698 check_ambiguity, override, 0, 0,
699 "net", 'n',
700 additional_error))
701 goto failure;
702
703 break;
704 case 'a': /* Access point name. */
705
706
707 if (update_arg( (void *)&(args_info->apn_arg),
708 &(args_info->apn_orig), &(args_info->apn_given),
709 &(local_args_info.apn_given), optarg, 0, "internet", ARG_STRING,
710 check_ambiguity, override, 0, 0,
711 "apn", 'a',
712 additional_error))
713 goto failure;
714
715 break;
716 case 'q': /* Requested quality of service. */
717
718
719 if (update_arg( (void *)&(args_info->qos_arg),
720 &(args_info->qos_orig), &(args_info->qos_given),
721 &(local_args_info.qos_given), optarg, 0, "0x0b921f", ARG_INT,
722 check_ambiguity, override, 0, 0,
723 "qos", 'q',
724 additional_error))
725 goto failure;
726
727 break;
728
729 case 0: /* Long option with no short option */
730 /* Filename of process id file. */
731 if (strcmp (long_options[option_index].name, "pidfile") == 0)
732 {
733
734
735 if (update_arg( (void *)&(args_info->pidfile_arg),
736 &(args_info->pidfile_orig), &(args_info->pidfile_given),
737 &(local_args_info.pidfile_given), optarg, 0, "/var/run/ggsn.pid", ARG_STRING,
738 check_ambiguity, override, 0, 0,
739 "pidfile", '-',
740 additional_error))
741 goto failure;
742
743 }
744 /* Directory of nonvolatile data. */
745 else if (strcmp (long_options[option_index].name, "statedir") == 0)
746 {
747
748
749 if (update_arg( (void *)&(args_info->statedir_arg),
750 &(args_info->statedir_orig), &(args_info->statedir_given),
751 &(local_args_info.statedir_given), optarg, 0, "/var/lib/ggsn/", ARG_STRING,
752 check_ambiguity, override, 0, 0,
753 "statedir", '-',
754 additional_error))
755 goto failure;
756
757 }
758 /* Script to run after link-up. */
759 else if (strcmp (long_options[option_index].name, "ipup") == 0)
760 {
761
762
763 if (update_arg( (void *)&(args_info->ipup_arg),
764 &(args_info->ipup_orig), &(args_info->ipup_given),
765 &(local_args_info.ipup_given), optarg, 0, 0, ARG_STRING,
766 check_ambiguity, override, 0, 0,
767 "ipup", '-',
768 additional_error))
769 goto failure;
770
771 }
772 /* Script to run after link-down. */
773 else if (strcmp (long_options[option_index].name, "ipdown") == 0)
774 {
775
776
777 if (update_arg( (void *)&(args_info->ipdown_arg),
778 &(args_info->ipdown_orig), &(args_info->ipdown_given),
779 &(local_args_info.ipdown_given), optarg, 0, 0, ARG_STRING,
780 check_ambiguity, override, 0, 0,
781 "ipdown", '-',
782 additional_error))
783 goto failure;
784
785 }
786 /* Dynamic IP address pool. */
787 else if (strcmp (long_options[option_index].name, "dynip") == 0)
788 {
789
790
791 if (update_arg( (void *)&(args_info->dynip_arg),
792 &(args_info->dynip_orig), &(args_info->dynip_given),
793 &(local_args_info.dynip_given), optarg, 0, 0, ARG_STRING,
794 check_ambiguity, override, 0, 0,
795 "dynip", '-',
796 additional_error))
797 goto failure;
798
799 }
800 /* Static IP address pool. */
801 else if (strcmp (long_options[option_index].name, "statip") == 0)
802 {
803
804
805 if (update_arg( (void *)&(args_info->statip_arg),
806 &(args_info->statip_orig), &(args_info->statip_given),
807 &(local_args_info.statip_given), optarg, 0, 0, ARG_STRING,
808 check_ambiguity, override, 0, 0,
809 "statip", '-',
810 additional_error))
811 goto failure;
812
813 }
814 /* PCO DNS Server 1. */
815 else if (strcmp (long_options[option_index].name, "pcodns1") == 0)
816 {
817
818
819 if (update_arg( (void *)&(args_info->pcodns1_arg),
820 &(args_info->pcodns1_orig), &(args_info->pcodns1_given),
821 &(local_args_info.pcodns1_given), optarg, 0, "0.0.0.0", ARG_STRING,
822 check_ambiguity, override, 0, 0,
823 "pcodns1", '-',
824 additional_error))
825 goto failure;
826
827 }
828 /* PCO DNS Server 2. */
829 else if (strcmp (long_options[option_index].name, "pcodns2") == 0)
830 {
831
832
833 if (update_arg( (void *)&(args_info->pcodns2_arg),
834 &(args_info->pcodns2_orig), &(args_info->pcodns2_given),
835 &(local_args_info.pcodns2_given), optarg, 0, "0.0.0.0", ARG_STRING,
836 check_ambiguity, override, 0, 0,
837 "pcodns2", '-',
838 additional_error))
839 goto failure;
840
841 }
842 /* Exit after timelimit seconds. */
843 else if (strcmp (long_options[option_index].name, "timelimit") == 0)
844 {
845
846
847 if (update_arg( (void *)&(args_info->timelimit_arg),
848 &(args_info->timelimit_orig), &(args_info->timelimit_given),
849 &(local_args_info.timelimit_given), optarg, 0, "0", ARG_INT,
850 check_ambiguity, override, 0, 0,
851 "timelimit", '-',
852 additional_error))
853 goto failure;
854
855 }
856
857 break;
858 case '?': /* Invalid option. */
859 /* `getopt_long' already printed an error message. */
860 goto failure;
861
862 default: /* bug: option not considered. */
863 fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
864 abort ();
865 } /* switch */
866 } /* while */
867
868
869
870
871 cmdline_parser_release (&local_args_info);
872
873 if ( error_occurred )
874 return (EXIT_FAILURE);
875
876 return 0;
Harald Welte1b3e5772010-05-04 11:13:56 +0200877
878failure:
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100879
880 cmdline_parser_release (&local_args_info);
881 return (EXIT_FAILURE);
jjako52c24142002-12-16 13:33:51 +0000882}
883
Harald Welte1b3e5772010-05-04 11:13:56 +0200884#ifndef CONFIG_FILE_LINE_SIZE
885#define CONFIG_FILE_LINE_SIZE 2048
886#endif
887#define ADDITIONAL_ERROR " in configuration file "
888
889#define CONFIG_FILE_LINE_BUFFER_SIZE (CONFIG_FILE_LINE_SIZE+3)
890/* 3 is for "--" and "=" */
891
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100892static int
893_cmdline_parser_configfile (const char *filename, int *my_argc)
894{
895 FILE* file;
896 char my_argv[CONFIG_FILE_LINE_BUFFER_SIZE+1];
897 char linebuf[CONFIG_FILE_LINE_SIZE];
898 int line_num = 0;
899 int result = 0, equal;
900 char *fopt, *farg;
901 char *str_index;
902 size_t len, next_token;
903 char delimiter;
904
905 if ((file = fopen(filename, "r")) == 0)
906 {
907 fprintf (stderr, "%s: Error opening configuration file '%s'\n",
908 CMDLINE_PARSER_PACKAGE, filename);
909 return EXIT_FAILURE;
910 }
911
912 while ((fgets(linebuf, CONFIG_FILE_LINE_SIZE, file)) != 0)
913 {
914 ++line_num;
915 my_argv[0] = '\0';
916 len = strlen(linebuf);
917 if (len > (CONFIG_FILE_LINE_BUFFER_SIZE-1))
918 {
919 fprintf (stderr, "%s:%s:%d: Line too long in configuration file\n",
920 CMDLINE_PARSER_PACKAGE, filename, line_num);
921 result = EXIT_FAILURE;
922 break;
923 }
924
925 /* find first non-whitespace character in the line */
926 next_token = strspn (linebuf, " \t\r\n");
927 str_index = linebuf + next_token;
928
929 if ( str_index[0] == '\0' || str_index[0] == '#')
930 continue; /* empty line or comment line is skipped */
931
932 fopt = str_index;
933
934 /* truncate fopt at the end of the first non-valid character */
935 next_token = strcspn (fopt, " \t\r\n=");
936
937 if (fopt[next_token] == '\0') /* the line is over */
938 {
939 farg = 0;
940 equal = 0;
941 goto noarg;
942 }
943
944 /* remember if equal sign is present */
945 equal = (fopt[next_token] == '=');
946 fopt[next_token++] = '\0';
947
948 /* advance pointers to the next token after the end of fopt */
949 next_token += strspn (fopt + next_token, " \t\r\n");
950
951 /* check for the presence of equal sign, and if so, skip it */
952 if ( !equal )
953 if ((equal = (fopt[next_token] == '=')))
954 {
955 next_token++;
956 next_token += strspn (fopt + next_token, " \t\r\n");
957 }
958 str_index += next_token;
959
960 /* find argument */
961 farg = str_index;
962 if ( farg[0] == '\"' || farg[0] == '\'' )
963 { /* quoted argument */
964 str_index = strchr (++farg, str_index[0] ); /* skip opening quote */
965 if (! str_index)
966 {
967 fprintf
968 (stderr,
969 "%s:%s:%d: unterminated string in configuration file\n",
970 CMDLINE_PARSER_PACKAGE, filename, line_num);
971 result = EXIT_FAILURE;
972 break;
973 }
974 }
975 else
976 { /* read up the remaining part up to a delimiter */
977 next_token = strcspn (farg, " \t\r\n#\'\"");
978 str_index += next_token;
979 }
980
981 /* truncate farg at the delimiter and store it for further check */
982 delimiter = *str_index, *str_index++ = '\0';
983
984 /* everything but comment is illegal at the end of line */
985 if (delimiter != '\0' && delimiter != '#')
986 {
987 str_index += strspn(str_index, " \t\r\n");
988 if (*str_index != '\0' && *str_index != '#')
989 {
990 fprintf
991 (stderr,
992 "%s:%s:%d: malformed string in configuration file\n",
993 CMDLINE_PARSER_PACKAGE, filename, line_num);
994 result = EXIT_FAILURE;
995 break;
996 }
997 }
998
999 noarg:
1000 if (!strcmp(fopt,"include")) {
1001 if (farg && *farg) {
1002 result = _cmdline_parser_configfile(farg, my_argc);
1003 } else {
1004 fprintf(stderr, "%s:%s:%d: include requires a filename argument.\n",
1005 CMDLINE_PARSER_PACKAGE, filename, line_num);
1006 }
1007 continue;
1008 }
1009 len = strlen(fopt);
1010 strcat (my_argv, len > 1 ? "--" : "-");
1011 strcat (my_argv, fopt);
1012 if (len > 1 && ((farg && *farg) || equal))
1013 strcat (my_argv, "=");
1014 if (farg && *farg)
1015 strcat (my_argv, farg);
1016 ++(*my_argc);
1017
1018 cmd_line_list_tmp = (struct line_list *) malloc (sizeof (struct line_list));
1019 cmd_line_list_tmp->next = cmd_line_list;
1020 cmd_line_list = cmd_line_list_tmp;
1021 cmd_line_list->string_arg = gengetopt_strdup(my_argv);
1022 } /* while */
1023
1024 if (file)
1025 fclose(file);
1026 return result;
1027}
jjako52c24142002-12-16 13:33:51 +00001028
1029int
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +01001030cmdline_parser_configfile (
1031 const char *filename,
1032 struct gengetopt_args_info *args_info,
1033 int override, int initialize, int check_required)
jjako52c24142002-12-16 13:33:51 +00001034{
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +01001035 struct cmdline_parser_params params;
Harald Welte1b3e5772010-05-04 11:13:56 +02001036
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +01001037 params.override = override;
1038 params.initialize = initialize;
1039 params.check_required = check_required;
1040 params.check_ambiguity = 0;
1041 params.print_errors = 1;
1042
1043 return cmdline_parser_config_file (filename, args_info, &params);
1044}
jjako52c24142002-12-16 13:33:51 +00001045
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +01001046int
1047cmdline_parser_config_file (const char *filename,
1048 struct gengetopt_args_info *args_info,
1049 struct cmdline_parser_params *params)
1050{
1051 int i, result;
1052 int my_argc = 1;
1053 char **my_argv_arg;
1054 char *additional_error;
jjako52c24142002-12-16 13:33:51 +00001055
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +01001056 /* store the program name */
1057 cmd_line_list_tmp = (struct line_list *) malloc (sizeof (struct line_list));
1058 cmd_line_list_tmp->next = cmd_line_list;
1059 cmd_line_list = cmd_line_list_tmp;
1060 cmd_line_list->string_arg = gengetopt_strdup (CMDLINE_PARSER_PACKAGE);
jjako52c24142002-12-16 13:33:51 +00001061
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +01001062 result = _cmdline_parser_configfile(filename, &my_argc);
jjako52c24142002-12-16 13:33:51 +00001063
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +01001064 if (result != EXIT_FAILURE) {
1065 my_argv_arg = (char **) malloc((my_argc+1) * sizeof(char *));
1066 cmd_line_list_tmp = cmd_line_list;
Harald Welte1b3e5772010-05-04 11:13:56 +02001067
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +01001068 for (i = my_argc - 1; i >= 0; --i) {
1069 my_argv_arg[i] = cmd_line_list_tmp->string_arg;
1070 cmd_line_list_tmp = cmd_line_list_tmp->next;
1071 }
Harald Welte1b3e5772010-05-04 11:13:56 +02001072
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +01001073 my_argv_arg[my_argc] = 0;
Harald Welte1b3e5772010-05-04 11:13:56 +02001074
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +01001075 additional_error = (char *)malloc(strlen(filename) + strlen(ADDITIONAL_ERROR) + 1);
1076 strcpy (additional_error, ADDITIONAL_ERROR);
1077 strcat (additional_error, filename);
1078 result =
1079 cmdline_parser_internal (my_argc, my_argv_arg, args_info,
1080 params,
1081 additional_error);
Harald Welte1b3e5772010-05-04 11:13:56 +02001082
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +01001083 free (additional_error);
1084 free (my_argv_arg);
1085 }
Harald Welte1b3e5772010-05-04 11:13:56 +02001086
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +01001087 free_cmd_list();
1088 if (result == EXIT_FAILURE)
1089 {
1090 cmdline_parser_free (args_info);
1091 exit (EXIT_FAILURE);
1092 }
1093
1094 return result;
jjako52c24142002-12-16 13:33:51 +00001095}