1 /* MI Command Set - MI Option Parser.
2 Copyright 2000, 2001 Free Software Foundation, Inc.
3 Contributed by Cygnus Solutions (a Red Hat company).
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
23 #include "mi-getopt.h"
24 #include "gdb_string.h"
27 mi_getopt (const char *prefix
,
28 int argc
, char **argv
,
30 int *optind
, char **optarg
)
34 /* We assume that argv/argc are ok. */
35 if (*optind
> argc
|| *optind
< 0)
36 internal_error (__FILE__
, __LINE__
,
37 "mi_getopt_long: optind out of bounds");
42 if (strcmp (arg
, "--") == 0)
48 /* End of option list. */
54 /* Look the option up. */
55 for (opt
= opts
; opt
->name
!= NULL
; opt
++)
57 if (strcmp (opt
->name
, arg
+ 1) != 0)
61 /* A non-simple optarg option. */
62 if (argc
< *optind
+ 2)
63 error ("%s: Option %s requires an argument", prefix
, arg
);
64 *optarg
= argv
[(*optind
) + 1];
65 *optind
= (*optind
) + 2;
71 *optind
= (*optind
) + 1;
75 error ("%s: Unknown option ``%s''", prefix
, arg
+ 1);
79 mi_valid_noargs (const char *prefix
, int argc
, char **argv
)
83 static struct mi_opt opts
[] =
88 if (mi_getopt (prefix
, argc
, argv
, opts
, &optind
, &optarg
) == -1)
This page took 0.032431 seconds and 4 git commands to generate.