gdb/mi/mi-getopt.h - gdb

Data types defined

Macros defined

Source code

  1. /* MI Option Parser.
  2.    Copyright (C) 2000-2015 Free Software Foundation, Inc.
  3.    Contributed by Cygnus Solutions (a Red Hat company).

  4.    This file is part of GDB.

  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 3 of the License, or
  8.    (at your option) any later version.

  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.

  13.    You should have received a copy of the GNU General Public License
  14.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  15. #ifndef MI_GETOPT_H
  16. #define MI_GETOPT_H

  17. /* The option list.  Terminated by NAME==NULL.  ARG_P that the option
  18.    requires an argument.  INDEX is returned to identify the option.  */

  19. struct mi_opt
  20.   {
  21.     const char *name;
  22.     int index;
  23.     int arg_p;
  24.   };

  25. /* Like getopt() but with simpler semantics.

  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.    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
  31.    argument before mi_getopt() returns.

  32.    If ARGV[OPTIND] is an option, that options INDEX is returned.
  33.    OPTARG is set to the options argument or NULL.  OPTIND is updated.

  34.    If ARGV[OPTIND] is not an option, -1 is returned and OPTIND updated
  35.    to specify the non-option argument.  OPTARG is set to NULL.

  36.    If an unknown option is encountered, mi_getopt() calls
  37.    ``error("%s: Unknown option %c", prefix, option)'' while
  38.    mi_getopt_allow_unknown returns -1.  */

  39. extern int mi_getopt (const char *prefix, int argc, char **argv,
  40.                       const struct mi_opt *opt, int *optind, char **optarg);
  41. extern int mi_getopt_allow_unknown (const char *prefix, int argc,
  42.                                     char **argv, const struct mi_opt *opts,
  43.                                     int *oind, char **oarg);

  44. /* mi_valid_noargs determines if ARGC/ARGV are a valid set of
  45.    parameters to satisfy an MI function that is not supposed to
  46.    recieve any arguments.

  47.    An MI function that should not receive arguments can still be
  48.    passed parameters after the special option '--' such as below.

  49.    Example: The MI function -exec-run takes no args.
  50.    However, the client may pass '-exec-run -- -a ...'
  51.    See PR-783

  52.    PREFIX is passed to mi_getopt for an error message.

  53.    This function Returns 1 if the parameter pair ARGC/ARGV are valid
  54.    for an MI function that takes no arguments. Otherwise, it returns 0
  55.    and the appropriate error message is displayed by mi_getopt.  */

  56. extern int mi_valid_noargs (const char *prefix, int argc, char **argv);

  57. #endif