Asterisk - The Open Source Telephony Project  21.4.1
Functions
_private.h File Reference

Prototypes for public functions only of internal interest,. More...

Go to the source code of this file.

Functions

int aco_init (void)
 
void ast_autoservice_init (void)
 
int ast_bridging_init (void)
 Initialize the bridging system. More...
 
void ast_builtins_init (void)
 initialize the _full_cmd string in * each of the builtins. More...
 
int ast_channels_init (void)
 
void ast_cli_channels_init (void)
 
int ast_cli_perms_init (int reload)
 
int ast_device_state_engine_init (void)
 Initialize the device state engine in separate thread. More...
 
int ast_dns_system_resolver_init (void)
 Initializes the resolver. More...
 
int ast_endpoint_init (void)
 Endpoint support initialization. More...
 
int ast_file_init (void)
 
int ast_local_init (void)
 Initialize the local proxy channel. More...
 
int ast_msg_init (void)
 
void ast_msg_shutdown (void)
 
int ast_named_locks_init (void)
 
int ast_parking_stasis_init (void)
 initializes the rtp engine arrays More...
 
int ast_pj_init (void)
 
void ast_process_pending_reloads (void)
 Process reload requests received during startup. More...
 
int ast_refer_init (void)
 
int ast_rtp_engine_init (void)
 initializes the rtp engine arrays
 
int ast_ssl_init (void)
 
void ast_stun_init (void)
 Initialize the STUN system in Asterisk. More...
 
int ast_term_init (void)
 
int ast_test_init (void)
 
int ast_timing_init (void)
 
int ast_tps_init (void)
 
int ast_xmldoc_load_documentation (void)
 Load XML documentation. Provided by xmldoc.c. More...
 
int astdb_init (void)
 
int astobj2_init (void)
 
void clean_time_zones (void)
 
void close_logger (void)
 
int dns_core_init (void)
 
void dnsmgr_start_refresh (void)
 
int init_logger (void)
 
void load_asterisk_conf (void)
 
void load_astmm_phase_1 (void)
 Initialize malloc debug phase 1. More...
 
void load_astmm_phase_2 (void)
 Initialize malloc debug phase 2.
 
int load_modules (void)
 
int load_pbx (void)
 
int load_pbx_app (void)
 
int load_pbx_builtins (void)
 
int load_pbx_functions_cli (void)
 
int load_pbx_hangup_handler (void)
 
int load_pbx_switch (void)
 
int load_pbx_variables (void)
 
void logger_queue_start (void)
 Start the ast_queue_log() logger. More...
 
int modules_shutdown (void)
 
void set_asterisk_conf_path (const char *path)
 
void set_socket_path (const char *path)
 
void threadstorage_init (void)
 

Detailed Description

Prototypes for public functions only of internal interest,.

Definition in file _private.h.

Function Documentation

int aco_init ( void  )

Provided by config_options.c

Definition at line 1428 of file config_options.c.

References ast_cli_register_multiple, ast_register_cleanup(), and ast_xmldoc_build_documentation().

1429 {
1430 #ifdef AST_XML_DOCS
1431  ast_register_cleanup(aco_deinit);
1432  if (!(xmldocs = ast_xmldoc_build_documentation("configInfo"))) {
1433  ast_log(LOG_ERROR, "Couldn't build config documentation\n");
1434  return -1;
1435  }
1436  ast_cli_register_multiple(cli_aco, ARRAY_LEN(cli_aco));
1437 #endif /* AST_XML_DOCS */
1438  return 0;
1439 }
struct ao2_container * ast_xmldoc_build_documentation(const char *type)
Build the documentation for a particular source type.
Definition: xmldoc.c:2684
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
void ast_autoservice_init ( void  )

Provided by autoservice.c

Definition at line 380 of file autoservice.c.

References ast_register_cleanup().

381 {
382  ast_register_cleanup(autoservice_shutdown);
383  ast_cond_init(&as_cond, NULL);
384 }
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
int ast_bridging_init ( void  )

Initialize the bridging system.

Since
12.0.0
Return values
0on success.
-1on error.

Definition at line 5543 of file bridge.c.

References AO2_ALLOC_OPT_LOCK_MUTEX, AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE, ao2_container_alloc_rbtree, ao2_container_register(), ast_bridging_init_basic(), ast_cli_register_multiple, ast_manager_register_xml_core, ast_register_cleanup(), and bridge_manager.

5544 {
5545  ast_register_cleanup(bridge_cleanup);
5546 
5547  if (ast_stasis_bridging_init()) {
5548  return -1;
5549  }
5550 
5551  bridge_manager = bridge_manager_create();
5552  if (!bridge_manager) {
5553  return -1;
5554  }
5555 
5557  AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE, bridge_sort_cmp, NULL);
5558  if (!bridges) {
5559  return -1;
5560  }
5561  ao2_container_register("bridges", bridges, bridge_prnt_obj);
5562 
5564 
5565  ast_cli_register_multiple(bridge_cli, ARRAY_LEN(bridge_cli));
5566 
5567  ast_manager_register_xml_core("BridgeTechnologyList", 0, manager_bridge_tech_list);
5568  ast_manager_register_xml_core("BridgeTechnologySuspend", 0, manager_bridge_tech_suspend);
5569  ast_manager_register_xml_core("BridgeTechnologyUnsuspend", 0, manager_bridge_tech_unsuspend);
5570 
5571  return 0;
5572 }
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
static struct bridge_manager_controller * bridge_manager
Definition: bridge.c:172
#define ast_manager_register_xml_core(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
Definition: manager.h:202
int ao2_container_register(const char *name, struct ao2_container *self, ao2_prnt_obj_fn *prnt_obj)
Register a container for CLI stats and integrity check.
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
static struct ao2_container * bridges
Definition: bridge.c:123
void ast_bridging_init_basic(void)
Replace objects with duplicate keys in container.
Definition: astobj2.h:1211
#define ao2_container_alloc_rbtree(ao2_options, container_options, sort_fn, cmp_fn)
Allocate and initialize a red-black tree container.
Definition: astobj2.h:1349
void ast_builtins_init ( void  )

initialize the _full_cmd string in * each of the builtins.

Provided by cli.c

Definition at line 2238 of file main/cli.c.

References ast_cli_register_multiple, ast_register_cleanup(), and AST_VECTOR_INIT.

2239 {
2240  AST_VECTOR_INIT(&shutdown_commands, 0);
2241  ast_cli_register_multiple(cli_cli, ARRAY_LEN(cli_cli));
2242  ast_register_cleanup(cli_shutdown);
2243 }
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Definition: vector.h:113
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
int ast_channels_init ( void  )

Provided by channel.c

Definition at line 8007 of file channel.c.

References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, ao2_container_register(), ast_channel_register(), ast_cli_register_multiple, AST_NUM_CHANNEL_BUCKETS, ast_register_cleanup(), AST_RWLIST_HEAD_INIT, and ast_stasis_channels_init().

8008 {
8010  ast_channel_hash_cb, NULL, ast_channel_cmp_cb);
8011  if (!channels) {
8012  return -1;
8013  }
8014  ao2_container_register("channels", channels, prnt_channel_key);
8015 
8017 
8019 
8020  ast_cli_register_multiple(cli_channel, ARRAY_LEN(cli_channel));
8021 
8022  ast_register_cleanup(channels_shutdown);
8023 
8024  AST_RWLIST_HEAD_INIT(&ami_vars);
8025  AST_RWLIST_HEAD_INIT(&ari_vars);
8026 
8027  return 0;
8028 }
#define AST_NUM_CHANNEL_BUCKETS
Definition: channel.h:155
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
#define AST_RWLIST_HEAD_INIT(head)
Initializes an rwlist head structure.
Definition: linkedlists.h:639
static const struct ast_channel_tech surrogate_tech
Channel technology used to extract a channel from a running application. The channel created with thi...
Definition: channel.c:696
int ao2_container_register(const char *name, struct ao2_container *self, ao2_prnt_obj_fn *prnt_obj)
Register a container for CLI stats and integrity check.
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
int ast_stasis_channels_init(void)
Initialize the stasis channel topic and message types.
#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
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:124
int ast_channel_register(const struct ast_channel_tech *tech)
Register a new telephony channel in Asterisk.
Definition: channel.c:539
void ast_cli_channels_init ( void  )

Provided by cli.c

Definition at line 2245 of file main/cli.c.

References ast_cli_register_multiple, and ast_register_cleanup().

2246 {
2247  ast_cli_register_multiple(cli_channels_cli, ARRAY_LEN(cli_channels_cli));
2248  ast_register_cleanup(cli_channels_shutdown);
2249 }
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
int ast_cli_perms_init ( int  reload)

Provided by cli.c

Definition at line 2105 of file main/cli.c.

References ast_calloc, ast_category_browse(), ast_config_destroy(), ast_config_load2(), AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_strdup, cli_default_perm, cli_perm::command, CONFIG_FLAG_FILEUNCHANGED, destroy_user_perms(), usergroup_cli_perm::gid, ast_variable::name, ast_variable::next, cli_perm::permit, usergroup_cli_perm::perms, perms_config, permsconfiglock, usergroup_cli_perm::uid, and ast_variable::value.

Referenced by handle_cli_reload_permissions().

2106 {
2107  struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
2108  struct ast_config *cfg;
2109  char *cat = NULL;
2110  struct ast_variable *v;
2111  struct usergroup_cli_perm *user_group, *cp_entry;
2112  struct cli_perm *perm = NULL;
2113  struct passwd *pw;
2114  struct group *gr;
2115 
2116  if (ast_mutex_trylock(&permsconfiglock)) {
2117  ast_log(LOG_NOTICE, "You must wait until last 'cli reload permissions' command finish\n");
2118  return 1;
2119  }
2120 
2121  cfg = ast_config_load2(perms_config, "" /* core, can't reload */, config_flags);
2122  if (!cfg) {
2123  ast_mutex_unlock(&permsconfiglock);
2124  return 1;
2125  } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
2126  ast_mutex_unlock(&permsconfiglock);
2127  return 0;
2128  }
2129 
2130  /* free current structures. */
2132 
2133  while ((cat = ast_category_browse(cfg, cat))) {
2134  if (!strcasecmp(cat, "general")) {
2135  /* General options */
2136  for (v = ast_variable_browse(cfg, cat); v; v = v->next) {
2137  if (!strcasecmp(v->name, "default_perm")) {
2138  cli_default_perm = (!strcasecmp(v->value, "permit")) ? 1: 0;
2139  }
2140  }
2141  continue;
2142  }
2143 
2144  /* users or groups */
2145  gr = NULL, pw = NULL;
2146  if (cat[0] == '@') {
2147  /* This is a group */
2148  gr = getgrnam(&cat[1]);
2149  if (!gr) {
2150  ast_log (LOG_WARNING, "Unknown group '%s'\n", &cat[1]);
2151  continue;
2152  }
2153  } else {
2154  /* This is a user */
2155  pw = getpwnam(cat);
2156  if (!pw) {
2157  ast_log (LOG_WARNING, "Unknown user '%s'\n", cat);
2158  continue;
2159  }
2160  }
2161  user_group = NULL;
2162  /* Check for duplicates */
2164  AST_LIST_TRAVERSE(&cli_perms, cp_entry, list) {
2165  if ((pw && cp_entry->uid == pw->pw_uid) || (gr && cp_entry->gid == gr->gr_gid)) {
2166  /* if it is duplicated, just added this new settings, to
2167  the current list. */
2168  user_group = cp_entry;
2169  break;
2170  }
2171  }
2173 
2174  if (!user_group) {
2175  /* alloc space for the new user config. */
2176  user_group = ast_calloc(1, sizeof(*user_group));
2177  if (!user_group) {
2178  continue;
2179  }
2180  user_group->uid = (pw ? pw->pw_uid : -1);
2181  user_group->gid = (gr ? gr->gr_gid : -1);
2182  user_group->perms = ast_calloc(1, sizeof(*user_group->perms));
2183  if (!user_group->perms) {
2184  ast_free(user_group);
2185  continue;
2186  }
2187  }
2188  for (v = ast_variable_browse(cfg, cat); v; v = v->next) {
2189  if (ast_strlen_zero(v->value)) {
2190  /* we need to check this condition cause it could break security. */
2191  ast_log(LOG_WARNING, "Empty permit/deny option in user '%s'\n", cat);
2192  continue;
2193  }
2194  if (!strcasecmp(v->name, "permit")) {
2195  perm = ast_calloc(1, sizeof(*perm));
2196  if (perm) {
2197  perm->permit = 1;
2198  perm->command = ast_strdup(v->value);
2199  }
2200  } else if (!strcasecmp(v->name, "deny")) {
2201  perm = ast_calloc(1, sizeof(*perm));
2202  if (perm) {
2203  perm->permit = 0;
2204  perm->command = ast_strdup(v->value);
2205  }
2206  } else {
2207  /* up to now, only 'permit' and 'deny' are possible values. */
2208  ast_log(LOG_WARNING, "Unknown '%s' option\n", v->name);
2209  continue;
2210  }
2211  if (perm) {
2212  /* Added the permission to the user's list. */
2213  AST_LIST_INSERT_TAIL(user_group->perms, perm, list);
2214  perm = NULL;
2215  }
2216  }
2218  AST_RWLIST_INSERT_TAIL(&cli_perms, user_group, list);
2220  }
2221 
2222  ast_config_destroy(cfg);
2223  ast_mutex_unlock(&permsconfiglock);
2224  return 0;
2225 }
struct ast_variable * next
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
Definition: main/config.c:3321
static ast_mutex_t permsconfiglock
mutex used to prevent a user from running the 'cli reload permissions' command while it is already ru...
Definition: main/cli.c:91
Structure for variables, used for configurations and for channel variables.
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:52
static const char perms_config[]
CLI permissions config file.
Definition: main/cli.c:85
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
Definition: extconf.c:3326
static int cli_default_perm
Default permissions value 1=Permit 0=Deny.
Definition: main/cli.c:87
struct cli_perm_head * perms
Definition: main/cli.c:81
List of restrictions per user.
Definition: main/cli.c:69
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:731
list of users to apply restrictions.
Definition: main/cli.c:78
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:491
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
Structure used to handle boolean flags.
Definition: utils.h:199
List of users and permissions.
Definition: main/cli.c:93
char * command
Definition: main/cli.c:71
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
Definition: extconf.c:1289
unsigned int permit
Definition: main/cli.c:70
static void destroy_user_perms(void)
cleanup (free) cli_perms linkedlist.
Definition: main/cli.c:2089
int ast_device_state_engine_init ( void  )

Initialize the device state engine in separate thread.

Provided by devicestate.c

Definition at line 618 of file devicestate.c.

References ast_register_cleanup(), change_pending, change_thread, and do_devstate_changes().

619 {
620  ast_cond_init(&change_pending, NULL);
621  if (ast_pthread_create_background(&change_thread, NULL, do_devstate_changes, NULL) < 0) {
622  ast_log(LOG_ERROR, "Unable to start device state change thread.\n");
623  return -1;
624  }
625  ast_register_cleanup(device_state_engine_cleanup);
626 
627  return 0;
628 }
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
static pthread_t change_thread
The device state change notification thread.
Definition: devicestate.c:211
static void * do_devstate_changes(void *data)
Go through the dev state change queue and update changes in the dev state thread. ...
Definition: devicestate.c:523
static ast_cond_t change_pending
Flag for the queue.
Definition: devicestate.c:214
int ast_dns_system_resolver_init ( void  )

Initializes the resolver.

Provided by dns_system_resolver.c

Return values
0on success
-1on failure

Definition at line 244 of file dns_system_resolver.c.

References ast_dns_resolver_register(), ast_register_cleanup(), ast_taskprocessor_get(), dns_system_resolver_destroy(), DNS_SYSTEM_RESOLVER_FAILURE, DNS_SYSTEM_RESOLVER_SUCCESS, and TPS_REF_DEFAULT.

245 {
246  /* Register the base resolver */
248 
249  if (res) {
251  }
252 
253  /* Instantiate the task processor */
254  dns_system_resolver_tp = ast_taskprocessor_get("dns_system_resolver_tp",
256 
257  /* Return error if the task processor failed to instantiate */
258  if (!dns_system_resolver_tp) {
260  }
261 
262  /* Register the cleanup function */
264 
266 }
struct ast_taskprocessor * ast_taskprocessor_get(const char *name, enum ast_tps_options create)
Get a reference to a taskprocessor with the specified name and create the taskprocessor if necessary...
return a reference to a taskprocessor, create one if it does not exist
Definition: taskprocessor.h:76
#define DNS_SYSTEM_RESOLVER_SUCCESS
Resolver return code upon success.
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
int ast_dns_resolver_register(struct ast_dns_resolver *resolver)
Register a DNS resolver.
Definition: dns_core.c:630
static void dns_system_resolver_destroy(void)
Destructor.
struct ast_dns_resolver dns_system_resolver_base
The base definition for the dns_system_resolver.
#define DNS_SYSTEM_RESOLVER_FAILURE
Resolver return code upon failure.
static struct ast_taskprocessor * dns_system_resolver_tp
The task processor to use for making DNS searches asynchronous.
int ast_endpoint_init ( void  )

Endpoint support initialization.

Returns
0 on success.
Non-zero on error.

Definition at line 496 of file main/endpoints.c.

References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, ast_register_cleanup(), ENDPOINT_BUCKETS, and TECH_ENDPOINT_BUCKETS.

497 {
498  ast_register_cleanup(endpoint_cleanup);
499 
501  ast_endpoint_hash_fn, NULL, ast_endpoint_cmp_fn);
502  if (!endpoints) {
503  return -1;
504  }
505 
507  TECH_ENDPOINT_BUCKETS, ast_endpoint_hash_fn, NULL, ast_endpoint_cmp_fn);
508  if (!tech_endpoints) {
509  return -1;
510  }
511 
512  return 0;
513 }
#define ENDPOINT_BUCKETS
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
#define TECH_ENDPOINT_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
static struct stasis_rest_handlers endpoints
REST handler for /api-docs/endpoints.json.
int ast_file_init ( void  )

Provided by file.c

Definition at line 2051 of file file.c.

2052 {
2055  ast_cli_register_multiple(cli_file, ARRAY_LEN(cli_file));
2056  ast_register_cleanup(file_shutdown);
2057  return 0;
2058 }
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
Definition: stasis.h:1493
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
struct stasis_message_type * ast_format_unregister_type(void)
Get the message type used for signaling a format unregistration.
struct stasis_message_type * ast_format_register_type(void)
Get the message type used for signaling a format registration.
int ast_local_init ( void  )

Initialize the local proxy channel.

Since
12.0.0
Return values
0on success.
-1on error.

Definition at line 1139 of file core_local.c.

References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_list, ast_channel_register(), ast_cli_register_multiple, ast_format_cap_alloc, ast_format_cap_append_by_type(), AST_FORMAT_CAP_FLAG_DEFAULT, ast_local_bridge_type(), ast_local_optimization_begin_type(), ast_local_optimization_end_type(), ast_manager_register_xml_core, ast_register_cleanup(), ast_channel_tech::capabilities, and STASIS_MESSAGE_TYPE_INIT.

1140 {
1142  return -1;
1143  }
1144 
1146  return -1;
1147  }
1148 
1150  return -1;
1151  }
1152 
1154  return -1;
1155  }
1156  ast_format_cap_append_by_type(local_tech.capabilities, AST_MEDIA_TYPE_UNKNOWN);
1157 
1158  locals = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_MUTEX, 0, NULL, locals_cmp_cb);
1159  if (!locals) {
1160  return -1;
1161  }
1162 
1163  /* Make sure we can register our channel type */
1164  if (ast_channel_register(&local_tech)) {
1165  ast_log(LOG_ERROR, "Unable to register channel class 'Local'\n");
1166 
1167  return -1;
1168  }
1169  ast_cli_register_multiple(cli_local, ARRAY_LEN(cli_local));
1170  ast_manager_register_xml_core("LocalOptimizeAway", EVENT_FLAG_SYSTEM|EVENT_FLAG_CALL, manager_optimize_away);
1171 
1172  ast_register_cleanup(local_shutdown);
1173  return 0;
1174 }
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
Definition: stasis.h:1493
#define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
Allocate and initialize a list container.
Definition: astobj2.h:1327
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
int ast_format_cap_append_by_type(struct ast_format_cap *cap, enum ast_media_type type)
Add all codecs Asterisk knows about for a specific type to the capabilities structure.
Definition: format_cap.c:216
int ast_channel_register(const struct ast_channel_tech *tech)
Register a channel technology (a new channel driver) Called by a channel module to register the kind ...
Definition: channel.c:539
#define ast_manager_register_xml_core(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
Definition: manager.h:202
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
#define ast_format_cap_alloc(flags)
Allocate a new ast_format_cap structure.
Definition: format_cap.h:49
struct stasis_message_type * ast_local_optimization_end_type(void)
Message type for when a local channel optimization completes.
struct ast_format_cap * capabilities
Definition: channel.h:632
struct stasis_message_type * ast_local_bridge_type(void)
Message type for when two local channel halves are bridged together.
struct stasis_message_type * ast_local_optimization_begin_type(void)
Message type for when a local channel optimization begins.
int ast_msg_init ( void  )

Provided by message.c

Definition at line 1758 of file main/message.c.

References __ast_custom_function_register(), ast_manager_register_xml_core, ast_msg_handler_register(), ast_register_application2(), ast_register_cleanup(), ast_rwlock_init, ast_taskprocessor_get(), AST_VECTOR_INIT, msg_handlers, msg_handlers_lock, msg_techs, and TPS_REF_DEFAULT.

1759 {
1760  int res;
1761 
1762  msg_q_tp = ast_taskprocessor_get("ast_msg_queue", TPS_REF_DEFAULT);
1763  if (!msg_q_tp) {
1764  return -1;
1765  }
1766 
1768  if (AST_VECTOR_INIT(&msg_techs, 8)) {
1769  return -1;
1770  }
1771 
1773  if (AST_VECTOR_INIT(&msg_handlers, 4)) {
1774  return -1;
1775  }
1776 
1777  res = ast_msg_handler_register(&dialplan_msg_handler);
1778 
1779  res |= __ast_custom_function_register(&msg_function, NULL);
1780  res |= __ast_custom_function_register(&msg_data_function, NULL);
1781  res |= ast_register_application2(app_msg_send, msg_send_exec, NULL, NULL, NULL);
1782  res |= ast_manager_register_xml_core("MessageSend", EVENT_FLAG_MESSAGE, action_messagesend);
1783 
1784  ast_register_cleanup(message_shutdown);
1785 
1786  return res;
1787 }
#define ast_rwlock_init(rwlock)
wrapper for rwlock with tracking enabled
Definition: lock.h:224
struct ast_taskprocessor * ast_taskprocessor_get(const char *name, enum ast_tps_options create)
Get a reference to a taskprocessor with the specified name and create the taskprocessor if necessary...
return a reference to a taskprocessor, create one if it does not exist
Definition: taskprocessor.h:76
struct @378 msg_handlers
Vector of received message handlers.
static ast_rwlock_t msg_techs_lock
Lock for msg_techs vector.
Definition: main/message.c:269
#define ast_manager_register_xml_core(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
Definition: manager.h:202
int ast_msg_handler_register(const struct ast_msg_handler *handler)
Register a ast_msg_handler.
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Definition: vector.h:113
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
struct @377 msg_techs
Vector of message technologies.
static ast_rwlock_t msg_handlers_lock
Lock for msg_handlers vector.
Definition: main/message.c:275
int __ast_custom_function_register(struct ast_custom_function *acf, struct ast_module *mod)
Register a custom function.
int ast_register_application2(const char *app, int(*execute)(struct ast_channel *, const char *), const char *synopsis, const char *description, void *mod)
Register an application.
Definition: pbx_app.c:103
void ast_msg_shutdown ( void  )

Provided by message.c

Definition at line 1717 of file main/message.c.

References ast_taskprocessor_unreference().

1718 {
1719  if (msg_q_tp) {
1720  msg_q_tp = ast_taskprocessor_unreference(msg_q_tp);
1721  }
1722 }
void * ast_taskprocessor_unreference(struct ast_taskprocessor *tps)
Unreference the specified taskprocessor and its reference count will decrement.
int ast_named_locks_init ( void  )

Provided by named_locks.c

Definition at line 52 of file named_locks.c.

References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, and ast_register_cleanup().

53 {
55  NAMED_LOCKS_BUCKETS, named_lock_proxy_hash_fn, NULL, named_lock_proxy_cmp_fn);
56  if (!named_locks) {
57  return -1;
58  }
59 
60  ast_register_cleanup(named_locks_shutdown);
61 
62  return 0;
63 }
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
#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
int ast_parking_stasis_init ( void  )

initializes the rtp engine arrays

Since
12.0.0

Definition at line 53 of file parking.c.

References ast_parked_call_type(), ast_register_cleanup(), STASIS_MESSAGE_TYPE_INIT, and stasis_topic_create().

54 {
56  return -1;
57  }
58 
59  parking_topic = stasis_topic_create("parking:all");
60  if (!parking_topic) {
61  return -1;
62  }
63  ast_register_cleanup(parking_stasis_cleanup);
64  return 0;
65 }
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
Definition: stasis.h:1493
struct stasis_message_type * ast_parked_call_type(void)
accessor for the parked call stasis message type
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
struct stasis_topic * stasis_topic_create(const char *name)
Create a new topic.
Definition: stasis.c:617
static struct stasis_topic * parking_topic
Topic for parking lots.
Definition: parking.c:41
int ast_pj_init ( void  )

Provided by libasteriskpj.c

Definition at line 45 of file libasteriskpj.c.

References AST_PJPROJECT_INIT_LOG_LEVEL.

46 {
47 #ifdef HAVE_PJPROJECT_BUNDLED
49  pj_init();
50 #endif
51  return 0;
52 }
#define AST_PJPROJECT_INIT_LOG_LEVEL()
Get maximum log level pjproject was compiled with.
Definition: options.h:167
void ast_process_pending_reloads ( void  )

Process reload requests received during startup.

This function requests that the loader execute the pending reload requests that were queued during server startup.

Note
This function will do nothing if the server has not completely started up. Once called, the reload queue is emptied, and further invocations will have no affect.

Definition at line 1566 of file loader.c.

References AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, and ast_module_reload().

1567 {
1568  struct reload_queue_item *item;
1569 
1570  modules_loaded = 1;
1571 
1573 
1574  if (do_full_reload) {
1575  do_full_reload = 0;
1577  ast_log(LOG_NOTICE, "Executing deferred reload request.\n");
1578  ast_module_reload(NULL);
1579  return;
1580  }
1581 
1582  while ((item = AST_LIST_REMOVE_HEAD(&reload_queue, entry))) {
1583  ast_log(LOG_NOTICE, "Executing deferred reload request for module '%s'.\n", item->module);
1584  ast_module_reload(item->module);
1585  ast_free(item);
1586  }
1587 
1589 }
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:40
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:140
enum ast_module_reload_result ast_module_reload(const char *name)
Reload asterisk modules.
Definition: loader.c:1721
static int modules_loaded
Internal flag to indicate all modules have been initially loaded.
Definition: loader.c:291
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:833
Definition: search.h:40
int ast_refer_init ( void  )

Provided by refer.c

Definition at line 529 of file refer.c.

References ast_register_cleanup(), ast_rwlock_init, AST_VECTOR_INIT, and refer_techs.

530 {
532  if (AST_VECTOR_INIT(&refer_techs, 8)) {
533  return -1;
534  }
535  ast_register_cleanup(refer_shutdown);
536  return 0;
537 }
#define ast_rwlock_init(rwlock)
wrapper for rwlock with tracking enabled
Definition: lock.h:224
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Definition: vector.h:113
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
struct @387 refer_techs
Vector of refer technologies.
static ast_rwlock_t refer_techs_lock
Lock for refer_techs vector.
Definition: refer.c:77
int ast_ssl_init ( void  )

Provided by ssl.c

Definition at line 130 of file libasteriskssl.c.

References ast_calloc, and ast_debug.

131 {
132  unsigned int i;
133  int (*real_SSL_library_init)(void);
134 #if OPENSSL_VERSION_NUMBER < 0x10000000L
135  void (*real_CRYPTO_set_id_callback)(unsigned long (*)(void));
136 #endif
137  void (*real_CRYPTO_set_locking_callback)(void (*)(int, int, const char *, int));
138  void (*real_SSL_load_error_strings)(void);
139  const char *errstr;
140 
141  /* clear any previous dynamic linker errors */
142  dlerror();
143  get_OpenSSL_function(SSL_library_init);
144  if ((errstr = dlerror()) != NULL) {
145  ast_debug(1, "unable to get real address of SSL_library_init: %s\n", errstr);
146  /* there is no way to continue in this situation... SSL will
147  * likely be broken in this process
148  */
149  return -1;
150  } else {
151  real_SSL_library_init();
152  }
153 
154  /* Make OpenSSL usage thread-safe. */
155 
156 #if OPENSSL_VERSION_NUMBER < 0x10000000L
157  dlerror();
158  get_OpenSSL_function(CRYPTO_set_id_callback);
159  if ((errstr = dlerror()) != NULL) {
160  ast_debug(1, "unable to get real address of CRYPTO_set_id_callback: %s\n", errstr);
161  /* there is no way to continue in this situation... SSL will
162  * likely be broken in this process
163  */
164  return -1;
165  } else {
166  real_CRYPTO_set_id_callback(ssl_threadid);
167  }
168 #endif
169 
170  dlerror();
171  get_OpenSSL_function(CRYPTO_set_locking_callback);
172  if ((errstr = dlerror()) != NULL) {
173  ast_debug(1, "unable to get real address of CRYPTO_set_locking_callback: %s\n", errstr);
174  /* there is no way to continue in this situation... SSL will
175  * likely be broken in this process
176  */
177  return -1;
178  } else {
179  ssl_num_locks = CRYPTO_num_locks();
180  if (!(ssl_locks = ast_calloc(ssl_num_locks, sizeof(ssl_locks[0])))) {
181  return -1;
182  }
183  for (i = 0; i < ssl_num_locks; i++) {
184  ast_mutex_init(&ssl_locks[i]);
185  }
186  real_CRYPTO_set_locking_callback(ssl_lock);
187  }
188 
189  /* after this point, we don't check for errors from the dlsym() calls,
190  * under the assumption that if the ones above were successful, all
191  * the rest will be too. this assumption holds as long as OpenSSL still
192  * provides all of these functions.
193  */
194 
195  get_OpenSSL_function(SSL_load_error_strings);
196  real_SSL_load_error_strings();
197 
198  startup_complete = 1;
199 
200  return 0;
201 }
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
void ast_stun_init ( void  )

Initialize the STUN system in Asterisk.

Provided by stun.c

Definition at line 576 of file stun.c.

References ast_cli_register_multiple, and ast_register_atexit().

577 {
578  ast_cli_register_multiple(cli_stun, sizeof(cli_stun) / sizeof(struct ast_cli_entry));
579  debug_category_stun_id = ast_debug_category_register(AST_LOG_CATEGORY_STUN);
580  debug_category_stun_packet_id = ast_debug_category_register(AST_LOG_CATEGORY_STUN_PACKET);
581 
582  /*
583  * Normnally a core module should call ast_register_cleanup
584  * which doesn't run if any module fails to unload. This
585  * prevents resources being pulled out from under a running
586  * module and ppossibly causing a segfault. In this case however,
587  * the only thing we're cleaning up is the cli command and
588  * the registers of the debug categories.
589  */
590  ast_register_atexit(stun_shutdown);
591 
592 }
descriptor for a cli entry.
Definition: cli.h:171
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
Definition: clicompat.c:13
int ast_term_init ( void  )

Provided by term.c

Definition at line 165 of file term.c.

Referenced by main().

166 {
167  char *term = getenv("TERM");
168  char termfile[256] = "";
169  int termfd = -1, parseokay = 0, i;
170 
171  if (ast_opt_no_color) {
172  return 0;
173  }
174 
175  if (!ast_opt_console) {
176  /* If any remote console is not compatible, we'll strip the color codes at that point */
177  vt100compat = 1;
178  goto end;
179  }
180 
181  if (!term) {
182  return 0;
183  }
184 
185  for (i = 0; !parseokay && termpath[i]; i++) {
186  snprintf(termfile, sizeof(termfile), "%s/%c/%s", termpath[i], *term, term);
187 
188  termfd = open(termfile, O_RDONLY);
189  if (termfd > -1) {
190  parseokay = parse_terminfo_file(termfd);
191  close(termfd);
192  }
193  }
194 
195  if (!parseokay) {
196  /* These comparisons should not be substrings nor case-insensitive, as
197  * terminal types are very particular about how they treat suffixes and
198  * capitalization. For example, terminal type 'linux-m' does NOT
199  * support color, while 'linux' does. Not even all vt100* terminals
200  * support color, either (e.g. 'vt100+fnkeys'). */
201  if (!strcmp(term, "linux")) {
202  vt100compat = 1;
203  } else if (!strcmp(term, "xterm")) {
204  vt100compat = 1;
205  } else if (!strcmp(term, "xterm-color")) {
206  vt100compat = 1;
207  } else if (!strcmp(term, "xterm-256color")) {
208  vt100compat = 1;
209  } else if (!strncmp(term, "Eterm", 5)) {
210  /* Both entries which start with Eterm support color */
211  vt100compat = 1;
212  } else if (!strcmp(term, "vt100")) {
213  vt100compat = 1;
214  } else if (!strncmp(term, "crt", 3)) {
215  /* Both crt terminals support color */
216  vt100compat = 1;
217  }
218  }
219 
220 end:
221  if (vt100compat) {
222  /* Make commands show up in nice colors */
223  if (ast_opt_light_background) {
224  snprintf(enddata, sizeof(enddata), "%c[%dm", ESC, COLOR_BLACK);
225  } else if (ast_opt_force_black_background) {
226  snprintf(enddata, sizeof(enddata), "%c[%d;%d;%dm", ESC, ATTR_RESET, COLOR_WHITE, COLOR_BLACK + 10);
227  } else {
228  snprintf(enddata, sizeof(enddata), "%c[%dm", ESC, ATTR_RESET);
229  }
230  snprintf(quitdata, sizeof(quitdata), "%c[%dm", ESC, ATTR_RESET);
231  }
232  return 0;
233 }
int ast_test_init ( void  )

Provided by test.c

Definition at line 1482 of file test.c.

References ast_cli_register_multiple, ast_register_cleanup(), STASIS_MESSAGE_TYPE_INIT, and stasis_topic_create().

1483 {
1484 #ifdef TEST_FRAMEWORK
1485  ast_register_cleanup(test_cleanup);
1486 
1487  /* Create stasis topic */
1488  test_suite_topic = stasis_topic_create("testsuite:all");
1489  if (!test_suite_topic) {
1490  return -1;
1491  }
1492 
1493  if (STASIS_MESSAGE_TYPE_INIT(ast_test_suite_message_type) != 0) {
1494  return -1;
1495  }
1496 
1497  AST_TEST_REGISTER(test_registrations);
1498 
1499  /* Register cli commands */
1500  ast_cli_register_multiple(test_cli, ARRAY_LEN(test_cli));
1501 #endif
1502 
1503  return 0;
1504 }
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
Definition: stasis.h:1493
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
struct stasis_topic * stasis_topic_create(const char *name)
Create a new topic.
Definition: stasis.c:617
int ast_timing_init ( void  )

Provided by timing.c

Definition at line 289 of file timing.c.

References ast_cli_register_multiple, ast_heap_create, and ast_register_cleanup().

290 {
291  if (!(timing_interfaces = ast_heap_create(2, timing_holder_cmp, 0))) {
292  return -1;
293  }
294 
295  ast_register_cleanup(timing_shutdown);
296 
297  return ast_cli_register_multiple(cli_timing, ARRAY_LEN(cli_timing));
298 }
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
#define ast_heap_create(init_height, cmp_fn, index_offset)
Create a max heap.
Definition: heap.h:100
int ast_tps_init ( void  )

Provided by taskprocessor.c

Definition at line 368 of file taskprocessor.c.

References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, ao2_ref, ast_cli_register_multiple, ast_register_cleanup(), AST_VECTOR_RW_INIT, tps_cmp_cb(), and tps_hash_cb().

369 {
371  TPS_MAX_BUCKETS, tps_hash_cb, NULL, tps_cmp_cb);
372  if (!tps_singletons) {
373  ast_log(LOG_ERROR, "taskprocessor container failed to initialize!\n");
374  return -1;
375  }
376 
377  if (AST_VECTOR_RW_INIT(&overloaded_subsystems, 10)) {
378  ao2_ref(tps_singletons, -1);
379  ast_log(LOG_ERROR, "taskprocessor subsystems vector failed to initialize!\n");
380  return -1;
381  }
382 
383  ast_cond_init(&cli_ping_cond, NULL);
384 
385  ast_cli_register_multiple(taskprocessor_clis, ARRAY_LEN(taskprocessor_clis));
386 
387  ast_register_cleanup(tps_shutdown);
388 
389  return 0;
390 }
#define AST_VECTOR_RW_INIT(vec, size)
Initialize a vector with a read/write lock.
Definition: vector.h:158
static int tps_cmp_cb(void *obj, void *arg, int flags)
The astobj2 compare callback for taskprocessors.
static int tps_hash_cb(const void *obj, const int flags)
The astobj2 hash callback for taskprocessors.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
#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
int ast_xmldoc_load_documentation ( void  )

Load XML documentation. Provided by xmldoc.c.

Return values
1on error.
0on success.

Definition at line 3047 of file xmldoc.c.

3048 {
3049  return xmldoc_load_documentation(1);
3050 }
int astdb_init ( void  )

Provided by db.c

Definition at line 1228 of file main/db.c.

References ast_cli_register_multiple, ast_manager_register_xml_core, ast_register_atexit(), and db_sync_thread().

1229 {
1230  ast_cond_init(&dbcond, NULL);
1231 
1232  if (db_init()) {
1233  return -1;
1234  }
1235 
1236  if (ast_pthread_create_background(&syncthread, NULL, db_sync_thread, NULL)) {
1237  return -1;
1238  }
1239 
1240  ast_register_atexit(astdb_atexit);
1241  ast_cli_register_multiple(cli_database, ARRAY_LEN(cli_database));
1242  ast_manager_register_xml_core("DBGet", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_dbget);
1243  ast_manager_register_xml_core("DBGetTree", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_db_tree_get);
1244  ast_manager_register_xml_core("DBPut", EVENT_FLAG_SYSTEM, manager_dbput);
1245  ast_manager_register_xml_core("DBDel", EVENT_FLAG_SYSTEM, manager_dbdel);
1246  ast_manager_register_xml_core("DBDelTree", EVENT_FLAG_SYSTEM, manager_dbdeltree);
1247  return 0;
1248 }
static void * db_sync_thread(void *data)
Wrap commands in transactions increased write performance.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
#define ast_manager_register_xml_core(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
Definition: manager.h:202
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
Definition: clicompat.c:13
int astobj2_init ( void  )

Provided by astobj2.c

Definition at line 1169 of file astobj2.c.

References ast_cli_register_multiple, and ast_register_cleanup().

1170 {
1171  char ref_filename[1024];
1172 
1173  if (ast_opt_ref_debug) {
1174  snprintf(ref_filename, sizeof(ref_filename), "%s/refs", ast_config_AST_LOG_DIR);
1175  ref_log = fopen(ref_filename, "w");
1176  if (!ref_log) {
1177  ast_log(LOG_ERROR, "Could not open ref debug log file: %s\n", ref_filename);
1178  }
1179  }
1180 
1181  ast_register_cleanup(astobj2_cleanup);
1182 
1183  if (container_init() != 0) {
1184  fclose(ref_log);
1185  ref_log = NULL;
1186  return -1;
1187  }
1188 
1189 #if defined(AO2_DEBUG)
1190  ast_cli_register_multiple(cli_astobj2, ARRAY_LEN(cli_astobj2));
1191 #endif /* defined(AO2_DEBUG) */
1192 
1193  return 0;
1194 }
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
void clean_time_zones ( void  )

Provided by localtime.c

Definition at line 1590 of file localtime.c.

References AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, and AST_LIST_UNLOCK.

Referenced by really_quit().

1591 {
1592  struct state *sp;
1593 
1595  while ((sp = AST_LIST_REMOVE_HEAD(&zonelist, list))) {
1596  sstate_free(sp);
1597  }
1599 }
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:40
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:140
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:833
void close_logger ( void  )

Provided by logger.c

Definition at line 2245 of file logger.c.

References ast_cli_unregister_multiple(), ast_custom_function_unregister(), AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, logchannel::fileptr, and logchannel::list.

Referenced by really_quit().

2246 {
2247  struct logchannel *f = NULL;
2248 
2249  ast_logger_category_unload();
2250 
2251  ast_custom_function_unregister(&log_group_function);
2252  ast_cli_unregister_multiple(cli_logger, ARRAY_LEN(cli_logger));
2253 
2254  logger_initialized = 0;
2255 
2256  /* Stop logger thread */
2258  close_logger_thread = 1;
2259  ast_cond_signal(&logcond);
2261 
2262  if (logthread != AST_PTHREADT_NULL) {
2263  pthread_join(logthread, NULL);
2264  }
2265 
2267 
2268  if (qlog) {
2269  fclose(qlog);
2270  qlog = NULL;
2271  }
2272 
2273  while ((f = AST_LIST_REMOVE_HEAD(&logchannels, list))) {
2274  if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) {
2275  fclose(f->fileptr);
2276  f->fileptr = NULL;
2277  }
2278  ast_free(f);
2279  }
2280 
2281  callid_group_remove_filters();
2282 
2283  closelog(); /* syslog */
2284 
2286 }
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:40
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Definition: clicompat.c:30
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:140
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:52
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:833
struct logchannel::@372 list
FILE * fileptr
Definition: logger.c:152
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
int dns_core_init ( void  )

Provided by dns_core.c

Definition at line 614 of file dns_core.c.

References ast_register_cleanup(), ast_sched_context_create(), and ast_sched_start_thread().

615 {
617  if (!sched) {
618  return -1;
619  }
620 
622  return -1;
623  }
624 
625  ast_register_cleanup(dns_shutdown);
626 
627  return 0;
628 }
int ast_sched_start_thread(struct ast_sched_context *con)
Start a thread for processing scheduler entries.
Definition: sched.c:197
Definition: sched.c:76
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
struct ast_sched_context * ast_sched_context_create(void)
Create a scheduler context.
Definition: sched.c:238
void dnsmgr_start_refresh ( void  )

Provided by dnsmgr.c

Definition at line 302 of file dnsmgr.c.

References ast_sched_add_variable(), and AST_SCHED_DEL.

303 {
304  if (refresh_sched > -1) {
305  AST_SCHED_DEL(sched, refresh_sched);
306  refresh_sched = ast_sched_add_variable(sched, 100, refresh_list, &master_refresh_info, 1);
307  }
308 }
Definition: sched.c:76
int ast_sched_add_variable(struct ast_sched_context *con, int when, ast_sched_cb callback, const void *data, int variable) attribute_warn_unused_result
Adds a scheduled event with rescheduling support.
Definition: sched.c:526
#define AST_SCHED_DEL(sched, id)
Remove a scheduler entry.
Definition: sched.h:46
int init_logger ( void  )

Provided by logger.c

Definition at line 2202 of file logger.c.

References ast_cli_register_multiple, ast_custom_function_register, ast_log(), ast_mkdir(), AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb_update(), init_logger_chain(), and logger_thread().

2203 {
2204  int res;
2205  /* auto rotate if sig SIGXFSZ comes a-knockin */
2206  sigaction(SIGXFSZ, &handle_SIGXFSZ, NULL);
2207 
2208  /* Re-initialize the logmsgs mutex. The recursive mutex can be accessed prior
2209  * to Asterisk being forked into the background, which can cause the thread
2210  * ID tracked by the underlying pthread mutex to be different than the ID of
2211  * the thread that unlocks the mutex. Since init_logger is called after the
2212  * fork, it is safe to initialize the mutex here for future accesses.
2213  */
2214  ast_mutex_destroy(&logmsgs.lock);
2215  ast_mutex_init(&logmsgs.lock);
2216  ast_cond_init(&logcond, NULL);
2217 
2218  /* start logger thread */
2219  if (ast_pthread_create(&logthread, NULL, logger_thread, NULL) < 0) {
2220  ast_cond_destroy(&logcond);
2221  return -1;
2222  }
2223 
2224  /* register the logger cli commands */
2225  ast_cli_register_multiple(cli_logger, ARRAY_LEN(cli_logger));
2226  ast_custom_function_register(&log_group_function);
2227 
2228  ast_mkdir(ast_config_AST_LOG_DIR, 0777);
2229 
2230  /* create log channels */
2232  res = init_logger_chain(NULL);
2234  ast_verb_update();
2235  logger_initialized = 1;
2236  if (res) {
2237  ast_log(LOG_ERROR, "Errors detected in logger.conf. Default console logging is being used.\n");
2238  }
2239 
2240  ast_logger_category_load();
2241 
2242  return 0;
2243 }
static int init_logger_chain(const char *altconf)
Read config, setup channels.
Definition: logger.c:759
void ast_verb_update(void)
Re-evaluate the system max verbosity level (ast_verb_sys_level).
Definition: logger.c:2584
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:52
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
static void * logger_thread(void *data)
Actual logging thread.
Definition: logger.c:2097
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:2453
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1558
int ast_mkdir(const char *path, int mode)
Recursively create directory path.
Definition: utils.c:2479
void load_astmm_phase_1 ( void  )

Initialize malloc debug phase 1.

Note
Must be called first thing after forking.

Definition at line 1525 of file main/astmm.c.

1526 {
1527 }
int load_modules ( void  )

Provided by loader.c

Definition at line 2508 of file loader.c.

References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_container_alloc_list, ast_copy_string(), ast_debug, AST_DLLIST_LOCK, AST_DLLIST_TRAVERSE, AST_DLLIST_UNLOCK, AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_REMOVE_HEAD, AST_LIST_TRAVERSE, ast_str_append(), ast_str_buffer(), ast_str_create, ast_str_reset(), ast_str_strlen(), ast_tvdiff_us(), ast_tvnow(), AST_VECTOR_FREE, AST_VECTOR_GET, AST_VECTOR_INIT, AST_VECTOR_SIZE, ast_xml_find_element(), ast_xml_get_text(), ast_xml_node_get_children(), ast_xml_xpath_get_first_result(), ast_xml_xpath_results_free(), ast_xmldoc_query(), ast_module::declined, load_resource_list(), ast_module::running, startup_errors, and ast_module_info::support_level.

2509 {
2510  struct load_order_entry *order;
2511  unsigned int load_count;
2512  struct load_order load_order;
2513  int res = 0;
2514  int modulecount = 0;
2515  int i;
2516  struct ast_module *cur;
2517 #ifdef AST_XML_DOCS
2518  struct ast_str *warning_msg;
2519  char deprecated_in[33];
2520  char removed_in[33];
2521  char replacement[129];
2522 #endif
2523  struct timeval start_time = ast_tvnow();
2524  struct timeval end_time;
2525  int64_t usElapsed;
2526 
2527  ast_verb(1, "Asterisk Dynamic Loader Starting:\n");
2528 
2529 #if defined(HAVE_PERMANENT_DLOPEN)
2531  info_list_obj_cmp_fn); /* must not be cleaned at shutdown */
2532  if (!info_list) {
2533  fprintf(stderr, "Module info list allocation failure.\n");
2534  return 1;
2535  }
2536 #endif
2537 
2540 
2542  startup_error_builder = ast_str_create(64);
2543 
2544  res = loader_builtin_init(&load_order);
2545  if (res) {
2546  goto done;
2547  }
2548 
2549  res = loader_config_init(&load_order);
2550  if (res) {
2551  goto done;
2552  }
2553 
2554  load_count = 0;
2556  load_count++;
2557 
2558  if (load_count)
2559  ast_log(LOG_NOTICE, "%u modules will be loaded.\n", load_count);
2560 
2561  res = load_resource_list(&load_order, &modulecount);
2562  if (res == -1) {
2563  ast_log(LOG_WARNING, "Some non-required modules failed to load.\n");
2564  res = 0;
2565  }
2566 
2567 done:
2568  while ((order = AST_LIST_REMOVE_HEAD(&load_order, entry))) {
2569  ast_free(order->resource);
2570  ast_free(order);
2571  }
2572 
2573 #ifdef AST_XML_DOCS
2574  warning_msg = ast_str_create(512);
2575 #endif
2576 
2578 #ifdef AST_XML_DOCS
2579  char *mod_name = NULL;
2580  struct ast_xml_xpath_results *results;
2581 #endif
2582 
2583  if (!cur->flags.running || cur->flags.declined) {
2584  continue;
2585  }
2586 
2587 #ifdef AST_XML_DOCS
2588  mod_name = get_name_from_resource(cur->resource);
2589  if (!warning_msg || !mod_name) {
2590  /* If we can't allocate memory, we have bigger issues */
2591  ast_free(mod_name);
2592  continue;
2593  }
2594 
2595  /* Clear out the previous values */
2596  deprecated_in[0] = removed_in[0] = replacement[0] = 0;
2597 
2598  results = ast_xmldoc_query("/docs/module[@name='%s']", mod_name);
2599  if (results) {
2600  struct ast_xml_node *deprecated_node, *removed_node, *replacement_node;
2601  struct ast_xml_node *metadata_nodes = ast_xml_node_get_children(ast_xml_xpath_get_first_result(results));
2602 
2603  deprecated_node = ast_xml_find_element(metadata_nodes, "deprecated_in", NULL, NULL);
2604  if (deprecated_node) {
2605  const char *result_tmp = ast_xml_get_text(deprecated_node);
2606  if (!ast_strlen_zero(result_tmp)) {
2607  ast_copy_string(deprecated_in, result_tmp, sizeof(deprecated_in));
2608  }
2609  }
2610 
2611  removed_node = ast_xml_find_element(metadata_nodes, "removed_in", NULL, NULL);
2612  if (removed_node) {
2613  const char *result_tmp = ast_xml_get_text(removed_node);
2614  if (!ast_strlen_zero(result_tmp)) {
2615  ast_copy_string(removed_in, result_tmp, sizeof(removed_in));
2616  }
2617  }
2618 
2619  replacement_node = ast_xml_find_element(metadata_nodes, "replacement", NULL, NULL);
2620  if (replacement_node) {
2621  const char *result_tmp = ast_xml_get_text(replacement_node);
2622  if (!ast_strlen_zero(result_tmp)) {
2623  ast_copy_string(replacement, result_tmp, sizeof(replacement));
2624  }
2625  }
2626 
2627  ast_xml_xpath_results_free(results);
2628  }
2629 
2630  ast_str_reset(warning_msg);
2631 
2632  if (cur->info->support_level == AST_MODULE_SUPPORT_DEPRECATED || !ast_strlen_zero(deprecated_in)
2633  || !ast_strlen_zero(removed_in) || !ast_strlen_zero(replacement)) {
2634  int already_butted = 0;
2635 
2636  ast_str_append(&warning_msg, -1, "Module '%s' has been loaded", mod_name);
2637  if (!ast_strlen_zero(deprecated_in)) {
2638  ast_str_append(&warning_msg, -1, " but %s deprecated in Asterisk version %s",
2639  cur->info->support_level == AST_MODULE_SUPPORT_DEPRECATED ? "was" : "will be", deprecated_in);
2640  already_butted = 1;
2641  }
2642 
2643  if (!ast_strlen_zero(removed_in)) {
2644  ast_str_append(&warning_msg, -1, " %s will be removed in Asterisk version %s", already_butted ? "and" : "but", removed_in);
2645  } else {
2646  ast_str_append(&warning_msg, -1, " %s may be removed in a future release", already_butted ? "and" : "but");
2647  }
2648 
2649  ast_str_append(&warning_msg, -1, ".");
2650 
2651  if (!ast_strlen_zero(replacement)) {
2652  ast_str_append(&warning_msg, -1, " Its replacement is '%s'.", replacement);
2653  }
2654  }
2655 
2656  if (ast_str_strlen(warning_msg)) {
2657  ast_log(LOG_WARNING, "%s\n", ast_str_buffer(warning_msg));
2658  }
2659 
2660  ast_free(mod_name);
2661 #else
2662  if (cur->info->support_level == AST_MODULE_SUPPORT_DEPRECATED) {
2663  ast_log(LOG_WARNING, "The deprecated module '%s' has been loaded and is running, it may be removed in a future version\n", cur->resource);
2664  }
2665 #endif
2666  }
2667 
2668 #ifdef AST_XML_DOCS
2669  ast_free(warning_msg);
2670 #endif
2671 
2673 
2674 
2675  for (i = 0; i < AST_VECTOR_SIZE(&startup_errors); i++) {
2676  char *str = AST_VECTOR_GET(&startup_errors, i);
2677 
2678  ast_log(LOG_ERROR, "%s", str);
2679  ast_free(str);
2680  }
2682 
2683  ast_free(startup_error_builder);
2684  startup_error_builder = NULL;
2685 
2686  end_time = ast_tvnow();
2687  usElapsed = ast_tvdiff_us(end_time, start_time);
2688 
2689 #ifdef AST_XML_DOCS
2690  ast_debug(1, "Loader time with AST_XML_DOCS: %" PRId64 ".%06" PRId64 "\n", usElapsed / 1000000, usElapsed % 1000000);
2691 #else
2692  ast_debug(1, "Loader time without AST_XML_DOCS: %" PRId64 ".%06" PRId64 "\n", usElapsed / 1000000, usElapsed % 1000000);
2693 #endif
2694 
2695  return res;
2696 }
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
Definition: vector.h:174
unsigned int running
Definition: loader.c:320
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:761
#define AST_DLLIST_UNLOCK(head)
Attempts to unlock a list.
Definition: dlinkedlists.h:123
#define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
Allocate and initialize a list container.
Definition: astobj2.h:1327
Definition: loader.c:2002
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition: strings.h:1139
struct ast_xml_xpath_results * ast_xmldoc_query(const char *fmt,...)
Execute an XPath query on the loaded XML documentation.
Definition: xmldoc.c:2576
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:159
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Definition: vector.h:113
#define AST_DLLIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: dlinkedlists.h:576
struct ast_xml_node * ast_xml_find_element(struct ast_xml_node *root_node, const char *name, const char *attrname, const char *attrvalue)
Find a node element by name.
Definition: xml.c:297
unsigned int declined
Definition: loader.c:322
#define ast_debug(level,...)
Log a DEBUG message.
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:833
static int load_resource_list(struct load_order *load_order, int *mod_count)
Definition: loader.c:2271
Support for dynamic strings.
Definition: strings.h:623
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:491
void ast_xml_xpath_results_free(struct ast_xml_xpath_results *results)
Free the XPath results.
Definition: xml.c:425
void ast_str_reset(struct ast_str *buf)
Reset the content of a dynamic string. Useful before a series of ast_str_append.
Definition: strings.h:693
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
Definition: strings.h:730
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:680
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
Definition: linkedlists.h:681
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
const char * ast_xml_get_text(struct ast_xml_node *node)
Get an element content string.
Definition: xml.c:353
Definition: search.h:40
int64_t ast_tvdiff_us(struct timeval end, struct timeval start)
Computes the difference (in microseconds) between two struct timeval instances.
Definition: time.h:87
static struct ast_vector_string startup_errors
Definition: loader.c:153
enum ast_module_support_level support_level
Definition: module.h:430
struct ast_xml_node * ast_xml_xpath_get_first_result(struct ast_xml_xpath_results *results)
Return the first result node of an XPath query.
Definition: xml.c:415
#define AST_DLLIST_LOCK(head)
Locks a list.
Definition: dlinkedlists.h:46
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:609
struct ast_xml_node * ast_xml_node_get_children(struct ast_xml_node *node)
Get the node's children.
Definition: xml.c:395
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition: strings.h:659
int load_pbx ( void  )

Provided by pbx.c

Definition at line 8421 of file pbx.c.

References __ast_custom_function_register(), ast_cli_register_multiple, ast_device_state_message_type(), ast_device_state_topic_all(), ast_manager_register_xml_core, ast_presence_state_message_type(), ast_presence_state_topic_all(), ast_register_cleanup(), manager_show_dialplan(), stasis_subscription_accept_message_type(), STASIS_SUBSCRIPTION_FILTER_SELECTIVE, and stasis_subscription_set_filter().

8422 {
8423  int res = 0;
8424 
8425  ast_register_cleanup(unload_pbx);
8426 
8427  /* Initialize the PBX */
8428  ast_verb(1, "Asterisk PBX Core Initializing\n");
8429 
8430  ast_verb(5, "Registering builtin functions:\n");
8431  ast_cli_register_multiple(pbx_cli, ARRAY_LEN(pbx_cli));
8432  __ast_custom_function_register(&exception_function, NULL);
8433  __ast_custom_function_register(&testtime_function, NULL);
8434 
8435  /* Register manager application */
8436  res |= ast_manager_register_xml_core("ShowDialPlan", EVENT_FLAG_CONFIG | EVENT_FLAG_REPORTING, manager_show_dialplan);
8437  res |= ast_manager_register_xml_core("ExtensionStateList", EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, action_extensionstatelist);
8438 
8439  if (res) {
8440  return -1;
8441  }
8442 
8443  if (!(device_state_sub = stasis_subscribe(ast_device_state_topic_all(), device_state_cb, NULL))) {
8444  return -1;
8445  }
8447  stasis_subscription_accept_message_type(device_state_sub, hint_change_message_type());
8448  stasis_subscription_accept_message_type(device_state_sub, hint_remove_message_type());
8450 
8451  if (!(presence_state_sub = stasis_subscribe(ast_presence_state_topic_all(), presence_state_cb, NULL))) {
8452  return -1;
8453  }
8456 
8457  return 0;
8458 }
static struct stasis_subscription * presence_state_sub
Subscription for presence state change events.
Definition: pbx.c:775
int stasis_subscription_set_filter(struct stasis_subscription *subscription, enum stasis_subscription_message_filter filter)
Set the message type filtering level on a subscription.
Definition: stasis.c:1077
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
#define ast_manager_register_xml_core(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
Definition: manager.h:202
struct stasis_message_type * ast_device_state_message_type(void)
Get the Stasis message type for device state messages.
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
static int manager_show_dialplan(struct mansession *s, const struct message *m)
Manager listing of dial plan.
Definition: pbx.c:5970
struct stasis_topic * ast_device_state_topic_all(void)
Get the Stasis topic for device state messages.
Definition: devicestate.c:668
struct stasis_message_type * ast_presence_state_message_type(void)
Get presence state message type.
int stasis_subscription_accept_message_type(struct stasis_subscription *subscription, const struct stasis_message_type *type)
Indicate to a subscription that we are interested in a message type.
Definition: stasis.c:1023
int __ast_custom_function_register(struct ast_custom_function *acf, struct ast_module *mod)
Register a custom function.
struct stasis_topic * ast_presence_state_topic_all(void)
Get presence state topic.
static struct stasis_subscription * device_state_sub
Subscription for device state change events.
Definition: pbx.c:773
int load_pbx_app ( void  )

Provided by pbx_app.c

Definition at line 538 of file pbx_app.c.

References ast_cli_register_multiple, and ast_register_cleanup().

539 {
540  ast_cli_register_multiple(app_cli, ARRAY_LEN(app_cli));
541  ast_register_cleanup(unload_pbx_app);
542 
543  return 0;
544 }
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
int load_pbx_builtins ( void  )

Provided by pbx_builtins.c

Definition at line 1506 of file pbx_builtins.c.

References ast_register_application2(), ast_register_cleanup(), execute(), and ast_channel::name.

1507 {
1508  int x;
1509 
1510  /* Register builtin applications */
1511  for (x = 0; x < ARRAY_LEN(builtins); x++) {
1512  if (ast_register_application2(builtins[x].name, builtins[x].execute, NULL, NULL, NULL)) {
1513  ast_log(LOG_ERROR, "Unable to register builtin application '%s'\n", builtins[x].name);
1514  return -1;
1515  }
1516  }
1517 
1518  ast_register_cleanup(unload_pbx_builtins);
1519 
1520  return 0;
1521 }
static SQLHSTMT execute(struct odbc_obj *obj, void *data, int silent)
Common execution function for SQL queries.
Definition: func_odbc.c:471
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
int ast_register_application2(const char *app, int(*execute)(struct ast_channel *, const char *), const char *synopsis, const char *description, void *mod)
Register an application.
Definition: pbx_app.c:103
int load_pbx_functions_cli ( void  )

Provided by pbx_functions.c

Definition at line 733 of file pbx_functions.c.

References ast_cli_register_multiple, and ast_register_cleanup().

734 {
735  ast_cli_register_multiple(acf_cli, ARRAY_LEN(acf_cli));
736  ast_register_cleanup(unload_pbx_functions_cli);
737 
738  return 0;
739 }
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
int load_pbx_hangup_handler ( void  )

Provided by pbx_hangup_handler.c

Definition at line 288 of file pbx_hangup_handler.c.

References ast_cli_register_multiple, and ast_register_cleanup().

289 {
290  ast_cli_register_multiple(cli, ARRAY_LEN(cli));
291  ast_register_cleanup(unload_pbx_hangup_handler);
292 
293  return 0;
294 }
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
int load_pbx_switch ( void  )

Provided by pbx_switch.c

Definition at line 125 of file pbx_switch.c.

References ast_cli_register_multiple, and ast_register_cleanup().

126 {
127  ast_cli_register_multiple(sw_cli, ARRAY_LEN(sw_cli));
128  ast_register_cleanup(unload_pbx_switch);
129 
130  return 0;
131 }
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
int load_pbx_variables ( void  )

Provided by pbx_variables.c

Definition at line 1403 of file pbx_variables.c.

References ast_cli_register_multiple, ast_register_application2(), ast_register_cleanup(), pbx_builtin_setvar(), and pbx_builtin_setvar_multiple().

1404 {
1405  int res = 0;
1406 
1407  res |= ast_cli_register_multiple(vars_cli, ARRAY_LEN(vars_cli));
1408  res |= ast_register_application2("Set", pbx_builtin_setvar, NULL, NULL, NULL);
1409  res |= ast_register_application2("MSet", pbx_builtin_setvar_multiple, NULL, NULL, NULL);
1410  ast_register_cleanup(unload_pbx_variables);
1411  AST_TEST_REGISTER(test_variable_substrings);
1412 
1413  return res;
1414 }
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
int pbx_builtin_setvar_multiple(struct ast_channel *chan, const char *vdata)
Parse and set multiple channel variables, where the pairs are separated by the ',' character...
int ast_register_application2(const char *app, int(*execute)(struct ast_channel *, const char *), const char *synopsis, const char *description, void *mod)
Register an application.
Definition: pbx_app.c:103
int pbx_builtin_setvar(struct ast_channel *chan, const char *data)
Parse and set a single channel variable, where the name and value are separated with an '=' character...
void logger_queue_start ( void  )

Start the ast_queue_log() logger.

Provided by logger.c

Note
Called when the system is fully booted after startup so preloaded realtime modules can get up.

Definition at line 2186 of file logger.c.

References AST_RWLIST_UNLOCK, and AST_RWLIST_WRLOCK.

2187 {
2188  /* Must not be called before the logger is initialized. */
2189  ast_assert(logger_initialized);
2190 
2192  if (!queuelog_init) {
2193  logger_queue_init();
2194  queuelog_init = 1;
2196  ast_queue_log("NONE", "NONE", "NONE", "QUEUESTART", "%s", "");
2197  } else {
2199  }
2200 }
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:52
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
int modules_shutdown ( void  )

Provided by loader.c

Note
Some resources, like timers, are started up dynamically, and thus may be still in use, even if all channels are dead. We must therefore check the usecount before asking modules to unload.

Definition at line 1172 of file loader.c.

References ast_debug, AST_DLLIST_EMPTY, AST_DLLIST_LOCK, AST_DLLIST_REMOVE_CURRENT, AST_DLLIST_TRAVERSE, AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_BEGIN, AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_END, AST_DLLIST_UNLOCK, ast_module_unref, ast_module::declined, ast_module::keepuntilshutdown, ast_module::running, ast_module_info::unload, and ast_module::usecount.

Referenced by really_quit().

1173 {
1174  struct ast_module *mod;
1175  int somethingchanged;
1176  int res;
1177 
1179 
1180  /*!\note Some resources, like timers, are started up dynamically, and thus
1181  * may be still in use, even if all channels are dead. We must therefore
1182  * check the usecount before asking modules to unload. */
1183  do {
1184  /* Reset flag before traversing the list */
1185  somethingchanged = 0;
1186 
1188  if (mod->usecount) {
1189  ast_debug(1, "Passing on %s: its use count is %d\n",
1190  mod->resource, mod->usecount);
1191  continue;
1192  }
1194  if (mod->flags.running && !mod->flags.declined && mod->info->unload) {
1195  ast_verb(4, "Unloading %s\n", mod->resource);
1196  mod->info->unload();
1197  }
1198  module_destroy(mod);
1199  somethingchanged = 1;
1200  }
1202  if (!somethingchanged) {
1204  if (mod->flags.keepuntilshutdown) {
1205  ast_module_unref(mod);
1206  mod->flags.keepuntilshutdown = 0;
1207  somethingchanged = 1;
1208  }
1209  }
1210  }
1211  } while (somethingchanged);
1212 
1213  res = AST_DLLIST_EMPTY(&module_list);
1215 
1216  return !res;
1217 }
unsigned int running
Definition: loader.c:320
#define AST_DLLIST_UNLOCK(head)
Attempts to unlock a list.
Definition: dlinkedlists.h:123
#define AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: dlinkedlists.h:888
int usecount
Definition: loader.c:300
#define AST_DLLIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: dlinkedlists.h:753
#define AST_DLLIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: dlinkedlists.h:576
int(* unload)(void)
Definition: module.h:362
unsigned int declined
Definition: loader.c:322
#define ast_debug(level,...)
Log a DEBUG message.
#define AST_DLLIST_EMPTY(head)
Checks whether the specified list contains any entries.
Definition: dlinkedlists.h:469
#define ast_module_unref(mod)
Release a reference to the module.
Definition: module.h:483
#define AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_END
Closes a safe loop traversal block.
Definition: dlinkedlists.h:921
unsigned int keepuntilshutdown
Definition: loader.c:324
Definition: search.h:40
#define AST_DLLIST_LOCK(head)
Locks a list.
Definition: dlinkedlists.h:46
void threadstorage_init ( void  )

Provided by threadstorage.c

Definition at line 35 of file threadstorage.c.

36 {
37 }