![]() |
Home page |
Mailing list |
Docs
Asterisk developer's documentation :: Codename Pineapple
asterisk.h File Reference
Definition in file asterisk.h.
#include "asterisk/autoconfig.h"
#include "asterisk/compat.h"
#include "asterisk/paths.h"
Include dependency graph for asterisk.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Defines | |
| #define | AST_DIR_MODE 0777 |
| #define | AST_FILE_MODE 0666 |
| #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) |
Functions | |
| int | ast_add_profile (const char *, uint64_t scale) |
| support for event profiling | |
| void | ast_builtins_init (void) |
| initialize the _full_cmd string in * each of the builtins. | |
| void | ast_channels_init (void) |
| int64_t | ast_mark (int, int start1_stop0) |
| int | ast_module_reload (const char *name) |
| Reload asterisk modules. | |
| 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) |
| 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_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 at line 38 of file asterisk.h. |
|
|
Definition at line 41 of file asterisk.h. Referenced by __ast_play_and_record(), ast_lock_path(), ast_monitor_start(), cli_audio_convert(), copy(), dbinit(), handle_recordfile(), and try_firmware(). |
|
|
Register/unregister a source code file with the core.
Example:
ASTERISK_FILE_VERSION(__FILE__, "\$Revision\$")
Definition at line 180 of file asterisk.h. |
|
|
Definition at line 44 of file asterisk.h. |
|
|
Definition at line 46 of file asterisk.h. Referenced by setformat(), and sound_thread(). |
|
|
Definition at line 47 of file asterisk.h. Referenced by ast_stream_fastforward(), and ast_stream_rewind(). |
|
||||||||||||
|
support for event profiling
Definition at line 364 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(). 00365 { 00366 int l = sizeof(struct profile_data); 00367 int n = 10; /* default entries */ 00368 00369 if (prof_data == NULL) { 00370 prof_data = ast_calloc(1, l + n*sizeof(struct profile_entry)); 00371 if (prof_data == NULL) 00372 return -1; 00373 prof_data->entries = 0; 00374 prof_data->max_size = n; 00375 } 00376 if (prof_data->entries >= prof_data->max_size) { 00377 void *p; 00378 n = prof_data->max_size + 20; 00379 p = ast_realloc(prof_data, l + n*sizeof(struct profile_entry)); 00380 if (p == NULL) 00381 return -1; 00382 prof_data = p; 00383 prof_data->max_size = n; 00384 } 00385 n = prof_data->entries++; 00386 prof_data->e[n].name = ast_strdup(name); 00387 prof_data->e[n].value = 0; 00388 prof_data->e[n].events = 0; 00389 prof_data->e[n].mark = 0; 00390 prof_data->e[n].scale = scale; 00391 return n; 00392 }
|
|
|
initialize the _full_cmd string in * each of the builtins. Provided by cli.c Definition at line 1046 of file cli.c. References ast_cli_register_multiple(), builtins, cli_cli, ast_cli_entry::cmda, and set_full_cmd(). 01047 { 01048 struct ast_cli_entry *e; 01049 01050 for (e = builtins; e->cmda[0] != NULL; e++) 01051 set_full_cmd(e); 01052 01053 ast_cli_register_multiple(cli_cli, sizeof(cli_cli) / sizeof(struct ast_cli_entry)); 01054 }
|
|
|
Provided by channel.c Definition at line 4290 of file channel.c. References ast_cli_register_multiple(), and cli_channel. 04291 { 04292 ast_cli_register_multiple(cli_channel, sizeof(cli_channel) / sizeof(struct ast_cli_entry)); 04293 }
|
|
||||||||||||
|
Definition at line 426 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(). 00427 { 00428 if (!prof_data || i < 0 || i > prof_data->entries) /* invalid index */ 00429 return 0; 00430 if (startstop == 1) 00431 prof_data->e[i].mark = rdtsc(); 00432 else { 00433 prof_data->e[i].mark = (rdtsc() - prof_data->e[i].mark); 00434 if (prof_data->e[i].scale > 1) 00435 prof_data->e[i].mark /= prof_data->e[i].scale; 00436 prof_data->e[i].value += prof_data->e[i].mark; 00437 prof_data->e[i].events++; 00438 } 00439 return prof_data->e[i].mark; 00440 }
|
|
|
Reload asterisk modules.
Definition at line 519 of file loader.c. References ast_mutex_trylock(), and ast_verbose(). Referenced by action_updateconfig(), and handle_reload(). 00520 { 00521 struct ast_module *cur; 00522 int res = 0; /* return value. 0 = not found, others, see below */ 00523 int i; 00524 00525 if (ast_mutex_trylock(&reloadlock)) { 00526 ast_verbose("The previous reload command didn't finish yet\n"); 00527 return -1; /* reload already in progress */ 00528 } 00529 00530 /* Call "predefined" reload here first */ 00531 for (i = 0; reload_classes[i].name; i++) { 00532 if (!name || !strcasecmp(name, reload_classes[i].name)) { 00533 reload_classes[i].reload_fn(); /* XXX should check error ? */ 00534 res = 2; /* found and reloaded */ 00535 } 00536 } 00537 ast_lastreloadtime = time(NULL); 00538 00539 if (name && res) 00540 return res; 00541 00542 AST_LIST_LOCK(&module_list); 00543 AST_LIST_TRAVERSE(&module_list, cur, entry) { 00544 const struct ast_module_info *info = cur->info; 00545 00546 if (name && resource_name_match(name, cur->resource)) 00547 continue; 00548 00549 if (!ast_test_flag(cur, FLAG_RUNNING | FLAG_DECLINED)) 00550 continue; 00551 00552 if (!info->reload) { /* cannot be reloaded */ 00553 if (res < 1) /* store result if possible */ 00554 res = 1; /* 1 = no reload() method */ 00555 continue; 00556 } 00557 00558 res = 2; 00559 if (option_verbose > 2) 00560 ast_verbose(VERBOSE_PREFIX_3 "Reloading module '%s' (%s)\n", cur->resource, info->description); 00561 info->reload(); 00562 } 00563 AST_LIST_UNLOCK(&module_list); 00564 00565 ast_mutex_unlock(&reloadlock); 00566 00567 return res; 00568 }
|
|
||||||||||||
|
Definition at line 394 of file asterisk.c. References profile_data::e, profile_data::entries, profile_entry::events, prof_data, profile_entry::scale, and profile_entry::value. 00395 { 00396 if (!prof_data || i < 0 || i > prof_data->entries) /* invalid index */ 00397 return 0; 00398 if (prof_data->e[i].scale > 1) 00399 delta /= prof_data->e[i].scale; 00400 prof_data->e[i].value += delta; 00401 prof_data->e[i].events++; 00402 return prof_data->e[i].value; 00403 }
|
|
|
Register a function to be executed before Asterisk exits.
Definition at line 571 of file asterisk.c. References ast_calloc, AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_UNLOCK, and ast_unregister_atexit(). Referenced by do_reload(), and load_module(). 00572 { 00573 int res = -1; 00574 struct ast_atexit *ae; 00575 ast_unregister_atexit(func); 00576 AST_LIST_LOCK(&atexits); 00577 if ((ae = ast_calloc(1, sizeof(*ae)))) { 00578 AST_LIST_INSERT_HEAD(&atexits, ae, list); 00579 ae->func = func; 00580 res = 0; 00581 } 00582 AST_LIST_UNLOCK(&atexits); 00583 return res; 00584 }
|
|
||||||||||||
|
Register the version of a source code file with the core.
Definition at line 248 of file asterisk.c. References ast_calloc, AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_UNLOCK, ast_strdupa, and ast_strip_quoted(). 00249 { 00250 struct file_version *new; 00251 char *work; 00252 size_t version_length; 00253 00254 work = ast_strdupa(version); 00255 work = ast_strip(ast_strip_quoted(work, "$", "$")); 00256 version_length = strlen(work) + 1; 00257 00258 if (!(new = ast_calloc(1, sizeof(*new) + version_length))) 00259 return; 00260 00261 new->file = file; 00262 new->version = (char *) new + sizeof(*new); 00263 memcpy(new->version, work, version_length); 00264 AST_LIST_LOCK(&file_versions); 00265 AST_LIST_INSERT_HEAD(&file_versions, new, list); 00266 AST_LIST_UNLOCK(&file_versions); 00267 }
|
|
|
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 1055 of file asterisk.c. References ast_log(), ast_verbose(), and LOG_WARNING. Referenced by ast_safe_system(), launch_script(), and spawn_mp3(). 01056 { 01057 struct sched_param sched; 01058 memset(&sched, 0, sizeof(sched)); 01059 #ifdef __linux__ 01060 if (pri) { 01061 sched.sched_priority = 10; 01062 if (sched_setscheduler(0, SCHED_RR, &sched)) { 01063 ast_log(LOG_WARNING, "Unable to set high priority\n"); 01064 return -1; 01065 } else 01066 if (option_verbose) 01067 ast_verbose("Set to realtime thread\n"); 01068 } else { 01069 sched.sched_priority = 0; 01070 if (sched_setscheduler(0, SCHED_OTHER, &sched)) { 01071 ast_log(LOG_WARNING, "Unable to set normal priority\n"); 01072 return -1; 01073 } 01074 } 01075 #else 01076 if (pri) { 01077 if (setpriority(PRIO_PROCESS, 0, -10) == -1) { 01078 ast_log(LOG_WARNING, "Unable to set high priority\n"); 01079 return -1; 01080 } else 01081 if (option_verbose) 01082 ast_verbose("Set to high priority\n"); 01083 } else { 01084 if (setpriority(PRIO_PROCESS, 0, 0) == -1) { 01085 ast_log(LOG_WARNING, "Unable to set normal priority\n"); 01086 return -1; 01087 } 01088 } 01089 #endif 01090 return 0; 01091 }
|
|
|
Provided by term.c Definition at line 75 of file term.c. References ast_opt_console, ast_opt_no_color, and ast_opt_no_fork. 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 }
|
|
|
Unregister a function registered with ast_register_atexit().
Definition at line 586 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, and ast_atexit::func. Referenced by ast_register_atexit(), and do_reload(). 00587 { 00588 struct ast_atexit *ae; 00589 AST_LIST_LOCK(&atexits); 00590 AST_LIST_TRAVERSE_SAFE_BEGIN(&atexits, ae, list) { 00591 if (ae->func == func) { 00592 AST_LIST_REMOVE_CURRENT(&atexits, list); 00593 break; 00594 } 00595 } 00596 AST_LIST_TRAVERSE_SAFE_END 00597 AST_LIST_UNLOCK(&atexits); 00598 }
|
|
|
Unregister a source code file from the core.
Definition at line 269 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, and free. 00270 { 00271 struct file_version *find; 00272 00273 AST_LIST_LOCK(&file_versions); 00274 AST_LIST_TRAVERSE_SAFE_BEGIN(&file_versions, find, list) { 00275 if (!strcasecmp(find->file, file)) { 00276 AST_LIST_REMOVE_CURRENT(&file_versions, list); 00277 break; 00278 } 00279 } 00280 AST_LIST_TRAVERSE_SAFE_END; 00281 AST_LIST_UNLOCK(&file_versions); 00282 if (find) 00283 free(find); 00284 }
|
|
|
Provided by db.c Definition at line 640 of file db.c. References ast_cli_register_multiple(), ast_manager_register, cli_database, dbinit(), EVENT_FLAG_SYSTEM, manager_dbdel(), manager_dbdeltree(), manager_dbget(), and manager_dbput(). 00641 { 00642 dbinit(); 00643 ast_cli_register_multiple(cli_database, sizeof(cli_database) / sizeof(struct ast_cli_entry)); 00644 ast_manager_register("DBGet", EVENT_FLAG_SYSTEM, manager_dbget, "Get DB Entry"); 00645 ast_manager_register("DBPut", EVENT_FLAG_SYSTEM, manager_dbput, "Put DB Entry"); 00646 ast_manager_register("DBDel", EVENT_FLAG_SYSTEM, manager_dbdel, "Delete DB Entry"); 00647 ast_manager_register("DBDelTree", EVENT_FLAG_SYSTEM, manager_dbdeltree, "Delete DB Tree"); 00648 return 0; 00649 }
|
|
|
Provided by logger.c Definition at line 825 of file logger.c. References ast_cond_signal(), AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, close_logger_thread, eventlog, logchannel::fileptr, logcond, and qlog. 00826 { 00827 struct logchannel *f = NULL; 00828 00829 /* Stop logger thread */ 00830 AST_LIST_LOCK(&logmsgs); 00831 close_logger_thread = 1; 00832 ast_cond_signal(&logcond); 00833 AST_LIST_UNLOCK(&logmsgs); 00834 00835 AST_LIST_LOCK(&logchannels); 00836 00837 if (eventlog) { 00838 fclose(eventlog); 00839 eventlog = NULL; 00840 } 00841 00842 if (qlog) { 00843 fclose(qlog); 00844 qlog = NULL; 00845 } 00846 00847 AST_LIST_TRAVERSE(&logchannels, f, list) { 00848 if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) { 00849 fclose(f->fileptr); 00850 f->fileptr = NULL; 00851 } 00852 } 00853 00854 closelog(); /* syslog */ 00855 00856 AST_LIST_UNLOCK(&logchannels); 00857 00858 return; 00859 }
|
|
|
Provided by dnsmgr.c Definition at line 336 of file dnsmgr.c. References ast_cli_register(), ast_log(), cli_reload, cli_status, do_reload(), LOG_ERROR, sched, and sched_context_create(). 00337 { 00338 if (!(sched = sched_context_create())) { 00339 ast_log(LOG_ERROR, "Unable to create schedule context.\n"); 00340 return -1; 00341 } 00342 ast_cli_register(&cli_reload); 00343 ast_cli_register(&cli_status); 00344 return do_reload(1); 00345 }
|
|
|
Provided by dnsmgr.c Definition at line 347 of file dnsmgr.c. References do_reload(). 00348 { 00349 return do_reload(0); 00350 }
|
|
|
Provided by dnsmgr.c Definition at line 251 of file dnsmgr.c. References ast_sched_add_variable(), ast_sched_del(), master_refresh_info, refresh_list(), and sched. 00252 { 00253 if (refresh_sched > -1) { 00254 ast_sched_del(sched, refresh_sched); 00255 refresh_sched = ast_sched_add_variable(sched, 100, refresh_list, &master_refresh_info, 1); 00256 } 00257 }
|
|
|
Provided by frame.c Definition at line 930 of file frame.c. References ast_cli_register_multiple(), and my_clis. 00931 { 00932 ast_cli_register_multiple(my_clis, sizeof(my_clis) / sizeof(struct ast_cli_entry)); 00933 return 0; 00934 }
|
|
|
Provided by logger.c Definition at line 779 of file logger.c. References ast_cli_register_multiple(), ast_cond_destroy(), ast_cond_init(), ast_config_AST_LOG_DIR, ast_log(), ast_pthread_create, ast_queue_log(), ast_verbose(), cli_logger, eventlog, EVENTLOG, handle_SIGXFSZ(), init_logger_chain(), LOG_ERROR, LOG_EVENT, logcond, logfiles, logger_thread(), logthread, option_verbose, and qlog. 00780 { 00781 char tmp[256]; 00782 int res = 0; 00783 00784 /* auto rotate if sig SIGXFSZ comes a-knockin */ 00785 (void) signal(SIGXFSZ,(void *) handle_SIGXFSZ); 00786 00787 /* start logger thread */ 00788 ast_cond_init(&logcond, NULL); 00789 if (ast_pthread_create(&logthread, NULL, logger_thread, NULL) < 0) { 00790 ast_cond_destroy(&logcond); 00791 return -1; 00792 } 00793 00794 /* register the logger cli commands */ 00795 ast_cli_register_multiple(cli_logger, sizeof(cli_logger) / sizeof(struct ast_cli_entry)); 00796 00797 mkdir(ast_config_AST_LOG_DIR, 0755); 00798 00799 /* create log channels */ 00800 init_logger_chain(); 00801 00802 /* create the eventlog */ 00803 if (logfiles.event_log) { 00804 mkdir(ast_config_AST_LOG_DIR, 0755); 00805 snprintf(tmp, sizeof(tmp), "%s/%s", ast_config_AST_LOG_DIR, EVENTLOG); 00806 eventlog = fopen(tmp, "a"); 00807 if (eventlog) { 00808 ast_log(LOG_EVENT, "Started Asterisk Event Logger\n"); 00809 if (option_verbose) 00810 ast_verbose("Asterisk Event Logger Started %s\n", tmp); 00811 } else { 00812 ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno)); 00813 res = -1; 00814 } 00815 } 00816 00817 if (logfiles.queue_log) { 00818 snprintf(tmp, sizeof(tmp), "%s/%s", ast_config_AST_LOG_DIR, queue_log_name); 00819 qlog = fopen(tmp, "a"); 00820 ast_queue_log("NONE", "NONE", "NONE", "QUEUESTART", "%s", ""); 00821 } 00822 return res; 00823 }
|
|
|
Provided by loader.c Definition at line 696 of file loader.c. References add_to_load_order(), ast_config_load(), AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_TRAVERSE, ast_log(), AST_MODULE_CONFIG, ast_variable_browse(), ast_verbose(), embedding, LOG_DEBUG, ast_variable::name, ast_variable::next, option_debug, option_verbose, and ast_variable::value. 00697 { 00698 struct ast_config *cfg; 00699 struct ast_module *mod; 00700 struct load_order_entry *order; 00701 struct ast_variable *v; 00702 unsigned int load_count; 00703 struct load_order load_order; 00704 int res = 0; 00705 #if LOADABLE_MODULES 00706 struct dirent *dirent; 00707 DIR *dir; 00708 #endif 00709 00710 /* all embedded modules have registered themselves by now */ 00711 embedding = 0; 00712 00713 if (option_verbose) 00714 ast_verbose("Asterisk Dynamic Loader Starting:\n"); 00715 00716 AST_LIST_TRAVERSE(&module_list, mod, entry) { 00717 if (option_debug > 1) 00718 ast_log(LOG_DEBUG, "Embedded module found: %s\n", mod->resource); 00719 } 00720 00721 if (!(cfg = ast_config_load(AST_MODULE_CONFIG))) { 00722 ast_log(LOG_WARNING, "No '%s' found, no modules will be loaded.\n", AST_MODULE_CONFIG); 00723 return 0; 00724 } 00725 00726 AST_LIST_HEAD_INIT_NOLOCK(&load_order); 00727 00728 /* first, find all the modules we have been explicitly requested to load */ 00729 for (v = ast_variable_browse(cfg, "modules"); v; v = v->next) { 00730 if (!strcasecmp(v->name, preload_only ? "preload" : "load")) 00731 add_to_load_order(v->value, &load_order); 00732 } 00733 00734 /* check if 'autoload' is on */ 00735 if (!preload_only && ast_true(ast_variable_retrieve(cfg, "modules", "autoload"))) { 00736 /* if so, first add all the embedded modules to the load order */ 00737 AST_LIST_TRAVERSE(&module_list, mod, entry) 00738 order = add_to_load_order(mod->resource, &load_order); 00739 00740 #if LOADABLE_MODULES 00741 /* if we are allowed to load dynamic modules, scan the directory for 00742 for all available modules and add them as well */ 00743 if ((dir = opendir(ast_config_AST_MODULE_DIR))) { 00744 while ((dirent = readdir(dir))) { 00745 int ld = strlen(dirent->d_name); 00746 00747 /* Must end in .so to load it. */ 00748 00749 if (ld < 4) 00750 continue; 00751 00752 if (strcasecmp(dirent->d_name + ld - 3, ".so")) 00753 continue; 00754 00755 |