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