Wed Jan 8 2020 09:49:51

Asterisk developer's documentation


_private.h File Reference

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

Go to the source code of this file.

Functions

void ast_autoservice_init (void)
 
void ast_builtins_init (void)
 initialize the _full_cmd string in * each of the builtins. More...
 
int ast_cel_engine_init (void)
 
int ast_cel_engine_reload (void)
 
void ast_channels_init (void)
 
int ast_cli_perms_init (int reload)
 
int ast_data_init (void)
 
int ast_device_state_engine_init (void)
 Initialize the device state engine in separate thread. More...
 
int ast_event_init (void)
 
int ast_features_init (void)
 
int ast_file_init (void)
 
int ast_http_init (void)
 
int ast_http_reload (void)
 
int ast_indications_init (void)
 Load indications module. More...
 
int ast_indications_reload (void)
 Reload indications module. More...
 
int ast_module_reload (const char *name)
 Reload asterisk modules. More...
 
int ast_plc_reload (void)
 Reload genericplc configuration value from codecs.conf. More...
 
void ast_process_pending_reloads (void)
 Process reload requests received during startup. More...
 
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 dnsmgr_init (void)
 
int dnsmgr_reload (void)
 
void dnsmgr_start_refresh (void)
 
int init_framer (void)
 
int init_logger (void)
 
int load_modules (unsigned int)
 
int load_pbx (void)
 
void threadstorage_init (void)
 

Detailed Description

Prototypes for public functions only of internal interest,.

Definition in file _private.h.

Function Documentation

void ast_autoservice_init ( void  )

Provided by autoservice.c

Definition at line 335 of file autoservice.c.

References as_cond, ast_cond_init, ast_register_cleanup(), and autoservice_shutdown().

Referenced by main().

336 {
338  ast_cond_init(&as_cond, NULL);
339 }
#define ast_cond_init(cond, attr)
Definition: lock.h:167
static void autoservice_shutdown(void)
Definition: autoservice.c:324
static ast_cond_t as_cond
Definition: autoservice.c:72
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: asterisk.c:1003
void ast_builtins_init ( void  )

initialize the _full_cmd string in * each of the builtins.

Provided by cli.c

Definition at line 1880 of file cli.c.

References ARRAY_LEN, ast_cli_register_multiple(), ast_register_atexit(), and cli_shutdown().

Referenced by main().

1881 {
1884 }
static struct ast_cli_entry cli_cli[]
Definition: cli.c:1661
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
Definition: asterisk.c:998
static void cli_shutdown(void)
Definition: cli.c:1874
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
Definition: cli.c:2167
int ast_cel_engine_init ( void  )

Provided by cel.c

Definition at line 860 of file cel.c.

References ao2_container_alloc, app_cmp(), app_hash(), ast_cel_engine_term(), ast_cli_register(), ast_register_atexit(), do_reload(), lid_cmp(), lid_hash(), and NUM_APP_BUCKETS.

Referenced by main().

861 {
862  /*
863  * Accesses to the appset and linkedids containers have to be
864  * protected by the reload_lock so they don't need a lock of
865  * their own.
866  */
868  if (!appset) {
869  return -1;
870  }
872  if (!linkedids) {
874  return -1;
875  }
876 
877  if (do_reload(0) || ast_cli_register(&cli_status)) {
879  return -1;
880  }
881 
883 
884  return 0;
885 }
#define NUM_APP_BUCKETS
Number of buckets for the appset container.
Definition: cel.c:80
static int do_reload(int is_reload)
Definition: cel.c:342
static int app_cmp(void *obj, void *arg, int flags)
Definition: cel.c:812
static struct ast_cli_entry cli_status
Definition: cel.c:252
int ast_cli_register(struct ast_cli_entry *e)
Registers a command or an array of commands.
Definition: cli.c:2159
static int app_hash(const void *obj, const int flags)
Definition: cel.c:807
static void ast_cel_engine_term(void)
Definition: cel.c:841
static struct ao2_container * appset
Container of Asterisk application names.
Definition: cel.c:100
static int lid_hash(const void *obj, const int flags)
Definition: cel.c:820
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
Definition: asterisk.c:998
static int lid_cmp(void *obj, void *arg, int flags)
Definition: cel.c:830
static struct ao2_container * linkedids
Container of channel references to a linkedid for CEL purposes.
Definition: cel.c:115
#define ao2_container_alloc(arg1, arg2, arg3)
Definition: astobj2.h:734
int ast_cel_engine_reload ( void  )

Provided by cel.c

Definition at line 887 of file cel.c.

References do_reload().

888 {
889  return do_reload(1);
890 }
static int do_reload(int is_reload)
Definition: cel.c:342
void ast_channels_init ( void  )

Provided by channel.c

Definition at line 8221 of file channel.c.

References ao2_container_alloc, ARRAY_LEN, ast_channel_cmp_cb(), ast_channel_hash_cb(), ast_cli_register_multiple(), ast_data_register_multiple_core, ast_plc_reload(), ast_register_atexit(), channels, channels_shutdown(), cli_channel, and NUM_CHANNEL_BUCKETS.

Referenced by main().

8222 {
8225 
8227 
8229 
8230  ast_plc_reload();
8231 
8233 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static int ast_channel_hash_cb(const void *obj, const int flags)
Definition: channel.c:8063
#define ast_data_register_multiple_core(data_entries, entries)
Definition: data.h:379
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
Definition: asterisk.c:998
static int ast_channel_cmp_cb(void *obj, void *arg, int flags)
Definition: channel.c:1720
int ast_plc_reload(void)
Reload genericplc configuration value from codecs.conf.
Definition: channel.c:8076
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:197
static void channels_shutdown(void)
Definition: channel.c:8211
#define NUM_CHANNEL_BUCKETS
Definition: channel.c:148
#define ao2_container_alloc(arg1, arg2, arg3)
Definition: astobj2.h:734
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
Definition: cli.c:2167
static struct ast_cli_entry cli_channel[]
Definition: channel.c:624
static struct ast_data_entry channel_providers[]
Definition: channel.c:8206
int ast_cli_perms_init ( int  reload)

Provided by cli.c

Definition at line 1752 of file cli.c.

References ast_calloc, ast_category_browse(), ast_config_destroy(), ast_config_load2(), ast_free, AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_log(), ast_mutex_trylock, ast_mutex_unlock, AST_RWLIST_INSERT_TAIL, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_strdup, ast_strlen_zero(), ast_variable_browse(), cli_perm::command, CONFIG_FLAG_FILEUNCHANGED, CONFIG_STATUS_FILEUNCHANGED, destroy_user_perms(), usergroup_cli_perm::gid, LOG_NOTICE, LOG_WARNING, ast_variable::name, ast_variable::next, cli_perm::permit, usergroup_cli_perm::perms, perms_config, usergroup_cli_perm::uid, and ast_variable::value.

Referenced by handle_cli_reload_permissions(), and main().

1753 {
1754  struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
1755  struct ast_config *cfg;
1756  char *cat = NULL;
1757  struct ast_variable *v;
1758  struct usergroup_cli_perm *user_group, *cp_entry;
1759  struct cli_perm *perm = NULL;
1760  struct passwd *pw;
1761  struct group *gr;
1762 
1764  ast_log(LOG_NOTICE, "You must wait until last 'cli reload permissions' command finish\n");
1765  return 1;
1766  }
1767 
1768  cfg = ast_config_load2(perms_config, "" /* core, can't reload */, config_flags);
1769  if (!cfg) {
1771  return 1;
1772  } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
1774  return 0;
1775  }
1776 
1777  /* free current structures. */
1779 
1780  while ((cat = ast_category_browse(cfg, cat))) {
1781  if (!strcasecmp(cat, "general")) {
1782  /* General options */
1783  for (v = ast_variable_browse(cfg, cat); v; v = v->next) {
1784  if (!strcasecmp(v->name, "default_perm")) {
1785  cli_default_perm = (!strcasecmp(v->value, "permit")) ? 1: 0;
1786  }
1787  }
1788  continue;
1789  }
1790 
1791  /* users or groups */
1792  gr = NULL, pw = NULL;
1793  if (cat[0] == '@') {
1794  /* This is a group */
1795  gr = getgrnam(&cat[1]);
1796  if (!gr) {
1797  ast_log (LOG_WARNING, "Unknown group '%s'\n", &cat[1]);
1798  continue;
1799  }
1800  } else {
1801  /* This is a user */
1802  pw = getpwnam(cat);
1803  if (!pw) {
1804  ast_log (LOG_WARNING, "Unknown user '%s'\n", cat);
1805  continue;
1806  }
1807  }
1808  user_group = NULL;
1809  /* Check for duplicates */
1811  AST_LIST_TRAVERSE(&cli_perms, cp_entry, list) {
1812  if ((pw && cp_entry->uid == pw->pw_uid) || (gr && cp_entry->gid == gr->gr_gid)) {
1813  /* if it is duplicated, just added this new settings, to
1814  the current list. */
1815  user_group = cp_entry;
1816  break;
1817  }
1818  }
1820 
1821  if (!user_group) {
1822  /* alloc space for the new user config. */
1823  user_group = ast_calloc(1, sizeof(*user_group));
1824  if (!user_group) {
1825  continue;
1826  }
1827  user_group->uid = (pw ? pw->pw_uid : -1);
1828  user_group->gid = (gr ? gr->gr_gid : -1);
1829  user_group->perms = ast_calloc(1, sizeof(*user_group->perms));
1830  if (!user_group->perms) {
1831  ast_free(user_group);
1832  continue;
1833  }
1834  }
1835  for (v = ast_variable_browse(cfg, cat); v; v = v->next) {
1836  if (ast_strlen_zero(v->value)) {
1837  /* we need to check this condition cause it could break security. */
1838  ast_log(LOG_WARNING, "Empty permit/deny option in user '%s'\n", cat);
1839  continue;
1840  }
1841  if (!strcasecmp(v->name, "permit")) {
1842  perm = ast_calloc(1, sizeof(*perm));
1843  if (perm) {
1844  perm->permit = 1;
1845  perm->command = ast_strdup(v->value);
1846  }
1847  } else if (!strcasecmp(v->name, "deny")) {
1848  perm = ast_calloc(1, sizeof(*perm));
1849  if (perm) {
1850  perm->permit = 0;
1851  perm->command = ast_strdup(v->value);
1852  }
1853  } else {
1854  /* up to now, only 'permit' and 'deny' are possible values. */
1855  ast_log(LOG_WARNING, "Unknown '%s' option\n", v->name);
1856  continue;
1857  }
1858  if (perm) {
1859  /* Added the permission to the user's list. */
1860  AST_LIST_INSERT_TAIL(user_group->perms, perm, list);
1861  perm = NULL;
1862  }
1863  }
1865  AST_RWLIST_INSERT_TAIL(&cli_perms, user_group, list);
1867  }
1868 
1869  ast_config_destroy(cfg);
1871  return 0;
1872 }
#define ast_strdup(a)
Definition: astmm.h:109
static int cli_default_perm
Default permissions value 1=Permit 0=Deny.
Definition: cli.c:76
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
#define LOG_WARNING
Definition: logger.h:144
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category)
Goes through variables.
Definition: config.c:597
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
Structure for variables, used for configurations and for channel variables.
Definition: config.h:75
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
Definition: config.c:2499
void ast_config_destroy(struct ast_config *config)
Destroys a config.
Definition: config.c:1037
const char * value
Definition: config.h:79
#define ast_mutex_trylock(a)
Definition: lock.h:157
struct cli_perm_head * perms
Definition: cli.c:70
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
static ast_mutex_t permsconfiglock
mutex used to prevent a user from running the 'cli reload permissions' command while it is already ru...
Definition: cli.c:80
static const char perms_config[]
CLI permissions config file.
Definition: cli.c:74
char * ast_category_browse(struct ast_config *config, const char *prev)
Goes through categories.
Definition: config.c:810
const char * name
Definition: config.h:77
List of restrictions per user.
Definition: cli.c:58
static int reload(void)
Definition: app_amd.c:497
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:716
list of users to apply restrictions.
Definition: cli.c:67
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:1207
#define LOG_NOTICE
Definition: logger.h:133
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
#define ast_free(a)
Definition: astmm.h:97
Structure used to handle boolean flags.
Definition: utils.h:200
#define AST_RWLIST_INSERT_TAIL
Definition: linkedlists.h:726
#define ast_calloc(a, b)
Definition: astmm.h:82
static void destroy_user_perms(void)
cleanup (free) cli_perms linkedlist.
Definition: cli.c:1736
List of users and permissions.
Definition: cli.c:82
char * command
Definition: cli.c:60
struct ast_variable * next
Definition: config.h:82
unsigned int permit
Definition: cli.c:59
#define CONFIG_STATUS_FILEUNCHANGED
Definition: config.h:51
#define ast_mutex_unlock(a)
Definition: lock.h:156
int ast_data_init ( void  )

Provided by data.c

Definition at line 3297 of file data.c.

References ao2_container_alloc, ARRAY_LEN, ast_cli_register_multiple(), ast_manager_register_xml, ast_register_atexit(), ast_rwlock_init, AST_TEST_REGISTER, cli_data, data_provider_cmp(), data_provider_hash(), data_shutdown(), manager_data_get(), NUM_DATA_NODE_BUCKETS, and root_data.

Referenced by main().

3298 {
3299  int res = 0;
3300 
3301  ast_rwlock_init(&root_data.lock);
3302 
3305  return -1;
3306  }
3307 
3309 
3310  res |= ast_manager_register_xml("DataGet", 0, manager_data_get);
3311 
3312  AST_TEST_REGISTER(test_data_get);
3313 
3315 
3316  return res;
3317 }
static void data_shutdown(void)
Definition: data.c:3287
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static int data_provider_hash(const void *obj, const int flags)
Definition: data.c:189
#define AST_TEST_REGISTER(cb)
Definition: test.h:127
static int data_provider_cmp(void *obj1, void *obj2, int flags)
Definition: data.c:200
static int manager_data_get(struct mansession *s, const struct message *m)
Definition: data.c:3075
static struct ast_cli_entry cli_data[]
Definition: data.c:2988
#define ast_manager_register_xml(a, b, c)
Register a manager callback using XML documentation to describe the manager.
Definition: manager.h:172
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
Definition: asterisk.c:998
struct @244 root_data
#define ast_rwlock_init(rwlock)
wrapper for rwlock with tracking enabled
Definition: lock.h:190
#define NUM_DATA_NODE_BUCKETS
Definition: data.c:66
#define ao2_container_alloc(arg1, arg2, arg3)
Definition: astobj2.h:734
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
Definition: cli.c:2167
int ast_device_state_engine_init ( void  )

Initialize the device state engine in separate thread.

Provided by devicestate.c

Definition at line 747 of file devicestate.c.

References ast_cond_init, ast_log(), ast_pthread_create_background, change_thread, do_devstate_changes(), and LOG_ERROR.

Referenced by main().

748 {
751  ast_log(LOG_ERROR, "Unable to start device state change thread.\n");
752  return -1;
753  }
754 
755  return 0;
756 }
#define ast_cond_init(cond, attr)
Definition: lock.h:167
#define ast_pthread_create_background(a, b, c, d)
Definition: utils.h:426
#define LOG_ERROR
Definition: logger.h:155
static pthread_t change_thread
The device state change notification thread.
Definition: devicestate.c:186
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:1207
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:541
static ast_cond_t change_pending
Flag for the queue.
Definition: devicestate.c:189
int ast_event_init ( void  )

Provided by event.c

Definition at line 1819 of file event.c.

References ao2_container_alloc, ARRAY_LEN, ast_cli_register_multiple(), ast_event_cache, ast_event_cmp(), ast_event_hash(), ast_event_subs, AST_EVENT_TOTAL, ast_register_atexit(), AST_RWDLLIST_HEAD_INIT, ast_taskprocessor_get(), container, event_cli, event_shutdown(), hash_fn, and NUM_CACHE_BUCKETS.

Referenced by main().

1820 {
1821  int i;
1822 
1823  for (i = 0; i < AST_EVENT_TOTAL; i++) {
1825  }
1826 
1827  for (i = 0; i < AST_EVENT_TOTAL; i++) {
1828  if (!ast_event_cache[i].hash_fn) {
1829  /* This event type is not cached. */
1830  continue;
1831  }
1832 
1835  goto event_init_cleanup;
1836  }
1837  }
1838 
1839  if (!(event_dispatcher = ast_taskprocessor_get("core_event_dispatcher", 0))) {
1840  goto event_init_cleanup;
1841  }
1842 
1844 
1846 
1847  return 0;
1848 
1849 event_init_cleanup:
1850  event_shutdown();
1851  return -1;
1852 }
#define NUM_CACHE_BUCKETS
Definition: event.c:148
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
#define AST_RWDLLIST_HEAD_INIT(head)
Initializes an rwlist head structure.
Definition: dlinkedlists.h:797
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...
struct ao2_container * container
The asterisk data main content structure.
Definition: data.c:177
static struct ast_event_sub_list ast_event_subs[AST_EVENT_TOTAL]
static int ast_event_cmp(void *obj, void *arg, int flags)
Definition: event.c:1628
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
Definition: asterisk.c:998
static struct ast_taskprocessor * event_dispatcher
Definition: event.c:47
static struct @255 ast_event_cache[AST_EVENT_TOTAL]
Event types that are kept in the cache.
static int ast_event_hash(const void *obj, const int flags)
Definition: event.c:1594
static struct ast_cli_entry event_cli[]
Definition: event.c:1781
#define ao2_container_alloc(arg1, arg2, arg3)
Definition: astobj2.h:734
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
Definition: cli.c:2167
static void event_shutdown(void)
Definition: event.c:1786
ao2_hash_fn * hash_fn
Event type specific hash function.
Definition: event.c:165
int ast_features_init ( void  )

Provided by features.c

Definition at line 8336 of file features.c.

References action_bridge(), ao2_container_alloc, ARRAY_LEN, ast_cli_register_multiple(), ast_devstate_prov_add(), ast_manager_register_xml, ast_pthread_create, ast_register_application2(), ast_register_atexit(), AST_TEST_REGISTER, bridge_exec(), do_parking_thread(), EVENT_FLAG_CALL, features_shutdown(), load_config(), manager_park(), manager_parking_status(), metermaidstate(), park_call_exec(), parkcall, parked_call_exec(), parking_thread, parkinglot_cmp_cb(), parkinglot_hash_cb(), and parkinglots.

Referenced by main().

8337 {
8338  int res;
8339 
8341  if (!parkinglots) {
8342  return -1;
8343  }
8344 
8345  res = load_config(0);
8346  if (res) {
8347  return res;
8348  }
8351  return -1;
8352  }
8353  ast_register_application2(app_bridge, bridge_exec, NULL, NULL, NULL);
8354  res = ast_register_application2(parkedcall, parked_call_exec, NULL, NULL, NULL);
8355  if (!res)
8356  res = ast_register_application2(parkcall, park_call_exec, NULL, NULL, NULL);
8357  if (!res) {
8361  }
8362 
8363  res |= ast_devstate_prov_add("Park", metermaidstate);
8364 #if defined(TEST_FRAMEWORK)
8365  res |= AST_TEST_REGISTER(features_test);
8366 #endif /* defined(TEST_FRAMEWORK) */
8367 
8369 
8370  return res;
8371 }
static void * do_parking_thread(void *ignore)
Take care of parked calls and unpark them if needed.
Definition: features.c:4984
static int parkinglot_hash_cb(const void *obj, const int flags)
Definition: features.c:862
static const char * parkedcall
Definition: features.c:419
static int parkinglot_cmp_cb(void *obj, void *arg, int flags)
Definition: features.c:869
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static int bridge_exec(struct ast_channel *chan, const char *data)
Bridge channels.
Definition: features.c:7650
static void features_shutdown(void)
Definition: features.c:8314
static struct ast_cli_entry cli_features[]
Definition: features.c:7165
static int park_call_exec(struct ast_channel *chan, const char *data)
Park a call.
Definition: features.c:5063
#define EVENT_FLAG_CALL
Definition: manager.h:72
#define AST_TEST_REGISTER(cb)
Definition: test.h:127
int ast_devstate_prov_add(const char *label, ast_devstate_prov_cb_type callback)
Add device state provider.
Definition: devicestate.c:371
static enum ast_device_state metermaidstate(const char *data)
metermaids callback from devicestate.c
Definition: features.c:1105
static int parked_call_exec(struct ast_channel *chan, const char *data)
Pickup parked call.
Definition: features.c:5173
#define ast_manager_register_xml(a, b, c)
Register a manager callback using XML documentation to describe the manager.
Definition: manager.h:172
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
Definition: asterisk.c:998
static pthread_t parking_thread
Definition: features.c:648
static char * app_bridge
Definition: features.c:7493
#define ast_pthread_create(a, b, c, d)
Definition: utils.h:418
static int action_bridge(struct mansession *s, const struct message *m)
Bridge channels together.
Definition: features.c:6975
static int manager_park(struct mansession *s, const struct message *m)
Create manager event for parked calls.
Definition: features.c:7245
#define ao2_container_alloc(arg1, arg2, arg3)
Definition: astobj2.h:734
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
Definition: cli.c:2167
static int load_config(int reload)
Definition: features.c:6717
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.c:6344
static struct ao2_container * parkinglots
The configured parking lots container. Always at least one - the default parking lot.
Definition: features.c:575
static int manager_parking_status(struct mansession *s, const struct message *m)
Dump parking lot status.
Definition: features.c:7179
static const char * parkcall
Definition: features.c:637
int ast_file_init ( void  )

Provided by file.c

Definition at line 1503 of file file.c.

Referenced by main().

1504 {
1507  return 0;
1508 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static struct ast_cli_entry cli_file[]
Definition: file.c:1494
static void file_shutdown(void)
Definition: file.c:1498
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
Definition: asterisk.c:998
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
Definition: cli.c:2167
int ast_http_init ( void  )

Provided by http.c

Definition at line 1319 of file http.c.

References __ast_http_load(), ARRAY_LEN, ast_cli_register_multiple(), ast_http_uri_link(), ast_register_atexit(), cli_http, http_shutdown(), staticuri, and statusuri.

Referenced by main().

1320 {
1325 
1326  return __ast_http_load(0);
1327 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static struct ast_cli_entry cli_http[]
Definition: http.c:1292
int ast_http_uri_link(struct ast_http_uri *urihandler)
Register a URI handler.
Definition: http.c:544
static struct ast_http_uri staticuri
Definition: http.c:381
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
Definition: asterisk.c:998
static int __ast_http_load(int reload)
Definition: http.c:1084
static void http_shutdown(void)
Definition: http.c:1296
static struct ast_http_uri statusuri
Definition: http.c:372
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
Definition: cli.c:2167
int ast_http_reload ( void  )

Provided by http.c

Definition at line 1287 of file http.c.

References __ast_http_load().

1288 {
1289  return __ast_http_load(1);
1290 }
static int __ast_http_load(int reload)
Definition: http.c:1084
int ast_indications_init ( void  )

Load indications module.

Provided by indications.c

Definition at line 1169 of file indications.c.

References ao2_container_alloc, ARRAY_LEN, ast_cli_register_multiple(), ast_register_atexit(), ast_tone_zone_cmp(), ast_tone_zone_hash(), indications_shutdown(), load_indications(), and NUM_TONE_ZONE_BUCKETS.

Referenced by main().

1170 {
1173  return -1;
1174  }
1175 
1176  if (load_indications(0)) {
1178  return -1;
1179  }
1180 
1182 
1184  return 0;
1185 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static struct ao2_container * ast_tone_zones
Definition: indications.c:81
static int ast_tone_zone_cmp(void *obj, void *arg, int flags)
Definition: indications.c:1118
static struct ast_cli_entry cli_indications[]
CLI entries for commands provided by this module.
Definition: indications.c:1105
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
Definition: asterisk.c:998
#define NUM_TONE_ZONE_BUCKETS
Definition: indications.c:83
static int ast_tone_zone_hash(const void *obj, const int flags)
Definition: indications.c:1111
static int load_indications(int reload)
load indications module
Definition: indications.c:1052
static void indications_shutdown(void)
Definition: indications.c:1155
#define ao2_container_alloc(arg1, arg2, arg3)
Definition: astobj2.h:734
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
Definition: cli.c:2167
int ast_indications_reload ( void  )

Reload indications module.

Provided by indications.c

Definition at line 1188 of file indications.c.

References load_indications().

1189 {
1190  return load_indications(1);
1191 }
static int load_indications(int reload)
load indications module
Definition: indications.c:1052
int ast_module_reload ( const char *  name)

Reload asterisk modules.

Parameters
namethe name of the module to reload

This function reloads the specified module, or if no modules are specified, it will reload all loaded modules.

Note
Modules are reloaded using their reload() functions, not unloading them and loading them again.
Returns
0 if the specified module was not found.
Return values
1if the module was found but cannot be reloaded.
-1if a reload operation is already in progress.
2if the specfied module was found and reloaded.

Definition at line 721 of file loader.c.

References ast_config_AST_CONFIG_DIR, ast_fully_booted, ast_lastreloadtime, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_lock_path(), AST_LOCK_SUCCESS, AST_LOCK_TIMEOUT, ast_log(), ast_mutex_trylock, ast_mutex_unlock, ast_opt_lock_confdir, ast_test_suite_event_notify, ast_tvnow(), ast_unlock_path(), ast_verb, ast_verbose(), ast_module::declined, ast_module_info::description, ast_module::flags, ast_module::info, LOG_NOTICE, LOG_WARNING, reload_classes::name, queue_reload_request(), ast_module_info::reload, ast_module::resource, resource_name_match(), and ast_module::running.

Referenced by action_reload(), action_updateconfig(), ast_process_pending_reloads(), handle_core_reload(), handle_reload(), manager_moduleload(), and monitor_sig_flags().

722 {
723  struct ast_module *cur;
724  int res = 0; /* return value. 0 = not found, others, see below */
725  int i;
726 
727  /* If we aren't fully booted, we just pretend we reloaded but we queue this
728  up to run once we are booted up. */
729  if (!ast_fully_booted) {
731  return 0;
732  }
733 
735  ast_verbose("The previous reload command didn't finish yet\n");
736  return -1; /* reload already in progress */
737  }
739 
740  if (ast_opt_lock_confdir) {
741  int try;
742  int res;
743  for (try = 1, res = AST_LOCK_TIMEOUT; try < 6 && (res == AST_LOCK_TIMEOUT); try++) {
745  if (res == AST_LOCK_TIMEOUT) {
746  ast_log(LOG_WARNING, "Failed to grab lock on %s, try %d\n", ast_config_AST_CONFIG_DIR, try);
747  }
748  }
749  if (res != AST_LOCK_SUCCESS) {
750  ast_verbose("Cannot grab lock on %s\n", ast_config_AST_CONFIG_DIR);
752  return -1;
753  }
754  }
755 
756  /* Call "predefined" reload here first */
757  for (i = 0; reload_classes[i].name; i++) {
758  if (!name || !strcasecmp(name, reload_classes[i].name)) {
759  if (!reload_classes[i].reload_fn()) {
760  ast_test_suite_event_notify("MODULE_RELOAD", "Message: %s", name);
761  }
762  res = 2; /* found and reloaded */
763  }
764  }
765 
766  if (name && res) {
767  if (ast_opt_lock_confdir) {
769  }
771  return res;
772  }
773 
776  const struct ast_module_info *info = cur->info;
777 
778  if (name && resource_name_match(name, cur->resource))
779  continue;
780 
781  if (!cur->flags.running || cur->flags.declined) {
782  if (!name)
783  continue;
784  ast_log(LOG_NOTICE, "The module '%s' was not properly initialized. "
785  "Before reloading the module, you must run \"module load %s\" "
786  "and fix whatever is preventing the module from being initialized.\n",
787  name, name);
788  res = 2; /* Don't report that the module was not found */
789  break;
790  }
791 
792  if (!info->reload) { /* cannot be reloaded */
793  /* Nothing to reload, so reload is successful */
794  ast_test_suite_event_notify("MODULE_RELOAD", "Message: %s", cur->resource);
795  if (res < 1) /* store result if possible */
796  res = 1; /* 1 = no reload() method */
797  continue;
798  }
799 
800  res = 2;
801  ast_verb(3, "Reloading module '%s' (%s)\n", cur->resource, info->description);
802  if (!info->reload()) {
803  ast_test_suite_event_notify("MODULE_RELOAD", "Message: %s", cur->resource);
804  }
805  }
807 
808  if (ast_opt_lock_confdir) {
810  }
812 
813  return res;
814 }
const char * description
Definition: module.h:234
unsigned int running
Definition: loader.c:95
struct ast_module::@278 entry
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
#define LOG_WARNING
Definition: logger.h:144
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
void ast_verbose(const char *fmt,...)
Definition: logger.c:1568
int ast_unlock_path(const char *path)
Unlock a path.
Definition: app.c:1668
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
const char * name
Definition: loader.c:277
#define ast_verb(level,...)
Definition: logger.h:243
static int resource_name_match(const char *name1_in, const char *name2_in)
Definition: loader.c:338
enum AST_LOCK_RESULT ast_lock_path(const char *path)
Lock a filesystem path.
Definition: app.c:1652
#define ast_mutex_trylock(a)
Definition: lock.h:157
int(* reload)(void)
Definition: module.h:229
#define ast_fully_booted
Definition: options.h:113
struct timeval ast_lastreloadtime
Definition: asterisk.c:219
unsigned int declined
Definition: loader.c:96
#define ast_test_suite_event_notify(s, f,...)
Definition: test.h:184
struct ast_module::@277 flags
const char * ast_config_AST_CONFIG_DIR
Definition: asterisk.c:256
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:1207
#define LOG_NOTICE
Definition: logger.h:133
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
static const char name[]
static void queue_reload_request(const char *module)
Definition: loader.c:683
static ast_mutex_t reloadlock
Definition: loader.c:128
struct ast_module_info * info
Definition: loader.c:90
char resource[0]
Definition: loader.c:99
#define ast_opt_lock_confdir
Definition: options.h:131
#define ast_mutex_unlock(a)
Definition: lock.h:156
int ast_plc_reload ( void  )

Reload genericplc configuration value from codecs.conf.

Implementation is in main/channel.c

Definition at line 8076 of file channel.c.

References ast_config_destroy(), ast_config_load, AST_OPT_FLAG_GENERIC_PLC, ast_options, ast_set2_flag, ast_true(), ast_variable_browse(), CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEMISSING, CONFIG_STATUS_FILEUNCHANGED, ast_variable::name, ast_variable::next, ast_variable::value, and var.

Referenced by ast_channels_init().

8077 {
8078  struct ast_variable *var;
8079  struct ast_flags config_flags = { 0 };
8080  struct ast_config *cfg = ast_config_load("codecs.conf", config_flags);
8082  return 0;
8083  for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) {
8084  if (!strcasecmp(var->name, "genericplc")) {
8086  }
8087  }
8088  ast_config_destroy(cfg);
8089  return 0;
8090 }
#define ast_set2_flag(p, value, flag)
Definition: utils.h:94
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category)
Goes through variables.
Definition: config.c:597
Structure for variables, used for configurations and for channel variables.
Definition: config.h:75
#define var
Definition: ast_expr2f.c:606
void ast_config_destroy(struct ast_config *config)
Destroys a config.
Definition: config.c:1037
#define CONFIG_STATUS_FILEMISSING
Definition: config.h:50
const char * value
Definition: config.h:79
#define ast_config_load(filename, flags)
Load a config file.
Definition: config.h:170
const char * name
Definition: config.h:77
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is &quot;true&quot;. This function checks to see whether a string passed to it is an indication of an &quot;true&quot; value. It checks to see if the string is &quot;yes&quot;, &quot;true&quot;, &quot;y&quot;, &quot;t&quot;, &quot;on&quot; or &quot;1&quot;.
Definition: utils.c:1533
Structure used to handle boolean flags.
Definition: utils.h:200
struct ast_flags ast_options
Definition: asterisk.c:178
struct ast_variable * next
Definition: config.h:82
#define CONFIG_STATUS_FILEINVALID
Definition: config.h:52
#define CONFIG_STATUS_FILEUNCHANGED
Definition: config.h:51
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 656 of file loader.c.

References ast_free, ast_fully_booted, AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, ast_log(), ast_module_reload(), do_full_reload, LOG_NOTICE, and reload_queue_item::module.

Referenced by main().

657 {
658  struct reload_queue_item *item;
659 
660  if (!ast_fully_booted) {
661  return;
662  }
663 
665 
666  if (do_full_reload) {
667  do_full_reload = 0;
669  ast_log(LOG_NOTICE, "Executing deferred reload request.\n");
670  ast_module_reload(NULL);
671  return;
672  }
673 
674  while ((item = AST_LIST_REMOVE_HEAD(&reload_queue, entry))) {
675  ast_log(LOG_NOTICE, "Executing deferred reload request for module '%s'.\n", item->module);
676  ast_module_reload(item->module);
677  ast_free(item);
678  }
679 
681 }
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
char module[0]
Definition: loader.c:132
#define ast_fully_booted
Definition: options.h:113
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:818
struct reload_queue_item::@280 entry
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:1207
#define LOG_NOTICE
Definition: logger.h:133
int ast_module_reload(const char *name)
Reload asterisk modules.
Definition: loader.c:721
#define ast_free(a)
Definition: astmm.h:97
static int do_full_reload
Definition: loader.c:135
int ast_ssl_init ( void  )

Provided by ssl.c

Definition at line 77 of file ssl.c.

References ast_calloc, ast_mutex_init, ssl_lock(), ssl_num_locks, and ssl_threadid().

Referenced by main().

78 {
79 #ifdef HAVE_OPENSSL
80  unsigned int i;
81 
82  SSL_library_init();
83  SSL_load_error_strings();
84  ERR_load_BIO_strings();
85 
86  /* Make OpenSSL thread-safe. */
87 
88  CRYPTO_set_id_callback(ssl_threadid);
89 
90  ssl_num_locks = CRYPTO_num_locks();
91  if (!(ssl_locks = ast_calloc(ssl_num_locks, sizeof(ssl_locks[0])))) {
92  return -1;
93  }
94  for (i = 0; i < ssl_num_locks; i++) {
96  }
97  CRYPTO_set_locking_callback(ssl_lock);
98 
99 #endif /* HAVE_OPENSSL */
100  return 0;
101 }
static void ssl_lock(int mode, int n, const char *file, int line)
Definition: ssl.c:55
static int ssl_num_locks
Definition: ssl.c:48
static unsigned long ssl_threadid(void)
Definition: ssl.c:50
static ast_mutex_t * ssl_locks
Definition: ssl.c:46
#define ast_calloc(a, b)
Definition: astmm.h:82
#define ast_mutex_init(pmutex)
Definition: lock.h:152
void ast_stun_init ( void  )

Initialize the STUN system in Asterisk.

Provided by stun.c

Definition at line 508 of file stun.c.

References ast_cli_register_multiple(), ast_register_atexit(), and stun_shutdown().

Referenced by main().

509 {
510  ast_cli_register_multiple(cli_stun, sizeof(cli_stun) / sizeof(struct ast_cli_entry));
512 }
static void stun_shutdown(void)
Definition: stun.c:502
descriptor for a cli entry.
Definition: cli.h:165
static struct ast_cli_entry cli_stun[]
Definition: stun.c:498
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
Definition: asterisk.c:998
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
Definition: cli.c:2167
int ast_term_init ( void  )

Provided by term.c

Definition at line 87 of file term.c.

References ast_opt_console, ast_opt_force_black_background, ast_opt_light_background, ast_opt_no_color, ATTR_BRIGHT, ATTR_RESET, COLOR_BLACK, COLOR_BROWN, COLOR_WHITE, convshort(), and ESC.

Referenced by main().

88 {
89  char *term = getenv("TERM");
90  char termfile[256] = "";
91  char buffer[512] = "";
92  int termfd = -1, parseokay = 0, i;
93 
94  if (ast_opt_no_color) {
95  return 0;
96  }
97 
98  if (!ast_opt_console) {
99  /* If any remote console is not compatible, we'll strip the color codes at that point */
100  vt100compat = 1;
101  goto end;
102  }
103 
104  if (!term) {
105  return 0;
106  }
107 
108  for (i = 0;; i++) {
109  if (termpath[i] == NULL) {
110  break;
111  }
112  snprintf(termfile, sizeof(termfile), "%s/%c/%s", termpath[i], *term, term);
113  termfd = open(termfile, O_RDONLY);
114  if (termfd > -1) {
115  break;
116  }
117  }
118  if (termfd > -1) {
119  int actsize = read(termfd, buffer, sizeof(buffer) - 1);
120  short sz_names = convshort(buffer + 2);
121  short sz_bools = convshort(buffer + 4);
122  short n_nums = convshort(buffer + 6);
123 
124  /* if ((sz_names + sz_bools) & 1)
125  sz_bools++; */
126 
127  if (sz_names + sz_bools + n_nums < actsize) {
128  /* Offset 13 is defined in /usr/include/term.h, though we do not
129  * include it here, as it conflicts with include/asterisk/term.h */
130  short max_colors = convshort(buffer + 12 + sz_names + sz_bools + 13 * 2);
131  if (max_colors > 0) {
132  vt100compat = 1;
133  }
134  parseokay = 1;
135  }
136  close(termfd);
137  }
138 
139  if (!parseokay) {
140  /* These comparisons should not be substrings nor case-insensitive, as
141  * terminal types are very particular about how they treat suffixes and
142  * capitalization. For example, terminal type 'linux-m' does NOT
143  * support color, while 'linux' does. Not even all vt100* terminals
144  * support color, either (e.g. 'vt100+fnkeys'). */
145  if (!strcmp(term, "linux")) {
146  vt100compat = 1;
147  } else if (!strcmp(term, "xterm")) {
148  vt100compat = 1;
149  } else if (!strcmp(term, "xterm-color")) {
150  vt100compat = 1;
151  } else if (!strcmp(term, "xterm-256color")) {
152  vt100compat = 1;
153  } else if (!strncmp(term, "Eterm", 5)) {
154  /* Both entries which start with Eterm support color */
155  vt100compat = 1;
156  } else if (!strcmp(term, "vt100")) {
157  vt100compat = 1;
158  } else if (!strncmp(term, "crt", 3)) {
159  /* Both crt terminals support color */
160  vt100compat = 1;
161  }
162  }
163 
164 end:
165  if (vt100compat) {
166  /* Make commands show up in nice colors */
168  snprintf(prepdata, sizeof(prepdata), "%c[%dm", ESC, COLOR_BROWN);
169  snprintf(enddata, sizeof(enddata), "%c[%dm", ESC, COLOR_BLACK);
170  snprintf(quitdata, sizeof(quitdata), "%c[0m", ESC);
171  } else if (ast_opt_force_black_background) {
172  snprintf(prepdata, sizeof(prepdata), "%c[%d;%d;%dm", ESC, ATTR_BRIGHT, COLOR_BROWN, COLOR_BLACK + 10);
173  snprintf(enddata, sizeof(enddata), "%c[%d;%d;%dm", ESC, ATTR_RESET, COLOR_WHITE, COLOR_BLACK + 10);
174  snprintf(quitdata, sizeof(quitdata), "%c[0m", ESC);
175  } else {
176  snprintf(prepdata, sizeof(prepdata), "%c[%d;%dm", ESC, ATTR_BRIGHT, COLOR_BROWN);
177  snprintf(enddata, sizeof(enddata), "%c[%d;%dm", ESC, ATTR_RESET, COLOR_WHITE);
178  snprintf(quitdata, sizeof(quitdata), "%c[0m", ESC);
179  }
180  }
181  return 0;
182 }
#define ast_opt_force_black_background
Definition: options.h:129
static int vt100compat
Definition: term.c:44
static short convshort(char *s)
Definition: term.c:72
#define COLOR_WHITE
Definition: term.h:61
static char enddata[80]
Definition: term.c:47
#define ast_opt_console
Definition: options.h:107
static char prepdata[80]
Definition: term.c:46
#define ATTR_BRIGHT
Definition: term.h:36
#define ast_opt_no_color
Definition: options.h:112
static char quitdata[80]
Definition: term.c:48
#define COLOR_BLACK
Definition: term.h:47
#define ATTR_RESET
Definition: term.h:35
#define ast_opt_light_background
Definition: options.h:128
static const char *const termpath[]
Definition: term.c:50
#define ESC
Definition: term.h:30
#define COLOR_BROWN
Definition: term.h:53
int ast_test_init ( void  )

Provided by test.c

Definition at line 941 of file test.c.

References ARRAY_LEN, ast_cli_register_multiple(), and ast_register_atexit().

Referenced by main().

942 {
943 #ifdef TEST_FRAMEWORK
944  /* Register cli commands */
945  ast_cli_register_multiple(test_cli, ARRAY_LEN(test_cli));
946  ast_register_atexit(test_shutdown);
947 #endif
948 
949  return 0;
950 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
Definition: asterisk.c:998
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
Definition: cli.c:2167
int ast_timing_init ( void  )

Provided by timing.c

Definition at line 310 of file timing.c.

References ARRAY_LEN, ast_cli_register_multiple(), ast_heap_create(), ast_register_atexit(), timing_holder_cmp(), and timing_shutdown().

Referenced by main().

311 {
313  return -1;
314  }
315 
317 
319 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static void timing_shutdown(void)
Definition: timing.c:302
static int timing_holder_cmp(void *_h1, void *_h2)
Definition: timing.c:61
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
Definition: asterisk.c:998
static struct ast_heap * timing_interfaces
Definition: timing.c:54
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
Definition: cli.c:2167
struct ast_heap * ast_heap_create(unsigned int init_height, ast_heap_cmp_fn cmp_fn, ssize_t index_offset)
Create a max heap.
Definition: heap.c:118
static struct ast_cli_entry cli_timing[]
Definition: timing.c:298
int ast_tps_init ( void  )

Provided by taskprocessor.c

Definition at line 134 of file taskprocessor.c.

References ao2_container_alloc, ARRAY_LEN, ast_cli_register_multiple(), ast_cond_init, ast_log(), ast_register_atexit(), cli_ping_cond, LOG_ERROR, taskprocessor_clis, tps_cmp_cb(), tps_hash_cb(), TPS_MAX_BUCKETS, tps_shutdown(), and tps_singletons.

Referenced by main().

135 {
137  ast_log(LOG_ERROR, "taskprocessor container failed to initialize!\n");
138  return -1;
139  }
140 
142 
144 
146 
147  return 0;
148 }
static ast_cond_t cli_ping_cond
CLI taskprocessor ping &lt;blah&gt;operation requires a ping condition.
Definition: taskprocessor.c:92
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static void tps_shutdown(void)
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.
static struct ao2_container * tps_singletons
tps_singletons is the astobj2 container for taskprocessor singletons
Definition: taskprocessor.c:89
#define ast_cond_init(cond, attr)
Definition: lock.h:167
#define TPS_MAX_BUCKETS
Definition: taskprocessor.c:87
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
Definition: asterisk.c:998
#define LOG_ERROR
Definition: logger.h:155
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:1207
static struct ast_cli_entry taskprocessor_clis[]
#define ao2_container_alloc(arg1, arg2, arg3)
Definition: astobj2.h:734
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
Definition: cli.c:2167
int ast_xmldoc_load_documentation ( void  )

Load XML documentation. Provided by xmldoc.c.

Return values
1on error.
0on success.

Definition at line 1963 of file xmldoc.c.

References ast_asprintf, ast_calloc, ast_config_AST_DATA_DIR, ast_config_destroy(), ast_config_load2(), ast_debug, ast_free, ast_log(), ast_malloc, ast_register_atexit(), AST_RWLIST_INSERT_TAIL, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_strdup, ast_strlen_zero(), ast_variable_browse(), ast_xml_close(), ast_xml_get_root(), ast_xml_init(), ast_xml_node_get_name(), ast_xml_open(), CONFIG_STATUS_FILEINVALID, documentation_tree::doc, documentation_tree::filename, GLOB_ABORTED, LOG_ERROR, LOG_WARNING, MY_GLOB_FLAGS, ast_variable::name, ast_variable::next, ast_variable::value, var, and xmldoc_unload_documentation().

Referenced by main().

1964 {
1965  struct ast_xml_node *root_node;
1966  struct ast_xml_doc *tmpdoc;
1967  struct documentation_tree *doc_tree;
1968  char *xmlpattern;
1969  struct ast_config *cfg = NULL;
1970  struct ast_variable *var = NULL;
1971  struct ast_flags cnfflags = { 0 };
1972  int globret, i, dup, duplicate;
1973  glob_t globbuf;
1974 #if !defined(HAVE_GLOB_NOMAGIC) || !defined(HAVE_GLOB_BRACE) || defined(DEBUG_NONGNU)
1975  int xmlpattern_maxlen;
1976 #endif
1977 
1978  /* setup default XML documentation language */
1980 
1981  if ((cfg = ast_config_load2("asterisk.conf", "" /* core can't reload */, cnfflags)) && cfg != CONFIG_STATUS_FILEINVALID) {
1982  for (var = ast_variable_browse(cfg, "options"); var; var = var->next) {
1983  if (!strcasecmp(var->name, "documentation_language")) {
1984  if (!ast_strlen_zero(var->value)) {
1985  snprintf(documentation_language, sizeof(documentation_language), "%s", var->value);
1986  }
1987  }
1988  }
1989  ast_config_destroy(cfg);
1990  }
1991 
1992  /* initialize the XML library. */
1993  ast_xml_init();
1994 
1995  /* register function to be run when asterisk finish. */
1997 
1998  globbuf.gl_offs = 0; /* slots to reserve in gl_pathv */
1999 
2000 #if !defined(HAVE_GLOB_NOMAGIC) || !defined(HAVE_GLOB_BRACE) || defined(DEBUG_NONGNU)
2001  xmlpattern_maxlen = strlen(ast_config_AST_DATA_DIR) + strlen("/documentation/thirdparty") + strlen("/*-??_??.xml") + 1;
2002  xmlpattern = ast_malloc(xmlpattern_maxlen);
2003  globret = xml_pathmatch(xmlpattern, xmlpattern_maxlen, &globbuf);
2004 #else
2005  /* Get every *-LANG.xml file inside $(ASTDATADIR)/documentation */
2006  if (ast_asprintf(&xmlpattern, "%s/documentation{/thirdparty/,/}*-{%s,%.2s_??,%s}.xml", ast_config_AST_DATA_DIR,
2008  return 1;
2009  }
2010  globret = glob(xmlpattern, MY_GLOB_FLAGS, NULL, &globbuf);
2011 #endif
2012 
2013  ast_debug(3, "gl_pathc %zu\n", globbuf.gl_pathc);
2014  if (globret == GLOB_NOSPACE) {
2015  ast_log(LOG_WARNING, "XML load failure, glob expansion of pattern '%s' failed: Not enough memory\n", xmlpattern);
2016  ast_free(xmlpattern);
2017  return 1;
2018  } else if (globret == GLOB_ABORTED) {
2019  ast_log(LOG_WARNING, "XML load failure, glob expansion of pattern '%s' failed: Read error\n", xmlpattern);
2020  ast_free(xmlpattern);
2021  return 1;
2022  }
2023  ast_free(xmlpattern);
2024 
2026  /* loop over expanded files */
2027  for (i = 0; i < globbuf.gl_pathc; i++) {
2028  /* check for duplicates (if we already [try to] open the same file. */
2029  duplicate = 0;
2030  for (dup = 0; dup < i; dup++) {
2031  if (!strcmp(globbuf.gl_pathv[i], globbuf.gl_pathv[dup])) {
2032  duplicate = 1;
2033  break;
2034  }
2035  }
2036  if (duplicate || strchr(globbuf.gl_pathv[i], '*')) {
2037  /* skip duplicates as well as pathnames not found
2038  * (due to use of GLOB_NOCHECK in xml_pathmatch) */
2039  continue;
2040  }
2041  tmpdoc = NULL;
2042  tmpdoc = ast_xml_open(globbuf.gl_pathv[i]);
2043  if (!tmpdoc) {
2044  ast_log(LOG_ERROR, "Could not open XML documentation at '%s'\n", globbuf.gl_pathv[i]);
2045  continue;
2046  }
2047  /* Get doc root node and check if it starts with '<docs>' */
2048  root_node = ast_xml_get_root(tmpdoc);
2049  if (!root_node) {
2050  ast_log(LOG_ERROR, "Error getting documentation root node\n");
2051  ast_xml_close(tmpdoc);
2052  continue;
2053  }
2054  /* Check root node name for malformed xmls. */
2055  if (strcmp(ast_xml_node_get_name(root_node), "docs")) {
2056  ast_log(LOG_ERROR, "Documentation file is not well formed!\n");
2057  ast_xml_close(tmpdoc);
2058  continue;
2059  }
2060  doc_tree = ast_calloc(1, sizeof(*doc_tree));
2061  if (!doc_tree) {
2062  ast_log(LOG_ERROR, "Unable to allocate documentation_tree structure!\n");
2063  ast_xml_close(tmpdoc);
2064  continue;
2065  }
2066  doc_tree->doc = tmpdoc;
2067  doc_tree->filename = ast_strdup(globbuf.gl_pathv[i]);
2068  AST_RWLIST_INSERT_TAIL(&xmldoc_tree, doc_tree, entry);
2069  }
2071 
2072  globfree(&globbuf);
2073 
2074  return 0;
2075 }
XML documentation tree.
Definition: xmldoc.c:60
int ast_xml_init(void)
Initialize the XML library implementation. This function is used to setup everything needed to start ...
Definition: xml.c:41
#define ast_strdup(a)
Definition: astmm.h:109
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
#define LOG_WARNING
Definition: logger.h:144
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category)
Goes through variables.
Definition: config.c:597
struct ast_xml_doc * ast_xml_open(char *filename)
Open an XML document.
Definition: xml.c:55
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
Structure for variables, used for configurations and for channel variables.
Definition: config.h:75
#define var
Definition: ast_expr2f.c:606
struct ast_xml_node * ast_xml_get_root(struct ast_xml_doc *doc)
Get the document root node.
Definition: xml.c:153
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
Definition: config.c:2499
void ast_config_destroy(struct ast_config *config)
Destroys a config.
Definition: config.c:1037
#define ast_asprintf(a, b, c...)
Definition: astmm.h:121
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
const char * value
Definition: config.h:79
static const char default_documentation_language[]
Default documentation language.
Definition: xmldoc.c:45
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
Definition: asterisk.c:998
const char * name
Definition: config.h:77
struct ast_xml_doc * doc
Definition: xmldoc.c:62
static char documentation_language[6]
XML documentation language.
Definition: xmldoc.c:57
const char * ast_config_AST_DATA_DIR
Definition: asterisk.c:262
char * filename
Definition: xmldoc.c:61
#define LOG_ERROR
Definition: logger.h:155
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:1207
#define MY_GLOB_FLAGS
Definition: compat.h:214
static void xmldoc_unload_documentation(void)
Close and unload XML documentation.
Definition: xmldoc.c:1948
#define ast_free(a)
Definition: astmm.h:97
#define GLOB_ABORTED
Definition: ael_lex.c:830
void ast_xml_close(struct ast_xml_doc *doc)
Close an already open document and free the used structure.
Definition: xml.c:134
Structure used to handle boolean flags.
Definition: utils.h:200
#define AST_RWLIST_INSERT_TAIL
Definition: linkedlists.h:726
#define ast_calloc(a, b)
Definition: astmm.h:82
struct ast_variable * next
Definition: config.h:82
Container of documentation trees.
Definition: xmldoc.c:76
#define CONFIG_STATUS_FILEINVALID
Definition: config.h:52
#define ast_malloc(a)
Definition: astmm.h:91
const char * ast_xml_node_get_name(struct ast_xml_node *node)
Get the name of a node.
Definition: xml.c:294
int astdb_init ( void  )

Provided by db.c

Definition at line 880 of file db.c.

References ARRAY_LEN, ast_cli_register_multiple(), ast_cond_init, ast_manager_register_xml, ast_mutex_lock, ast_mutex_unlock, ast_pthread_create_background, ast_register_atexit(), astdb_shutdown(), db_sync_thread(), dbinit(), dblock, EVENT_FLAG_REPORTING, EVENT_FLAG_SYSTEM, manager_dbdel(), manager_dbdeltree(), manager_dbget(), and manager_dbput().

Referenced by main().

881 {
882  ast_cond_init(&dbcond, NULL);
884  return -1;
885  }
886 
888  /* Ignore check_return warning from Coverity for dbinit below */
889  dbinit();
891 
897 
899  return 0;
900 }
static struct ast_cli_entry cli_database[]
Definition: db.c:666
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
#define ast_cond_init(cond, attr)
Definition: lock.h:167
#define ast_mutex_lock(a)
Definition: lock.h:155
static ast_mutex_t dblock
Definition: db.c:110
static int dbinit(void)
Definition: db.c:118
static ast_cond_t dbcond
Definition: db.c:111
static int manager_dbget(struct mansession *s, const struct message *m)
Definition: db.c:700
#define ast_pthread_create_background(a, b, c, d)
Definition: utils.h:426
static pthread_t syncthread
Definition: db.c:112
#define EVENT_FLAG_SYSTEM
Definition: manager.h:71
static int manager_dbdel(struct mansession *s, const struct message *m)
Definition: db.c:741
#define ast_manager_register_xml(a, b, c)
Register a manager callback using XML documentation to describe the manager.
Definition: manager.h:172
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
Definition: asterisk.c:998
static void * db_sync_thread(void *data)
Definition: db.c:815
#define EVENT_FLAG_REPORTING
Definition: manager.h:80
static int manager_dbput(struct mansession *s, const struct message *m)
Definition: db.c:675
static int manager_dbdeltree(struct mansession *s, const struct message *m)
Definition: db.c:766
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
Definition: cli.c:2167
#define ast_mutex_unlock(a)
Definition: lock.h:156
static void astdb_shutdown(void)
Definition: db.c:854
int astobj2_init ( void  )

Provided by astobj2.c

Definition at line 1150 of file astobj2.c.

References ARRAY_LEN, ast_cli_register_multiple(), ast_config_AST_LOG_DIR, ast_log(), ast_register_atexit(), astobj2_cleanup(), and LOG_ERROR.

Referenced by main().

1151 {
1152 #ifdef REF_DEBUG
1153  char ref_filename[1024];
1154 #endif
1155 
1156 #ifdef REF_DEBUG
1157  snprintf(ref_filename, sizeof(ref_filename), "%s/refs", ast_config_AST_LOG_DIR);
1158  ref_log = fopen(ref_filename, "w");
1159  if (!ref_log) {
1160  ast_log(LOG_ERROR, "Could not open ref debug log file: %s\n", ref_filename);
1161  }
1162 #endif
1163 
1164 #ifdef AO2_DEBUG
1165  ast_cli_register_multiple(cli_astobj2, ARRAY_LEN(cli_astobj2));
1166 #endif
1167 
1169  return 0;
1170 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static void astobj2_cleanup(void)
Definition: astobj2.c:1137
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
Definition: asterisk.c:998
#define LOG_ERROR
Definition: logger.h:155
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:1207
const char * ast_config_AST_LOG_DIR
Definition: asterisk.c:263
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
Definition: cli.c:2167
static FILE * ref_log
Definition: astobj2.c:35
void clean_time_zones ( void  )

Provided by localtime.c

Definition at line 1421 of file localtime.c.

References ast_free, AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, and AST_LIST_UNLOCK.

Referenced by really_quit().

1422 {
1423  struct state *sp;
1424 
1426  while ((sp = AST_LIST_REMOVE_HEAD(&zonelist, list))) {
1427  ast_free(sp);
1428  }
1430 }
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
struct state::@306 list
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:818
#define ast_free(a)
Definition: astmm.h:97
void close_logger ( void  )

Provided by logger.c

Definition at line 1160 of file logger.c.

References ARRAY_LEN, ast_cli_unregister_multiple(), ast_cond_signal, ast_free, AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, AST_PTHREADT_NULL, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, cli_logger, close_logger_thread, f, logchannel::fileptr, logchannel::list, logcond, logthread, and qlog.

Referenced by really_quit().

1161 {
1162  struct logchannel *f = NULL;
1163  struct verb *cur = NULL;
1164 
1166 
1167  logger_initialized = 0;
1168 
1169  /* Stop logger thread */
1171  close_logger_thread = 1;
1174 
1176  pthread_join(logthread, NULL);
1177 
1179  while ((cur = AST_LIST_REMOVE_HEAD(&verbosers, list))) {
1180  ast_free(cur);
1181  }
1183 
1185 
1186  if (qlog) {
1187  fclose(qlog);
1188  qlog = NULL;
1189  }
1190 
1191  while ((f = AST_LIST_REMOVE_HEAD(&logchannels, list))) {
1192  if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) {
1193  fclose(f->fileptr);
1194  f->fileptr = NULL;
1195  }
1196  ast_free(f);
1197  }
1198 
1199  closelog(); /* syslog */
1200 
1202 }
static struct ast_cli_entry cli_logger[]
Definition: logger.c:934
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Definition: cli.c:2177
static pthread_t logthread
Definition: logger.c:143
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
#define ast_cond_signal(cond)
Definition: lock.h:169
static FILE * qlog
Definition: logger.c:147
static int logger_initialized
Definition: logger.c:77
struct verb::@285 list
#define AST_PTHREADT_NULL
Definition: lock.h:65
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:818
Definition: logger.c:927
#define ast_free(a)
Definition: astmm.h:97
static struct ast_format f[]
Definition: format_g726.c:181
FILE * fileptr
Definition: logger.c:109
static int close_logger_thread
Definition: logger.c:145
static ast_cond_t logcond
Definition: logger.c:144
int dnsmgr_init ( void  )

Provided by dnsmgr.c

Definition at line 417 of file dnsmgr.c.

References ast_cli_register(), ast_log(), ast_register_atexit(), cli_refresh, cli_reload, cli_status, dnsmgr_shutdown(), do_reload(), LOG_ERROR, and sched_context_create().

Referenced by main().

418 {
419  if (!(sched = sched_context_create())) {
420  ast_log(LOG_ERROR, "Unable to create schedule context.\n");
421  return -1;
422  }
426 
428 
429  return do_reload(1);
430 }
int ast_cli_register(struct ast_cli_entry *e)
Registers a command or an array of commands.
Definition: cli.c:2159
static struct ast_cli_entry cli_reload
Definition: dnsmgr.c:393
Definition: sched.c:57
static struct ast_cli_entry cli_refresh
Definition: dnsmgr.c:394
static int do_reload(int loading)
Definition: dnsmgr.c:437
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
Definition: asterisk.c:998
static struct ast_cli_entry cli_status
Definition: dnsmgr.c:395
#define LOG_ERROR
Definition: logger.h:155
static void dnsmgr_shutdown(void)
Definition: dnsmgr.c:397
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:1207
struct sched_context * sched_context_create(void)
New schedule context.
Definition: sched.c:246
int dnsmgr_reload ( void  )

Provided by dnsmgr.c

Definition at line 432 of file dnsmgr.c.

References do_reload().

433 {
434  return do_reload(0);
435 }
static int do_reload(int loading)
Definition: dnsmgr.c:437
void dnsmgr_start_refresh ( void  )

Provided by dnsmgr.c

Definition at line 291 of file dnsmgr.c.

References ast_sched_add_variable(), AST_SCHED_DEL, master_refresh_info, and refresh_list().

Referenced by main().

292 {
293  if (refresh_sched > -1) {
296  }
297 }
static struct refresh_info master_refresh_info
Definition: dnsmgr.c:91
int ast_sched_add_variable(struct sched_context *con, int when, ast_sched_cb callback, const void *data, int variable) attribute_warn_unused_result
Schedule callback(data) to happen when ms into the future.
Definition: sched.c:406
Definition: sched.c:57
static int refresh_sched
Definition: dnsmgr.c:53
#define AST_SCHED_DEL(sched, id)
a loop construct to ensure that the scheduled task get deleted. The idea is that if we loop attemptin...
Definition: sched.h:51
static int refresh_list(const void *data)
Definition: dnsmgr.c:263
int init_framer ( void  )

Provided by frame.c

Definition at line 995 of file frame.c.

References ARRAY_LEN, ast_cli_register_multiple(), ast_register_atexit(), and framer_shutdown().

Referenced by main().

996 {
999  return 0;
1000 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static void framer_shutdown(void)
Definition: frame.c:990
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
Definition: asterisk.c:998
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
Definition: cli.c:2167
static struct ast_cli_entry my_clis[]
Definition: frame.c:985
int init_logger ( void  )

Provided by logger.c

Definition at line 1127 of file logger.c.

References ARRAY_LEN, ast_cli_register_multiple(), ast_cond_destroy, ast_cond_init, ast_config_AST_LOG_DIR, ast_mkdir(), ast_mutex_destroy, ast_mutex_init, ast_pthread_create, cli_logger, handle_SIGXFSZ, init_logger_chain(), logmsgs::lock, logcond, logger_thread(), and logthread.

Referenced by main().

1128 {
1129  /* auto rotate if sig SIGXFSZ comes a-knockin */
1130  sigaction(SIGXFSZ, &handle_SIGXFSZ, NULL);
1131 
1132  /* Re-initialize the logmsgs mutex. The recursive mutex can be accessed prior
1133  * to Asterisk being forked into the background, which can cause the thread
1134  * ID tracked by the underlying pthread mutex to be different than the ID of
1135  * the thread that unlocks the mutex. Since init_logger is called after the
1136  * fork, it is safe to initialize the mutex here for future accesses.
1137  */
1140  ast_cond_init(&logcond, NULL);
1141 
1142  /* start logger thread */
1143  if (ast_pthread_create(&logthread, NULL, logger_thread, NULL) < 0) {
1145  return -1;
1146  }
1147 
1148  /* register the logger cli commands */
1150 
1152 
1153  /* create log channels */
1154  init_logger_chain(0 /* locked */);
1155  logger_initialized = 1;
1156 
1157  return 0;
1158 }
static struct ast_cli_entry cli_logger[]
Definition: logger.c:934
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static struct sigaction handle_SIGXFSZ
Definition: logger.c:947
static pthread_t logthread
Definition: logger.c:143
#define ast_cond_init(cond, attr)
Definition: lock.h:167
static int logger_initialized
Definition: logger.c:77
#define ast_cond_destroy(cond)
Definition: lock.h:168
const char * ast_config_AST_LOG_DIR
Definition: asterisk.c:263
static void * logger_thread(void *data)
Actual logging thread.
Definition: logger.c:1060
#define ast_pthread_create(a, b, c, d)
Definition: utils.h:418
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
Definition: cli.c:2167
#define ast_mutex_init(pmutex)
Definition: lock.h:152
static void init_logger_chain(int locked)
Definition: logger.c:307
#define ast_mutex_destroy(a)
Definition: lock.h:154
ast_mutex_t lock
Definition: logger.c:142
static ast_cond_t logcond
Definition: logger.c:144
int ast_mkdir(const char *path, int mode)
Recursively create directory path.
Definition: utils.c:2151
int load_modules ( unsigned  int)

Provided by loader.c

Definition at line 1072 of file loader.c.

References add_to_load_order(), ast_config_AST_MODULE_DIR, ast_config_destroy(), ast_config_load2(), ast_debug, ast_free, AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_REMOVE_HEAD, AST_LIST_TRAVERSE, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, ast_log(), AST_MODULE_CONFIG, ast_opt_quiet, ast_true(), ast_variable_browse(), ast_variable_retrieve(), ast_verb, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEMISSING, embedded_module_list, embedding, EVENT_FLAG_SYSTEM, find_resource(), module_list::first, ast_module::flags, module_list::last, ast_module::lib, load_resource_list(), LOG_NOTICE, LOG_WARNING, manager_event, ast_variable::name, ast_variable::next, ast_module::resource, load_order_entry::resource, resource_name_match(), ast_module::running, and ast_variable::value.

Referenced by main().

1073 {
1074  struct ast_config *cfg;
1075  struct ast_module *mod;
1076  struct load_order_entry *order;
1077  struct ast_variable *v;
1078  unsigned int load_count;
1079  struct load_order load_order;
1080  int res = 0;
1081  struct ast_flags config_flags = { 0 };
1082  int modulecount = 0;
1083 
1084 #ifdef LOADABLE_MODULES
1085  struct dirent *dirent;
1086  DIR *dir;
1087 #endif
1088 
1089  /* all embedded modules have registered themselves by now */
1090  embedding = 0;
1091 
1092  ast_verb(1, "Asterisk Dynamic Loader Starting:\n");
1093 
1095 
1097 
1101  embedded_module_list.first = NULL;
1102  }
1103 
1104  cfg = ast_config_load2(AST_MODULE_CONFIG, "" /* core, can't reload */, config_flags);
1106  ast_log(LOG_WARNING, "No '%s' found, no modules will be loaded.\n", AST_MODULE_CONFIG);
1107  goto done;
1108  }
1109 
1110  /* first, find all the modules we have been explicitly requested to load */
1111  for (v = ast_variable_browse(cfg, "modules"); v; v = v->next) {
1112  if (!strcasecmp(v->name, preload_only ? "preload" : "load")) {
1114  }
1115  if (!strcasecmp(v->name, preload_only ? "preload-require" : "require")) {
1116  /* Add the module to the list and make sure it's required */
1118  ast_debug(2, "Adding module to required list: %s (%s)\n", v->value, v->name);
1119  }
1120 
1121  }
1122 
1123  /* check if 'autoload' is on */
1124  if (!preload_only && ast_true(ast_variable_retrieve(cfg, "modules", "autoload"))) {
1125  /* if so, first add all the embedded modules that are not already running to the load order */
1126  AST_LIST_TRAVERSE(&module_list, mod, entry) {
1127  /* if it's not embedded, skip it */
1128  if (mod->lib)
1129  continue;
1130 
1131  if (mod->flags.running)
1132  continue;
1133 
1135  }
1136 
1137 #ifdef LOADABLE_MODULES
1138  /* if we are allowed to load dynamic modules, scan the directory for
1139  for all available modules and add them as well */
1140  if ((dir = opendir(ast_config_AST_MODULE_DIR))) {
1141  while ((dirent = readdir(dir))) {
1142  int ld = strlen(dirent->d_name);
1143 
1144  /* Must end in .so to load it. */
1145 
1146  if (ld < 4)
1147  continue;
1148 
1149  if (strcasecmp(dirent->d_name + ld - 3, ".so"))
1150  continue;
1151 
1152  /* if there is already a module by this name in the module_list,
1153  skip this file */
1154  if (find_resource(dirent->d_name, 0))
1155  continue;
1156 
1157  add_to_load_order(dirent->d_name, &load_order, 0);
1158  }
1159 
1160  closedir(dir);
1161  } else {
1162  if (!ast_opt_quiet)
1163  ast_log(LOG_WARNING, "Unable to open modules directory '%s'.\n",
1165  }
1166 #endif
1167  }
1168 
1169  /* now scan the config for any modules we are prohibited from loading and
1170  remove them from the load order */
1171  for (v = ast_variable_browse(cfg, "modules"); v; v = v->next) {
1172  if (strcasecmp(v->name, "noload"))
1173  continue;
1174 
1175  AST_LIST_TRAVERSE_SAFE_BEGIN(&load_order, order, entry) {
1176  if (!resource_name_match(order->resource, v->value)) {
1177  AST_LIST_REMOVE_CURRENT(entry);
1178  ast_free(order->resource);
1179  ast_free(order);
1180  }
1181  }
1183  }
1184 
1185  /* we are done with the config now, all the information we need is in the
1186  load_order list */
1187  ast_config_destroy(cfg);
1188 
1189  load_count = 0;
1190  AST_LIST_TRAVERSE(&load_order, order, entry)
1191  load_count++;
1192 
1193  if (load_count)
1194  ast_log(LOG_NOTICE, "%u modules will be loaded.\n", load_count);
1195 
1196  /* first, load only modules that provide global symbols */
1197  if ((res = load_resource_list(&load_order, 1, &modulecount)) < 0) {
1198  goto done;
1199  }
1200 
1201  /* now load everything else */
1202  if ((res = load_resource_list(&load_order, 0, &modulecount)) < 0) {
1203  goto done;
1204  }
1205 
1206 done:
1207  while ((order = AST_LIST_REMOVE_HEAD(&load_order, entry))) {
1208  ast_free(order->resource);
1209  ast_free(order);
1210  }
1211 
1213 
1214  /* Tell manager clients that are aggressive at logging in that we're done
1215  loading modules. If there's a DNS problem in chan_sip, we might not
1216  even reach this */
1217  manager_event(EVENT_FLAG_SYSTEM, "ModuleLoadReport", "ModuleLoadStatus: Done\r\nModuleSelection: %s\r\nModuleCount: %d\r\n", preload_only ? "Preload" : "All", modulecount);
1218 
1219  return res;
1220 }
unsigned int running
Definition: loader.c:95
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
const char * ast_variable_retrieve(const struct ast_config *config, const char *category, const char *variable)
Gets a variable.
Definition: config.c:625
struct ast_module * last
Definition: loader.c:102
struct ast_module * first
Definition: loader.c:102
const char * ast_config_AST_MODULE_DIR
Definition: asterisk.c:258
#define LOG_WARNING
Definition: logger.h:144
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category)
Goes through variables.
Definition: config.c:597
Structure for variables, used for configurations and for channel variables.
Definition: config.h:75
static int loaded
Definition: cdr_csv.c:56
Definition: loader.c:960
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:600
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
Definition: config.c:2499
static struct ast_module * find_resource(const char *resource, int do_lock)
Definition: loader.c:356
#define ast_verb(level,...)
Definition: logger.h:243
void ast_config_destroy(struct ast_config *config)
Destroys a config.
Definition: config.c:1037
static int resource_name_match(const char *name1_in, const char *name2_in)
Definition: loader.c:338
#define CONFIG_STATUS_FILEMISSING
Definition: config.h:50
char * resource
Definition: loader.c:961
#define EVENT_FLAG_SYSTEM
Definition: manager.h:71
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
const char * value
Definition: config.h:79
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:554
#define ast_opt_quiet
Definition: options.h:106
const char * name
Definition: config.h:77
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:818
struct ast_module::@277 flags
static int load_resource_list(struct load_order *load_order, unsigned int global_symbols, int *mod_count)
Definition: loader.c:1010
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is &quot;true&quot;. This function checks to see whether a string passed to it is an indication of an &quot;true&quot; value. It checks to see if the string is &quot;yes&quot;, &quot;true&quot;, &quot;y&quot;, &quot;t&quot;, &quot;on&quot; or &quot;1&quot;.
Definition: utils.c:1533
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:1207
#define LOG_NOTICE
Definition: logger.h:133
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
#define ast_free(a)
Definition: astmm.h:97
if(yyss+yystacksize-1<=yyssp)
Definition: ast_expr2.c:1874
Structure used to handle boolean flags.
Definition: utils.h:200
static struct module_list embedded_module_list
Definition: loader.c:119
#define AST_MODULE_CONFIG
Module configuration file.
Definition: module.h:51
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
Definition: linkedlists.h:666
static struct load_order_entry * add_to_load_order(const char *resource, struct load_order *load_order, int required)
Definition: loader.c:968
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: linkedlists.h:528
struct ast_variable * next
Definition: config.h:82
#define CONFIG_STATUS_FILEINVALID
Definition: config.h:52
static unsigned int embedding
Definition: loader.c:85
#define manager_event(category, event, contents,...)
External routines may send asterisk manager events this way.
Definition: manager.h:219
void * lib
Definition: loader.c:91
char resource[0]
Definition: loader.c:99
int load_pbx ( void  )

Provided by pbx.c

Definition at line 10996 of file pbx.c.

References __ast_custom_function_register(), ARRAY_LEN, ast_cli_register_multiple(), ast_data_register_multiple_core, AST_EVENT_DEVICE_STATE, AST_EVENT_IE_END, ast_event_subscribe(), ast_log(), ast_manager_register_xml, ast_register_application2(), ast_register_atexit(), ast_taskprocessor_get(), ast_verb, builtins, device_state_cb(), device_state_sub, EVENT_FLAG_CONFIG, EVENT_FLAG_REPORTING, exception_function, LOG_ERROR, LOG_WARNING, manager_show_dialplan(), pbx_cli, pbx_data_providers, testtime_function, and unload_pbx().

Referenced by main().

10997 {
10998  int x;
10999 
11001 
11002  /* Initialize the PBX */
11003  ast_verb(1, "Asterisk PBX Core Initializing\n");
11004  if (!(device_state_tps = ast_taskprocessor_get("pbx-core", 0))) {
11005  ast_log(LOG_WARNING, "failed to create pbx-core taskprocessor\n");
11006  }
11007 
11008  ast_verb(1, "Registering builtin applications:\n");
11013 
11014  /* Register builtin applications */
11015  for (x = 0; x < ARRAY_LEN(builtins); x++) {
11016  ast_verb(1, "[%s]\n", builtins[x].name);
11017  if (ast_register_application2(builtins[x].name, builtins[x].execute, NULL, NULL, NULL)) {
11018  ast_log(LOG_ERROR, "Unable to register builtin application '%s'\n", builtins[x].name);
11019  return -1;
11020  }
11021  }
11022 
11023  /* Register manager application */
11025 
11026  if (!(device_state_sub = ast_event_subscribe(AST_EVENT_DEVICE_STATE, device_state_cb, "pbx Device State Change", NULL,
11027  AST_EVENT_IE_END))) {
11028  return -1;
11029  }
11030 
11031  return 0;
11032 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
#define LOG_WARNING
Definition: logger.h:144
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...
static struct ast_cli_entry pbx_cli[]
Definition: pbx.c:7665
#define ast_verb(level,...)
Definition: logger.h:243
#define ast_data_register_multiple_core(data_entries, entries)
Definition: data.h:379
#define ast_manager_register_xml(a, b, c)
Register a manager callback using XML documentation to describe the manager.
Definition: manager.h:172
static struct ast_event_sub * device_state_sub
Subscription for device state change events.
Definition: pbx.c:1225
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
Definition: asterisk.c:998
static struct ast_custom_function testtime_function
Definition: pbx.c:10114
static void unload_pbx(void)
Definition: pbx.c:10973
#define LOG_ERROR
Definition: logger.h:155
#define EVENT_FLAG_CONFIG
Definition: manager.h:78
static int manager_show_dialplan(struct mansession *s, const struct message *m)
Manager listing of dial plan.
Definition: pbx.c:7397
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:1207
static struct ast_data_entry pbx_data_providers[]
Definition: pbx.c:10967
static const char name[]
static struct ast_custom_function exception_function
Definition: pbx.c:3646
#define EVENT_FLAG_REPORTING
Definition: manager.h:80
struct ast_event_sub * ast_event_subscribe(enum ast_event_type event_type, ast_event_cb_t cb, const char *description, void *userdata,...)
Subscribe to events.
Definition: event.c:909
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
Definition: cli.c:2167
int __ast_custom_function_register(struct ast_custom_function *acf, struct ast_module *mod)
Register a custom function.
Definition: pbx.c:3946
static struct ast_taskprocessor * device_state_tps
Definition: pbx.c:862
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.c:6344
static void device_state_cb(const struct ast_event *event, void *unused)
Definition: pbx.c:10905
static struct pbx_builtin builtins[]
void threadstorage_init ( void  )

Provided by threadstorage.c

Definition at line 35 of file threadstorage.c.

Referenced by main().

36 {
37 }