119370Spst/* Header file for command-reading library command.c.
219370Spst
3130803Smarcel   Copyright 1986, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1999,
4130803Smarcel   2000, 2002 Free Software Foundation, Inc.
5130803Smarcel
698944Sobrien   This program is free software; you can redistribute it and/or modify
798944Sobrien   it under the terms of the GNU General Public License as published by
898944Sobrien   the Free Software Foundation; either version 2 of the License, or
998944Sobrien   (at your option) any later version.
1019370Spst
1198944Sobrien   This program is distributed in the hope that it will be useful,
1298944Sobrien   but WITHOUT ANY WARRANTY; without even the implied warranty of
1398944Sobrien   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1498944Sobrien   GNU General Public License for more details.
1519370Spst
1698944Sobrien   You should have received a copy of the GNU General Public License
1798944Sobrien   along with this program; if not, write to the Free Software
1898944Sobrien   Foundation, Inc., 59 Temple Place - Suite 330,
1998944Sobrien   Boston, MA 02111-1307, USA.  */
2019370Spst
2119370Spst#if !defined (COMMAND_H)
2219370Spst#define COMMAND_H 1
2319370Spst
2498944Sobrien/* Command classes are top-level categories into which commands are broken
2598944Sobrien   down for "help" purposes.
2698944Sobrien   Notes on classes: class_alias is for alias commands which are not
2798944Sobrien   abbreviations of the original command.  class-pseudo is for
2898944Sobrien   commands which are not really commands nor help topics ("stop").  */
2998944Sobrien
3098944Sobrienenum command_class
3198944Sobrien{
3298944Sobrien  /* Special args to help_list */
3398944Sobrien  class_deprecated, all_classes = -2, all_commands = -1,
3498944Sobrien  /* Classes of commands */
3598944Sobrien  no_class = -1, class_run = 0, class_vars, class_stack,
3698944Sobrien  class_files, class_support, class_info, class_breakpoint, class_trace,
3798944Sobrien  class_alias, class_obscure, class_user, class_maintenance,
3898944Sobrien  class_pseudo, class_tui, class_xdb
3998944Sobrien};
4098944Sobrien
41130803Smarcel/* FIXME: cagney/2002-03-17: Once cmd_type() has been removed, ``enum
42130803Smarcel   cmd_types'' can be moved from "command.h" to "cli-decode.h".  */
4319370Spst/* Not a set/show command.  Note that some commands which begin with
4419370Spst   "set" or "show" might be in this category, if their syntax does
4519370Spst   not fall into one of the following categories.  */
4698944Sobrientypedef enum cmd_types
4798944Sobrien  {
4898944Sobrien    not_set_cmd,
4998944Sobrien    set_cmd,
5098944Sobrien    show_cmd
5198944Sobrien  }
5298944Sobriencmd_types;
5319370Spst
5419370Spst/* Types of "set" or "show" command.  */
5598944Sobrientypedef enum var_types
5698944Sobrien  {
5798944Sobrien    /* "on" or "off".  *VAR is an integer which is nonzero for on,
5898944Sobrien       zero for off.  */
5998944Sobrien    var_boolean,
6019370Spst
6198944Sobrien    /* "on" / "true" / "enable" or "off" / "false" / "disable" or
62130803Smarcel       "auto.  *VAR is an ``enum auto_boolean''.  NOTE: In general a
63130803Smarcel       custom show command will need to be implemented - one that for
64130803Smarcel       "auto" prints both the "auto" and the current auto-selected
6598944Sobrien       value. */
6698944Sobrien    var_auto_boolean,
6719370Spst
6898944Sobrien    /* Unsigned Integer.  *VAR is an unsigned int.  The user can type 0
6998944Sobrien       to mean "unlimited", which is stored in *VAR as UINT_MAX.  */
7098944Sobrien    var_uinteger,
7119370Spst
7298944Sobrien    /* Like var_uinteger but signed.  *VAR is an int.  The user can type 0
7398944Sobrien       to mean "unlimited", which is stored in *VAR as INT_MAX.  */
7498944Sobrien    var_integer,
7598944Sobrien
7698944Sobrien    /* String which the user enters with escapes (e.g. the user types \n and
7798944Sobrien       it is a real newline in the stored string).
7898944Sobrien       *VAR is a malloc'd string, or NULL if the string is empty.  */
7998944Sobrien    var_string,
8098944Sobrien    /* String which stores what the user types verbatim.
8198944Sobrien       *VAR is a malloc'd string, or NULL if the string is empty.  */
8298944Sobrien    var_string_noescape,
8398944Sobrien    /* String which stores a filename.
8498944Sobrien       *VAR is a malloc'd string, or NULL if the string is empty.  */
8598944Sobrien    var_filename,
8698944Sobrien    /* ZeroableInteger.  *VAR is an int.  Like Unsigned Integer except
8798944Sobrien       that zero really means zero.  */
8898944Sobrien    var_zinteger,
8998944Sobrien    /* Enumerated type.  Can only have one of the specified values.  *VAR is a
9098944Sobrien       char pointer to the name of the element that we find.  */
9198944Sobrien    var_enum
9298944Sobrien  }
9398944Sobrienvar_types;
9498944Sobrien
9519370Spst/* This structure records one command'd definition.  */
96130803Smarcelstruct cmd_list_element;
9719370Spst
9898944Sobrien/* Forward-declarations of the entry-points of cli/cli-decode.c.  */
9919370Spst
10098944Sobrienextern struct cmd_list_element *add_cmd (char *, enum command_class,
10198944Sobrien					 void (*fun) (char *, int), char *,
10298944Sobrien					 struct cmd_list_element **);
10319370Spst
10498944Sobrienextern struct cmd_list_element *add_alias_cmd (char *, char *,
10598944Sobrien					       enum command_class, int,
10698944Sobrien					       struct cmd_list_element **);
10719370Spst
10898944Sobrienextern struct cmd_list_element *add_prefix_cmd (char *, enum command_class,
10998944Sobrien						void (*fun) (char *, int),
11098944Sobrien						char *,
11198944Sobrien						struct cmd_list_element **,
11298944Sobrien						char *, int,
11398944Sobrien						struct cmd_list_element **);
11419370Spst
11598944Sobrienextern struct cmd_list_element *add_abbrev_prefix_cmd (char *,
11698944Sobrien						       enum command_class,
11798944Sobrien						       void (*fun) (char *,
11898944Sobrien								    int),
11998944Sobrien						       char *,
12098944Sobrien						       struct cmd_list_element
12198944Sobrien						       **, char *, int,
12298944Sobrien						       struct cmd_list_element
12398944Sobrien						       **);
12419370Spst
12598944Sobrien/* Set the commands corresponding callback.  */
12619370Spst
127130803Smarceltypedef void cmd_cfunc_ftype (char *args, int from_tty);
12898944Sobrienextern void set_cmd_cfunc (struct cmd_list_element *cmd,
129130803Smarcel			   cmd_cfunc_ftype *cfunc);
13098944Sobrien
131130803Smarceltypedef void cmd_sfunc_ftype (char *args, int from_tty,
132130803Smarcel			      struct cmd_list_element *c);
13398944Sobrienextern void set_cmd_sfunc (struct cmd_list_element *cmd,
134130803Smarcel			   cmd_sfunc_ftype *sfunc);
13598944Sobrien
136130803Smarcelextern void set_cmd_completer (struct cmd_list_element *cmd,
137130803Smarcel			       char **(*completer) (char *text, char *word));
138130803Smarcel
13998944Sobrien/* HACK: cagney/2002-02-23: Code, mostly in tracepoints.c, grubs
14098944Sobrien   around in cmd objects to test the value of the commands sfunc().  */
14198944Sobrienextern int cmd_cfunc_eq (struct cmd_list_element *cmd,
14298944Sobrien			 void (*cfunc) (char *args, int from_tty));
14398944Sobrien
144130803Smarcel/* Each command object has a local context attached to it. .  */
145130803Smarcelextern void set_cmd_context (struct cmd_list_element *cmd, void *context);
146130803Smarcelextern void *get_cmd_context (struct cmd_list_element *cmd);
147130803Smarcel
148130803Smarcel
149130803Smarcel/* Execute CMD's pre/post hook.  Throw an error if the command fails.
150130803Smarcel   If already executing this pre/post hook, or there is no pre/post
151130803Smarcel   hook, the call is silently ignored.  */
152130803Smarcelextern void execute_cmd_pre_hook (struct cmd_list_element *cmd);
153130803Smarcelextern void execute_cmd_post_hook (struct cmd_list_element *cmd);
154130803Smarcel
155130803Smarcel/* Return the type of the command.  */
156130803Smarcel/* NOTE: cagney/2002-03-17: The add_show_from_set() function clones
157130803Smarcel   the set command passed as a parameter.  The clone operation will
158130803Smarcel   include (BUG?) any ``set'' command callback, if present.  Commands
159130803Smarcel   like ``info set'' call all the ``show'' command callbacks.
160130803Smarcel   Unfortunately, for ``show'' commands cloned from ``set'', this
161130803Smarcel   includes callbacks belonging to ``set'' commands.  Making this
162130803Smarcel   worse, this only occures if add_show_from_set() is called after
163130803Smarcel   add_cmd_sfunc() (BUG?).  */
164130803Smarcelextern enum cmd_types cmd_type (struct cmd_list_element *cmd);
165130803Smarcel
166130803Smarcel
16798944Sobrienextern struct cmd_list_element *lookup_cmd (char **,
16898944Sobrien					    struct cmd_list_element *, char *,
16998944Sobrien					    int, int);
17098944Sobrien
17198944Sobrienextern struct cmd_list_element *lookup_cmd_1 (char **,
17298944Sobrien					      struct cmd_list_element *,
17398944Sobrien					      struct cmd_list_element **,
17498944Sobrien					      int);
17598944Sobrien
17619370Spstextern struct cmd_list_element *
17798944Sobrien  deprecate_cmd (struct cmd_list_element *, char * );
17819370Spst
17919370Spstextern void
18098944Sobrien  deprecated_cmd_warning (char **);
18119370Spst
18298944Sobrienextern int
18398944Sobrien  lookup_cmd_composition (char *text,
18498944Sobrien                        struct cmd_list_element **alias,
18598944Sobrien                        struct cmd_list_element **prefix_cmd,
18698944Sobrien                        struct cmd_list_element **cmd);
18719370Spst
18898944Sobrienextern struct cmd_list_element *add_com (char *, enum command_class,
18998944Sobrien					 void (*fun) (char *, int), char *);
19019370Spst
19198944Sobrienextern struct cmd_list_element *add_com_alias (char *, char *,
19298944Sobrien					       enum command_class, int);
19319370Spst
19498944Sobrienextern struct cmd_list_element *add_info (char *, void (*fun) (char *, int),
19598944Sobrien					  char *);
19619370Spst
19798944Sobrienextern struct cmd_list_element *add_info_alias (char *, char *, int);
19819370Spst
19998944Sobrienextern char **complete_on_cmdlist (struct cmd_list_element *, char *, char *);
20019370Spst
20198944Sobrienextern char **complete_on_enum (const char *enumlist[], char *, char *);
20219370Spst
20398944Sobrienextern void delete_cmd (char *, struct cmd_list_element **);
20419370Spst
20598944Sobrienextern void help_cmd (char *, struct ui_file *);
20619370Spst
20798944Sobrienextern void help_list (struct cmd_list_element *, char *,
20898944Sobrien		       enum command_class, struct ui_file *);
20919370Spst
21098944Sobrienextern void help_cmd_list (struct cmd_list_element *, enum command_class,
21198944Sobrien			   char *, int, struct ui_file *);
21219370Spst
213130803Smarcelextern void add_setshow_cmd (char *name,
214130803Smarcel			     enum command_class class,
215130803Smarcel			     var_types var_type, void *var,
216130803Smarcel			     char *set_doc, char *show_doc,
217130803Smarcel			     cmd_sfunc_ftype *set_func,
218130803Smarcel			     cmd_sfunc_ftype *show_func,
219130803Smarcel			     struct cmd_list_element **set_list,
220130803Smarcel			     struct cmd_list_element **show_list);
221130803Smarcel
222130803Smarcelextern void add_setshow_cmd_full (char *name,
223130803Smarcel				  enum command_class class,
224130803Smarcel				  var_types var_type, void *var,
225130803Smarcel				  char *set_doc, char *show_doc,
226130803Smarcel				  cmd_sfunc_ftype *set_func,
227130803Smarcel				  cmd_sfunc_ftype *show_func,
228130803Smarcel				  struct cmd_list_element **set_list,
229130803Smarcel				  struct cmd_list_element **show_list,
230130803Smarcel				  struct cmd_list_element **set_result,
231130803Smarcel				  struct cmd_list_element **show_result);
232130803Smarcel
23398944Sobrienextern struct cmd_list_element *add_set_cmd (char *name, enum
23498944Sobrien					     command_class class,
23598944Sobrien					     var_types var_type, void *var,
23698944Sobrien					     char *doc,
23798944Sobrien					     struct cmd_list_element **list);
23819370Spst
23998944Sobrienextern struct cmd_list_element *add_set_enum_cmd (char *name,
24098944Sobrien						  enum command_class class,
24198944Sobrien						  const char *enumlist[],
24298944Sobrien						  const char **var,
24398944Sobrien						  char *doc,
24498944Sobrien						  struct cmd_list_element **list);
24519370Spst
246130803Smarcelextern void add_setshow_auto_boolean_cmd (char *name,
247130803Smarcel					  enum command_class class,
248130803Smarcel					  enum auto_boolean *var,
249130803Smarcel					  char *set_doc, char *show_doc,
250130803Smarcel					  cmd_sfunc_ftype *set_func,
251130803Smarcel					  cmd_sfunc_ftype *show_func,
252130803Smarcel					  struct cmd_list_element **set_list,
253130803Smarcel					  struct cmd_list_element **show_list);
25419370Spst
255130803Smarcelextern void add_setshow_boolean_cmd (char *name,
256130803Smarcel				     enum command_class class,
257130803Smarcel				     int *var,
258130803Smarcel				     char *set_doc,
259130803Smarcel				     char *show_doc,
260130803Smarcel				     cmd_sfunc_ftype *set_func,
261130803Smarcel				     cmd_sfunc_ftype *show_func,
262130803Smarcel				     struct cmd_list_element **set_list,
263130803Smarcel				     struct cmd_list_element **show_list);
26498944Sobrien
265130803Smarcelextern void add_setshow_uinteger_cmd (char *name,
266130803Smarcel				      enum command_class class,
267130803Smarcel				      unsigned int *var,
268130803Smarcel				      char *set_doc,
269130803Smarcel				      char *show_doc,
270130803Smarcel				      cmd_sfunc_ftype *set_func,
271130803Smarcel				      cmd_sfunc_ftype *show_func,
272130803Smarcel				      struct cmd_list_element **set_list,
273130803Smarcel				      struct cmd_list_element **show_list);
274130803Smarcel
27598944Sobrienextern struct cmd_list_element *add_show_from_set (struct cmd_list_element *,
27698944Sobrien						   struct cmd_list_element
27798944Sobrien						   **);
27898944Sobrien
27919370Spst/* Do a "show" command for each thing on a command list.  */
28019370Spst
28198944Sobrienextern void cmd_show_list (struct cmd_list_element *, int, char *);
28219370Spst
28398944Sobrienextern NORETURN void error_no_arg (char *) ATTR_NORETURN;
28419370Spst
28598944Sobrienextern void dont_repeat (void);
28619370Spst
28719370Spst/* Used to mark commands that don't do anything.  If we just leave the
28819370Spst   function field NULL, the command is interpreted as a help topic, or
28919370Spst   as a class of commands.  */
29019370Spst
29198944Sobrienextern void not_just_help_class_command (char *, int);
29219370Spst
293130803Smarcel/* check function pointer */
294130803Smarcelextern int cmd_func_p (struct cmd_list_element *cmd);
295130803Smarcel
296130803Smarcel/* call the command function */
297130803Smarcelextern void cmd_func (struct cmd_list_element *cmd, char *args, int from_tty);
298130803Smarcel
29919370Spst#endif /* !defined (COMMAND_H) */
300