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_LOG_DIR   ASTLOGDIR
#define AST_AGI_DIR   ASTAGIDIR
#define AST_KEY_DIR   ASTVARLIBDIR "/keys"
#define AST_DB   ASTVARLIBDIR "/astdb"
#define AST_DATA_DIR   ASTDATADIR
#define AST_CONFIG_FILE   ASTCONFPATH
#define AST_SOUNDS   ASTDATADIR "/sounds"
#define AST_IMAGES   ASTDATADIR "/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 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 33 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 31 of file asterisk.h.

#define AST_DB   ASTVARLIBDIR "/astdb"
 

Definition at line 30 of file asterisk.h.

#define AST_IMAGES   ASTDATADIR "/images"
 

Definition at line 36 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   ASTDATADIR "/sounds"
 

Definition at line 35 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 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 432 of file logger.c.

References ast_mutex_lock, ast_mutex_unlock, and free.

00433 { 00434 struct msglist *m, *tmp; 00435 00436 m = list; 00437 ast_mutex_lock(&msglist_lock); 00438 while(m) { 00439 if (m->msg) { 00440 free(m->msg); 00441 } 00442 tmp = m->next; 00443 free(m); 00444 m = tmp; 00445 } 00446 list = last = NULL; 00447 ast_mutex_unlock(&msglist_lock); 00448 return; 00449 }

int init_framer void   ) 
 

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

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

int init_logger void   ) 
 

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

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

int load_modules void   ) 
 

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

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

int load_pbx void   ) 
 

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

04722 { 04723 int x; 04724 04725 /* Initialize the PBX */ 04726 if (option_verbose) { 04727 ast_verbose( "Asterisk PBX Core Initializing\n"); 04728 ast_verbose( "Registering builtin applications:\n"); 04729 } 04730 AST_LIST_HEAD_INIT(&globals); 04731 ast_cli_register(&show_applications_cli); 04732 ast_cli_register(&show_application_cli); 04733 ast_cli_register(&show_dialplan_cli); 04734 ast_cli_register(&show_switches_cli); 04735 04736 /* Register builtin applications */ 04737 for (x=0; x<sizeof(builtins) / sizeof(struct pbx_builtin); x++) { 04738 if (option_verbose) 04739 ast_verbose( VERBOSE_PREFIX_1 "[%s]\n", builtins[x].name); 04740 if (ast_register_application(builtins[x].name, builtins[x].execute, builtins[x].synopsis, builtins[x].description)) { 04741 ast_log(LOG_ERROR, "Unable to register builtin application '%s'\n", builtins[x].name); 04742 return -1; 04743 } 04744 } 04745 return 0; 04746 }

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(), and main().

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) - 1); 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 Tue Aug 17 16:13:54 2004 for Asterisk by doxygen 1.3.8