diff options
author | Luigi Rizzo <rizzo@icir.org> | 2006-03-28 22:25:08 +0000 |
---|---|---|
committer | Luigi Rizzo <rizzo@icir.org> | 2006-03-28 22:25:08 +0000 |
commit | e5c455e15ade8146d91acd13d3b852ce6804eae9 (patch) | |
tree | 4f6b1dc0fd0d79a6b00c9c0872e6983a8bee15a2 /include | |
parent | e255a172f09418e8a4c18a110c1a754b88e15b10 (diff) |
bring in the code that was discussed on Mantis #6068,
which is the basis for several simplifications and fixes
to the CLI interfaces.
The core is in cli.c, some documentation on a new function
to help command completion is in cli.h, and one line of
glue code in the other two files.
Next step is to bring in the patches described in #6066 and
other simplifications.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@15817 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk.h | 2 | ||||
-rw-r--r-- | include/asterisk/cli.h | 19 |
2 files changed, 21 insertions, 0 deletions
diff --git a/include/asterisk.h b/include/asterisk.h index 1918af58c..7d052bbf3 100644 --- a/include/asterisk.h +++ b/include/asterisk.h @@ -61,6 +61,8 @@ int term_init(void); int astdb_init(void); /* Provided by channel.c */ void ast_channels_init(void); +/* Provided by cli.c */ +void ast_builtins_init(void); /* Provided by dnsmgr.c */ int dnsmgr_init(void); void dnsmgr_start_refresh(void); diff --git a/include/asterisk/cli.h b/include/asterisk/cli.h index d230efe97..d9c9b7ab3 100644 --- a/include/asterisk/cli.h +++ b/include/asterisk/cli.h @@ -71,10 +71,29 @@ struct ast_cli_entry { char *(*generator)(const char *line, const char *word, int pos, int n); /*! For keeping track of usage */ int inuse; + struct module *module; /*! module this belongs to */ + char *_full_cmd; /* built at load time from cmda[] */ /*! For linking */ AST_LIST_ENTRY(ast_cli_entry) list; }; +/*! + * \brief Helper function to generate cli entries from a NULL-terminated array. + * Returns the n-th matching entry from the array, or NULL if not found. + * Can be used to implement generate() for static entries as below + * (in this example we complete the word in position 2): + \code + char *my_generate(const char *line, const char *word, int pos, int n) + { + static char *choices = { "one", "two", "three", NULL }; + if (pos == 2) + return ast_cli_complete(word, choices, n); + else + return NULL; + } + \endcode + */ +char *ast_cli_complete(const char *word, char *const choices[], int pos); /*! \brief Interprets a command * Interpret a command s, sending output to fd |