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

asterisk.h File Reference

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_DATA_DIR   ASTDATADIR
#define AST_LOG_DIR   ASTLOGDIR
#define AST_AGI_DIR   ASTAGIDIR
#define AST_KEY_DIR   ASTVARLIBDIR "/keys"
#define AST_DB   ASTVARLIBDIR "/astdb"
#define AST_TMP_DIR   ASTSPOOLDIR "/tmp"
#define AST_CONFIG_FILE   ASTCONFPATH
#define AST_SOUNDS   AST_DATA_DIR "/sounds"
#define AST_IMAGES   AST_DATA_DIR "/images"

Functions

int load_modules (void)
int load_pbx (void)
int init_logger (void)
void close_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 29 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 34 of file asterisk.h.

#define AST_CONFIG_MAX_PATH   255
 

Definition at line 19 of file asterisk.h.

#define AST_DATA_DIR   ASTDATADIR
 

Definition at line 27 of file asterisk.h.

#define AST_DB   ASTVARLIBDIR "/astdb"
 

Definition at line 31 of file asterisk.h.

#define AST_IMAGES   AST_DATA_DIR "/images"
 

Definition at line 37 of file asterisk.h.

#define AST_KEY_DIR   ASTVARLIBDIR "/keys"
 

Definition at line 30 of file asterisk.h.

#define AST_LOG_DIR   ASTLOGDIR
 

Definition at line 28 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_DATA_DIR "/sounds"
 

Definition at line 36 of file asterisk.h.

#define AST_SPOOL_DIR   ASTSPOOLDIR
 

Definition at line 25 of file asterisk.h.

#define AST_TMP_DIR   ASTSPOOLDIR "/tmp"
 

Definition at line 32 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 418 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().

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

void close_logger void   ) 
 

Definition at line 454 of file logger.c.

References ast_mutex_lock, ast_mutex_unlock, and free.

00455 { 00456 struct msglist *m, *tmp; 00457 00458 m = list; 00459 ast_mutex_lock(&msglist_lock); 00460 while(m) { 00461 if (m->msg) { 00462 free(m->msg); 00463 } 00464 tmp = m->next; 00465 free(m); 00466 m = tmp; 00467 } 00468 list = last = NULL; 00469 msgcnt = 0; 00470 ast_mutex_unlock(&msglist_lock); 00471 return; 00472 }

int init_framer void   ) 
 

Definition at line 784 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().

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

int init_logger void   ) 
 

Definition at line 422 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().

00423 { 00424 char tmp[256]; 00425 00426 /* auto rotate if sig SIGXFSZ comes a-knockin */ 00427 (void) signal(SIGXFSZ,(void *) handle_SIGXFSZ); 00428 00429 /* register the relaod logger cli command */ 00430 ast_cli_register(&reload_logger_cli); 00431 ast_cli_register(&rotate_logger_cli); 00432 00433 /* initialize queue logger */ 00434 queue_log_init(); 00435 00436 /* create the eventlog */ 00437 mkdir((char *)ast_config_AST_LOG_DIR, 0755); 00438 snprintf(tmp, sizeof(tmp), "%s/%s", (char *)ast_config_AST_LOG_DIR, EVENTLOG); 00439 eventlog = fopen((char *)tmp, "a"); 00440 if (eventlog) { 00441 init_logger_chain(); 00442 ast_log(LOG_EVENT, "Started Asterisk Event Logger\n"); 00443 if (option_verbose) 00444 ast_verbose("Asterisk Event Logger Started %s\n",(char *)tmp); 00445 return 0; 00446 } else 00447 ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno)); 00448 00449 /* create log channels */ 00450 init_logger_chain(); 00451 return -1; 00452 }

int load_modules void   ) 
 

Definition at line 360 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().

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

int load_pbx void   ) 
 

Definition at line 4843 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().

04844 { 04845 int x; 04846 04847 /* Initialize the PBX */ 04848 if (option_verbose) { 04849 ast_verbose( "Asterisk PBX Core Initializing\n"); 04850 ast_verbose( "Registering builtin applications:\n"); 04851 } 04852 AST_LIST_HEAD_INIT(&globals); 04853 ast_cli_register(&show_applications_cli); 04854 ast_cli_register(&show_application_cli); 04855 ast_cli_register(&show_dialplan_cli); 04856 ast_cli_register(&show_switches_cli); 04857 04858 /* Register builtin applications */ 04859 for (x=0; x<sizeof(builtins) / sizeof(struct pbx_builtin); x++) { 04860 if (option_verbose) 04861 ast_verbose( VERBOSE_PREFIX_1 "[%s]\n", builtins[x].name); 04862 if (ast_register_application(builtins[x].name, builtins[x].execute, builtins[x].synopsis, builtins[x].description)) { 04863 ast_log(LOG_ERROR, "Unable to register builtin application '%s'\n", builtins[x].name); 04864 return -1; 04865 } 04866 } 04867 return 0; 04868 }

int reload_logger int   ) 
 

Definition at line 289 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(), and main().

00290 { 00291 char old[AST_CONFIG_MAX_PATH] = ""; 00292 char new[AST_CONFIG_MAX_PATH]; 00293 struct logchannel *f; 00294 FILE *myf; 00295 00296 int x; 00297 ast_mutex_lock(&loglock); 00298 if (eventlog) 00299 fclose(eventlog); 00300 else 00301 rotate = 0; 00302 eventlog = NULL; 00303 00304 00305 00306 mkdir((char *)ast_config_AST_LOG_DIR, 0755); 00307 snprintf(old, sizeof(old), "%s/%s", (char *)ast_config_AST_LOG_DIR, EVENTLOG); 00308 00309 if(rotate) { 00310 for(x=0;;x++) { 00311 snprintf(new, sizeof(new), "%s/%s.%d", (char *)ast_config_AST_LOG_DIR, EVENTLOG,x); 00312 myf = fopen((char *)new, "r"); 00313 if(myf) 00314 fclose(myf); 00315 else 00316 break; 00317 } 00318 00319 /* do it */ 00320 if (rename(old,new)) 00321 fprintf(stderr, "Unable to rename file '%s' to '%s'\n", old, new); 00322 } 00323 00324 eventlog = fopen(old, "a"); 00325 00326 f = logchannels; 00327 while(f) { 00328 if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) { 00329 fclose(f->fileptr); 00330 f->fileptr = NULL; 00331 if(rotate) { 00332 strncpy(old, f->filename, sizeof(old) - 1); 00333 00334 for(x=0;;x++) { 00335 snprintf(new, sizeof(new), "%s.%d", f->filename, x); 00336 myf = fopen((char *)new, "r"); 00337 if (myf) { 00338 fclose(myf); 00339 } else { 00340 break; 00341 } 00342 } 00343 00344 /* do it */ 00345 if (rename(old,new)) 00346 fprintf(stderr, "Unable to rename file '%s' to '%s'\n", old, new); 00347 } 00348 } 00349 f = f->next; 00350 } 00351 00352 ast_mutex_unlock(&loglock); 00353 00354 queue_log_init(); 00355 00356 if (eventlog) { 00357 init_logger_chain(); 00358 ast_log(LOG_EVENT, "Restarted Asterisk Event Logger\n"); 00359 if (option_verbose) 00360 ast_verbose("Asterisk Event Logger restarted\n"); 00361 return 0; 00362 } else 00363 ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno)); 00364 init_logger_chain(); 00365 pending_logger_reload = 0; 00366 return -1; 00367 }

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, "Eterm", 5)) 00044 vt100compat = 1; else 00045 if (!strncasecmp(term, "crt", 3)) 00046 vt100compat = 1; else 00047 if (!strncasecmp(term, "vt", 2)) 00048 vt100compat = 1; 00049 if (vt100compat) { 00050 /* Make commands show up in nice colors */ 00051 snprintf(prepdata, sizeof(prepdata), "%c[%d;%d;%dm", ESC, ATTR_BRIGHT, COLOR_BROWN, COLOR_BLACK + 10); 00052 snprintf(enddata, sizeof(enddata), "%c[%d;%d;%dm", ESC, ATTR_RESET, COLOR_WHITE, COLOR_BLACK + 10); 00053 snprintf(quitdata, sizeof(quitdata), "%c[0m", ESC); 00054 } 00055 return 0; 00056 }


Generated on Fri Sep 24 21:03:49 2004 for Asterisk by doxygen 1.3.8