50 #define MAX_ALIAS_BUCKETS 53
73 const struct cli_alias *alias0 = obj, *alias1 = arg;
106 char *generator = NULL;
110 if (!(alias = ao2_find(cli_aliases, &tmp,
OBJ_POINTER))) {
120 line += (strlen(alias->
alias));
122 struct ast_str *real_cmd = ast_str_alloca(strlen(alias->
real_cmd) + strlen(line) + 1);
131 if (a->argc != e->
args) {
132 struct ast_str *real_cmd = ast_str_alloca(2048);
138 for (i = e->
args + 1; i <= a->argc; i++) {
155 #define FORMAT "%-50.50s %-50.50s\n"
161 e->
command =
"cli show aliases";
163 "Usage: cli show aliases\n"
164 " Displays a list of aliased CLI commands.\n";
170 ast_cli(a->fd, FORMAT,
"Alias Command",
"Real Command");
173 for (; (alias = ao2_iterator_next(&i));
ao2_ref(alias, -1)) {
184 AST_CLI_DEFINE(
alias_show,
"Show CLI command aliases"),
192 struct cli_alias *
alias;
196 ast_log(LOG_ERROR,
"res_clialiases configuration file '%s' not found\n",
config_file);
198 }
else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
207 for (v = ast_variable_browse(cfg,
"general"); v; v = v->
next) {
208 if (strcmp(v->
name,
"template")) {
209 ast_log(LOG_WARNING,
"%s is not a correct option in [%s]\n", v->
name,
"general");
213 for (v1 = ast_variable_browse(cfg, v->
value); v1; v1 = v1->
next) {
217 ast_log(LOG_WARNING,
"Alias '%s' could not be unregistered and has been retained\n",
223 if (!(alias = ao2_alloc((
sizeof(*alias) + strlen(v1->
name) + strlen(v1->
value) + 2), NULL))) {
226 alias->
alias = ((
char *) alias) +
sizeof(*alias);
239 ast_verb(5,
"Aliased CLI command '%s' to '%s'\n", v1->
name, v1->
value);
262 ast_log(LOG_ERROR,
"Could not unregister all CLI aliases\n");
299 .support_level = AST_MODULE_SUPPORT_CORE,
struct ast_variable * next
static void load_config(int reload)
Function called to load or reload the configuration file.
Asterisk main include file. File version handling, generic pbx functions.
static char * alias_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI Command to display CLI Aliases.
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
static int alias_name_cb(void *obj, void *arg, int flags)
Callback for finding an alias based on name.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
int ast_cli_unregister(struct ast_cli_entry *e)
Unregisters a command or an array of commands.
descriptor for a cli entry.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container, as described below.
Structure for variables, used for configurations and for channel variables.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
static int unload_module(void)
Function called to unload the module.
int args
This gets set in ast_cli_register()
#define ast_cli_register(e)
Registers a command or an array of commands.
Configuration File Parser.
static const char config_file[]
#define ast_config_load(filename, flags)
Load a config file.
static int alias_cmp_cb(void *obj, void *arg, int flags)
Comparison function used for aliases.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
ast_cli_command
calling arguments for new-style handlers.
static int alias_unregister_cb(void *obj, void *arg, int flags)
Callback for unregistering an alias.
#define MAX_ALIAS_BUCKETS
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
Support for dynamic strings.
struct ast_cli_entry cli_entry
static int reload_module(void)
Function called to reload the module.
Module has failed to load, may be in an inconsistent state.
static int load_module(void)
Load the module.
char * ast_cli_generator(const char *, const char *, int)
Readline madness Useful for readline, that's about it.
Structure used to handle boolean flags.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Standard Command Line Interface.
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
static int alias_hash_cb(const void *obj, const int flags)
Hashing function used for aliases.
static char * cli_alias_passthrough(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Function which passes through an aliased CLI command to the real one.
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
#define ao2_link(container, obj)
Add an object to a container.