Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

asterisk.h File Reference

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

Included by dependency graph

Go to the source code of this file.

Defines

#define DEFAULT_LANGUAGE   "en"
#define AST_CONFIG_MAX_PATH   255
#define AST_CONFIG_DIR   ASTETCDIR
#define AST_RUN_DIR   ASTVARRUNDIR
#define AST_SOCKET   ASTVARRUNDIR "/asterisk.ctl"
#define AST_PID   ASTVARRUNDIR "/asterisk.pid"
#define AST_MODULE_DIR   ASTMODDIR
#define AST_SPOOL_DIR   ASTSPOOLDIR
#define AST_VAR_DIR   ASTVARLIBDIR
#define AST_LOG_DIR   ASTLOGDIR
#define AST_AGI_DIR   ASTAGIDIR
#define AST_KEY_DIR   ASTVARLIBDIR "/keys"
#define AST_DB   ASTVARLIBDIR "/astdb"
#define AST_CONFIG_FILE   ASTCONFPATH
#define AST_SOUNDS   AST_VAR_DIR "/sounds"
#define AST_IMAGES   AST_VAR_DIR "/images"

Functions

int load_modules (void)
int load_pbx (void)
int init_logger (void)
int init_framer (void)
int reload_logger (int)
int term_init (void)
int astdb_init (void)


Define Documentation

#define AST_AGI_DIR   ASTAGIDIR
 

Definition at line 28 of file asterisk.h.

#define AST_CONFIG_DIR   ASTETCDIR
 

Definition at line 20 of file asterisk.h.

Referenced by ast_save().

#define AST_CONFIG_FILE   ASTCONFPATH
 

Definition at line 32 of file asterisk.h.

#define AST_CONFIG_MAX_PATH   255
 

Definition at line 19 of file asterisk.h.

#define AST_DB   ASTVARLIBDIR "/astdb"
 

Definition at line 30 of file asterisk.h.

#define AST_IMAGES   AST_VAR_DIR "/images"
 

Definition at line 35 of file asterisk.h.

#define AST_KEY_DIR   ASTVARLIBDIR "/keys"
 

Definition at line 29 of file asterisk.h.

#define AST_LOG_DIR   ASTLOGDIR
 

Definition at line 27 of file asterisk.h.

#define AST_MODULE_DIR   ASTMODDIR
 

Definition at line 24 of file asterisk.h.

#define AST_PID   ASTVARRUNDIR "/asterisk.pid"
 

Definition at line 23 of file asterisk.h.

#define AST_RUN_DIR   ASTVARRUNDIR
 

Definition at line 21 of file asterisk.h.

#define AST_SOCKET   ASTVARRUNDIR "/asterisk.ctl"
 

Definition at line 22 of file asterisk.h.

#define AST_SOUNDS   AST_VAR_DIR "/sounds"
 

Definition at line 34 of file asterisk.h.

#define AST_SPOOL_DIR   ASTSPOOLDIR
 

Definition at line 25 of file asterisk.h.

#define AST_VAR_DIR   ASTVARLIBDIR
 

Definition at line 26 of file asterisk.h.

#define DEFAULT_LANGUAGE   "en"
 

Definition at line 17 of file asterisk.h.


Function Documentation

int astdb_init void   ) 
 

Definition at line 417 of file db.c.

References ast_cli_register(), cli_database_del, cli_database_deltree, cli_database_get, cli_database_put, and cli_database_show.

Referenced by main().

00418 { 00419 dbinit(); 00420 ast_cli_register(&cli_database_show); 00421 ast_cli_register(&cli_database_get); 00422 ast_cli_register(&cli_database_put); 00423 ast_cli_register(&cli_database_del); 00424 ast_cli_register(&cli_database_deltree); 00425 return 0; 00426 }

int init_framer void   ) 
 

Definition at line 782 of file frame.c.

References ast_cli_register(), cli_show_codec_n, cli_show_codecs, cli_show_codecs_audio, cli_show_codecs_image, and cli_show_codecs_video.

Referenced by main().

00783 { 00784 #ifdef TRACE_FRAMES 00785 ast_cli_register(&cli_frame_stats); 00786 #endif 00787 ast_cli_register(&cli_show_codecs); 00788 ast_cli_register(&cli_show_codecs_audio); 00789 ast_cli_register(&cli_show_codecs_video); 00790 ast_cli_register(&cli_show_codecs_image); 00791 ast_cli_register(&cli_show_codec_n); 00792 return 0; 00793 }

int init_logger void   ) 
 

Definition at line 399 of file logger.c.

References ast_cli_register(), ast_config_AST_LOG_DIR, ast_log(), ast_verbose(), EVENTLOG, LOG_ERROR, LOG_EVENT, and option_verbose.

Referenced by main().

00400 { 00401 char tmp[256]; 00402 00403 /* auto rotate if sig SIGXFSZ comes a-knockin */ 00404 (void) signal(SIGXFSZ,(void *) handle_SIGXFSZ); 00405 00406 /* register the relaod logger cli command */ 00407 ast_cli_register(&reload_logger_cli); 00408 ast_cli_register(&rotate_logger_cli); 00409 00410 /* initialize queue logger */ 00411 queue_log_init(); 00412 00413 /* create the eventlog */ 00414 mkdir((char *)ast_config_AST_LOG_DIR, 0755); 00415 snprintf(tmp, sizeof(tmp), "%s/%s", (char *)ast_config_AST_LOG_DIR, EVENTLOG); 00416 eventlog = fopen((char *)tmp, "a"); 00417 if (eventlog) { 00418 init_logger_chain(); 00419 ast_log(LOG_EVENT, "Started Asterisk Event Logger\n"); 00420 if (option_verbose) 00421 ast_verbose("Asterisk Event Logger Started %s\n",(char *)tmp); 00422 return 0; 00423 } else 00424 ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno)); 00425 00426 init_logger_chain(); 00427 00428 /* create log channels */ 00429 init_logger_chain(); 00430 return -1; 00431 }

int load_modules void   ) 
 

Definition at line 352 of file loader.c.

References ast_config_AST_MODULE_DIR, ast_destroy(), ast_load(), ast_load_resource(), ast_log(), AST_MODULE_CONFIG, ast_true(), ast_variable_browse(), ast_variable_retrieve(), ast_verbose(), COLOR_BRWHITE, LOG_DEBUG, LOG_WARNING, option_debug, option_quiet, option_verbose, term_color(), and VERBOSE_PREFIX_1.

Referenced by main().

00353 { 00354 struct ast_config *cfg; 00355 struct ast_variable *v; 00356 char tmp[80]; 00357 if (option_verbose) 00358 ast_verbose( "Asterisk Dynamic Loader Starting:\n"); 00359 cfg = ast_load(AST_MODULE_CONFIG); 00360 if (cfg) { 00361 /* Load explicitly defined modules */ 00362 v = ast_variable_browse(cfg, "modules"); 00363 while(v) { 00364 if (!strcasecmp(v->name, "load")) { 00365 if (option_debug && !option_verbose) 00366 ast_log(LOG_DEBUG, "Loading module %s\n", v->value); 00367 if (option_verbose) { 00368 ast_verbose( VERBOSE_PREFIX_1 "[%s]", term_color(tmp, v->value, COLOR_BRWHITE, 0, sizeof(tmp))); 00369 fflush(stdout); 00370 } 00371 if (ast_load_resource(v->value)) { 00372 ast_log(LOG_WARNING, "Loading module %s failed!\n", v->value); 00373 if (cfg) 00374 ast_destroy(cfg); 00375 return -1; 00376 } 00377 } 00378 v=v->next; 00379 } 00380 } 00381 if (!cfg || ast_true(ast_variable_retrieve(cfg, "modules", "autoload"))) { 00382 /* Load all modules */ 00383 DIR *mods; 00384 struct dirent *d; 00385 int x; 00386 /* Make two passes. First, load any resource modules, then load the others. */ 00387 for (x=0;x<2;x++) { 00388 mods = opendir((char *)ast_config_AST_MODULE_DIR); 00389 if (mods) { 00390 while((d = readdir(mods))) { 00391 /* Must end in .so to load it. */ 00392 if ((strlen(d->d_name) > 3) && (x || !strncasecmp(d->d_name, "res_", 4)) && 00393 !strcasecmp(d->d_name + strlen(d->d_name) - 3, ".so") && 00394 !ast_resource_exists(d->d_name)) { 00395 /* It's a shared library -- Just be sure we're allowed to load it -- kinda 00396 an inefficient way to do it, but oh well. */ 00397 if (cfg) { 00398 v = ast_variable_browse(cfg, "modules"); 00399 while(v) { 00400 if (!strcasecmp(v->name, "noload") && 00401 !strcasecmp(v->value, d->d_name)) 00402 break; 00403 v = v->next; 00404 } 00405 if (v) { 00406 if (option_verbose) { 00407 ast_verbose( VERBOSE_PREFIX_1 "[skipping %s]\n", d->d_name); 00408 fflush(stdout); 00409 } 00410 continue; 00411 } 00412 00413 } 00414 if (option_debug && !option_verbose) 00415 ast_log(LOG_DEBUG, "Loading module %s\n", d->d_name); 00416 if (option_verbose) { 00417 ast_verbose( VERBOSE_PREFIX_1 "[%s]", term_color(tmp, d->d_name, COLOR_BRWHITE, 0, sizeof(tmp))); 00418 fflush(stdout); 00419 } 00420 if (ast_load_resource(d->d_name)) { 00421 ast_log(LOG_WARNING, "Loading module %s failed!\n", d->d_name); 00422 if (cfg) 00423 ast_destroy(cfg); 00424 return -1; 00425 } 00426 } 00427 } 00428 closedir(mods); 00429 } else { 00430 if (!option_quiet) 00431 ast_log(LOG_WARNING, "Unable to open modules directory %s.\n", (char *)ast_config_AST_MODULE_DIR); 00432 } 00433 } 00434 } 00435 ast_destroy(cfg); 00436 return 0; 00437 }

int load_pbx void   ) 
 

Definition at line 4649 of file pbx.c.

References ast_cli_register(), AST_LIST_HEAD_INIT, ast_log(), ast_register_application(), ast_verbose(), description(), LOG_ERROR, option_verbose, and VERBOSE_PREFIX_1.

Referenced by main().

04650 { 04651 int x; 04652 /* Initialize the PBX */ 04653 if (option_verbose) { 04654 ast_verbose( "Asterisk PBX Core Initializing\n"); 04655 ast_verbose( "Registering builtin applications:\n"); 04656 } 04657 AST_LIST_HEAD_INIT(&globals); 04658 ast_cli_register(&show_applications_cli); 04659 ast_cli_register(&show_application_cli); 04660 ast_cli_register(&show_dialplan_cli); 04661 ast_cli_register(&show_switches_cli); 04662 for (x=0;x<sizeof(builtins) / sizeof(struct pbx_builtin); x++) { 04663 if (option_verbose) 04664 ast_verbose( VERBOSE_PREFIX_1 "[%s]\n", builtins[x].name); 04665 if (ast_register_application(builtins[x].name, builtins[x].execute, builtins[x].synopsis, builtins[x].description)) { 04666 ast_log(LOG_ERROR, "Unable to register builtin application '%s'\n", builtins[x].name); 04667 return -1; 04668 } 04669 } 04670 return 0; 04671 }

int reload_logger int   ) 
 

Definition at line 267 of file logger.c.

References ast_config_AST_LOG_DIR, AST_CONFIG_MAX_PATH, ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_verbose(), EVENTLOG, LOG_ERROR, LOG_EVENT, and option_verbose.

Referenced by ast_log().

00268 { 00269 char old[AST_CONFIG_MAX_PATH]; 00270 char new[AST_CONFIG_MAX_PATH]; 00271 struct logchannel *f; 00272 FILE *myf; 00273 00274 int x; 00275 ast_mutex_lock(&loglock); 00276 if (eventlog) 00277 fclose(eventlog); 00278 else 00279 rotate = 0; 00280 eventlog = NULL; 00281 00282 00283 00284 mkdir((char *)ast_config_AST_LOG_DIR, 0755); 00285 snprintf(old, sizeof(old), "%s/%s", (char *)ast_config_AST_LOG_DIR, EVENTLOG); 00286 00287 if(rotate) { 00288 for(x=0;;x++) { 00289 snprintf(new, sizeof(new), "%s/%s.%d", (char *)ast_config_AST_LOG_DIR, EVENTLOG,x); 00290 myf = fopen((char *)new, "r"); 00291 if(myf) 00292 fclose(myf); 00293 else 00294 break; 00295 } 00296 00297 /* do it */ 00298 if (rename(old,new)) 00299 fprintf(stderr, "Unable to rename file '%s' to '%s'\n", old, new); 00300 } 00301 00302 eventlog = fopen(old, "a"); 00303 00304 f = logchannels; 00305 while(f) { 00306 if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) { 00307 fclose(f->fileptr); 00308 f->fileptr = NULL; 00309 if(rotate) { 00310 strncpy(old, f->filename, sizeof(old)); 00311 00312 for(x=0;;x++) { 00313 snprintf(new, sizeof(new), "%s.%d", f->filename, x); 00314 myf = fopen((char *)new, "r"); 00315 if (myf) { 00316 fclose(myf); 00317 } else { 00318 break; 00319 } 00320 } 00321 00322 /* do it */ 00323 if (rename(old,new)) 00324 fprintf(stderr, "Unable to rename file '%s' to '%s'\n", old, new); 00325 } 00326 } 00327 f = f->next; 00328 } 00329 00330 ast_mutex_unlock(&loglock); 00331 00332 queue_log_init(); 00333 00334 if (eventlog) { 00335 init_logger_chain(); 00336 ast_log(LOG_EVENT, "Restarted Asterisk Event Logger\n"); 00337 if (option_verbose) 00338 ast_verbose("Asterisk Event Logger restarted\n"); 00339 return 0; 00340 } else 00341 ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno)); 00342 init_logger_chain(); 00343 pending_logger_reload = 0; 00344 return -1; 00345 }

int term_init void   ) 
 

Definition at line 32 of file term.c.

References ATTR_BRIGHT, ATTR_RESET, COLOR_BLACK, COLOR_BROWN, COLOR_WHITE, ESC, option_console, option_nocolor, and option_nofork.

Referenced by main().

00033 { 00034 char *term = getenv("TERM"); 00035 if (!term) 00036 return 0; 00037 if (!option_console || option_nocolor || !option_nofork) 00038 return 0; 00039 if (!strncasecmp(term, "linux", 5)) 00040 vt100compat = 1; else 00041 if (!strncasecmp(term, "xterm", 5)) 00042 vt100compat = 1; else 00043 if (!strncasecmp(term, "crt", 3)) 00044 vt100compat = 1; else 00045 if (!strncasecmp(term, "vt", 2)) 00046 vt100compat = 1; 00047 if (vt100compat) { 00048 /* Make commands show up in nice colors */ 00049 snprintf(prepdata, sizeof(prepdata), "%c[%d;%d;%dm", ESC, ATTR_BRIGHT, COLOR_BROWN, COLOR_BLACK + 10); 00050 snprintf(enddata, sizeof(enddata), "%c[%d;%d;%dm", ESC, ATTR_RESET, COLOR_WHITE, COLOR_BLACK + 10); 00051 snprintf(quitdata, sizeof(quitdata), "%c[0m", ESC); 00052 } 00053 return 0; 00054 }


Generated on Sat Jun 12 16:41:04 2004 for Asterisk by doxygen 1.3.7