summaryrefslogtreecommitdiff
path: root/include/asterisk/cli.h
diff options
context:
space:
mode:
authorKevin P. Fleming <kpfleming@digium.com>2009-05-21 21:13:09 +0000
committerKevin P. Fleming <kpfleming@digium.com>2009-05-21 21:13:09 +0000
commite6b2e9a7501b5d2e351a5e626fa13dfc3c113f1e (patch)
treeb40d978190102dbe6f14458ab8a70f358db533e4 /include/asterisk/cli.h
parent88bda581ec7c524050bca769c6705ee5c66357ad (diff)
Const-ify the world (or at least a good part of it)
This patch adds 'const' tags to a number of Asterisk APIs where they are appropriate (where the API already demanded that the function argument not be modified, but the compiler was not informed of that fact). The list includes: - CLI command handlers - CLI command handler arguments - AGI command handlers - AGI command handler arguments - Dialplan application handler arguments - Speech engine API function arguments In addition, various file-scope and function-scope constant arrays got 'const' and/or 'static' qualifiers where they were missing. Review: https://reviewboard.asterisk.org/r/251/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@196072 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk/cli.h')
-rw-r--r--include/asterisk/cli.h32
1 files changed, 15 insertions, 17 deletions
diff --git a/include/asterisk/cli.h b/include/asterisk/cli.h
index a02764dfa..f03a39ffe 100644
--- a/include/asterisk/cli.h
+++ b/include/asterisk/cli.h
@@ -97,7 +97,7 @@ void ast_cli(int fd, const char *fmt, ...)
\code
static char *test_new_cli(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- static char *choices = { "one", "two", "three", NULL };
+ static const char * const choices = { "one", "two", "three", NULL };
switch (cmd) {
case CLI_INIT:
@@ -128,7 +128,7 @@ static char *test_new_cli(struct ast_cli_entry *e, int cmd, struct ast_cli_args
/*! \brief calling arguments for new-style handlers.
* \arg \ref CLI_command_API
*/
-enum ast_cli_fn {
+enum ast_cli_command {
CLI_INIT = -2, /* return the usage string */
CLI_GENERATE = -3, /* behave as 'generator', remap argv to struct ast_cli_args */
CLI_HANDLER = -4, /* run the normal handler */
@@ -136,27 +136,25 @@ enum ast_cli_fn {
/* argument for new-style CLI handler */
struct ast_cli_args {
- int fd;
- int argc;
- char **argv;
+ const int fd;
+ const int argc;
+ const char * const *argv;
const char *line; /* the current input line */
const char *word; /* the word we want to complete */
- int pos; /* position of the word to complete */
- int n; /* the iteration count (n-th entry we generate) */
+ const int pos; /* position of the word to complete */
+ const int n; /* the iteration count (n-th entry we generate) */
};
-struct ast_cli_entry;
-typedef char *(*cli_fn)(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
-
/*! \brief descriptor for a cli entry.
* \arg \ref CLI_command_API
*/
struct ast_cli_entry {
- char * const cmda[AST_MAX_CMD_LEN]; /*!< words making up the command.
- * set the first entry to NULL for a new-style entry. */
+ const char * const cmda[AST_MAX_CMD_LEN]; /*!< words making up the command.
+ * set the first entry to NULL for a new-style entry.
+ */
- const char *summary; /*!< Summary of the command (< 60 characters) */
- const char *usage; /*!< Detailed usage information */
+ const char * const summary; /*!< Summary of the command (< 60 characters) */
+ const char * usage; /*!< Detailed usage information */
int inuse; /*!< For keeping track of usage */
struct module *module; /*!< module this belongs to */
@@ -166,7 +164,7 @@ struct ast_cli_entry {
*/
int args; /*!< number of non-null entries in cmda */
char *command; /*!< command, non-null for new-style entries */
- cli_fn handler;
+ char *(*handler)(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
/*! For linking */
AST_LIST_ENTRY(ast_cli_entry) list;
};
@@ -183,7 +181,7 @@ struct ast_cli_entry {
\code
char *my_generate(const char *line, const char *word, int pos, int n)
{
- static char *choices = { "one", "two", "three", NULL };
+ static const char * const choices = { "one", "two", "three", NULL };
if (pos == 2)
return ast_cli_complete(word, choices, n);
else
@@ -191,7 +189,7 @@ struct ast_cli_entry {
}
\endcode
*/
-char *ast_cli_complete(const char *word, char *const choices[], int pos);
+char *ast_cli_complete(const char *word, const char * const choices[], int pos);
/*!
* \brief Interprets a command