Asterisk main include file. File version handling, generic pbx functions. More...
#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] |
Asterisk main include file. File version handling, generic pbx functions.
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) |
This macro will place a file-scope constructor and destructor into the source of the module using it; this will cause the version of this file to registered with the Asterisk core (and unregistered) at the appropriate times.
Example:
ASTERISK_FILE_VERSION(__FILE__, "\$Revision\$")
Definition at line 222 of file asterisk.h.
#define DEFAULT_LANGUAGE "en" |
Definition at line 31 of file asterisk.h.
Referenced by fileexists_core().
#define DEFAULT_SAMPLE_RATE 8000 |
Definition at line 33 of file asterisk.h.
Referenced by check_header(), check_header_fmt(), ogg_vorbis_open(), 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__ |
Definition at line 36 of file asterisk.h.
Referenced by ast_set_priority().
#define setpriority __PLEASE_USE_ast_set_priority_INSTEAD_OF_setpriority__ |
Definition at line 35 of file asterisk.h.
Referenced by ast_set_priority().
int ast_add_profile | ( | const char * | name, | |
uint64_t | scale | |||
) |
support for event profiling
(note, this must be documented a lot more) ast_add_profile allocates a generic 'counter' with a given name, which can be shown with the command 'show profile <name>'
The counter accumulates positive or negative values supplied by ast_add_profile(), dividing them by the 'scale' value passed in the create call, and also counts the number of 'events'. Values can also be taked by the TSC counter on ia32 architectures, in which case you can mark the start of an event calling ast_mark(id, 1) and then the end of the event with ast_mark(id, 0). For non-i386 architectures, these two calls return 0.
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, 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(), 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, 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 |
This function reloads the specified module, or if no modules are specified, it will reload all loaded modules.
Definition at line 646 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::flags, ast_module::info, LOG_NOTICE, option_verbose, queue_reload_request(), ast_module_info::reload, 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().
00647 { 00648 struct ast_module *cur; 00649 int res = 0; /* return value. 0 = not found, others, see below */ 00650 int i; 00651 00652 /* If we aren't fully booted, we just pretend we reloaded but we queue this 00653 up to run once we are booted up. */ 00654 if (!ast_fully_booted) { 00655 queue_reload_request(name); 00656 return 0; 00657 } 00658 00659 if (ast_mutex_trylock(&reloadlock)) { 00660 ast_verbose("The previous reload command didn't finish yet\n"); 00661 return -1; /* reload already in progress */ 00662 } 00663 ast_lastreloadtime = time(NULL); 00664 00665 /* Call "predefined" reload here first */ 00666 for (i = 0; reload_classes[i].name; i++) { 00667 if (!name || !strcasecmp(name, reload_classes[i].name)) { 00668 reload_classes[i].reload_fn(); /* XXX should check error ? */ 00669 res = 2; /* found and reloaded */ 00670 } 00671 } 00672 00673 if (name && res) { 00674 ast_mutex_unlock(&reloadlock); 00675 return res; 00676 } 00677 00678 AST_LIST_LOCK(&module_list); 00679 AST_LIST_TRAVERSE(&module_list, cur, entry) { 00680 const struct ast_module_info *info = cur->info; 00681 00682 if (name && resource_name_match(name, cur->resource)) 00683 continue; 00684 00685 if (!cur->flags.running || cur->flags.declined) { 00686 if (!name) 00687 continue; 00688 ast_log(LOG_NOTICE, "The module '%s' was not properly initialized. " 00689 "Before reloading the module, you must run \"module load %s\" " 00690 "and fix whatever is preventing the module from being initialized.\n", 00691 name, name); 00692 res = 2; /* Don't report that the module was not found */ 00693 break; 00694 } 00695 00696 if (!info->reload) { /* cannot be reloaded */ 00697 if (res < 1) /* store result if possible */ 00698 res = 1; /* 1 = no reload() method */ 00699 continue; 00700 } 00701 00702 res = 2; 00703 if (option_verbose > 2) 00704 ast_verbose(VERBOSE_PREFIX_3 "Reloading module '%s' (%s)\n", cur->resource, info->description); 00705 info->reload(); 00706 } 00707 AST_LIST_UNLOCK(&module_list); 00708 00709 ast_mutex_unlock(&reloadlock); 00710 00711 return res; 00712 }
int ast_pbx_init | ( | void | ) |
Provided by pbx.c
Definition at line 6681 of file pbx.c.
References ao2_container_alloc(), hint_cmp(), and hint_hash().
Referenced by main().
06682 { 06683 hints = ao2_container_alloc(1, hint_hash, hint_cmp); 06684 06685 return hints ? 0 : -1; 06686 }
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 581 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, and LOG_NOTICE.
Referenced by main().
00582 { 00583 struct reload_queue_item *item; 00584 00585 if (!ast_fully_booted) { 00586 return; 00587 } 00588 00589 AST_LIST_LOCK(&reload_queue); 00590 00591 if (do_full_reload) { 00592 do_full_reload = 0; 00593 AST_LIST_UNLOCK(&reload_queue); 00594 ast_log(LOG_NOTICE, "Executing deferred reload request.\n"); 00595 ast_module_reload(NULL); 00596 return; 00597 } 00598 00599 while ((item = AST_LIST_REMOVE_HEAD(&reload_queue, entry))) { 00600 ast_log(LOG_NOTICE, "Executing deferred reload request for module '%s'.\n", item->module); 00601 ast_module_reload(item->module); 00602 ast_free(item); 00603 } 00604 00605 AST_LIST_UNLOCK(&reload_queue); 00606 }
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, profile_entry::scale, and profile_entry::value.
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::func.
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) |
This function should not be called directly, but instead the ASTERISK_FILE_VERSION macro should be used to register a file with the core.
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(), and ast_strip_quoted().
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, and ast_atexit::func.
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 |
This function should not be called directly, but instead the ASTERISK_FILE_VERSION macro should be used to automatically unregister the file when the module is unloaded.
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, and AST_LIST_UNLOCK.
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, 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 633 of file logger.c.
References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, eventlog, f, logchannel::fileptr, 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; 00661 }
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, 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, and refresh_list().
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().
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 594 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().
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; 00631 }
int load_modules | ( | unsigned | int | ) |
Provided by loader.c
Definition at line 882 of file loader.c.
References add_to_load_order(), ast_config_AST_MODULE_DIR, ast_config_destroy(), ast_config_load(), 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_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_SKIP, AST_MODULE_LOAD_SUCCESS, ast_opt_quiet, ast_true(), ast_variable_browse(), ast_variable_retrieve(), ast_verbose(), embedding, find_resource(), ast_module::flags, free, ast_module::lib, LOAD_DONE, load_resource(), LOG_NOTICE, LOG_WARNING, ast_variable::name, ast_variable::next, option_verbose, load_order_entry::resource, resource_name_match(), ast_module::running, translate_module_name(), and ast_variable::value.
Referenced by main().
00883 { 00884 struct ast_config *cfg; 00885 struct ast_module *mod; 00886 struct load_order_entry *order; 00887 struct ast_variable *v; 00888 unsigned int load_count; 00889 struct load_order load_order; 00890 int res = 0; 00891 int load_pass; 00892 00893 int translate_status; 00894 char newname[18]; /* although this would normally be 80, max length in translate_module_name is 18 */ 00895 #ifdef LOADABLE_MODULES 00896 struct dirent *dirent; 00897 DIR *dir; 00898 #endif 00899 00900 /* all embedded modules have registered themselves by now */ 00901 embedding = 0; 00902 00903 if (option_verbose) 00904 ast_verbose("Asterisk Dynamic Loader Starting:\n"); 00905 00906 AST_LIST_HEAD_INIT_NOLOCK(&load_order); 00907 00908 AST_LIST_LOCK(&module_list); 00909 00910 if (!(cfg = ast_config_load(AST_MODULE_CONFIG))) { 00911 ast_log(LOG_WARNING, "No '%s' found, no modules will be loaded.\n", AST_MODULE_CONFIG); 00912 goto done; 00913 } 00914 00915 /* first, find all the modules we have been explicitly requested to load */ 00916 for (v = ast_variable_browse(cfg, "modules"); v; v = v->next) { 00917 if (!strcasecmp(v->name, preload_only ? "preload" : "load")) { 00918 translate_status = translate_module_name(v->value, newname); 00919 if (!translate_status) 00920 ast_log(LOG_WARNING, "Use of old module name %s is deprecated, please use %s instead.\n", v->value, newname); 00921 add_to_load_order(translate_status ? v->value : newname, &load_order); 00922 } 00923 } 00924 00925 /* check if 'autoload' is on */ 00926 if (!preload_only && ast_true(ast_variable_retrieve(cfg, "modules", "autoload"))) { 00927 /* if so, first add all the embedded modules that are not already running to the load order */ 00928 AST_LIST_TRAVERSE(&module_list, mod, entry) { 00929 /* if it's not embedded, skip it */ 00930 if (mod->lib) 00931 continue; 00932 00933 if (mod->flags.running) 00934 continue; 00935 00936 order = add_to_load_order(mod->resource, &load_order); 00937 } 00938 00939 #ifdef LOADABLE_MODULES 00940 /* if we are allowed to load dynamic modules, scan the directory for 00941 for all available modules and add them as well */ 00942 if ((dir = opendir(ast_config_AST_MODULE_DIR))) { 00943 while ((dirent = readdir(dir))) { 00944 int ld = strlen(dirent->d_name); 00945 00946 /* Must end in .so to load it. */ 00947 00948 if (ld < 4) 00949 continue; 00950 00951 if (strcasecmp(dirent->d_name + ld - 3, ".so")) 00952 continue; 00953 00954 /* if there is already a module by this name in the module_list, 00955 skip this file */ 00956 if (find_resource(dirent->d_name, 0)) 00957 continue; 00958 00959 add_to_load_order(dirent->d_name, &load_order); 00960 } 00961 00962 closedir(dir); 00963 } else { 00964 if (!ast_opt_quiet) 00965 ast_log(LOG_WARNING, "Unable to open modules directory '%s'.\n", 00966 ast_config_AST_MODULE_DIR); 00967 } 00968 #endif 00969 } 00970 00971 /* now scan the config for any modules we are prohibited from loading and 00972 remove them from the load order */ 00973 for (v = ast_variable_browse(cfg, "modules"); v; v = v->next) { 00974 if (strcasecmp(v->name, "noload")) 00975 continue; 00976 00977 AST_LIST_TRAVERSE_SAFE_BEGIN(&load_order, order, entry) { 00978 translate_status = translate_module_name(v->value, newname); 00979 if (!resource_name_match(order->resource, translate_status ? v->value : newname)) { 00980 if (!translate_status) 00981 ast_log(LOG_WARNING, "Use of old module name %s is deprecated, please use %s instead.\n", v->value, newname); 00982 AST_LIST_REMOVE_CURRENT(&load_order, entry); 00983 free(order->resource); 00984 free(order); 00985 } 00986 } 00987 AST_LIST_TRAVERSE_SAFE_END; 00988 } 00989 00990 /* we are done with the config now, all the information we need is in the 00991 load_order list */ 00992 ast_config_destroy(cfg); 00993 00994 load_count = 0; 00995 AST_LIST_TRAVERSE(&load_order, order, entry) 00996 load_count++; 00997 00998 if (load_count) 00999 ast_log(LOG_NOTICE, "%d modules will be loaded.\n", load_count); 01000 01001 for (load_pass = 0; load_pass < LOAD_DONE; load_pass++) { 01002 AST_LIST_TRAVERSE_SAFE_BEGIN(&load_order, order, entry) { 01003 switch (load_resource(order->resource, load_pass)) { 01004 case AST_MODULE_LOAD_SUCCESS: 01005 case AST_MODULE_LOAD_DECLINE: 01006 AST_LIST_REMOVE_CURRENT(&load_order, entry); 01007 free(order->resource); 01008 free(order); 01009 break; 01010 case AST_MODULE_LOAD_FAILURE: 01011 res = -1; 01012 goto done; 01013 case AST_MODULE_LOAD_SKIP: 01014 /* 01015 * Try again later. This result is received when a module is 01016 * deferred because it is not a part of the current pass. 01017 */ 01018 break; 01019 } 01020 } 01021 AST_LIST_TRAVERSE_SAFE_END; 01022 } 01023 01024 done: 01025 while ((order = AST_LIST_REMOVE_HEAD(&load_order, entry))) { 01026 free(order->resource); 01027 free(order); 01028 } 01029 01030 AST_LIST_UNLOCK(&module_list); 01031 01032 return res; 01033 }
int load_pbx | ( | void | ) |
Provided by pbx.c
Definition at line 6365 of file pbx.c.
References ast_cli_register_multiple(), ast_log(), ast_register_application(), ast_verbose(), builtins, LOG_ERROR, option_verbose, and VERBOSE_PREFIX_1.
Referenced by main().
06366 { 06367 int x; 06368 06369 /* Initialize the PBX */ 06370 if (option_verbose) { 06371 ast_verbose( "Asterisk PBX Core Initializing\n"); 06372 ast_verbose( "Registering builtin applications:\n"); 06373 } 06374 ast_cli_register_multiple(pbx_cli, sizeof(pbx_cli) / sizeof(struct ast_cli_entry)); 06375 06376 /* Register builtin applications */ 06377 for (x=0; x<sizeof(builtins) / sizeof(struct pbx_builtin); x++) { 06378 if (option_verbose) 06379 ast_verbose( VERBOSE_PREFIX_1 "[%s]\n", builtins[x].name); 06380 if (ast_register_application(builtins[x].name, builtins[x].execute, builtins[x].synopsis, builtins[x].description)) { 06381 ast_log(LOG_ERROR, "Unable to register builtin application '%s'\n", builtins[x].name); 06382 return -1; 06383 } 06384 } 06385 return 0; 06386 }
int reload_logger | ( | int | ) |
Provided by logger.c
Definition at line 369 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(), logchannel::disabled, errno, EVENT_FLAG_SYSTEM, EVENTLOG, eventlog, f, logchannel::filename, logchannel::fileptr, init_logger_chain(), 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; 00485 }
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().
char ast_config_AST_RUN_USER[PATH_MAX] |
Definition at line 235 of file asterisk.c.
Referenced by action_coresettings().
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.