GDB (API)
/home/stan/gdb/src/gdb/mi/mi-getopt.h
Go to the documentation of this file.
00001 /* MI Option Parser.
00002    Copyright (C) 2000-2013 Free Software Foundation, Inc.
00003    Contributed by Cygnus Solutions (a Red Hat company).
00004 
00005    This file is part of GDB.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 3 of the License, or
00010    (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00019 
00020 #ifndef MI_GETOPT_H
00021 #define MI_GETOPT_H
00022 
00023 /* The option list.  Terminated by NAME==NULL.  ARG_P that the option
00024    requires an argument.  INDEX is returned to identify the option.  */
00025 
00026 struct mi_opt
00027   {
00028     const char *name;
00029     int index;
00030     int arg_p;
00031   };
00032 
00033 /* Like getopt() but with simpler semantics.
00034 
00035    An option has the form ``-<name>''. The special option ``--''
00036    denotes the end of the option list. An option can be followed by a
00037    separate argument (on a per option basis).
00038 
00039    On entry OPTIND contains the index of the next element of ARGV that
00040    needs parsing.  OPTIND is updated to indicate the index of the next
00041    argument before mi_getopt() returns.
00042 
00043    If ARGV[OPTIND] is an option, that options INDEX is returned.
00044    OPTARG is set to the options argument or NULL.  OPTIND is updated.
00045 
00046    If ARGV[OPTIND] is not an option, -1 is returned and OPTIND updated
00047    to specify the non-option argument.  OPTARG is set to NULL.
00048 
00049    If an unknown option is encountered, mi_getopt() calls
00050    ``error("%s: Unknown option %c", prefix, option)'' while
00051    mi_getopt_allow_unknown returns -1.  */
00052 
00053 extern int mi_getopt (const char *prefix, int argc, char **argv,
00054                       const struct mi_opt *opt, int *optind, char **optarg);
00055 extern int mi_getopt_allow_unknown (const char *prefix, int argc,
00056                                     char **argv, const struct mi_opt *opts,
00057                                     int *oind, char **oarg);
00058 
00059 /* mi_valid_noargs determines if ARGC/ARGV are a valid set of
00060    parameters to satisfy an MI function that is not supposed to
00061    recieve any arguments.
00062    
00063    An MI function that should not receive arguments can still be 
00064    passed parameters after the special option '--' such as below.
00065 
00066    Example: The MI function -exec-run takes no args.
00067    However, the client may pass '-exec-run -- -a ...'
00068    See PR-783
00069 
00070    PREFIX is passed to mi_getopt for an error message.
00071     
00072    This function Returns 1 if the parameter pair ARGC/ARGV are valid
00073    for an MI function that takes no arguments. Otherwise, it returns 0
00074    and the appropriate error message is displayed by mi_getopt.  */
00075 
00076 extern int mi_valid_noargs (const char *prefix, int argc, char **argv);
00077                                 
00078 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines