1 /* MI Command Set - MI Option Parser.
2 Copyright (C) 2000, 2001, 2007, 2008, 2009, 2010
3 Free Software Foundation, Inc.
4 Contributed by Cygnus Solutions (a Red Hat company).
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 #include "mi-getopt.h"
23 #include "gdb_string.h"
26 mi_getopt (const char *prefix
,
27 int argc
, char **argv
,
29 int *optind
, char **optarg
)
33 /* We assume that argv/argc are ok. */
34 if (*optind
> argc
|| *optind
< 0)
35 internal_error (__FILE__
, __LINE__
,
36 _("mi_getopt_long: optind out of bounds"));
41 if (strcmp (arg
, "--") == 0)
47 /* End of option list. */
53 /* Look the option up. */
54 for (opt
= opts
; opt
->name
!= NULL
; opt
++)
56 if (strcmp (opt
->name
, arg
+ 1) != 0)
60 /* A non-simple optarg option. */
61 if (argc
< *optind
+ 2)
62 error (_("%s: Option %s requires an argument"), prefix
, arg
);
63 *optarg
= argv
[(*optind
) + 1];
64 *optind
= (*optind
) + 2;
70 *optind
= (*optind
) + 1;
74 error (_("%s: Unknown option ``%s''"), prefix
, arg
+ 1);
78 mi_valid_noargs (const char *prefix
, int argc
, char **argv
)
82 static struct mi_opt opts
[] =
87 if (mi_getopt (prefix
, argc
, argv
, opts
, &optind
, &optarg
) == -1)
This page took 0.03182 seconds and 5 git commands to generate.