198944Sobrien/* MI Option Parser.
298944Sobrien   Copyright 2000 Free Software Foundation, Inc.
398944Sobrien   Contributed by Cygnus Solutions (a Red Hat company).
498944Sobrien
598944Sobrien   This file is part of GDB.
698944Sobrien
798944Sobrien   This program is free software; you can redistribute it and/or modify
898944Sobrien   it under the terms of the GNU General Public License as published by
998944Sobrien   the Free Software Foundation; either version 2 of the License, or
1098944Sobrien   (at your option) any later version.
1198944Sobrien
1298944Sobrien   This program is distributed in the hope that it will be useful,
1398944Sobrien   but WITHOUT ANY WARRANTY; without even the implied warranty of
1498944Sobrien   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1598944Sobrien   GNU General Public License for more details.
1698944Sobrien
1798944Sobrien   You should have received a copy of the GNU General Public License
1898944Sobrien   along with this program; if not, write to the Free Software
1998944Sobrien   Foundation, Inc., 59 Temple Place - Suite 330,
2098944Sobrien   Boston, MA 02111-1307, USA.  */
2198944Sobrien
2298944Sobrien#ifndef MI_GETOPT_H
2398944Sobrien#define MI_GETOPT_H
2498944Sobrien
2598944Sobrien/* Like getopt() but with simpler semantics.
2698944Sobrien
2798944Sobrien   An option has the form ``-<name>''. The special option ``--''
2898944Sobrien   denotes the end of the option list. An option can be followed by a
2998944Sobrien   separate argument (on a per option basis).
3098944Sobrien
3198944Sobrien   On entry OPTIND contains the index of the next element of ARGV that
3298944Sobrien   needs parsing.  OPTIND is updated to indicate the index of the next
3398944Sobrien   argument before mi_getopt() returns.
3498944Sobrien
3598944Sobrien   If ARGV[OPTIND] is an option, that options INDEX is returned.
3698944Sobrien   OPTARG is set to the options argument or NULL.  OPTIND is updated.
3798944Sobrien
3898944Sobrien   If ARGV[OPTIND] is not an option, -1 is returned and OPTIND updated
3998944Sobrien   to specify the non-option argument.  OPTARG is set to NULL.
4098944Sobrien
4198944Sobrien   mi_getopt() calls ``error("%s: Unknown option %c", prefix,
4298944Sobrien   option)'' if an unknown option is encountered. */
4398944Sobrien
4498944Sobrienstruct mi_opt;
4598944Sobrienextern int mi_getopt (const char *prefix, int argc, char **argv,
4698944Sobrien		      struct mi_opt *opt, int *optind, char **optarg);
4798944Sobrien
4898944Sobrien/* The option list.  Terminated by NAME==NULL.  ARG_P that the option
4998944Sobrien   requires an argument.  INDEX is returned to identify th option. */
5098944Sobrien
5198944Sobrienstruct mi_opt
5298944Sobrien  {
5398944Sobrien    const char *name;
5498944Sobrien    int index;
5598944Sobrien    int arg_p;
5698944Sobrien  };
5798944Sobrien
5898944Sobrienstruct mi_opt;
5998944Sobrien
60130803Smarcel/* mi_valid_noargs
61130803Smarcel
62130803Smarcel   Determines if ARGC/ARGV are a valid set of parameters to satisfy
63130803Smarcel   an MI function that is not supposed to recieve any arguments.
64130803Smarcel
65130803Smarcel   An MI function that should not recieve arguments can still be
66130803Smarcel   passed parameters after the special option '--' such as below.
67130803Smarcel
68130803Smarcel   Example: The MI function -exec-run takes no args.
69130803Smarcel   However, the client may pass '-exec-run -- -a ...'
70130803Smarcel   See PR-783
71130803Smarcel
72130803Smarcel   PREFIX is passed to mi_getopt for an error message.
73130803Smarcel
74130803Smarcel   This function Returns 1 if the parameter pair ARGC/ARGV are valid
75130803Smarcel   for an MI function that takes no arguments. Otherwise, it returns 0
76130803Smarcel   and the appropriate error message is displayed by mi_getopt.  */
77130803Smarcel
78130803Smarcelextern int mi_valid_noargs (const char *prefix, int argc, char **argv);
79130803Smarcel
8098944Sobrien#endif
81