/* Header file for command creation.
- Copyright (C) 1986-2020 Free Software Foundation, Inc.
+ Copyright (C) 1986-2021 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
no_set_class
};
-/* FIXME: cagney/2002-03-17: Once cmd_type() has been removed, ``enum
- cmd_types'' can be moved from "command.h" to "cli-decode.h". */
-/* Not a set/show command. Note that some commands which begin with
- "set" or "show" might be in this category, if their syntax does
- not fall into one of the following categories. */
-typedef enum cmd_types
- {
- not_set_cmd,
- set_cmd,
- show_cmd
- }
-cmd_types;
-
/* Types of "set" or "show" command. */
typedef enum var_types
{
struct cmd_list_element **list,
int *suppress_notification);
-extern struct cmd_list_element *add_alias_cmd (const char *, const char *,
- enum command_class, int,
- struct cmd_list_element **);
-
extern struct cmd_list_element *add_alias_cmd (const char *,
cmd_list_element *,
enum command_class, int,
cmd_const_cfunc_ftype *fun,
const char *,
struct cmd_list_element **,
- const char *, int,
+ int,
struct cmd_list_element **);
/* Like add_prefix_cmd, but sets the callback to a function that
extern struct cmd_list_element *add_basic_prefix_cmd
(const char *, enum command_class, const char *, struct cmd_list_element **,
- const char *, int, struct cmd_list_element **);
+ int, struct cmd_list_element **);
/* Like add_prefix_cmd, but useful for "show" prefixes. This sets the
callback to a function that simply calls cmd_show_list. */
extern struct cmd_list_element *add_show_prefix_cmd
(const char *, enum command_class, const char *, struct cmd_list_element **,
- const char *, int, struct cmd_list_element **);
+ int, struct cmd_list_element **);
extern struct cmd_list_element *add_prefix_cmd_suppress_notification
(const char *name, enum command_class theclass,
cmd_const_cfunc_ftype *fun,
- const char *doc, struct cmd_list_element **prefixlist,
- const char *prefixname, int allow_unknown,
+ const char *doc, struct cmd_list_element **subcommands,
+ int allow_unknown,
struct cmd_list_element **list,
int *suppress_notification);
cmd_const_cfunc_ftype *fun,
const char *,
struct cmd_list_element
- **, const char *, int,
+ **, int,
struct cmd_list_element
**);
extern void execute_cmd_pre_hook (struct cmd_list_element *cmd);
extern void execute_cmd_post_hook (struct cmd_list_element *cmd);
-/* Return the type of the command. */
-extern enum cmd_types cmd_type (struct cmd_list_element *cmd);
-
/* Flag for an ambiguous cmd_list result. */
#define CMD_LIST_AMBIGUOUS ((struct cmd_list_element *) -1)
std::string *,
int, int);
-extern struct cmd_list_element *lookup_cmd_1 (const char **,
- struct cmd_list_element *,
- struct cmd_list_element **,
- std::string *,
- int);
+/* This routine takes a line of TEXT and a CLIST in which to start the
+ lookup. When it returns it will have incremented the text pointer past
+ the section of text it matched, set *RESULT_LIST to point to the list in
+ which the last word was matched, and will return a pointer to the cmd
+ list element which the text matches. It will return NULL if no match at
+ all was possible. It will return -1 (cast appropriately, ick) if ambigous
+ matches are possible; in this case *RESULT_LIST will be set to point to
+ the list in which there are ambiguous choices (and *TEXT will be set to
+ the ambiguous text string).
+
+ if DEFAULT_ARGS is not null, *DEFAULT_ARGS is set to the found command
+ default args (possibly empty).
+
+ If the located command was an abbreviation, this routine returns the base
+ command of the abbreviation. Note that *DEFAULT_ARGS will contain the
+ default args defined for the alias.
+
+ It does no error reporting whatsoever; control will always return
+ to the superior routine.
+
+ In the case of an ambiguous return (-1), *RESULT_LIST will be set to point
+ at the prefix_command (ie. the best match) *or* (special case) will be NULL
+ if no prefix command was ever found. For example, in the case of "info a",
+ "info" matches without ambiguity, but "a" could be "args" or "address", so
+ *RESULT_LIST is set to the cmd_list_element for "info". So in this case
+ RESULT_LIST should not be interpreted as a pointer to the beginning of a
+ list; it simply points to a specific command. In the case of an ambiguous
+ return *TEXT is advanced past the last non-ambiguous prefix (e.g.
+ "info t" can be "info types" or "info target"; upon return *TEXT has been
+ advanced past "info ").
+
+ If RESULT_LIST is NULL, don't set *RESULT_LIST (but don't otherwise
+ affect the operation).
+
+ This routine does *not* modify the text pointed to by TEXT.
+
+ If IGNORE_HELP_CLASSES is nonzero, ignore any command list elements which
+ are actually help classes rather than commands (i.e. the function field of
+ the struct cmd_list_element is NULL).
+
+ When LOOKUP_FOR_COMPLETION_P is true the completion is being requested
+ for the completion engine, no warnings should be printed. */
+
+extern struct cmd_list_element *lookup_cmd_1
+ (const char **text, struct cmd_list_element *clist,
+ struct cmd_list_element **result_list, std::string *default_args,
+ int ignore_help_classes, bool lookup_for_completion_p = false);
+
+/* Look up the command called NAME in the command list LIST.
+
+ Unlike LOOKUP_CMD, partial matches are ignored and only exact matches
+ on NAME are considered.
+
+ LIST is a chain of struct cmd_list_element's.
+
+ If IGNORE_HELP_CLASSES is true (the default), ignore any command list
+ elements which are actually help classes rather than commands (i.e.
+ the function field of the struct cmd_list_element is null).
+
+ If found, return the struct cmd_list_element for that command,
+ otherwise return NULLPTR. */
+
+extern struct cmd_list_element *lookup_cmd_exact
+ (const char *name,
+ struct cmd_list_element *list,
+ bool ignore_help_classes = true);
extern struct cmd_list_element *deprecate_cmd (struct cmd_list_element *,
const char * );
-extern void deprecated_cmd_warning (const char *);
+extern void deprecated_cmd_warning (const char *, struct cmd_list_element *);
extern int lookup_cmd_composition (const char *text,
struct cmd_list_element **alias,
cmd_const_cfunc_ftype *fun,
const char *);
-extern struct cmd_list_element *add_com_alias (const char *, const char *,
- enum command_class, int);
+extern cmd_list_element *add_com_alias (const char *name,
+ cmd_list_element *target,
+ command_class theclass,
+ int abbrev_flag);
extern struct cmd_list_element *add_com_suppress_notification
(const char *name, enum command_class theclass,
cmd_const_cfunc_ftype *fun,
const char *);
-extern struct cmd_list_element *add_info_alias (const char *, const char *,
- int);
+extern cmd_list_element *add_info_alias (const char *name,
+ cmd_list_element *target,
+ int abbrev_flag);
extern void complete_on_cmdlist (struct cmd_list_element *,
completion_tracker &tracker,
instead print the value out directly. */
extern show_value_ftype deprecated_show_value_hack;
-extern void add_setshow_enum_cmd (const char *name,
- enum command_class theclass,
- const char *const *enumlist,
- const char **var,
- const char *set_doc,
- const char *show_doc,
- const char *help_doc,
- cmd_const_sfunc_ftype *set_func,
- show_value_ftype *show_func,
- struct cmd_list_element **set_list,
- struct cmd_list_element **show_list,
- void *context = nullptr);
-
-extern void add_setshow_auto_boolean_cmd (const char *name,
- enum command_class theclass,
- enum auto_boolean *var,
- const char *set_doc,
- const char *show_doc,
- const char *help_doc,
- cmd_const_sfunc_ftype *set_func,
- show_value_ftype *show_func,
- struct cmd_list_element **set_list,
- struct cmd_list_element **show_list);
-
-extern cmd_list_element *
- add_setshow_boolean_cmd (const char *name,
- enum command_class theclass,
- bool *var,
- const char *set_doc, const char *show_doc,
- const char *help_doc,
- cmd_const_sfunc_ftype *set_func,
- show_value_ftype *show_func,
- struct cmd_list_element **set_list,
- struct cmd_list_element **show_list);
-
-extern void add_setshow_filename_cmd (const char *name,
- enum command_class theclass,
- char **var,
- const char *set_doc,
- const char *show_doc,
- const char *help_doc,
- cmd_const_sfunc_ftype *set_func,
- show_value_ftype *show_func,
- struct cmd_list_element **set_list,
- struct cmd_list_element **show_list);
-
-extern void add_setshow_string_cmd (const char *name,
- enum command_class theclass,
- char **var,
- const char *set_doc,
- const char *show_doc,
- const char *help_doc,
- cmd_const_sfunc_ftype *set_func,
- show_value_ftype *show_func,
- struct cmd_list_element **set_list,
- struct cmd_list_element **show_list);
-
-extern struct cmd_list_element *add_setshow_string_noescape_cmd
- (const char *name,
- enum command_class theclass,
- char **var,
- const char *set_doc,
- const char *show_doc,
- const char *help_doc,
- cmd_const_sfunc_ftype *set_func,
- show_value_ftype *show_func,
- struct cmd_list_element **set_list,
- struct cmd_list_element **show_list);
-
-extern void add_setshow_optional_filename_cmd (const char *name,
- enum command_class theclass,
- char **var,
- const char *set_doc,
- const char *show_doc,
- const char *help_doc,
- cmd_const_sfunc_ftype *set_func,
- show_value_ftype *show_func,
- struct cmd_list_element **set_list,
- struct cmd_list_element **show_list);
-
-extern void add_setshow_integer_cmd (const char *name,
- enum command_class theclass,
- int *var,
- const char *set_doc,
- const char *show_doc,
- const char *help_doc,
- cmd_const_sfunc_ftype *set_func,
- show_value_ftype *show_func,
- struct cmd_list_element **set_list,
- struct cmd_list_element **show_list);
-
-extern void add_setshow_uinteger_cmd (const char *name,
- enum command_class theclass,
- unsigned int *var,
- const char *set_doc,
- const char *show_doc,
- const char *help_doc,
- cmd_const_sfunc_ftype *set_func,
- show_value_ftype *show_func,
- struct cmd_list_element **set_list,
- struct cmd_list_element **show_list);
-
-extern void add_setshow_zinteger_cmd (const char *name,
- enum command_class theclass,
- int *var,
- const char *set_doc,
- const char *show_doc,
- const char *help_doc,
- cmd_const_sfunc_ftype *set_func,
- show_value_ftype *show_func,
- struct cmd_list_element **set_list,
- struct cmd_list_element **show_list);
-
-extern void add_setshow_zuinteger_cmd (const char *name,
- enum command_class theclass,
- unsigned int *var,
- const char *set_doc,
- const char *show_doc,
- const char *help_doc,
- cmd_const_sfunc_ftype *set_func,
- show_value_ftype *show_func,
- struct cmd_list_element **set_list,
- struct cmd_list_element **show_list);
-
-extern void
- add_setshow_zuinteger_unlimited_cmd (const char *name,
- enum command_class theclass,
- int *var,
- const char *set_doc,
- const char *show_doc,
- const char *help_doc,
- cmd_const_sfunc_ftype *set_func,
- show_value_ftype *show_func,
- struct cmd_list_element **set_list,
- struct cmd_list_element **show_list);
+/* Return value type for the add_setshow_* functions. */
+
+struct set_show_commands
+{
+ cmd_list_element *set, *show;
+};
+
+extern set_show_commands add_setshow_enum_cmd
+ (const char *name, command_class theclass, const char *const *enumlist,
+ const char **var, const char *set_doc, const char *show_doc,
+ const char *help_doc, cmd_const_sfunc_ftype *set_func,
+ show_value_ftype *show_func, cmd_list_element **set_list,
+ cmd_list_element **show_list, void *context = nullptr);
+
+extern set_show_commands add_setshow_auto_boolean_cmd
+ (const char *name, command_class theclass, auto_boolean *var,
+ const char *set_doc, const char *show_doc, const char *help_doc,
+ cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func,
+ cmd_list_element **set_list, cmd_list_element **show_list);
+
+extern set_show_commands add_setshow_boolean_cmd
+ (const char *name, command_class theclass, bool *var, const char *set_doc,
+ const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func,
+ show_value_ftype *show_func, cmd_list_element **set_list,
+ cmd_list_element **show_list);
+
+extern set_show_commands add_setshow_filename_cmd
+ (const char *name, command_class theclass, char **var, const char *set_doc,
+ const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func,
+ show_value_ftype *show_func, cmd_list_element **set_list,
+ cmd_list_element **show_list);
+
+extern set_show_commands add_setshow_string_cmd
+ (const char *name, command_class theclass, char **var, const char *set_doc,
+ const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func,
+ show_value_ftype *show_func, cmd_list_element **set_list,
+ cmd_list_element **show_list);
+
+extern set_show_commands add_setshow_string_noescape_cmd
+ (const char *name, command_class theclass, char **var, const char *set_doc,
+ const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func,
+ show_value_ftype *show_func, cmd_list_element **set_list,
+ cmd_list_element **show_list);
+
+extern set_show_commands add_setshow_optional_filename_cmd
+ (const char *name, command_class theclass, char **var, const char *set_doc,
+ const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func,
+ show_value_ftype *show_func, cmd_list_element **set_list,
+ cmd_list_element **show_list);
+
+extern set_show_commands add_setshow_integer_cmd
+ (const char *name, command_class theclass, int *var, const char *set_doc,
+ const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func,
+ show_value_ftype *show_func, cmd_list_element **set_list,
+ cmd_list_element **show_list);
+
+extern set_show_commands add_setshow_uinteger_cmd
+ (const char *name, command_class theclass, unsigned int *var,
+ const char *set_doc, const char *show_doc, const char *help_doc,
+ cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func,
+ cmd_list_element **set_list, cmd_list_element **show_list);
+
+extern set_show_commands add_setshow_zinteger_cmd
+ (const char *name, command_class theclass, int *var, const char *set_doc,
+ const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func,
+ show_value_ftype *show_func, cmd_list_element **set_list,
+ cmd_list_element **show_list);
+
+extern set_show_commands add_setshow_zuinteger_cmd
+ (const char *name, command_class theclass, unsigned int *var,
+ const char *set_doc, const char *show_doc, const char *help_doc,
+ cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func,
+ cmd_list_element **set_list, cmd_list_element **show_list);
+
+extern set_show_commands add_setshow_zuinteger_unlimited_cmd
+ (const char *name, command_class theclass, int *var, const char *set_doc,
+ const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func,
+ show_value_ftype *show_func, cmd_list_element **set_list,
+ cmd_list_element **show_list);
/* Do a "show" command for each thing on a command list. */
extern void not_just_help_class_command (const char *, int);
-/* Check function pointer. */
-extern int cmd_func_p (struct cmd_list_element *cmd);
-
/* Call the command function. */
extern void cmd_func (struct cmd_list_element *cmd,
const char *args, int from_tty);