Asterisk - The Open Source Telephony Project  21.4.1
Data Structures | Macros | Functions | Variables
res_clialiases.c File Reference

CLI Aliases. More...

#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/config.h"
#include "asterisk/cli.h"
#include "asterisk/astobj2.h"

Go to the source code of this file.

Data Structures

struct  cli_alias
 

Macros

#define FORMAT   "%-50.50s %-50.50s\n"
 
#define MAX_ALIAS_BUCKETS   53
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
static int alias_cmp_cb (void *obj, void *arg, int flags)
 Comparison function used for aliases.
 
static int alias_hash_cb (const void *obj, const int flags)
 Hashing function used for aliases.
 
static int alias_name_cb (void *obj, void *arg, int flags)
 Callback for finding an alias based on name.
 
static char * alias_show (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 CLI Command to display CLI Aliases.
 
static int alias_unregister_cb (void *obj, void *arg, int flags)
 Callback for unregistering an alias.
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
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.
 
static void load_config (int reload)
 Function called to load or reload the configuration file.
 
static int load_module (void)
 Load the module. More...
 
static int reload_module (void)
 Function called to reload the module.
 
static int unload_module (void)
 Function called to unload the module.
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "CLI Aliases" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "da6642af068ee5e6490c5b1d2cc1d238" , .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .reload = reload_module, }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_cli_entry cli_alias []
 CLI commands to interact with things. More...
 
static struct ao2_containercli_aliases
 
static const char config_file [] = "cli_aliases.conf"
 

Detailed Description

CLI Aliases.

Author
Joshua Colp <jcolp@digium.com> 

This module provides the capability to create aliases to other CLI commands.

Definition in file res_clialiases.c.

Macro Definition Documentation

#define MAX_ALIAS_BUCKETS   53

Maximum number of buckets for CLI aliases

Definition at line 50 of file res_clialiases.c.

Referenced by load_module().

Function Documentation

static int load_module ( void  )
static

Load the module.

Module loading including tests for configuration or dependencies. This function can return AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_DECLINE, or AST_MODULE_LOAD_SUCCESS. If a dependency or environment variable fails tests return AST_MODULE_LOAD_FAILURE. If the module can not load the configuration file or other non-critical problem return AST_MODULE_LOAD_DECLINE. On success return AST_MODULE_LOAD_SUCCESS.

Definition at line 283 of file res_clialiases.c.

References alias_cmp_cb(), alias_hash_cb(), AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, ast_cli_register_multiple, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, load_config(), and MAX_ALIAS_BUCKETS.

284 {
287  if (!cli_aliases) {
289  }
290 
291  load_config(0);
292 
294 
296 }
static void load_config(int reload)
Function called to load or reload the configuration file.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
static int alias_cmp_cb(void *obj, void *arg, int flags)
Comparison function used for aliases.
#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.
Definition: astobj2.h:1303
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
static int alias_hash_cb(const void *obj, const int flags)
Hashing function used for aliases.

Variable Documentation

struct ast_cli_entry cli_alias[]
static
Initial value:
= {
{ .handler = alias_show , .summary = "Show CLI command aliases" ,},
}
static char * alias_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI Command to display CLI Aliases.

CLI commands to interact with things.

Definition at line 183 of file res_clialiases.c.

const char config_file[] = "cli_aliases.conf"
static

Configuration file used for this application

Definition at line 53 of file res_clialiases.c.

Referenced by load_config(), and write_config_file().