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. | |
| void | ast_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. | |
| 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. | |
| int | ast_indications_reload (void) |
| Reload indications module. | |
| int | ast_module_reload (const char *name) |
| Reload asterisk modules. | |
| void | ast_process_pending_reloads (void) |
| Process reload requests received during startup. | |
| int | ast_ssl_init (void) |
| int | ast_term_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. | |
| int | astdb_init (void) |
| int | astobj2_init (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) |
Prototypes for public functions only of internal interest,.
Definition in file _private.h.
| void ast_autoservice_init | ( | void | ) |
Provided by autoservice.c
Definition at line 318 of file autoservice.c.
References as_cond, and ast_cond_init().
Referenced by main().
00319 { 00320 ast_cond_init(&as_cond, NULL); 00321 }
| void ast_builtins_init | ( | void | ) |
initialize the _full_cmd string in * each of the builtins.
Provided by cli.c
Definition at line 1678 of file cli.c.
References ARRAY_LEN, and ast_cli_register_multiple().
Referenced by main().
01679 { 01680 ast_cli_register_multiple(cli_cli, ARRAY_LEN(cli_cli)); 01681 }
| void ast_channels_init | ( | void | ) |
Provided by channel.c
Definition at line 5561 of file channel.c.
References ARRAY_LEN, ast_cli_register_multiple(), and cli_channel.
Referenced by main().
05562 { 05563 ast_cli_register_multiple(cli_channel, ARRAY_LEN(cli_channel)); 05564 }
| int ast_cli_perms_init | ( | int | reload | ) |
Provided by cli.c
Definition at line 1555 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().
01556 { 01557 struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; 01558 struct ast_config *cfg; 01559 char *cat = NULL; 01560 struct ast_variable *v; 01561 struct usergroup_cli_perm *user_group, *cp_entry; 01562 struct cli_perm *perm = NULL; 01563 struct passwd *pw; 01564 struct group *gr; 01565 01566 if (ast_mutex_trylock(&permsconfiglock)) { 01567 ast_log(LOG_NOTICE, "You must wait until last 'cli reload permissions' command finish\n"); 01568 return 1; 01569 } 01570 01571 cfg = ast_config_load2(perms_config, "" /* core, can't reload */, config_flags); 01572 if (!cfg) { 01573 ast_mutex_unlock(&permsconfiglock); 01574 return 1; 01575 } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { 01576 ast_mutex_unlock(&permsconfiglock); 01577 return 0; 01578 } 01579 01580 /* free current structures. */ 01581 destroy_user_perms(); 01582 01583 while ((cat = ast_category_browse(cfg, cat))) { 01584 if (!strcasecmp(cat, "general")) { 01585 /* General options */ 01586 for (v = ast_variable_browse(cfg, cat); v; v = v->next) { 01587 if (!strcasecmp(v->name, "default_perm")) { 01588 cli_default_perm = (!strcasecmp(v->value, "permit")) ? 1: 0; 01589 } 01590 } 01591 continue; 01592 } 01593 01594 /* users or groups */ 01595 gr = NULL, pw = NULL; 01596 if (cat[0] == '@') { 01597 /* This is a group */ 01598 gr = getgrnam(&cat[1]); 01599 if (!gr) { 01600 ast_log (LOG_WARNING, "Unknown group '%s'\n", &cat[1]); 01601 continue; 01602 } 01603 } else { 01604 /* This is a user */ 01605 pw = getpwnam(cat); 01606 if (!pw) { 01607 ast_log (LOG_WARNING, "Unknown user '%s'\n", cat); 01608 continue; 01609 } 01610 } 01611 user_group = NULL; 01612 /* Check for duplicates */ 01613 AST_RWLIST_WRLOCK(&cli_perms); 01614 AST_LIST_TRAVERSE(&cli_perms, cp_entry, list) { 01615 if ((pw && cp_entry->uid == pw->pw_uid) || (gr && cp_entry->gid == gr->gr_gid)) { 01616 /* if it is duplicated, just added this new settings, to 01617 the current list. */ 01618 user_group = cp_entry; 01619 break; 01620 } 01621 } 01622 AST_RWLIST_UNLOCK(&cli_perms); 01623 01624 if (!user_group) { 01625 /* alloc space for the new user config. */ 01626 user_group = ast_calloc(1, sizeof(*user_group)); 01627 if (!user_group) { 01628 continue; 01629 } 01630 user_group->uid = (pw ? pw->pw_uid : -1); 01631 user_group->gid = (gr ? gr->gr_gid : -1); 01632 user_group->perms = ast_calloc(1, sizeof(*user_group->perms)); 01633 if (!user_group->perms) { 01634 ast_free(user_group); 01635 continue; 01636 } 01637 } 01638 for (v = ast_variable_browse(cfg, cat); v; v = v->next) { 01639 if (ast_strlen_zero(v->value)) { 01640 /* we need to check this condition cause it could break security. */ 01641 ast_log(LOG_WARNING, "Empty permit/deny option in user '%s'\n", cat); 01642 continue; 01643 } 01644 if (!strcasecmp(v->name, "permit")) { 01645 perm = ast_calloc(1, sizeof(*perm)); 01646 if (perm) { 01647 perm->permit = 1; 01648 perm->command = ast_strdup(v->value); 01649 } 01650 } else if (!strcasecmp(v->name, "deny")) { 01651 perm = ast_calloc(1, sizeof(*perm)); 01652 if (perm) { 01653 perm->permit = 0; 01654 perm->command = ast_strdup(v->value); 01655 } 01656 } else { 01657 /* up to now, only 'permit' and 'deny' are possible values. */ 01658 ast_log(LOG_WARNING, "Unknown '%s' option\n", v->name); 01659 continue; 01660 } 01661 if (perm) { 01662 /* Added the permission to the user's list. */ 01663 AST_LIST_INSERT_TAIL(user_group->perms, perm, list); 01664 perm = NULL; 01665 } 01666 } 01667 AST_RWLIST_WRLOCK(&cli_perms); 01668 AST_RWLIST_INSERT_TAIL(&cli_perms, user_group, list); 01669 AST_RWLIST_UNLOCK(&cli_perms); 01670 } 01671 01672 ast_config_destroy(cfg); 01673 ast_mutex_unlock(&permsconfiglock); 01674 return 0; 01675 }
| int ast_device_state_engine_init | ( | void | ) |
Initialize the device state engine in separate thread.
Provided by devicestate.c
Definition at line 722 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().
00723 { 00724 ast_cond_init(&change_pending, NULL); 00725 if (ast_pthread_create_background(&change_thread, NULL, do_devstate_changes, NULL) < 0) { 00726 ast_log(LOG_ERROR, "Unable to start device state change thread.\n"); 00727 return -1; 00728 } 00729 00730 return 0; 00731 }
| int ast_event_init | ( | void | ) |
Provided by event.c
Definition at line 1289 of file event.c.
References ao2_container_alloc, ast_event_cache, ast_event_cmp(), ast_event_hash(), ast_event_subs, AST_RWDLLIST_HEAD_INIT, ast_taskprocessor_get(), container, hash_fn, and NUM_CACHE_BUCKETS.
Referenced by main().
01290 { 01291 int i; 01292 01293 for (i = 0; i < AST_EVENT_TOTAL; i++) { 01294 AST_RWDLLIST_HEAD_INIT(&ast_event_subs[i]); 01295 } 01296 01297 for (i = 0; i < AST_EVENT_TOTAL; i++) { 01298 if (!ast_event_cache[i].hash_fn) { 01299 /* This event type is not cached. */ 01300 continue; 01301 } 01302 01303 if (!(ast_event_cache[i].container = ao2_container_alloc(NUM_CACHE_BUCKETS, 01304 ast_event_hash, ast_event_cmp))) { 01305 return -1; 01306 } 01307 } 01308 01309 if (!(event_dispatcher = ast_taskprocessor_get("core_event_dispatcher", 0))) { 01310 return -1; 01311 } 01312 01313 return 0; 01314 }
| int ast_features_init | ( | void | ) |
Provided by features.c
Definition at line 4642 of file features.c.
References action_bridge(), ao2_container_alloc, ARRAY_LEN, ast_cli_register_multiple(), ast_devstate_prov_add(), ast_manager_register, ast_manager_register2(), ast_pthread_create, ast_register_application2(), bridge_exec(), do_parking_thread(), EVENT_FLAG_CALL, load_config(), manager_park(), manager_parking_status(), metermaidstate(), park_call_exec(), park_exec(), parkcall, parkedcall, parking_thread, parkinglot_cmp_cb(), parkinglot_hash_cb(), and parkinglots.
Referenced by main().
04643 { 04644 int res; 04645 04646 ast_register_application2(app_bridge, bridge_exec, NULL, NULL, NULL); 04647 04648 parkinglots = ao2_container_alloc(7, parkinglot_hash_cb, parkinglot_cmp_cb); 04649 04650 if ((res = load_config())) 04651 return res; 04652 ast_cli_register_multiple(cli_features, ARRAY_LEN(cli_features)); 04653 ast_pthread_create(&parking_thread, NULL, do_parking_thread, NULL); 04654 res = ast_register_application2(parkedcall, park_exec, NULL, NULL, NULL); 04655 if (!res) 04656 res = ast_register_application2(parkcall, park_call_exec, NULL, NULL, NULL); 04657 if (!res) { 04658 ast_manager_register("ParkedCalls", 0, manager_parking_status, "List parked calls"); 04659 ast_manager_register2("Park", EVENT_FLAG_CALL, manager_park, "Park a channel", mandescr_park); 04660 ast_manager_register2("Bridge", EVENT_FLAG_CALL, action_bridge, "Bridge two channels already in the PBX", mandescr_bridge); 04661 } 04662 04663 res |= ast_devstate_prov_add("Park", metermaidstate); 04664 04665 return res; 04666 }
| int ast_file_init | ( | void | ) |
| int ast_http_init | ( | void | ) |
Provided by http.c
Definition at line 1023 of file http.c.
References __ast_http_load(), ARRAY_LEN, ast_cli_register_multiple(), ast_http_uri_link(), cli_http, staticuri, and statusuri.
Referenced by main().
01024 { 01025 ast_http_uri_link(&statusuri); 01026 ast_http_uri_link(&staticuri); 01027 ast_cli_register_multiple(cli_http, ARRAY_LEN(cli_http)); 01028 01029 return __ast_http_load(0); 01030 }
| int ast_http_reload | ( | void | ) |
Provided by http.c
Definition at line 1014 of file http.c.
References __ast_http_load().
01015 { 01016 return __ast_http_load(1); 01017 }
| int ast_indications_init | ( | void | ) |
Load indications module.
Provided by indications.c
Definition at line 1106 of file indications.c.
References ao2_container_alloc, ARRAY_LEN, ast_cli_register_multiple(), ast_tone_zone_cmp(), ast_tone_zone_hash(), load_indications(), and NUM_TONE_ZONE_BUCKETS.
Referenced by main().
01107 { 01108 if (!(ast_tone_zones = ao2_container_alloc(NUM_TONE_ZONE_BUCKETS, 01109 ast_tone_zone_hash, ast_tone_zone_cmp))) { 01110 return -1; 01111 } 01112 01113 if (load_indications(0)) { 01114 return -1; 01115 } 01116 01117 ast_cli_register_multiple(cli_indications, ARRAY_LEN(cli_indications)); 01118 01119 return 0; 01120 }
| int ast_indications_reload | ( | void | ) |
Reload indications module.
Provided by indications.c
Definition at line 1123 of file indications.c.
References load_indications().
01124 { 01125 return load_indications(1); 01126 }
| int ast_module_reload | ( | const char * | name | ) |
Reload asterisk modules.
| name | the name of the module to reload |
This function reloads the specified module, or if no modules are specified, it will reload all loaded modules.
| 1 | if the module was found but cannot be reloaded. | |
| -1 | if a reload operation is already in progress. | |
| 2 | if the specfied module was found and reloaded. |
Definition at line 637 of file loader.c.
References ast_fully_booted, ast_lastreloadtime, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), ast_mutex_trylock(), ast_mutex_unlock(), ast_tvnow(), ast_verb, ast_verbose, ast_module::declined, ast_module_info::description, ast_module::flags, ast_module::info, LOG_NOTICE, 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_reload(), manager_moduleload(), and monitor_sig_flags().
00638 { 00639 struct ast_module *cur; 00640 int res = 0; /* return value. 0 = not found, others, see below */ 00641 int i; 00642 00643 /* If we aren't fully booted, we just pretend we reloaded but we queue this 00644 up to run once we are booted up. */ 00645 if (!ast_fully_booted) { 00646 queue_reload_request(name); 00647 return 0; 00648 } 00649 00650 if (ast_mutex_trylock(&reloadlock)) { 00651 ast_verbose("The previous reload command didn't finish yet\n"); 00652 return -1; /* reload already in progress */ 00653 } 00654 ast_lastreloadtime = ast_tvnow(); 00655 00656 /* Call "predefined" reload here first */ 00657 for (i = 0; reload_classes[i].name; i++) { 00658 if (!name || !strcasecmp(name, reload_classes[i].name)) { 00659 reload_classes[i].reload_fn(); /* XXX should check error ? */ 00660 res = 2; /* found and reloaded */ 00661 } 00662 } 00663 00664 if (name && res) { 00665 ast_mutex_unlock(&reloadlock); 00666 return res; 00667 } 00668 00669 AST_LIST_LOCK(&module_list); 00670 AST_LIST_TRAVERSE(&module_list, cur, entry) { 00671 const struct ast_module_info *info = cur->info; 00672 00673 if (name && resource_name_match(name, cur->resource)) 00674 continue; 00675 00676 if (!cur->flags.running || cur->flags.declined) { 00677 if (!name) 00678 continue; 00679 ast_log(LOG_NOTICE, "The module '%s' was not properly initialized. " 00680 "Before reloading the module, you must run \"module load %s\" " 00681 "and fix whatever is preventing the module from being initialized.\n", 00682 name, name); 00683 res = 2; /* Don't report that the module was not found */ 00684 break; 00685 } 00686 00687 if (!info->reload) { /* cannot be reloaded */ 00688 if (res < 1) /* store result if possible */ 00689 res = 1; /* 1 = no reload() method */ 00690 continue; 00691 } 00692 00693 res = 2; 00694 ast_verb(3, "Reloading module '%s' (%s)\n", cur->resource, info->description); 00695 info->reload(); 00696 } 00697 AST_LIST_UNLOCK(&module_list); 00698 00699 ast_mutex_unlock(&reloadlock); 00700 00701 return res; 00702 }
| 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.
Definition at line 572 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().
00573 { 00574 struct reload_queue_item *item; 00575 00576 if (!ast_fully_booted) { 00577 return; 00578 } 00579 00580 AST_LIST_LOCK(&reload_queue); 00581 00582 if (do_full_reload) { 00583 do_full_reload = 0; 00584 AST_LIST_UNLOCK(&reload_queue); 00585 ast_log(LOG_NOTICE, "Executing deferred reload request.\n"); 00586 ast_module_reload(NULL); 00587 return; 00588 } 00589 00590 while ((item = AST_LIST_REMOVE_HEAD(&reload_queue, entry))) { 00591 ast_log(LOG_NOTICE, "Executing deferred reload request for module '%s'.\n", item->module); 00592 ast_module_reload(item->module); 00593 ast_free(item); 00594 } 00595 00596 AST_LIST_UNLOCK(&reload_queue); 00597 }
| int ast_ssl_init | ( | void | ) |
Porvided by ssl.c
Definition at line 73 of file ssl.c.
References ast_calloc, ast_mutex_init(), ssl_lock(), and ssl_threadid().
Referenced by main().
00074 { 00075 #ifdef HAVE_OPENSSL 00076 unsigned int i; 00077 00078 SSL_library_init(); 00079 SSL_load_error_strings(); 00080 ERR_load_crypto_strings(); 00081 ERR_load_BIO_strings(); 00082 OpenSSL_add_all_algorithms(); 00083 00084 /* Make OpenSSL thread-safe. */ 00085 00086 CRYPTO_set_id_callback(ssl_threadid); 00087 00088 ssl_num_locks = CRYPTO_num_locks(); 00089 if (!(ssl_locks = ast_calloc(ssl_num_locks, sizeof(ssl_locks[0])))) { 00090 return -1; 00091 } 00092 for (i = 0; i < ssl_num_locks; i++) { 00093 ast_mutex_init(&ssl_locks[i]); 00094 } 00095 CRYPTO_set_locking_callback(ssl_lock); 00096 00097 #endif /* HAVE_OPENSSL */ 00098 return 0; 00099 }
| int ast_term_init | ( | void | ) |
Provided by term.c
Definition at line 83 of file term.c.
References ast_opt_console, ast_opt_force_black_background, ast_opt_light_background, ast_opt_no_color, ast_opt_no_fork, ATTR_BRIGHT, ATTR_RESET, COLOR_BLACK, COLOR_BROWN, COLOR_WHITE, convshort(), and ESC.
Referenced by main().
00084 { 00085 char *term = getenv("TERM"); 00086 char termfile[256] = ""; 00087 char buffer[512] = ""; 00088 int termfd = -1, parseokay = 0, i; 00089 00090 if (!term) 00091 return 0; 00092 if (!ast_opt_console || ast_opt_no_color || !ast_opt_no_fork) 00093 return 0; 00094 00095 for (i=0 ;; i++) { 00096 if (termpath[i] == NULL) { 00097 break; 00098 } 00099 snprintf(termfile, sizeof(termfile), "%s/%c/%s", termpath[i], *term, term); 00100 termfd = open(termfile, O_RDONLY); 00101 if (termfd > -1) { 00102 break; 00103 } 00104 } 00105 if (termfd > -1) { 00106 int actsize = read(termfd, buffer, sizeof(buffer) - 1); 00107 short sz_names = convshort(buffer + 2); 00108 short sz_bools = convshort(buffer + 4); 00109 short n_nums = convshort(buffer + 6); 00110 00111 /* if ((sz_names + sz_bools) & 1) 00112 sz_bools++; */ 00113 00114 if (sz_names + sz_bools + n_nums < actsize) { 00115 /* Offset 13 is defined in /usr/include/term.h, though we do not 00116 * include it here, as it conflicts with include/asterisk/term.h */ 00117 short max_colors = convshort(buffer + 12 + sz_names + sz_bools + 13 * 2); 00118 if (max_colors > 0) { 00119 vt100compat = 1; 00120 } 00121 parseokay = 1; 00122 } 00123 close(termfd); 00124 } 00125 00126 if (!parseokay) { 00127 /* These comparisons should not be substrings nor case-insensitive, as 00128 * terminal types are very particular about how they treat suffixes and 00129 * capitalization. For example, terminal type 'linux-m' does NOT 00130 * support color, while 'linux' does. Not even all vt100* terminals 00131 * support color, either (e.g. 'vt100+fnkeys'). */ 00132 if (!strcmp(term, "linux")) { 00133 vt100compat = 1; 00134 } else if (!strcmp(term, "xterm")) { 00135 vt100compat = 1; 00136 } else if (!strcmp(term, "xterm-color")) { 00137 vt100compat = 1; 00138 } else if (!strncmp(term, "Eterm", 5)) { 00139 /* Both entries which start with Eterm support color */ 00140 vt100compat = 1; 00141 } else if (!strcmp(term, "vt100")) { 00142 vt100compat = 1; 00143 } else if (!strncmp(term, "crt", 3)) { 00144 /* Both crt terminals support color */ 00145 vt100compat = 1; 00146 } 00147 } 00148 00149 if (vt100compat) { 00150 /* Make commands show up in nice colors */ 00151 if (ast_opt_light_background) { 00152 snprintf(prepdata, sizeof(prepdata), "%c[%dm", ESC, COLOR_BROWN); 00153 snprintf(enddata, sizeof(enddata), "%c[%dm", ESC, COLOR_BLACK); 00154 snprintf(quitdata, sizeof(quitdata), "%c[0m", ESC); 00155 } else if (ast_opt_force_black_background) { 00156 snprintf(prepdata, sizeof(prepdata), "%c[%d;%d;%dm", ESC, ATTR_BRIGHT, COLOR_BROWN, COLOR_BLACK + 10); 00157 snprintf(enddata, sizeof(enddata), "%c[%d;%d;%dm", ESC, ATTR_RESET, COLOR_WHITE, COLOR_BLACK + 10); 00158 snprintf(quitdata, sizeof(quitdata), "%c[0m", ESC); 00159 } else { 00160 snprintf(prepdata, sizeof(prepdata), "%c[%d;%dm", ESC, ATTR_BRIGHT, COLOR_BROWN); 00161 snprintf(enddata, sizeof(enddata), "%c[%d;%dm", ESC, ATTR_RESET, COLOR_WHITE); 00162 snprintf(quitdata, sizeof(quitdata), "%c[0m", ESC); 00163 } 00164 } 00165 return 0; 00166 }
| int ast_timing_init | ( | void | ) |
Provided by timing.c
Definition at line 283 of file timing.c.
References ARRAY_LEN, ast_cli_register_multiple(), ast_heap_create(), and timing_holder_cmp().
Referenced by main().
00284 { 00285 if (!(timing_interfaces = ast_heap_create(2, timing_holder_cmp, 0))) { 00286 return -1; 00287 } 00288 00289 return ast_cli_register_multiple(cli_timing, ARRAY_LEN(cli_timing)); 00290 }
| int ast_tps_init | ( | void | ) |
Provided by taskprocessor.c
Definition at line 122 of file taskprocessor.c.
References ao2_container_alloc, ARRAY_LEN, ast_cli_register_multiple(), ast_cond_init(), ast_log(), cli_ping_cond, LOG_ERROR, taskprocessor_clis, tps_cmp_cb(), tps_hash_cb(), TPS_MAX_BUCKETS, and tps_singletons.
Referenced by main().
00123 { 00124 if (!(tps_singletons = ao2_container_alloc(TPS_MAX_BUCKETS, tps_hash_cb, tps_cmp_cb))) { 00125 ast_log(LOG_ERROR, "taskprocessor container failed to initialize!\n"); 00126 return -1; 00127 } 00128 00129 ast_cond_init(&cli_ping_cond, NULL); 00130 00131 ast_cli_register_multiple(taskprocessor_clis, ARRAY_LEN(taskprocessor_clis)); 00132 return 0; 00133 }
| int ast_xmldoc_load_documentation | ( | void | ) |
Load XML documentation. Provided by xmldoc.c.
| 1 | on error. | |
| 0 | on success. |
Definition at line 1765 of file xmldoc.c.
References ast_asprintf, ast_calloc, ast_config_AST_DATA_DIR, ast_config_destroy(), ast_config_load2(), ast_free, ast_log(), 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::entry, 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().
01766 { 01767 struct ast_xml_node *root_node; 01768 struct ast_xml_doc *tmpdoc; 01769 struct documentation_tree *doc_tree; 01770 char *xmlpattern; 01771 struct ast_config *cfg = NULL; 01772 struct ast_variable *var = NULL; 01773 struct ast_flags cnfflags = { 0 }; 01774 int globret, i, dup, duplicate; 01775 glob_t globbuf; 01776 01777 /* setup default XML documentation language */ 01778 snprintf(documentation_language, sizeof(documentation_language), default_documentation_language); 01779 01780 if ((cfg = ast_config_load2("asterisk.conf", "" /* core can't reload */, cnfflags)) && cfg != CONFIG_STATUS_FILEINVALID) { 01781 for (var = ast_variable_browse(cfg, "options"); var; var = var->next) { 01782 if (!strcasecmp(var->name, "documentation_language")) { 01783 if (!ast_strlen_zero(var->value)) { 01784 snprintf(documentation_language, sizeof(documentation_language), "%s", var->value); 01785 } 01786 } 01787 } 01788 ast_config_destroy(cfg); 01789 } 01790 01791 /* initialize the XML library. */ 01792 ast_xml_init(); 01793 01794 /* register function to be run when asterisk finish. */ 01795 ast_register_atexit(xmldoc_unload_documentation); 01796 01797 /* Get every *-LANG.xml file inside $(ASTDATADIR)/documentation */ 01798 ast_asprintf(&xmlpattern, "%s/documentation{/thirdparty/,/}*-{%s,%.2s_??,%s}.xml", ast_config_AST_DATA_DIR, 01799 documentation_language, documentation_language, default_documentation_language); 01800 globbuf.gl_offs = 0; /* initialize it to silence gcc */ 01801 globret = glob(xmlpattern, MY_GLOB_FLAGS, NULL, &globbuf); 01802 if (globret == GLOB_NOSPACE) { 01803 ast_log(LOG_WARNING, "Glob Expansion of pattern '%s' failed: Not enough memory\n", xmlpattern); 01804 ast_free(xmlpattern); 01805 return 1; 01806 } else if (globret == GLOB_ABORTED) { 01807 ast_log(LOG_WARNING, "Glob Expansion of pattern '%s' failed: Read error\n", xmlpattern); 01808 ast_free(xmlpattern); 01809 return 1; 01810 } 01811 ast_free(xmlpattern); 01812 01813 AST_RWLIST_WRLOCK(&xmldoc_tree); 01814 /* loop over expanded files */ 01815 for (i = 0; i < globbuf.gl_pathc; i++) { 01816 /* check for duplicates (if we already [try to] open the same file. */ 01817 duplicate = 0; 01818 for (dup = 0; dup < i; dup++) { 01819 if (!strcmp(globbuf.gl_pathv[i], globbuf.gl_pathv[dup])) { 01820 duplicate = 1; 01821 break; 01822 } 01823 } 01824 if (duplicate) { 01825 continue; 01826 } 01827 tmpdoc = NULL; 01828 tmpdoc = ast_xml_open(globbuf.gl_pathv[i]); 01829 if (!tmpdoc) { 01830 ast_log(LOG_ERROR, "Could not open XML documentation at '%s'\n", globbuf.gl_pathv[i]); 01831 continue; 01832 } 01833 /* Get doc root node and check if it starts with '<docs>' */ 01834 root_node = ast_xml_get_root(tmpdoc); 01835 if (!root_node) { 01836 ast_log(LOG_ERROR, "Error getting documentation root node"); 01837 ast_xml_close(tmpdoc); 01838 continue; 01839 } 01840 /* Check root node name for malformed xmls. */ 01841 if (strcmp(ast_xml_node_get_name(root_node), "docs")) { 01842 ast_log(LOG_ERROR, "Documentation file is not well formed!\n"); 01843 ast_xml_close(tmpdoc); 01844 continue; 01845 } 01846 doc_tree = ast_calloc(1, sizeof(*doc_tree)); 01847 if (!doc_tree) { 01848 ast_log(LOG_ERROR, "Unable to allocate documentation_tree structure!\n"); 01849 ast_xml_close(tmpdoc); 01850 continue; 01851 } 01852 doc_tree->doc = tmpdoc; 01853 doc_tree->filename = ast_strdup(globbuf.gl_pathv[i]); 01854 AST_RWLIST_INSERT_TAIL(&xmldoc_tree, doc_tree, entry); 01855 } 01856 AST_RWLIST_UNLOCK(&xmldoc_tree); 01857 01858 globfree(&globbuf); 01859 01860 return 0; 01861 }
| int astdb_init | ( | void | ) |
Provided by db.c
Definition at line 665 of file db.c.
References ARRAY_LEN, ast_cli_register_multiple(), ast_manager_register, dbinit(), EVENT_FLAG_REPORTING, EVENT_FLAG_SYSTEM, manager_dbdel(), manager_dbdeltree(), manager_dbget(), and manager_dbput().
Referenced by main().
00666 { 00667 dbinit(); 00668 ast_cli_register_multiple(cli_database, ARRAY_LEN(cli_database)); 00669 ast_manager_register("DBGet", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_dbget, "Get DB Entry"); 00670 ast_manager_register("DBPut", EVENT_FLAG_SYSTEM, manager_dbput, "Put DB Entry"); 00671 ast_manager_register("DBDel", EVENT_FLAG_SYSTEM, manager_dbdel, "Delete DB Entry"); 00672 ast_manager_register("DBDelTree", EVENT_FLAG_SYSTEM, manager_dbdeltree, "Delete DB Tree"); 00673 return 0; 00674 }
| int astobj2_init | ( | void | ) |
Provided by astobj2.c
Definition at line 1081 of file astobj2.c.
References ARRAY_LEN, and ast_cli_register_multiple().
Referenced by main().
01082 { 01083 #ifdef AO2_DEBUG 01084 ast_cli_register_multiple(cli_astobj2, ARRAY_LEN(cli_astobj2)); 01085 #endif 01086 01087 return 0; 01088 }
| void close_logger | ( | void | ) |
Provided by logger.c
Definition at line 1048 of file logger.c.
References ast_cond_signal(), AST_LIST_LOCK, AST_LIST_UNLOCK, AST_PTHREADT_NULL, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, close_logger_thread, eventlog, f, logchannel::fileptr, logchannel::list, logcond, logthread, and qlog.
Referenced by quit_handler().
01049 { 01050 struct logchannel *f = NULL; 01051 01052 /* Stop logger thread */ 01053 AST_LIST_LOCK(&logmsgs); 01054 close_logger_thread = 1; 01055 ast_cond_signal(&logcond); 01056 AST_LIST_UNLOCK(&logmsgs); 01057 01058 if (logthread != AST_PTHREADT_NULL) 01059 pthread_join(logthread, NULL); 01060 01061 AST_RWLIST_WRLOCK(&logchannels); 01062 01063 if (eventlog) { 01064 fclose(eventlog); 01065 eventlog = NULL; 01066 } 01067 01068 if (qlog) { 01069 fclose(qlog); 01070 qlog = NULL; 01071 } 01072 01073 AST_RWLIST_TRAVERSE(&logchannels, f, list) { 01074 if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) { 01075 fclose(f->fileptr); 01076 f->fileptr = NULL; 01077 } 01078 } 01079 01080 closelog(); /* syslog */ 01081 01082 AST_RWLIST_UNLOCK(&logchannels); 01083 01084 return; 01085 }
| int dnsmgr_init | ( | void | ) |
Provided by dnsmgr.c
Definition at line 350 of file dnsmgr.c.
References ast_cli_register(), ast_log(), cli_refresh, cli_reload, cli_status, do_reload(), LOG_ERROR, and sched_context_create().
Referenced by main().
00351 { 00352 if (!(sched = sched_context_create())) { 00353 ast_log(LOG_ERROR, "Unable to create schedule context.\n"); 00354 return -1; 00355 } 00356 ast_cli_register(&cli_reload); 00357 ast_cli_register(&cli_status); 00358 ast_cli_register(&cli_refresh); 00359 return do_reload(1); 00360 }
| int dnsmgr_reload | ( | void | ) |
Provided by dnsmgr.c
Definition at line 362 of file dnsmgr.c.
References do_reload().
00363 { 00364 return do_reload(0); 00365 }
| void dnsmgr_start_refresh | ( | void | ) |
Provided by dnsmgr.c
Definition at line 244 of file dnsmgr.c.
References ast_sched_add_variable(), AST_SCHED_DEL, master_refresh_info, and refresh_list().
Referenced by main().
00245 { 00246 if (refresh_sched > -1) { 00247 AST_SCHED_DEL(sched, refresh_sched); 00248 refresh_sched = ast_sched_add_variable(sched, 100, refresh_list, &master_refresh_info, 1); 00249 } 00250 }
| int init_framer | ( | void | ) |
Provided by frame.c
Definition at line 968 of file frame.c.
References ARRAY_LEN, and ast_cli_register_multiple().
Referenced by main().
00969 { 00970 ast_cli_register_multiple(my_clis, ARRAY_LEN(my_clis)); 00971 return 0; 00972 }
| int init_logger | ( | void | ) |
Provided by logger.c
Definition at line 1004 of file logger.c.
References ARRAY_LEN, ast_cli_register_multiple(), ast_cond_destroy(), ast_cond_init(), ast_config_AST_LOG_DIR, ast_log(), ast_mkdir(), ast_pthread_create, ast_queue_log(), ast_verb, cli_logger, errno, eventlog, EVENTLOG, handle_SIGXFSZ(), init_logger_chain(), LOG_ERROR, LOG_EVENT, logcond, logfiles, logger_thread(), logthread, and qlog.
Referenced by main().
01005 { 01006 char tmp[256]; 01007 int res = 0; 01008 01009 /* auto rotate if sig SIGXFSZ comes a-knockin */ 01010 (void) signal(SIGXFSZ, (void *) handle_SIGXFSZ); 01011 01012 /* start logger thread */ 01013 ast_cond_init(&logcond, NULL); 01014 if (ast_pthread_create(&logthread, NULL, logger_thread, NULL) < 0) { 01015 ast_cond_destroy(&logcond); 01016 return -1; 01017 } 01018 01019 /* register the logger cli commands */ 01020 ast_cli_register_multiple(cli_logger, ARRAY_LEN(cli_logger)); 01021 01022 ast_mkdir(ast_config_AST_LOG_DIR, 0777); 01023 01024 /* create log channels */ 01025 init_logger_chain(0 /* locked */); 01026 01027 /* create the eventlog */ 01028 if (logfiles.event_log) { 01029 snprintf(tmp, sizeof(tmp), "%s/%s", ast_config_AST_LOG_DIR, EVENTLOG); 01030 eventlog = fopen(tmp, "a"); 01031 if (eventlog) { 01032 ast_log(LOG_EVENT, "Started Asterisk Event Logger\n"); 01033 ast_verb(1, "Asterisk Event Logger Started %s\n", tmp); 01034 } else { 01035 ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno)); 01036 res = -1; 01037 } 01038 } 01039 01040 if (logfiles.queue_log) { 01041 snprintf(tmp, sizeof(tmp), "%s/%s", ast_config_AST_LOG_DIR, queue_log_name); 01042 qlog = fopen(tmp, "a"); 01043 ast_queue_log("NONE", "NONE", "NONE", "QUEUESTART", "%s", ""); 01044 } 01045 return res; 01046 }
| int load_modules | ( | unsigned | int | ) |
Provided by loader.c
Definition at line 941 of file loader.c.
References add_to_load_order(), ast_config_AST_MODULE_DIR, ast_config_destroy(), ast_config_load2(), 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, dir, embedding, EVENT_FLAG_SYSTEM, find_resource(), ast_module::flags, ast_module::lib, load_resource_list(), LOG_NOTICE, LOG_WARNING, manager_event, ast_variable::name, ast_variable::next, load_order_entry::resource, ast_module::resource, resource_name_match(), ast_module::running, and ast_variable::value.
Referenced by main().
00942 { 00943 struct ast_config *cfg; 00944 struct ast_module *mod; 00945 struct load_order_entry *order; 00946 struct ast_variable *v; 00947 unsigned int load_count; 00948 struct load_order load_order; 00949 int res = 0; 00950 struct ast_flags config_flags = { 0 }; 00951 int modulecount = 0; 00952 00953 #ifdef LOADABLE_MODULES 00954 struct dirent *dirent; 00955 DIR *dir; 00956 #endif 00957 00958 /* all embedded modules have registered themselves by now */ 00959 embedding = 0; 00960 00961 ast_verb(1, "Asterisk Dynamic Loader Starting:\n"); 00962 00963 AST_LIST_HEAD_INIT_NOLOCK(&load_order); 00964 00965 AST_LIST_LOCK(&module_list); 00966 00967 if (embedded_module_list.first) { 00968 module_list.first = embedded_module_list.first; 00969 module_list.last = embedded_module_list.last; 00970 embedded_module_list.first = NULL; 00971 } 00972 00973 cfg = ast_config_load2(AST_MODULE_CONFIG, "" /* core, can't reload */, config_flags); 00974 if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) { 00975 ast_log(LOG_WARNING, "No '%s' found, no modules will be loaded.\n", AST_MODULE_CONFIG); 00976 goto done; 00977 } 00978 00979 /* first, find all the modules we have been explicitly requested to load */ 00980 for (v = ast_variable_browse(cfg, "modules"); v; v = v->next) { 00981 if (!strcasecmp(v->name, preload_only ? "preload" : "load")) { 00982 add_to_load_order(v->value, &load_order); 00983 } 00984 } 00985 00986 /* check if 'autoload' is on */ 00987 if (!preload_only && ast_true(ast_variable_retrieve(cfg, "modules", "autoload"))) { 00988 /* if so, first add all the embedded modules that are not already running to the load order */ 00989 AST_LIST_TRAVERSE(&module_list, mod, entry) { 00990 /* if it's not embedded, skip it */ 00991 if (mod->lib) 00992 continue; 00993 00994 if (mod->flags.running) 00995 continue; 00996 00997 order = add_to_load_order(mod->resource, &load_order); 00998 } 00999 01000 #ifdef LOADABLE_MODULES 01001 /* if we are allowed to load dynamic modules, scan the directory for 01002 for all available modules and add them as well */ 01003 if ((dir = opendir(ast_config_AST_MODULE_DIR))) { 01004 while ((dirent = readdir(dir))) { 01005 int ld = strlen(dirent->d_name); 01006 01007 /* Must end in .so to load it. */ 01008 01009 if (ld < 4) 01010 continue; 01011 01012 if (strcasecmp(dirent->d_name + ld - 3, ".so")) 01013 continue; 01014 01015 /* if there is already a module by this name in the module_list, 01016 skip this file */ 01017 if (find_resource(dirent->d_name, 0)) 01018 continue; 01019 01020 add_to_load_order(dirent->d_name, &load_order); 01021 } 01022 01023 closedir(dir); 01024 } else { 01025 if (!ast_opt_quiet) 01026 ast_log(LOG_WARNING, "Unable to open modules directory '%s'.\n", 01027 ast_config_AST_MODULE_DIR); 01028 } 01029 #endif 01030 } 01031 01032 /* now scan the config for any modules we are prohibited from loading and 01033 remove them from the load order */ 01034 for (v = ast_variable_browse(cfg, "modules"); v; v = v->next) { 01035 if (strcasecmp(v->name, "noload")) 01036 continue; 01037 01038 AST_LIST_TRAVERSE_SAFE_BEGIN(&load_order, order, entry) { 01039 if (!resource_name_match(order->resource, v->value)) { 01040 AST_LIST_REMOVE_CURRENT(entry); 01041 ast_free(order->resource); 01042 ast_free(order); 01043 } 01044 } 01045 AST_LIST_TRAVERSE_SAFE_END; 01046 } 01047 01048 /* we are done with the config now, all the information we need is in the 01049 load_order list */ 01050 ast_config_destroy(cfg); 01051 01052 load_count = 0; 01053 AST_LIST_TRAVERSE(&load_order, order, entry) 01054 load_count++; 01055 01056 if (load_count) 01057 ast_log(LOG_NOTICE, "%d modules will be loaded.\n", load_count); 01058 01059 /* first, load only modules that provide global symbols */ 01060 if ((res = load_resource_list(&load_order, 1, &modulecount)) < 0) { 01061 goto done; 01062 } 01063 01064 /* now load everything else */ 01065 if ((res = load_resource_list(&load_order, 0, &modulecount)) < 0) { 01066 goto done; 01067 } 01068 01069 done: 01070 while ((order = AST_LIST_REMOVE_HEAD(&load_order, entry))) { 01071 ast_free(order->resource); 01072 ast_free(order); 01073 } 01074 01075 AST_LIST_UNLOCK(&module_list); 01076 01077 /* Tell manager clients that are aggressive at logging in that we're done 01078 loading modules. If there's a DNS problem in chan_sip, we might not 01079 even reach this */ 01080 manager_event(EVENT_FLAG_SYSTEM, "ModuleLoadReport", "ModuleLoadStatus: Done\r\nModuleSelection: %s\r\nModuleCount: %d\r\n", preload_only ? "Preload" : "All", modulecount); 01081 01082 return res; 01083 }
| int load_pbx | ( | void | ) |
Provided by pbx.c
Definition at line 9302 of file pbx.c.
References __ast_custom_function_register(), ARRAY_LEN, ast_cli_register_multiple(), AST_EVENT_DEVICE_STATE, AST_EVENT_IE_END, ast_event_subscribe(), ast_log(), ast_manager_register2(), ast_register_application2(), 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(), mandescr_show_dialplan, and pbx_cli.
Referenced by main().
09303 { 09304 int x; 09305 09306 /* Initialize the PBX */ 09307 ast_verb(1, "Asterisk PBX Core Initializing\n"); 09308 if (!(device_state_tps = ast_taskprocessor_get("pbx-core", 0))) { 09309 ast_log(LOG_WARNING, "failed to create pbx-core taskprocessor\n"); 09310 } 09311 09312 ast_verb(1, "Registering builtin applications:\n"); 09313 ast_cli_register_multiple(pbx_cli, ARRAY_LEN(pbx_cli)); 09314 __ast_custom_function_register(&exception_function, NULL); 09315 09316 /* Register builtin applications */ 09317 for (x = 0; x < ARRAY_LEN(builtins); x++) { 09318 ast_verb(1, "[%s]\n", builtins[x].name); 09319 if (ast_register_application2(builtins[x].name, builtins[x].execute, NULL, NULL, NULL)) { 09320 ast_log(LOG_ERROR, "Unable to register builtin application '%s'\n", builtins[x].name); 09321 return -1; 09322 } 09323 } 09324 09325 /* Register manager application */ 09326 ast_manager_register2("ShowDialPlan", EVENT_FLAG_CONFIG | EVENT_FLAG_REPORTING, manager_show_dialplan, "List dialplan", mandescr_show_dialplan); 09327 09328 if (!(device_state_sub = ast_event_subscribe(AST_EVENT_DEVICE_STATE, device_state_cb, NULL, 09329 AST_EVENT_IE_END))) { 09330 return -1; 09331 } 09332 09333 return 0; 09334 }
| void threadstorage_init | ( | void | ) |
1.6.2