#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. | |
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) |
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 214 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(), 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 484 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().
00485 { 00486 int l = sizeof(struct profile_data); 00487 int n = 10; /* default entries */ 00488 00489 if (prof_data == NULL) { 00490 prof_data = ast_calloc(1, l + n*sizeof(struct profile_entry)); 00491 if (prof_data == NULL) 00492 return -1; 00493 prof_data->entries = 0; 00494 prof_data->max_size = n; 00495 } 00496 if (prof_data->entries >= prof_data->max_size) { 00497 void *p; 00498 n = prof_data->max_size + 20; 00499 p = ast_realloc(prof_data, l + n*sizeof(struct profile_entry)); 00500 if (p == NULL) 00501 return -1; 00502 prof_data = p; 00503 prof_data->max_size = n; 00504 } 00505 n = prof_data->entries++; 00506 prof_data->e[n].name = ast_strdup(name); 00507 prof_data->e[n].value = 0; 00508 prof_data->e[n].events = 0; 00509 prof_data->e[n].mark = 0; 00510 prof_data->e[n].scale = scale; 00511 return n; 00512 }
void ast_autoservice_init | ( | void | ) |
Provided by astobj2.c Provided by autoservice.c
Definition at line 323 of file autoservice.c.
References as_cond, and ast_cond_init().
Referenced by main().
00324 { 00325 ast_cond_init(&as_cond, NULL); 00326 }
void ast_builtins_init | ( | void | ) |
initialize the _full_cmd string in * each of the builtins.
Provided by cli.c
Definition at line 1506 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().
01507 { 01508 struct ast_cli_entry *e; 01509 01510 for (e = builtins; e->cmda[0] != NULL; e++) { 01511 char buf[80]; 01512 ast_join(buf, sizeof(buf), e->cmda); 01513 e->_full_cmd = strdup(buf); 01514 if (!e->_full_cmd) 01515 ast_log(LOG_WARNING, "-- cannot allocate <%s>\n", buf); 01516 } 01517 01518 ast_cli_register_multiple(cli_cli, sizeof(cli_cli) / sizeof(struct ast_cli_entry)); 01519 }
void ast_channels_init | ( | void | ) |
Provided by channel.c
Definition at line 4850 of file channel.c.
References ast_cli_register_multiple(), and cli_channel.
Referenced by main().
04851 { 04852 ast_cli_register_multiple(cli_channel, sizeof(cli_channel) / sizeof(struct ast_cli_entry)); 04853 }
int ast_fd_init | ( | void | ) |
int64_t ast_mark | ( | int | , | |
int | start1_stop0 | |||
) |
Definition at line 549 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().
00550 { 00551 if (!prof_data || i < 0 || i > prof_data->entries) /* invalid index */ 00552 return 0; 00553 if (startstop == 1) 00554 prof_data->e[i].mark = rdtsc(); 00555 else { 00556 prof_data->e[i].mark = (rdtsc() - prof_data->e[i].mark); 00557 if (prof_data->e[i].scale > 1) 00558 prof_data->e[i].mark /= prof_data->e[i].scale; 00559 prof_data->e[i].value += prof_data->e[i].mark; 00560 prof_data->e[i].events++; 00561 } 00562 return prof_data->e[i].mark; 00563 }
int ast_module_reload | ( | const char * | name | ) |
Reload asterisk modules.
name | the name of the module to reload |
Definition at line 612 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().
00613 { 00614 struct ast_module *cur; 00615 int res = 0; /* return value. 0 = not found, others, see below */ 00616 int i; 00617 00618 /* If we aren't fully booted, we just pretend we reloaded but we queue this 00619 up to run once we are booted up. */ 00620 if (!ast_fully_booted) { 00621 queue_reload_request(name); 00622 return 0; 00623 } 00624 00625 if (ast_mutex_trylock(&reloadlock)) { 00626 ast_verbose("The previous reload command didn't finish yet\n"); 00627 return -1; /* reload already in progress */ 00628 } 00629 ast_lastreloadtime = time(NULL); 00630 00631 /* Call "predefined" reload here first */ 00632 for (i = 0; reload_classes[i].name; i++) { 00633 if (!name || !strcasecmp(name, reload_classes[i].name)) { 00634 reload_classes[i].reload_fn(); /* XXX should check error ? */ 00635 res = 2; /* found and reloaded */ 00636 } 00637 } 00638 00639 if (name && res) { 00640 ast_mutex_unlock(&reloadlock); 00641 return res; 00642 } 00643 00644 AST_LIST_LOCK(&module_list); 00645 AST_LIST_TRAVERSE(&module_list, cur, entry) { 00646 const struct ast_module_info *info = cur->info; 00647 00648 if (name && resource_name_match(name, cur->resource)) 00649 continue; 00650 00651 if (!cur->flags.running || cur->flags.declined) { 00652 if (!name) 00653 continue; 00654 ast_log(LOG_NOTICE, "The module '%s' was not properly initialized. " 00655 "Before reloading the module, you must run \"module load %s\" " 00656 "and fix whatever is preventing the module from being initialized.\n", 00657 name, name); 00658 res = 2; /* Don't report that the module was not found */ 00659 break; 00660 } 00661 00662 if (!info->reload) { /* cannot be reloaded */ 00663 if (res < 1) /* store result if possible */ 00664 res = 1; /* 1 = no reload() method */ 00665 continue; 00666 } 00667 00668 res = 2; 00669 if (option_verbose > 2) 00670 ast_verbose(VERBOSE_PREFIX_3 "Reloading module '%s' (%s)\n", cur->resource, info->description); 00671 info->reload(); 00672 } 00673 AST_LIST_UNLOCK(&module_list); 00674 00675 ast_mutex_unlock(&reloadlock); 00676 00677 return res; 00678 }
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 547 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().
00548 { 00549 struct reload_queue_item *item; 00550 00551 if (!ast_fully_booted) { 00552 return; 00553 } 00554 00555 AST_LIST_LOCK(&reload_queue); 00556 00557 if (do_full_reload) { 00558 do_full_reload = 0; 00559 AST_LIST_UNLOCK(&reload_queue); 00560 ast_log(LOG_NOTICE, "Executing deferred reload request.\n"); 00561 ast_module_reload(NULL); 00562 return; 00563 } 00564 00565 while ((item = AST_LIST_REMOVE_HEAD(&reload_queue, entry))) { 00566 ast_log(LOG_NOTICE, "Executing deferred reload request for module '%s'.\n", item->module); 00567 ast_module_reload(item->module); 00568 ast_free(item); 00569 } 00570 00571 AST_LIST_UNLOCK(&reload_queue); 00572 }
int64_t ast_profile | ( | int | , | |
int64_t | ||||
) |
Definition at line 514 of file asterisk.c.
References profile_data::e, profile_data::entries, profile_entry::events, prof_data, profile_entry::scale, and profile_entry::value.
00515 { 00516 if (!prof_data || i < 0 || i > prof_data->entries) /* invalid index */ 00517 return 0; 00518 if (prof_data->e[i].scale > 1) 00519 delta /= prof_data->e[i].scale; 00520 prof_data->e[i].value += delta; 00521 prof_data->e[i].events++; 00522 return prof_data->e[i].value; 00523 }
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 817 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().
00818 { 00819 struct ast_atexit *ae; 00820 00821 if (!(ae = ast_calloc(1, sizeof(*ae)))) 00822 return -1; 00823 00824 ae->func = func; 00825 00826 ast_unregister_atexit(func); 00827 00828 AST_LIST_LOCK(&atexits); 00829 AST_LIST_INSERT_HEAD(&atexits, ae, list); 00830 AST_LIST_UNLOCK(&atexits); 00831 00832 return 0; 00833 }
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 273 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.
00274 { 00275 struct file_version *new; 00276 char *work; 00277 size_t version_length; 00278 00279 work = ast_strdupa(version); 00280 work = ast_strip(ast_strip_quoted(work, "$", "$")); 00281 version_length = strlen(work) + 1; 00282 00283 if (!(new = ast_calloc(1, sizeof(*new) + version_length))) 00284 return; 00285 00286 new->file = file; 00287 new->version = (char *) new + sizeof(*new); 00288 memcpy(new->version, work, version_length); 00289 AST_LIST_LOCK(&file_versions); 00290 AST_LIST_INSERT_HEAD(&file_versions, new, list); 00291 AST_LIST_UNLOCK(&file_versions); 00292 }
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 1332 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().
01333 { 01334 struct sched_param sched; 01335 memset(&sched, 0, sizeof(sched)); 01336 #ifdef __linux__ 01337 if (pri) { 01338 sched.sched_priority = 10; 01339 if (sched_setscheduler(0, SCHED_RR, &sched)) { 01340 ast_log(LOG_WARNING, "Unable to set high priority\n"); 01341 return -1; 01342 } else 01343 if (option_verbose) 01344 ast_verbose("Set to realtime thread\n"); 01345 } else { 01346 sched.sched_priority = 0; 01347 /* According to the manpage, these parameters can never fail. */ 01348 sched_setscheduler(0, SCHED_OTHER, &sched); 01349 } 01350 #else 01351 if (pri) { 01352 if (setpriority(PRIO_PROCESS, 0, -10) == -1) { 01353 ast_log(LOG_WARNING, "Unable to set high priority\n"); 01354 return -1; 01355 } else 01356 if (option_verbose) 01357 ast_verbose("Set to high priority\n"); 01358 } else { 01359 /* According to the manpage, these parameters can never fail. */ 01360 setpriority(PRIO_PROCESS, 0, 0); 01361 } 01362 #endif 01363 return 0; 01364 }
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, ast_opt_no_fork, 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 (!term) 00083 return 0; 00084 if (!ast_opt_console || ast_opt_no_color || !ast_opt_no_fork) 00085 return 0; 00086 00087 for (i=0 ;; i++) { 00088 if (termpath[i] == NULL) { 00089 break; 00090 } 00091 snprintf(termfile, sizeof(termfile), "%s/%c/%s", termpath[i], *term, term); 00092 termfd = open(termfile, O_RDONLY); 00093 if (termfd > -1) { 00094 break; 00095 } 00096 } 00097 if (termfd > -1) { 00098 int actsize = read(termfd, buffer, sizeof(buffer) - 1); 00099 short sz_names = convshort(buffer + 2); 00100 short sz_bools = convshort(buffer + 4); 00101 short n_nums = convshort(buffer + 6); 00102 00103 /* if ((sz_names + sz_bools) & 1) 00104 sz_bools++; */ 00105 00106 if (sz_names + sz_bools + n_nums < actsize) { 00107 /* Offset 13 is defined in /usr/include/term.h, though we do not 00108 * include it here, as it conflicts with include/asterisk/term.h */ 00109 short max_colors = convshort(buffer + 12 + sz_names + sz_bools + 13 * 2); 00110 if (max_colors > 0) { 00111 vt100compat = 1; 00112 } 00113 parseokay = 1; 00114 } 00115 close(termfd); 00116 } 00117 00118 if (!parseokay) { 00119 /* These comparisons should not be substrings nor case-insensitive, as 00120 * terminal types are very particular about how they treat suffixes and 00121 * capitalization. For example, terminal type 'linux-m' does NOT 00122 * support color, while 'linux' does. Not even all vt100* terminals 00123 * support color, either (e.g. 'vt100+fnkeys'). */ 00124 if (!strcmp(term, "linux")) { 00125 vt100compat = 1; 00126 } else if (!strcmp(term, "xterm")) { 00127 vt100compat = 1; 00128 } else if (!strcmp(term, "xterm-color")) { 00129 vt100compat = 1; 00130 } else if (!strncmp(term, "Eterm", 5)) { 00131 /* Both entries which start with Eterm support color */ 00132 vt100compat = 1; 00133 } else if (!strcmp(term, "vt100")) { 00134 vt100compat = 1; 00135 } else if (!strncmp(term, "crt", 3)) { 00136 /* Both crt terminals support color */ 00137 vt100compat = 1; 00138 } 00139 } 00140 00141 if (vt100compat) { 00142 /* Make commands show up in nice colors */ 00143 snprintf(prepdata, sizeof(prepdata), "%c[%d;%d;%dm", ESC, ATTR_BRIGHT, COLOR_BROWN, COLOR_BLACK + 10); 00144 snprintf(enddata, sizeof(enddata), "%c[%d;%d;%dm", ESC, ATTR_RESET, COLOR_WHITE, COLOR_BLACK + 10); 00145 snprintf(quitdata, sizeof(quitdata), "%c[0m", ESC); 00146 } 00147 return 0; 00148 }
void ast_unregister_atexit | ( | void(*)(void) | func | ) |
Unregister a function registered with ast_register_atexit().
func | The callback function to unregister. |
Definition at line 835 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().
00836 { 00837 struct ast_atexit *ae = NULL; 00838 00839 AST_LIST_LOCK(&atexits); 00840 AST_LIST_TRAVERSE_SAFE_BEGIN(&atexits, ae, list) { 00841 if (ae->func == func) { 00842 AST_LIST_REMOVE_CURRENT(&atexits, list); 00843 break; 00844 } 00845 } 00846 AST_LIST_TRAVERSE_SAFE_END 00847 AST_LIST_UNLOCK(&atexits); 00848 00849 if (ae) 00850 free(ae); 00851 }
void ast_unregister_file_version | ( | const char * | file | ) |
Unregister a source code file from the core.
file | the source file name |
Definition at line 294 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.
00295 { 00296 struct file_version *find; 00297 00298 AST_LIST_LOCK(&file_versions); 00299 AST_LIST_TRAVERSE_SAFE_BEGIN(&file_versions, find, list) { 00300 if (!strcasecmp(find->file, file)) { 00301 AST_LIST_REMOVE_CURRENT(&file_versions, list); 00302 break; 00303 } 00304 } 00305 AST_LIST_TRAVERSE_SAFE_END; 00306 AST_LIST_UNLOCK(&file_versions); 00307 if (find) 00308 ast_free(find); 00309 }
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 764 of file astobj2.c.
References ARRAY_LEN, and ast_cli_register_multiple().
Referenced by main().
00765 { 00766 #ifdef AO2_DEBUG 00767 ast_cli_register_multiple(cli_astobj2, ARRAY_LEN(cli_astobj2)); 00768 #endif 00769 00770 return 0; 00771 }
void close_logger | ( | void | ) |
Provided by logger.c
Definition at line 621 of file logger.c.
References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, eventlog, f, logchannel::list, and qlog.
Referenced by quit_handler().
00623 { 00624 struct logchannel *f; 00625 00626 AST_LIST_LOCK(&logchannels); 00627 00628 if (eventlog) { 00629 fclose(eventlog); 00630 eventlog = NULL; 00631 } 00632 00633 if (qlog) { 00634 fclose(qlog); 00635 qlog = NULL; 00636 } 00637 00638 AST_LIST_TRAVERSE(&logchannels, f, list) { 00639 if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) { 00640 fclose(f->fileptr); 00641 f->fileptr = NULL; 00642 } 00643 } 00644 00645 closelog(); /* syslog */ 00646 00647 AST_LIST_UNLOCK(&logchannels); 00648 00649 return;
int dnsmgr_init | ( | void | ) |
Provided by dnsmgr.c
Definition at line 342 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().
00343 { 00344 if (!(sched = sched_context_create())) { 00345 ast_log(LOG_ERROR, "Unable to create schedule context.\n"); 00346 return -1; 00347 } 00348 ast_cli_register(&cli_reload); 00349 ast_cli_register(&cli_status); 00350 ast_cli_register(&cli_refresh); 00351 return do_reload(1); 00352 }
int dnsmgr_reload | ( | void | ) |
Provided by dnsmgr.c
Definition at line 354 of file dnsmgr.c.
References do_reload().
00355 { 00356 return do_reload(0); 00357 }
void dnsmgr_start_refresh | ( | void | ) |
Provided by dnsmgr.c
Definition at line 252 of file dnsmgr.c.
References ast_sched_add_variable(), AST_SCHED_DEL, master_refresh_info, refresh_list(), and sched.
Referenced by main().
00253 { 00254 if (refresh_sched > -1) { 00255 AST_SCHED_DEL(sched, refresh_sched); 00256 refresh_sched = ast_sched_add_variable(sched, 100, refresh_list, &master_refresh_info, 1); 00257 } 00258 }
int init_framer | ( | void | ) |
Provided by frame.c
Definition at line 1050 of file frame.c.
References ast_cli_register_multiple(), and my_clis.
Referenced by main().
01051 { 01052 ast_cli_register_multiple(my_clis, sizeof(my_clis) / sizeof(struct ast_cli_entry)); 01053 return 0; 01054 }
int init_logger | ( | void | ) |
Provided by logger.c
Definition at line 582 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, handle_SIGXFSZ(), init_logger_chain(), LOG_ERROR, LOG_EVENT, logfiles, option_verbose, qlog, and QUEUELOG.
Referenced by main().
00584 { 00585 char tmp[256]; 00586 int res = 0; 00587 00588 /* auto rotate if sig SIGXFSZ comes a-knockin */ 00589 (void) signal(SIGXFSZ,(void *) handle_SIGXFSZ); 00590 00591 /* register the logger cli commands */ 00592 ast_cli_register_multiple(cli_logger, sizeof(cli_logger) / sizeof(struct ast_cli_entry)); 00593 00594 mkdir((char *)ast_config_AST_LOG_DIR, 0755); 00595 00596 /* create log channels */ 00597 init_logger_chain(); 00598 00599 /* create the eventlog */ 00600 if (logfiles.event_log) { 00601 mkdir((char *)ast_config_AST_LOG_DIR, 0755); 00602 snprintf(tmp, sizeof(tmp), "%s/%s", (char *)ast_config_AST_LOG_DIR, EVENTLOG); 00603 eventlog = fopen((char *)tmp, "a"); 00604 if (eventlog) { 00605 ast_log(LOG_EVENT, "Started Asterisk Event Logger\n"); 00606 if (option_verbose) 00607 ast_verbose("Asterisk Event Logger Started %s\n",(char *)tmp); 00608 } else { 00609 ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno)); 00610 res = -1; 00611 } 00612 } 00613 00614 if (logfiles.queue_log) { 00615 snprintf(tmp, sizeof(tmp), "%s/%s", (char *)ast_config_AST_LOG_DIR, QUEUELOG); 00616 qlog = fopen(tmp, "a"); 00617 ast_queue_log("NONE", "NONE", "NONE", "QUEUESTART", "%s", ""); 00618 } 00619 return res;
int load_modules | ( | unsigned | int | ) |
Provided by loader.c
Definition at line 832 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().
00833 { 00834 struct ast_config *cfg; 00835 struct ast_module *mod; 00836 struct load_order_entry *order; 00837 struct ast_variable *v; 00838 unsigned int load_count; 00839 struct load_order load_order; 00840 int res = 0; 00841 00842 int translate_status; 00843 char newname[18]; /* although this would normally be 80, max length in translate_module_name is 18 */ 00844 #ifdef LOADABLE_MODULES 00845 struct dirent *dirent; 00846 DIR *dir; 00847 #endif 00848 00849 /* all embedded modules have registered themselves by now */ 00850 embedding = 0; 00851 00852 if (option_verbose) 00853 ast_verbose("Asterisk Dynamic Loader Starting:\n"); 00854 00855 AST_LIST_HEAD_INIT_NOLOCK(&load_order); 00856 00857 AST_LIST_LOCK(&module_list); 00858 00859 if (!(cfg = ast_config_load(AST_MODULE_CONFIG))) { 00860 ast_log(LOG_WARNING, "No '%s' found, no modules will be loaded.\n", AST_MODULE_CONFIG); 00861 goto done; 00862 } 00863 00864 /* first, find all the modules we have been explicitly requested to load */ 00865 for (v = ast_variable_browse(cfg, "modules"); v; v = v->next) { 00866 if (!strcasecmp(v->name, preload_only ? "preload" : "load")) { 00867 translate_status = translate_module_name(v->value, newname); 00868 if (!translate_status) 00869 ast_log(LOG_WARNING, "Use of old module name %s is deprecated, please use %s instead.\n", v->value, newname); 00870 add_to_load_order(translate_status ? v->value : newname, &load_order); 00871 } 00872 } 00873 00874 /* check if 'autoload' is on */ 00875 if (!preload_only && ast_true(ast_variable_retrieve(cfg, "modules", "autoload"))) { 00876 /* if so, first add all the embedded modules that are not already running to the load order */ 00877 AST_LIST_TRAVERSE(&module_list, mod, entry) { 00878 /* if it's not embedded, skip it */ 00879 if (mod->lib) 00880 continue; 00881 00882 if (mod->flags.running) 00883 continue; 00884 00885 order = add_to_load_order(mod->resource, &load_order); 00886 } 00887 00888 #ifdef LOADABLE_MODULES 00889 /* if we are allowed to load dynamic modules, scan the directory for 00890 for all available modules and add them as well */ 00891 if ((dir = opendir(ast_config_AST_MODULE_DIR))) { 00892 while ((dirent = readdir(dir))) { 00893 int ld = strlen(dirent->d_name); 00894 00895 /* Must end in .so to load it. */ 00896 00897 if (ld < 4) 00898 continue; 00899 00900 if (strcasecmp(dirent->d_name + ld - 3, ".so")) 00901 continue; 00902 00903 /* if there is already a module by this name in the module_list, 00904 skip this file */ 00905 if (find_resource(dirent->d_name, 0)) 00906 continue; 00907 00908 add_to_load_order(dirent->d_name, &load_order); 00909 } 00910 00911 closedir(dir); 00912 } else { 00913 if (!ast_opt_quiet) 00914 ast_log(LOG_WARNING, "Unable to open modules directory '%s'.\n", 00915 ast_config_AST_MODULE_DIR); 00916 } 00917 #endif 00918 } 00919 00920 /* now scan the config for any modules we are prohibited from loading and 00921 remove them from the load order */ 00922 for (v = ast_variable_browse(cfg, "modules"); v; v = v->next) { 00923 if (strcasecmp(v->name, "noload")) 00924 continue; 00925 00926 AST_LIST_TRAVERSE_SAFE_BEGIN(&load_order, order, entry) { 00927 translate_status = translate_module_name(v->value, newname); 00928 if (!resource_name_match(order->resource, translate_status ? v->value : newname)) { 00929 if (!translate_status) 00930 ast_log(LOG_WARNING, "Use of old module name %s is deprecated, please use %s instead.\n", v->value, newname); 00931 AST_LIST_REMOVE_CURRENT(&load_order, entry); 00932 free(order->resource); 00933 free(order); 00934 } 00935 } 00936 AST_LIST_TRAVERSE_SAFE_END; 00937 } 00938 00939 /* we are done with the config now, all the information we need is in the 00940 load_order list */ 00941 ast_config_destroy(cfg); 00942 00943 load_count = 0; 00944 AST_LIST_TRAVERSE(&load_order, order, entry) 00945 load_count++; 00946 00947 if (load_count) 00948 ast_log(LOG_NOTICE, "%d modules will be loaded.\n", load_count); 00949 00950 /* first, load only modules that provide global symbols */ 00951 AST_LIST_TRAVERSE_SAFE_BEGIN(&load_order, order, entry) { 00952 switch (load_resource(order->resource, 1)) { 00953 case AST_MODULE_LOAD_SUCCESS: 00954 case AST_MODULE_LOAD_DECLINE: 00955 AST_LIST_REMOVE_CURRENT(&load_order, entry); 00956 free(order->resource); 00957 free(order); 00958 break; 00959 case AST_MODULE_LOAD_FAILURE: 00960 res = -1; 00961 goto done; 00962 case AST_MODULE_LOAD_SKIP: 00963 /* try again later */ 00964 break; 00965 } 00966 } 00967 AST_LIST_TRAVERSE_SAFE_END; 00968 00969 /* now load everything else */ 00970 AST_LIST_TRAVERSE_SAFE_BEGIN(&load_order, order, entry) { 00971 switch (load_resource(order->resource, 0)) { 00972 case AST_MODULE_LOAD_SUCCESS: 00973 case AST_MODULE_LOAD_DECLINE: 00974 AST_LIST_REMOVE_CURRENT(&load_order, entry); 00975 free(order->resource); 00976 free(order); 00977 break; 00978 case AST_MODULE_LOAD_FAILURE: 00979 res = -1; 00980 goto done; 00981 case AST_MODULE_LOAD_SKIP: 00982 /* should not happen */ 00983 break; 00984 } 00985 } 00986 AST_LIST_TRAVERSE_SAFE_END; 00987 00988 done: 00989 while ((order = AST_LIST_REMOVE_HEAD(&load_order, entry))) { 00990 free(order->resource); 00991 free(order); 00992 } 00993 00994 AST_LIST_UNLOCK(&module_list); 00995 00996 return res; 00997 }
int load_pbx | ( | void | ) |
Provided by pbx.c
Definition at line 6257 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().
06258 { 06259 int x; 06260 06261 /* Initialize the PBX */ 06262 if (option_verbose) { 06263 ast_verbose( "Asterisk PBX Core Initializing\n"); 06264 ast_verbose( "Registering builtin applications:\n"); 06265 } 06266 ast_cli_register_multiple(pbx_cli, sizeof(pbx_cli) / sizeof(struct ast_cli_entry)); 06267 06268 /* Register builtin applications */ 06269 for (x=0; x<sizeof(builtins) / sizeof(struct pbx_builtin); x++) { 06270 if (option_verbose) 06271 ast_verbose( VERBOSE_PREFIX_1 "[%s]\n", builtins[x].name); 06272 if (ast_register_application(builtins[x].name, builtins[x].execute, builtins[x].synopsis, builtins[x].description)) { 06273 ast_log(LOG_ERROR, "Unable to register builtin application '%s'\n", builtins[x].name); 06274 return -1; 06275 } 06276 } 06277 return 0; 06278 }
int reload_logger | ( | int | ) |
Provided by logger.c
Definition at line 361 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().
00363 { 00364 char old[PATH_MAX] = ""; 00365 char new[PATH_MAX]; 00366 int event_rotate = rotate, queue_rotate = rotate; 00367 struct logchannel *f; 00368 FILE *myf; 00369 int x, res = 0; 00370 00371 AST_LIST_LOCK(&logchannels); 00372 00373 if (eventlog) 00374 fclose(eventlog); 00375 else 00376 event_rotate = 0; 00377 eventlog = NULL; 00378 00379 if (qlog) 00380 fclose(qlog); 00381 else 00382 queue_rotate = 0; 00383 qlog = NULL; 00384 00385 mkdir((char *)ast_config_AST_LOG_DIR, 0755); 00386 00387 AST_LIST_TRAVERSE(&logchannels, f, list) { 00388 if (f->disabled) { 00389 f->disabled = 0; /* Re-enable logging at reload */ 00390 manager_event(EVENT_FLAG_SYSTEM, "LogChannel", "Channel: %s\r\nEnabled: Yes\r\n", f->filename); 00391 } 00392 if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) { 00393 fclose(f->fileptr); /* Close file */ 00394 f->fileptr = NULL; 00395 if (rotate) { 00396 ast_copy_string(old, f->filename, sizeof(old)); 00397 00398 for (x = 0; ; x++) { 00399 snprintf(new, sizeof(new), "%s.%d", f->filename, x); 00400 myf = fopen((char *)new, "r"); 00401 if (myf) 00402 fclose(myf); 00403 else 00404 break; 00405 } 00406 00407 /* do it */ 00408 if (rename(old,new)) 00409 fprintf(stderr, "Unable to rename file '%s' to '%s'\n", old, new); 00410 } 00411 } 00412 } 00413 00414 filesize_reload_needed = 0; 00415 00416 init_logger_chain(); 00417 00418 if (logfiles.event_log) { 00419 snprintf(old, sizeof(old), "%s/%s", (char *)ast_config_AST_LOG_DIR, EVENTLOG); 00420 if (event_rotate) { 00421 for (x=0;;x++) { 00422 snprintf(new, sizeof(new), "%s/%s.%d", (char *)ast_config_AST_LOG_DIR, EVENTLOG,x); 00423 myf = fopen((char *)new, "r"); 00424 if (myf) /* File exists */ 00425 fclose(myf); 00426 else 00427 break; 00428 } 00429 00430 /* do it */ 00431 if (rename(old,new)) 00432 ast_log(LOG_ERROR, "Unable to rename file '%s' to '%s'\n", old, new); 00433 } 00434 00435 eventlog = fopen(old, "a"); 00436 if (eventlog) { 00437 ast_log(LOG_EVENT, "Restarted Asterisk Event Logger\n"); 00438 if (option_verbose) 00439 ast_verbose("Asterisk Event Logger restarted\n"); 00440 } else { 00441 ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno)); 00442 res = -1; 00443 } 00444 } 00445 00446 if (logfiles.queue_log) { 00447 snprintf(old, sizeof(old), "%s/%s", (char *)ast_config_AST_LOG_DIR, QUEUELOG); 00448 if (queue_rotate) { 00449 for (x = 0; ; x++) { 00450 snprintf(new, sizeof(new), "%s/%s.%d", (char *)ast_config_AST_LOG_DIR, QUEUELOG, x); 00451 myf = fopen((char *)new, "r"); 00452 if (myf) /* File exists */ 00453 fclose(myf); 00454 else 00455 break; 00456 } 00457 00458 /* do it */ 00459 if (rename(old, new)) 00460 ast_log(LOG_ERROR, "Unable to rename file '%s' to '%s'\n", old, new); 00461 } 00462 00463 qlog = fopen(old, "a"); 00464 if (qlog) { 00465 ast_queue_log("NONE", "NONE", "NONE", "CONFIGRELOAD", "%s", ""); 00466 ast_log(LOG_EVENT, "Restarted Asterisk Queue Logger\n"); 00467 if (option_verbose) 00468 ast_verbose("Asterisk Queue Logger restarted\n"); 00469 } else { 00470 ast_log(LOG_ERROR, "Unable to create queue log: %s\n", strerror(errno)); 00471 res = -1; 00472 } 00473 } 00474 00475 AST_LIST_UNLOCK(&logchannels); 00476 00477 return res;
void threadstorage_init | ( | void | ) |
char ast_config_AST_AGI_DIR[PATH_MAX] |
Definition at line 230 of file asterisk.c.
char ast_config_AST_CONFIG_DIR[PATH_MAX] |
Definition at line 222 of file asterisk.c.
char ast_config_AST_CONFIG_FILE[PATH_MAX] |
Definition at line 223 of file asterisk.c.
char ast_config_AST_CTL[PATH_MAX] |
Definition at line 241 of file asterisk.c.
char ast_config_AST_CTL_GROUP[PATH_MAX] |
Definition at line 240 of file asterisk.c.
char ast_config_AST_CTL_OWNER[PATH_MAX] |
Definition at line 239 of file asterisk.c.
char ast_config_AST_CTL_PERMISSIONS[PATH_MAX] |
Definition at line 238 of file asterisk.c.
char ast_config_AST_DATA_DIR[PATH_MAX] |
Definition at line 228 of file asterisk.c.
char ast_config_AST_DB[PATH_MAX] |
Definition at line 231 of file asterisk.c.
char ast_config_AST_KEY_DIR[PATH_MAX] |
Definition at line 232 of file asterisk.c.
char ast_config_AST_LOG_DIR[PATH_MAX] |
Definition at line 229 of file asterisk.c.
char ast_config_AST_MODULE_DIR[PATH_MAX] |
Definition at line 224 of file asterisk.c.
char ast_config_AST_MONITOR_DIR[PATH_MAX] |
Definition at line 226 of file asterisk.c.
char ast_config_AST_PID[PATH_MAX] |
Definition at line 233 of file asterisk.c.
char ast_config_AST_RUN_DIR[PATH_MAX] |
Definition at line 235 of file asterisk.c.
char ast_config_AST_RUN_GROUP[PATH_MAX] |
Definition at line 237 of file asterisk.c.
Referenced by action_coresettings(), handle_show_settings(), and main().
char ast_config_AST_RUN_USER[PATH_MAX] |
Definition at line 236 of file asterisk.c.
Referenced by action_coresettings(), handle_show_settings(), and main().
char ast_config_AST_SOCKET[PATH_MAX] |
Definition at line 234 of file asterisk.c.
char ast_config_AST_SPOOL_DIR[PATH_MAX] |
Definition at line 225 of file asterisk.c.
char ast_config_AST_SYSTEM_NAME[20] |
Definition at line 242 of file asterisk.c.
char ast_config_AST_VAR_DIR[PATH_MAX] |
Definition at line 227 of file asterisk.c.