#include "asterisk/autoconfig.h"
#include "asterisk/compat.h"
#include "asterisk/paths.h"
Go to the source code of this file.
Defines | |
#define | ASTERISK_FILE_VERSION(file, version) |
Register/unregister a source code file with the core. | |
#define | DEFAULT_LANGUAGE "en" |
#define | DEFAULT_SAMPLE_RATE 8000 |
#define | DEFAULT_SAMPLES_PER_MS ((DEFAULT_SAMPLE_RATE)/1000) |
#define | sched_setscheduler __PLEASE_USE_ast_set_priority_INSTEAD_OF_sched_setscheduler__ |
#define | setpriority __PLEASE_USE_ast_set_priority_INSTEAD_OF_setpriority__ |
Functions | |
int | ast_add_profile (const char *, uint64_t scale) |
support for event profiling | |
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_fd_init (void) |
int64_t | ast_mark (int, int start1_stop0) |
int | ast_module_reload (const char *name) |
Reload asterisk modules. | |
int | ast_pbx_init (void) |
void | ast_process_pending_reloads (void) |
Process reload requests received during startup. | |
int64_t | ast_profile (int, int64_t) |
int | ast_register_atexit (void(*func)(void)) |
Register a function to be executed before Asterisk exits. | |
void | ast_register_file_version (const char *file, const char *version) |
Register the version of a source code file with the core. | |
int | ast_set_priority (int) |
We set ourselves to a high priority, that we might pre-empt everything else. If your PBX has heavy activity on it, this is a good thing. | |
int | ast_term_init (void) |
int | ast_test_init (void) |
void | ast_unregister_atexit (void(*func)(void)) |
Unregister a function registered with ast_register_atexit(). | |
void | ast_unregister_file_version (const char *file) |
Unregister a source code file from the core. | |
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) |
int | reload_logger (int) |
void | threadstorage_init (void) |
Variables | |
char | ast_config_AST_AGI_DIR [PATH_MAX] |
char | ast_config_AST_CONFIG_DIR [PATH_MAX] |
char | ast_config_AST_CONFIG_FILE [PATH_MAX] |
char | ast_config_AST_CTL [PATH_MAX] |
char | ast_config_AST_CTL_GROUP [PATH_MAX] |
char | ast_config_AST_CTL_OWNER [PATH_MAX] |
char | ast_config_AST_CTL_PERMISSIONS [PATH_MAX] |
char | ast_config_AST_DATA_DIR [PATH_MAX] |
char | ast_config_AST_DB [PATH_MAX] |
char | ast_config_AST_KEY_DIR [PATH_MAX] |
char | ast_config_AST_LOG_DIR [PATH_MAX] |
char | ast_config_AST_MODULE_DIR [PATH_MAX] |
char | ast_config_AST_MONITOR_DIR [PATH_MAX] |
char | ast_config_AST_PID [PATH_MAX] |
char | ast_config_AST_RUN_DIR [PATH_MAX] |
char | ast_config_AST_RUN_GROUP [PATH_MAX] |
char | ast_config_AST_RUN_USER [PATH_MAX] |
char | ast_config_AST_SOCKET [PATH_MAX] |
char | ast_config_AST_SPOOL_DIR [PATH_MAX] |
char | ast_config_AST_SYSTEM_NAME [20] |
char | ast_config_AST_VAR_DIR [PATH_MAX] |
Definition in file asterisk.h.
#define ASTERISK_FILE_VERSION | ( | file, | |||
version | ) |
Register/unregister a source code file with the core.
file | the source file name | |
version | the version string (typically a CVS revision keyword string) |
Example:
ASTERISK_FILE_VERSION(__FILE__, "\$Revision\$")
Definition at line 222 of file asterisk.h.
#define DEFAULT_LANGUAGE "en" |
#define DEFAULT_SAMPLE_RATE 8000 |
Definition at line 33 of file asterisk.h.
Referenced by check_header(), check_header_fmt(), ogg_vorbis_rewrite(), setformat(), and write_header().
#define DEFAULT_SAMPLES_PER_MS ((DEFAULT_SAMPLE_RATE)/1000) |
Definition at line 34 of file asterisk.h.
Referenced by ast_stream_fastforward(), ast_stream_rewind(), and isAnsweringMachine().
#define sched_setscheduler __PLEASE_USE_ast_set_priority_INSTEAD_OF_sched_setscheduler__ |
#define setpriority __PLEASE_USE_ast_set_priority_INSTEAD_OF_setpriority__ |
int ast_add_profile | ( | const char * | name, | |
uint64_t | scale | |||
) |
support for event profiling
Definition at line 498 of file asterisk.c.
References ast_calloc, ast_realloc, ast_strdup, profile_data::e, profile_data::entries, profile_entry::events, profile_entry::mark, profile_data::max_size, profile_entry::name, prof_data, profile_entry::scale, and profile_entry::value.
Referenced by extension_match_core().
00499 { 00500 int l = sizeof(struct profile_data); 00501 int n = 10; /* default entries */ 00502 00503 if (prof_data == NULL) { 00504 prof_data = ast_calloc(1, l + n*sizeof(struct profile_entry)); 00505 if (prof_data == NULL) 00506 return -1; 00507 prof_data->entries = 0; 00508 prof_data->max_size = n; 00509 } 00510 if (prof_data->entries >= prof_data->max_size) { 00511 void *p; 00512 n = prof_data->max_size + 20; 00513 p = ast_realloc(prof_data, l + n*sizeof(struct profile_entry)); 00514 if (p == NULL) 00515 return -1; 00516 prof_data = p; 00517 prof_data->max_size = n; 00518 } 00519 n = prof_data->entries++; 00520 prof_data->e[n].name = ast_strdup(name); 00521 prof_data->e[n].value = 0; 00522 prof_data->e[n].events = 0; 00523 prof_data->e[n].mark = 0; 00524 prof_data->e[n].scale = scale; 00525 return n; 00526 }
void ast_autoservice_init | ( | void | ) |
Provided by astobj2.c Provided by autoservice.c
Definition at line 325 of file autoservice.c.
References as_cond, and ast_cond_init().
Referenced by main().
00326 { 00327 ast_cond_init(&as_cond, NULL); 00328 }
void ast_builtins_init | ( | void | ) |
initialize the _full_cmd string in * each of the builtins.
Provided by cli.c
Definition at line 1530 of file cli.c.
References ast_cli_entry::_full_cmd, ast_cli_register_multiple(), ast_join(), ast_log(), builtins, cli_cli, ast_cli_entry::cmda, LOG_WARNING, and strdup.
Referenced by main().
01531 { 01532 struct ast_cli_entry *e; 01533 01534 for (e = builtins; e->cmda[0] != NULL; e++) { 01535 char buf[80]; 01536 ast_join(buf, sizeof(buf), e->cmda); 01537 e->_full_cmd = strdup(buf); 01538 if (!e->_full_cmd) 01539 ast_log(LOG_WARNING, "-- cannot allocate <%s>\n", buf); 01540 } 01541 01542 ast_cli_register_multiple(cli_cli, sizeof(cli_cli) / sizeof(struct ast_cli_entry)); 01543 }
void ast_channels_init | ( | void | ) |
Provided by channel.c
Definition at line 5295 of file channel.c.
References ast_cli_register_multiple(), ast_plc_reload(), and cli_channel.
Referenced by main().
05296 { 05297 ast_cli_register_multiple(cli_channel, sizeof(cli_channel) / sizeof(struct ast_cli_entry)); 05298 05299 ast_plc_reload(); 05300 }
int ast_fd_init | ( | void | ) |
int64_t ast_mark | ( | int | , | |
int | start1_stop0 | |||
) |
Definition at line 563 of file asterisk.c.
References profile_data::e, profile_data::entries, profile_entry::events, profile_entry::mark, prof_data, rdtsc(), profile_entry::scale, and profile_entry::value.
Referenced by extension_match_core().
00564 { 00565 if (!prof_data || i < 0 || i > prof_data->entries) /* invalid index */ 00566 return 0; 00567 if (startstop == 1) 00568 prof_data->e[i].mark = rdtsc(); 00569 else { 00570 prof_data->e[i].mark = (rdtsc() - prof_data->e[i].mark); 00571 if (prof_data->e[i].scale > 1) 00572 prof_data->e[i].mark /= prof_data->e[i].scale; 00573 prof_data->e[i].value += prof_data->e[i].mark; 00574 prof_data->e[i].events++; 00575 } 00576 return prof_data->e[i].mark; 00577 }
int ast_module_reload | ( | const char * | name | ) |
Reload asterisk modules.
name | the name of the module to reload |
Definition at line 652 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_verbose(), ast_module::declined, ast_module_info::description, ast_module_user::entry, ast_module::flags, ast_module::info, LOG_NOTICE, option_verbose, queue_reload_request(), ast_module_info::reload, ast_module::resource, resource_name_match(), ast_module::running, and VERBOSE_PREFIX_3.
Referenced by action_updateconfig(), ast_process_pending_reloads(), handle_reload(), handle_reload_deprecated(), and monitor_sig_flags().
00653 { 00654 struct ast_module *cur; 00655 int res = 0; /* return value. 0 = not found, others, see below */ 00656 int i; 00657 00658 /* If we aren't fully booted, we just pretend we reloaded but we queue this 00659 up to run once we are booted up. */ 00660 if (!ast_fully_booted) { 00661 queue_reload_request(name); 00662 return 0; 00663 } 00664 00665 if (ast_mutex_trylock(&reloadlock)) { 00666 ast_verbose("The previous reload command didn't finish yet\n"); 00667 return -1; /* reload already in progress */ 00668 } 00669 ast_lastreloadtime = time(NULL); 00670 00671 /* Call "predefined" reload here first */ 00672 for (i = 0; reload_classes[i].name; i++) { 00673 if (!name || !strcasecmp(name, reload_classes[i].name)) { 00674 reload_classes[i].reload_fn(); /* XXX should check error ? */ 00675 res = 2; /* found and reloaded */ 00676 } 00677 } 00678 00679 if (name && res) { 00680 ast_mutex_unlock(&reloadlock); 00681 return res; 00682 } 00683 00684 AST_LIST_LOCK(&module_list); 00685 AST_LIST_TRAVERSE(&module_list, cur, entry) { 00686 const struct ast_module_info *info = cur->info; 00687 00688 if (name && resource_name_match(name, cur->resource)) 00689 continue; 00690 00691 if (!cur->flags.running || cur->flags.declined) { 00692 if (!name) 00693 continue; 00694 ast_log(LOG_NOTICE, "The module '%s' was not properly initialized. " 00695 "Before reloading the module, you must run \"module load %s\" " 00696 "and fix whatever is preventing the module from being initialized.\n", 00697 name, name); 00698 res = 2; /* Don't report that the module was not found */ 00699 break; 00700 } 00701 00702 if (!info->reload) { /* cannot be reloaded */ 00703 if (res < 1) /* store result if possible */ 00704 res = 1; /* 1 = no reload() method */ 00705 continue; 00706 } 00707 00708 res = 2; 00709 if (option_verbose > 2) 00710 ast_verbose(VERBOSE_PREFIX_3 "Reloading module '%s' (%s)\n", cur->resource, info->description); 00711 info->reload(); 00712 } 00713 AST_LIST_UNLOCK(&module_list); 00714 00715 ast_mutex_unlock(&reloadlock); 00716 00717 return res; 00718 }
int ast_pbx_init | ( | void | ) |
Provided by pbx.c
Definition at line 6705 of file pbx.c.
References ao2_container_alloc(), hint_cmp(), hint_hash(), and hints.
Referenced by main().
06706 { 06707 hints = ao2_container_alloc(1, hint_hash, hint_cmp); 06708 06709 return hints ? 0 : -1; 06710 }
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 587 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, ast_module_user::entry, LOG_NOTICE, and reload_queue_item::module.
Referenced by main().
00588 { 00589 struct reload_queue_item *item; 00590 00591 if (!ast_fully_booted) { 00592 return; 00593 } 00594 00595 AST_LIST_LOCK(&reload_queue); 00596 00597 if (do_full_reload) { 00598 do_full_reload = 0; 00599 AST_LIST_UNLOCK(&reload_queue); 00600 ast_log(LOG_NOTICE, "Executing deferred reload request.\n"); 00601 ast_module_reload(NULL); 00602 return; 00603 } 00604 00605 while ((item = AST_LIST_REMOVE_HEAD(&reload_queue, entry))) { 00606 ast_log(LOG_NOTICE, "Executing deferred reload request for module '%s'.\n", item->module); 00607 ast_module_reload(item->module); 00608 ast_free(item); 00609 } 00610 00611 AST_LIST_UNLOCK(&reload_queue); 00612 }
int64_t ast_profile | ( | int | , | |
int64_t | ||||
) |
Definition at line 528 of file asterisk.c.
References profile_data::e, profile_data::entries, profile_entry::events, prof_data, profile_entry::scale, and profile_entry::value.
00529 { 00530 if (!prof_data || i < 0 || i > prof_data->entries) /* invalid index */ 00531 return 0; 00532 if (prof_data->e[i].scale > 1) 00533 delta /= prof_data->e[i].scale; 00534 prof_data->e[i].value += delta; 00535 prof_data->e[i].events++; 00536 return prof_data->e[i].value; 00537 }
int ast_register_atexit | ( | void(*)(void) | func | ) |
Register a function to be executed before Asterisk exits.
func | The callback function to use. |
Definition at line 831 of file asterisk.c.
References ast_calloc, AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_UNLOCK, ast_unregister_atexit(), and ast_atexit::list.
Referenced by do_reload(), and load_module().
00832 { 00833 struct ast_atexit *ae; 00834 00835 if (!(ae = ast_calloc(1, sizeof(*ae)))) 00836 return -1; 00837 00838 ae->func = func; 00839 00840 ast_unregister_atexit(func); 00841 00842 AST_LIST_LOCK(&atexits); 00843 AST_LIST_INSERT_HEAD(&atexits, ae, list); 00844 AST_LIST_UNLOCK(&atexits); 00845 00846 return 0; 00847 }
void ast_register_file_version | ( | const char * | file, | |
const char * | version | |||
) |
Register the version of a source code file with the core.
file | the source file name | |
version | the version string (typically a CVS revision keyword string) |
Definition at line 284 of file asterisk.c.
References ast_calloc, AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_UNLOCK, ast_strdupa, ast_strip(), ast_strip_quoted(), and ast_atexit::list.
00285 { 00286 struct file_version *new; 00287 char *work; 00288 size_t version_length; 00289 00290 work = ast_strdupa(version); 00291 work = ast_strip(ast_strip_quoted(work, "$", "$")); 00292 version_length = strlen(work) + 1; 00293 00294 if (!(new = ast_calloc(1, sizeof(*new) + version_length))) 00295 return; 00296 00297 new->file = file; 00298 new->version = (char *) new + sizeof(*new); 00299 memcpy(new->version, work, version_length); 00300 #ifdef AST_MUTEX_INIT_W_CONSTRUCTORS 00301 pthread_once(&file_versions_once, file_versions_init); 00302 #endif 00303 AST_LIST_LOCK(&file_versions); 00304 AST_LIST_INSERT_HEAD(&file_versions, new, list); 00305 AST_LIST_UNLOCK(&file_versions); 00306 }
int ast_set_priority | ( | int | ) |
We set ourselves to a high priority, that we might pre-empt everything else. If your PBX has heavy activity on it, this is a good thing.
Provided by asterisk.c
Definition at line 1365 of file asterisk.c.
References ast_log(), ast_verbose(), LOG_WARNING, sched_setscheduler, and setpriority.
Referenced by app_exec(), ast_safe_system(), icesencode(), launch_script(), main(), mp3play(), NBScatplay(), send_waveform_to_fd(), spawn_mp3(), and spawn_ras().
01366 { 01367 struct sched_param sched; 01368 memset(&sched, 0, sizeof(sched)); 01369 #ifdef __linux__ 01370 if (pri) { 01371 sched.sched_priority = 10; 01372 if (sched_setscheduler(0, SCHED_RR, &sched)) { 01373 ast_log(LOG_WARNING, "Unable to set high priority\n"); 01374 return -1; 01375 } else 01376 if (option_verbose) 01377 ast_verbose("Set to realtime thread\n"); 01378 } else { 01379 sched.sched_priority = 0; 01380 /* According to the manpage, these parameters can never fail. */ 01381 sched_setscheduler(0, SCHED_OTHER, &sched); 01382 } 01383 #else 01384 if (pri) { 01385 if (setpriority(PRIO_PROCESS, 0, -10) == -1) { 01386 ast_log(LOG_WARNING, "Unable to set high priority\n"); 01387 return -1; 01388 } else 01389 if (option_verbose) 01390 ast_verbose("Set to high priority\n"); 01391 } else { 01392 /* According to the manpage, these parameters can never fail. */ 01393 setpriority(PRIO_PROCESS, 0, 0); 01394 } 01395 #endif 01396 return 0; 01397 }
int ast_term_init | ( | void | ) |
Provided by term.c
Definition at line 75 of file term.c.
References ast_opt_console, ast_opt_no_color, ATTR_BRIGHT, ATTR_RESET, COLOR_BLACK, COLOR_BROWN, COLOR_WHITE, convshort(), and ESC.
Referenced by main().
00076 { 00077 char *term = getenv("TERM"); 00078 char termfile[256] = ""; 00079 char buffer[512] = ""; 00080 int termfd = -1, parseokay = 0, i; 00081 00082 if (ast_opt_no_color) { 00083 return 0; 00084 } 00085 00086 if (!ast_opt_console) { 00087 /* If any remote console is not compatible, we'll strip the color codes at that point */ 00088 vt100compat = 1; 00089 goto end; 00090 } 00091 00092 if (!term) { 00093 return 0; 00094 } 00095 00096 for (i = 0;; i++) { 00097 if (termpath[i] == NULL) { 00098 break; 00099 } 00100 snprintf(termfile, sizeof(termfile), "%s/%c/%s", termpath[i], *term, term); 00101 termfd = open(termfile, O_RDONLY); 00102 if (termfd > -1) { 00103 break; 00104 } 00105 } 00106 if (termfd > -1) { 00107 int actsize = read(termfd, buffer, sizeof(buffer) - 1); 00108 short sz_names = convshort(buffer + 2); 00109 short sz_bools = convshort(buffer + 4); 00110 short n_nums = convshort(buffer + 6); 00111 00112 /* if ((sz_names + sz_bools) & 1) 00113 sz_bools++; */ 00114 00115 if (sz_names + sz_bools + n_nums < actsize) { 00116 /* Offset 13 is defined in /usr/include/term.h, though we do not 00117 * include it here, as it conflicts with include/asterisk/term.h */ 00118 short max_colors = convshort(buffer + 12 + sz_names + sz_bools + 13 * 2); 00119 if (max_colors > 0) { 00120 vt100compat = 1; 00121 } 00122 parseokay = 1; 00123 } 00124 close(termfd); 00125 } 00126 00127 if (!parseokay) { 00128 /* These comparisons should not be substrings nor case-insensitive, as 00129 * terminal types are very particular about how they treat suffixes and 00130 * capitalization. For example, terminal type 'linux-m' does NOT 00131 * support color, while 'linux' does. Not even all vt100* terminals 00132 * support color, either (e.g. 'vt100+fnkeys'). */ 00133 if (!strcmp(term, "linux")) { 00134 vt100compat = 1; 00135 } else if (!strcmp(term, "xterm")) { 00136 vt100compat = 1; 00137 } else if (!strcmp(term, "xterm-color")) { 00138 vt100compat = 1; 00139 } else if (!strncmp(term, "Eterm", 5)) { 00140 /* Both entries which start with Eterm support color */ 00141 vt100compat = 1; 00142 } else if (!strcmp(term, "vt100")) { 00143 vt100compat = 1; 00144 } else if (!strncmp(term, "crt", 3)) { 00145 /* Both crt terminals support color */ 00146 vt100compat = 1; 00147 } 00148 } 00149 00150 end: 00151 if (vt100compat) { 00152 /* Make commands show up in nice colors */ 00153 snprintf(prepdata, sizeof(prepdata), "%c[%d;%d;%dm", ESC, ATTR_BRIGHT, COLOR_BROWN, COLOR_BLACK + 10); 00154 snprintf(enddata, sizeof(enddata), "%c[%d;%d;%dm", ESC, ATTR_RESET, COLOR_WHITE, COLOR_BLACK + 10); 00155 snprintf(quitdata, sizeof(quitdata), "%c[0m", ESC); 00156 } 00157 return 0; 00158 }
int ast_test_init | ( | void | ) |
Provided by test.c
Definition at line 896 of file test.c.
References ARRAY_LEN, and ast_cli_register_multiple().
Referenced by main().
00897 { 00898 #ifdef TEST_FRAMEWORK 00899 /* Register cli commands */ 00900 ast_cli_register_multiple(test_cli, ARRAY_LEN(test_cli)); 00901 #endif 00902 00903 return 0; 00904 }
void ast_unregister_atexit | ( | void(*)(void) | func | ) |
Unregister a function registered with ast_register_atexit().
func | The callback function to unregister. |
Definition at line 849 of file asterisk.c.
References AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, free, ast_atexit::func, and ast_atexit::list.
Referenced by ast_register_atexit(), and do_reload().
00850 { 00851 struct ast_atexit *ae = NULL; 00852 00853 AST_LIST_LOCK(&atexits); 00854 AST_LIST_TRAVERSE_SAFE_BEGIN(&atexits, ae, list) { 00855 if (ae->func == func) { 00856 AST_LIST_REMOVE_CURRENT(&atexits, list); 00857 break; 00858 } 00859 } 00860 AST_LIST_TRAVERSE_SAFE_END 00861 AST_LIST_UNLOCK(&atexits); 00862 00863 if (ae) 00864 free(ae); 00865 }
void ast_unregister_file_version | ( | const char * | file | ) |
Unregister a source code file from the core.
file | the source file name |
Definition at line 308 of file asterisk.c.
References ast_free, AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, file_version::file, and ast_atexit::list.
00309 { 00310 struct file_version *find; 00311 00312 AST_LIST_LOCK(&file_versions); 00313 AST_LIST_TRAVERSE_SAFE_BEGIN(&file_versions, find, list) { 00314 if (!strcasecmp(find->file, file)) { 00315 AST_LIST_REMOVE_CURRENT(&file_versions, list); 00316 break; 00317 } 00318 } 00319 AST_LIST_TRAVERSE_SAFE_END; 00320 AST_LIST_UNLOCK(&file_versions); 00321 if (find) 00322 ast_free(find); 00323 }
int astdb_init | ( | void | ) |
Provided by db.c
Definition at line 588 of file db.c.
References ast_cli_register_multiple(), ast_manager_register, cli_database, dbinit(), EVENT_FLAG_SYSTEM, manager_dbget(), and manager_dbput().
Referenced by main().
00589 { 00590 dbinit(); 00591 ast_cli_register_multiple(cli_database, sizeof(cli_database) / sizeof(struct ast_cli_entry)); 00592 ast_manager_register("DBGet", EVENT_FLAG_SYSTEM, manager_dbget, "Get DB Entry"); 00593 ast_manager_register("DBPut", EVENT_FLAG_SYSTEM, manager_dbput, "Put DB Entry"); 00594 return 0; 00595 }
int astobj2_init | ( | void | ) |
Definition at line 837 of file astobj2.c.
References ARRAY_LEN, and ast_cli_register_multiple().
Referenced by main().
00838 { 00839 #ifdef AO2_DEBUG 00840 ast_cli_register_multiple(cli_astobj2, ARRAY_LEN(cli_astobj2)); 00841 #endif 00842 00843 return 0; 00844 }
void close_logger | ( | void | ) |
Provided by logger.c
Definition at line 632 of file logger.c.
References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, eventlog, f, logchannel::list, and qlog.
Referenced by quit_handler().
00634 { 00635 struct logchannel *f; 00636 00637 AST_LIST_LOCK(&logchannels); 00638 00639 if (eventlog) { 00640 fclose(eventlog); 00641 eventlog = NULL; 00642 } 00643 00644 if (qlog) { 00645 fclose(qlog); 00646 qlog = NULL; 00647 } 00648 00649 AST_LIST_TRAVERSE(&logchannels, f, list) { 00650 if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) { 00651 fclose(f->fileptr); 00652 f->fileptr = NULL; 00653 } 00654 } 00655 00656 closelog(); /* syslog */ 00657 00658 AST_LIST_UNLOCK(&logchannels); 00659 00660 return;
int dnsmgr_init | ( | void | ) |
Provided by dnsmgr.c
Definition at line 338 of file dnsmgr.c.
References ast_cli_register(), ast_log(), cli_refresh, cli_reload, cli_status, do_reload(), LOG_ERROR, sched, and sched_context_create().
Referenced by main().
00339 { 00340 if (!(sched = sched_context_create())) { 00341 ast_log(LOG_ERROR, "Unable to create schedule context.\n"); 00342 return -1; 00343 } 00344 ast_cli_register(&cli_reload); 00345 ast_cli_register(&cli_status); 00346 ast_cli_register(&cli_refresh); 00347 return do_reload(1); 00348 }
int dnsmgr_reload | ( | void | ) |
Provided by dnsmgr.c
Definition at line 350 of file dnsmgr.c.
References do_reload().
00351 { 00352 return do_reload(0); 00353 }
void dnsmgr_start_refresh | ( | void | ) |
Provided by dnsmgr.c
Definition at line 248 of file dnsmgr.c.
References ast_sched_add_variable(), AST_SCHED_DEL, master_refresh_info, refresh_list(), and sched.
Referenced by main().
00249 { 00250 if (refresh_sched > -1) { 00251 AST_SCHED_DEL(sched, refresh_sched); 00252 refresh_sched = ast_sched_add_variable(sched, 100, refresh_list, &master_refresh_info, 1); 00253 } 00254 }
int init_framer | ( | void | ) |
Provided by frame.c
Definition at line 1039 of file frame.c.
References ast_cli_register_multiple(), and my_clis.
Referenced by main().
01040 { 01041 ast_cli_register_multiple(my_clis, sizeof(my_clis) / sizeof(struct ast_cli_entry)); 01042 return 0; 01043 }
int init_logger | ( | void | ) |
Provided by logger.c
Definition at line 593 of file logger.c.
References ast_cli_register_multiple(), ast_config_AST_LOG_DIR, ast_log(), ast_queue_log(), ast_verbose(), cli_logger, errno, eventlog, EVENTLOG, init_logger_chain(), LOG_ERROR, LOG_EVENT, logfiles, option_verbose, qlog, and QUEUELOG.
Referenced by main().
00595 { 00596 char tmp[256]; 00597 int res = 0; 00598 00599 /* auto rotate if sig SIGXFSZ comes a-knockin */ 00600 sigaction(SIGXFSZ, &handle_SIGXFSZ, NULL); 00601 00602 /* register the logger cli commands */ 00603 ast_cli_register_multiple(cli_logger, sizeof(cli_logger) / sizeof(struct ast_cli_entry)); 00604 00605 mkdir((char *)ast_config_AST_LOG_DIR, 0755); 00606 00607 /* create log channels */ 00608 init_logger_chain(); 00609 00610 /* create the eventlog */ 00611 if (logfiles.event_log) { 00612 mkdir((char *)ast_config_AST_LOG_DIR, 0755); 00613 snprintf(tmp, sizeof(tmp), "%s/%s", (char *)ast_config_AST_LOG_DIR, EVENTLOG); 00614 eventlog = fopen((char *)tmp, "a"); 00615 if (eventlog) { 00616 ast_log(LOG_EVENT, "Started Asterisk Event Logger\n"); 00617 if (option_verbose) 00618 ast_verbose("Asterisk Event Logger Started %s\n",(char *)tmp); 00619 } else { 00620 ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno)); 00621 res = -1; 00622 } 00623 } 00624 00625 if (logfiles.queue_log) { 00626 snprintf(tmp, sizeof(tmp), "%s/%s", (char *)ast_config_AST_LOG_DIR, QUEUELOG); 00627 qlog = fopen(tmp, "a"); 00628 ast_queue_log("NONE", "NONE", "NONE", "QUEUESTART", "%s", ""); 00629 } 00630 return res;
int load_modules | ( | unsigned | int | ) |
Provided by loader.c
Definition at line 888 of file loader.c.
References add_to_load_order(), ast_config_load(), AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_LOCK, ast_log(), AST_MODULE_CONFIG, ast_variable_browse(), ast_verbose(), embedding, LOG_WARNING, ast_variable::name, ast_variable::next, option_verbose, translate_module_name(), and ast_variable::value.
Referenced by main().
00889 { 00890 struct ast_config *cfg; 00891 struct ast_module *mod; 00892 struct load_order_entry *order; 00893 struct ast_variable *v; 00894 unsigned int load_count; 00895 struct load_order load_order; 00896 int res = 0; 00897 int load_pass; 00898 00899 int translate_status; 00900 char newname[18]; /* although this would normally be 80, max length in translate_module_name is 18 */ 00901 #ifdef LOADABLE_MODULES 00902 struct dirent *dirent; 00903 DIR *dir; 00904 #endif 00905 00906 /* all embedded modules have registered themselves by now */ 00907 embedding = 0; 00908 00909 if (option_verbose) 00910 ast_verbose("Asterisk Dynamic Loader Starting:\n"); 00911 00912 AST_LIST_HEAD_INIT_NOLOCK(&load_order); 00913 00914 AST_LIST_LOCK(&module_list); 00915 00916 if (!(cfg = ast_config_load(AST_MODULE_CONFIG))) { 00917 ast_log(LOG_WARNING, "No '%s' found, no modules will be loaded.\n", AST_MODULE_CONFIG); 00918 goto done; 00919 } 00920 00921 /* first, find all the modules we have been explicitly requested to load */ 00922 for (v = ast_variable_browse(cfg, "modules"); v; v = v->next) { 00923 if (!strcasecmp(v->name, preload_only ? "preload" : "load")) { 00924 translate_status = translate_module_name(v->value, newname); 00925 if (!translate_status) 00926 ast_log(LOG_WARNING, "Use of old module name %s is deprecated, please use %s instead.\n", v->value, newname); 00927 add_to_load_order(translate_status ? v->value : newname, &load_order); 00928 } 00929 } 00930 00931 /* check if 'autoload' is on */ 00932 if (!preload_only && ast_true(ast_variable_retrieve(cfg, "modules", "autoload"))) { 00933 /* if so, first add all the embedded modules that are not already running to the load order */ 00934 AST_LIST_TRAVERSE(&module_list, mod, entry) { 00935 /* if it's not embedded, skip it */ 00936 if (mod->lib) 00937 continue; 00938 00939 if (mod->flags.running) 00940 continue; 00941 00942 order = add_to_load_order(mod->resource, &load_order); 00943 } 00944 00945 #ifdef LOADABLE_MODULES 00946 /* if we are allowed to load dynamic modules, scan the directory for 00947 for all available modules and add them as well */ 00948 if ((dir = opendir(ast_config_AST_MODULE_DIR))) { 00949 while ((dirent = readdir(dir))) { 00950 int ld = strlen(dirent->d_name); 00951 00952 /* Must end in .so to load it. */ 00953 00954 if (ld < 4) 00955 continue; 00956 00957 if (strcasecmp(dirent->d_name + ld - 3, ".so")) 00958 continue; 00959 00960 /* if there is already a module by this name in the module_list, 00961 skip this file */ 00962 if (find_resource(dirent->d_name, 0)) 00963 continue; 00964 00965 add_to_load_order(dirent->d_name, &load_order); 00966 } 00967 00968 closedir(dir); 00969 } else { 00970 if (!ast_opt_quiet) 00971 ast_log(LOG_WARNING, "Unable to open modules directory '%s'.\n", 00972 ast_config_AST_MODULE_DIR); 00973 } 00974 #endif 00975 } 00976 00977 /* now scan the config for any modules we are prohibited from loading and 00978 remove them from the load order */ 00979 for (v = ast_variable_browse(cfg, "modules"); v; v = v->next) { 00980 if (strcasecmp(v->name, "noload")) 00981 continue; 00982 00983 AST_LIST_TRAVERSE_SAFE_BEGIN(&load_order, order, entry) { 00984 translate_status = translate_module_name(v->value, newname); 00985 if (!resource_name_match(order->resource, translate_status ? v->value : newname)) { 00986 if (!translate_status) 00987 ast_log(LOG_WARNING, "Use of old module name %s is deprecated, please use %s instead.\n", v->value, newname); 00988 AST_LIST_REMOVE_CURRENT(&load_order, entry); 00989 free(order->resource); 00990 free(order); 00991 } 00992 } 00993 AST_LIST_TRAVERSE_SAFE_END; 00994 } 00995 00996 /* we are done with the config now, all the information we need is in the 00997 load_order list */ 00998 ast_config_destroy(cfg); 00999 01000 load_count = 0; 01001 AST_LIST_TRAVERSE(&load_order, order, entry) 01002 load_count++; 01003 01004 if (load_count) 01005 ast_log(LOG_NOTICE, "%d modules will be loaded.\n", load_count); 01006 01007 for (load_pass = 0; load_pass < LOAD_DONE; load_pass++) { 01008 AST_LIST_TRAVERSE_SAFE_BEGIN(&load_order, order, entry) { 01009 switch (load_resource(order->resource, load_pass)) { 01010 case AST_MODULE_LOAD_SUCCESS: 01011 case AST_MODULE_LOAD_DECLINE: 01012 AST_LIST_REMOVE_CURRENT(&load_order, entry); 01013 free(order->resource); 01014 free(order); 01015 break; 01016 case AST_MODULE_LOAD_FAILURE: 01017 res = -1; 01018 goto done; 01019 case AST_MODULE_LOAD_SKIP: 01020 /* 01021 * Try again later. This result is received when a module is 01022 * deferred because it is not a part of the current pass. 01023 */ 01024 break; 01025 } 01026 } 01027 AST_LIST_TRAVERSE_SAFE_END; 01028 } 01029 01030 done: 01031 while ((order = AST_LIST_REMOVE_HEAD(&load_order, entry))) { 01032 free(order->resource); 01033 free(order); 01034 } 01035 01036 AST_LIST_UNLOCK(&module_list); 01037 01038 return res; 01039 }
int load_pbx | ( | void | ) |
Provided by pbx.c
Definition at line 6389 of file pbx.c.
References ast_cli_register_multiple(), ast_log(), ast_register_application(), ast_verbose(), builtins, LOG_ERROR, option_verbose, pbx_cli, and VERBOSE_PREFIX_1.
Referenced by main().
06390 { 06391 int x; 06392 06393 /* Initialize the PBX */ 06394 if (option_verbose) { 06395 ast_verbose( "Asterisk PBX Core Initializing\n"); 06396 ast_verbose( "Registering builtin applications:\n"); 06397 } 06398 ast_cli_register_multiple(pbx_cli, sizeof(pbx_cli) / sizeof(struct ast_cli_entry)); 06399 06400 /* Register builtin applications */ 06401 for (x=0; x<sizeof(builtins) / sizeof(struct pbx_builtin); x++) { 06402 if (option_verbose) 06403 ast_verbose( VERBOSE_PREFIX_1 "[%s]\n", builtins[x].name); 06404 if (ast_register_application(builtins[x].name, builtins[x].execute, builtins[x].synopsis, builtins[x].description)) { 06405 ast_log(LOG_ERROR, "Unable to register builtin application '%s'\n", builtins[x].name); 06406 return -1; 06407 } 06408 } 06409 return 0; 06410 }
int reload_logger | ( | int | ) |
Provided by logger.c
Definition at line 368 of file logger.c.
References ast_config_AST_LOG_DIR, ast_copy_string(), AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), ast_queue_log(), ast_verbose(), errno, EVENT_FLAG_SYSTEM, EVENTLOG, eventlog, f, init_logger_chain(), logchannel::list, LOG_ERROR, LOG_EVENT, logfiles, manager_event(), option_verbose, qlog, and QUEUELOG.
Referenced by ast_log(), handle_logger_rotate(), and logger_reload().
00370 { 00371 char old[PATH_MAX] = ""; 00372 char new[PATH_MAX]; 00373 int event_rotate = rotate, queue_rotate = rotate; 00374 struct logchannel *f; 00375 FILE *myf; 00376 int x, res = 0; 00377 00378 AST_LIST_LOCK(&logchannels); 00379 00380 if (eventlog) 00381 fclose(eventlog); 00382 else 00383 event_rotate = 0; 00384 eventlog = NULL; 00385 00386 if (qlog) 00387 fclose(qlog); 00388 else 00389 queue_rotate = 0; 00390 qlog = NULL; 00391 00392 mkdir((char *)ast_config_AST_LOG_DIR, 0755); 00393 00394 AST_LIST_TRAVERSE(&logchannels, f, list) { 00395 if (f->disabled) { 00396 f->disabled = 0; /* Re-enable logging at reload */ 00397 manager_event(EVENT_FLAG_SYSTEM, "LogChannel", "Channel: %s\r\nEnabled: Yes\r\n", f->filename); 00398 } 00399 if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) { 00400 fclose(f->fileptr); /* Close file */ 00401 f->fileptr = NULL; 00402 if (rotate) { 00403 ast_copy_string(old, f->filename, sizeof(old)); 00404 00405 for (x = 0; ; x++) { 00406 snprintf(new, sizeof(new), "%s.%d", f->filename, x); 00407 myf = fopen((char *)new, "r"); 00408 if (myf) 00409 fclose(myf); 00410 else 00411 break; 00412 } 00413 00414 /* do it */ 00415 if (rename(old,new)) 00416 fprintf(stderr, "Unable to rename file '%s' to '%s'\n", old, new); 00417 } 00418 } 00419 } 00420 00421 filesize_reload_needed = 0; 00422 00423 init_logger_chain(); 00424 00425 if (logfiles.event_log) { 00426 snprintf(old, sizeof(old), "%s/%s", (char *)ast_config_AST_LOG_DIR, EVENTLOG); 00427 if (event_rotate) { 00428 for (x=0;;x++) { 00429 snprintf(new, sizeof(new), "%s/%s.%d", (char *)ast_config_AST_LOG_DIR, EVENTLOG,x); 00430 myf = fopen((char *)new, "r"); 00431 if (myf) /* File exists */ 00432 fclose(myf); 00433 else 00434 break; 00435 } 00436 00437 /* do it */ 00438 if (rename(old,new)) 00439 ast_log(LOG_ERROR, "Unable to rename file '%s' to '%s'\n", old, new); 00440 } 00441 00442 eventlog = fopen(old, "a"); 00443 if (eventlog) { 00444 ast_log(LOG_EVENT, "Restarted Asterisk Event Logger\n"); 00445 if (option_verbose) 00446 ast_verbose("Asterisk Event Logger restarted\n"); 00447 } else { 00448 ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno)); 00449 res = -1; 00450 } 00451 } 00452 00453 if (logfiles.queue_log) { 00454 snprintf(old, sizeof(old), "%s/%s", (char *)ast_config_AST_LOG_DIR, QUEUELOG); 00455 if (queue_rotate) { 00456 for (x = 0; ; x++) { 00457 snprintf(new, sizeof(new), "%s/%s.%d", (char *)ast_config_AST_LOG_DIR, QUEUELOG, x); 00458 myf = fopen((char *)new, "r"); 00459 if (myf) /* File exists */ 00460 fclose(myf); 00461 else 00462 break; 00463 } 00464 00465 /* do it */ 00466 if (rename(old, new)) 00467 ast_log(LOG_ERROR, "Unable to rename file '%s' to '%s'\n", old, new); 00468 } 00469 00470 qlog = fopen(old, "a"); 00471 if (qlog) { 00472 ast_queue_log("NONE", "NONE", "NONE", "CONFIGRELOAD", "%s", ""); 00473 ast_log(LOG_EVENT, "Restarted Asterisk Queue Logger\n"); 00474 if (option_verbose) 00475 ast_verbose("Asterisk Queue Logger restarted\n"); 00476 } else { 00477 ast_log(LOG_ERROR, "Unable to create queue log: %s\n", strerror(errno)); 00478 res = -1; 00479 } 00480 } 00481 00482 AST_LIST_UNLOCK(&logchannels); 00483 00484 return res;
void threadstorage_init | ( | void | ) |
char ast_config_AST_AGI_DIR[PATH_MAX] |
Definition at line 229 of file asterisk.c.
char ast_config_AST_CONFIG_DIR[PATH_MAX] |
Definition at line 221 of file asterisk.c.
char ast_config_AST_CONFIG_FILE[PATH_MAX] |
Definition at line 222 of file asterisk.c.
char ast_config_AST_CTL[PATH_MAX] |
Definition at line 240 of file asterisk.c.
char ast_config_AST_CTL_GROUP[PATH_MAX] |
Definition at line 239 of file asterisk.c.
char ast_config_AST_CTL_OWNER[PATH_MAX] |
Definition at line 238 of file asterisk.c.
char ast_config_AST_CTL_PERMISSIONS[PATH_MAX] |
Definition at line 237 of file asterisk.c.
char ast_config_AST_DATA_DIR[PATH_MAX] |
Definition at line 227 of file asterisk.c.
char ast_config_AST_DB[PATH_MAX] |
Definition at line 230 of file asterisk.c.
char ast_config_AST_KEY_DIR[PATH_MAX] |
Definition at line 231 of file asterisk.c.
char ast_config_AST_LOG_DIR[PATH_MAX] |
Definition at line 228 of file asterisk.c.
char ast_config_AST_MODULE_DIR[PATH_MAX] |
Definition at line 223 of file asterisk.c.
char ast_config_AST_MONITOR_DIR[PATH_MAX] |
Definition at line 225 of file asterisk.c.
char ast_config_AST_PID[PATH_MAX] |
Definition at line 232 of file asterisk.c.
char ast_config_AST_RUN_DIR[PATH_MAX] |
Definition at line 234 of file asterisk.c.
char ast_config_AST_RUN_GROUP[PATH_MAX] |
Definition at line 236 of file asterisk.c.
Referenced by action_coresettings(), handle_show_settings(), and main().
char ast_config_AST_RUN_USER[PATH_MAX] |
Definition at line 235 of file asterisk.c.
Referenced by action_coresettings(), handle_show_settings(), and main().
char ast_config_AST_SOCKET[PATH_MAX] |
Definition at line 233 of file asterisk.c.
char ast_config_AST_SPOOL_DIR[PATH_MAX] |
Definition at line 224 of file asterisk.c.
char ast_config_AST_SYSTEM_NAME[20] |
Definition at line 241 of file asterisk.c.
char ast_config_AST_VAR_DIR[PATH_MAX] |
Definition at line 226 of file asterisk.c.