Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
CLI commands are described by a struct ast_cli_entry that contains all the components for their implementation.
In the "old-style" format, the record must contain:
a 'generator' function which, given a partial string, can generate legal completions for it. An example is
int old_setdebug(int fd, int argc, char *argv[]); char *dbg_complete(const char *line, const char *word, int pos, int n);
{ { "set", "debug", "on", NULL }, do_setdebug, "Enable debugging", set_debug_usage, dbg_complete },
In the "new-style" format, all the above functionalities are implemented by a single function, and the arguments tell which output is required. The prototype is the following:
char *new_setdebug(const struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
... this is how we create the entry to register AST_CLI_DEFINE(new_setdebug, "short description") ...
To help the transition, we make the pointer to the struct ast_cli_entry available to old-style handlers via argv[-1].
An example of new-style handler is the following