Commit | Line | Data |
---|---|---|
fb40c209 | 1 | /* MI Option Parser. |
7b6bb8da JB |
2 | Copyright (C) 2000, 2007, 2008, 2009, 2010, 2011 |
3 | Free Software Foundation, Inc. | |
ab91fdd5 | 4 | Contributed by Cygnus Solutions (a Red Hat company). |
fb40c209 AC |
5 | |
6 | This file is part of GDB. | |
7 | ||
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 | |
a9762ec7 | 10 | the Free Software Foundation; either version 3 of the License, or |
fb40c209 AC |
11 | (at your option) any later version. |
12 | ||
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. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
a9762ec7 | 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
fb40c209 AC |
20 | |
21 | #ifndef MI_GETOPT_H | |
22 | #define MI_GETOPT_H | |
23 | ||
24 | /* Like getopt() but with simpler semantics. | |
25 | ||
26 | An option has the form ``-<name>''. The special option ``--'' | |
27 | denotes the end of the option list. An option can be followed by a | |
28 | separate argument (on a per option basis). | |
29 | ||
30 | On entry OPTIND contains the index of the next element of ARGV that | |
31 | needs parsing. OPTIND is updated to indicate the index of the next | |
32 | argument before mi_getopt() returns. | |
33 | ||
34 | If ARGV[OPTIND] is an option, that options INDEX is returned. | |
35 | OPTARG is set to the options argument or NULL. OPTIND is updated. | |
36 | ||
37 | If ARGV[OPTIND] is not an option, -1 is returned and OPTIND updated | |
38 | to specify the non-option argument. OPTARG is set to NULL. | |
39 | ||
40 | mi_getopt() calls ``error("%s: Unknown option %c", prefix, | |
41 | option)'' if an unknown option is encountered. */ | |
42 | ||
43 | struct mi_opt; | |
44 | extern int mi_getopt (const char *prefix, int argc, char **argv, | |
45 | struct mi_opt *opt, int *optind, char **optarg); | |
46 | ||
47 | /* The option list. Terminated by NAME==NULL. ARG_P that the option | |
48 | requires an argument. INDEX is returned to identify th option. */ | |
49 | ||
50 | struct mi_opt | |
51 | { | |
52 | const char *name; | |
53 | int index; | |
54 | int arg_p; | |
55 | }; | |
56 | ||
57 | struct mi_opt; | |
58 | ||
1abaf70c BR |
59 | /* mi_valid_noargs |
60 | ||
61 | Determines if ARGC/ARGV are a valid set of parameters to satisfy | |
62 | an MI function that is not supposed to recieve any arguments. | |
63 | ||
64 | An MI function that should not recieve arguments can still be | |
65 | passed parameters after the special option '--' such as below. | |
66 | ||
67 | Example: The MI function -exec-run takes no args. | |
68 | However, the client may pass '-exec-run -- -a ...' | |
69 | See PR-783 | |
70 | ||
71 | PREFIX is passed to mi_getopt for an error message. | |
72 | ||
73 | This function Returns 1 if the parameter pair ARGC/ARGV are valid | |
74 | for an MI function that takes no arguments. Otherwise, it returns 0 | |
75 | and the appropriate error message is displayed by mi_getopt. */ | |
76 | ||
77 | extern int mi_valid_noargs (const char *prefix, int argc, char **argv); | |
78 | ||
fb40c209 | 79 | #endif |