asterisk.h File Reference

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

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_TMP_DIR   ASTSPOOLDIR "/tmp"
#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)
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.

#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_DB   ASTVARLIBDIR "/astdb"

Definition at line 30 of file asterisk.h.

#define AST_IMAGES   AST_VAR_DIR "/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   AST_VAR_DIR "/sounds"

Definition at line 35 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 31 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.

void close_logger ( void   ) 

Definition at line 463 of file logger.c.

00464 {
00465    struct msglist *m, *tmp;
00466 
00467    ast_mutex_lock(&msglist_lock);
00468    m = list;
00469    while(m) {
00470       if (m->msg) {
00471          free(m->msg);
00472       }
00473       tmp = m->next;
00474       free(m);
00475       m = tmp;
00476    }
00477    list = last = NULL;
00478    msgcnt = 0;
00479    ast_mutex_unlock(&msglist_lock);
00480    return;
00481 }

int init_framer ( void   ) 

Definition at line 813 of file frame.c.

00814 {
00815 #ifdef TRACE_FRAMES
00816    ast_cli_register(&cli_frame_stats);
00817 #endif
00818    ast_cli_register(&cli_show_codecs);
00819    ast_cli_register(&cli_show_codecs_audio);
00820    ast_cli_register(&cli_show_codecs_video);
00821    ast_cli_register(&cli_show_codecs_image);
00822    ast_cli_register(&cli_show_codec_n);
00823    return 0;   
00824 }

int init_logger ( void   ) 

Definition at line 431 of file logger.c.

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

int load_modules ( void   ) 

Definition at line 371 of file loader.c.

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

int load_pbx ( void   ) 

Definition at line 4888 of file pbx.c.

04889 {
04890    int x;
04891 
04892    /* Initialize the PBX */
04893    if (option_verbose) {
04894       ast_verbose( "Asterisk PBX Core Initializing\n");
04895       ast_verbose( "Registering builtin applications:\n");
04896    }
04897         AST_LIST_HEAD_INIT(&globals);
04898    ast_cli_register(&show_applications_cli);
04899    ast_cli_register(&show_application_cli);
04900    ast_cli_register(&show_dialplan_cli);
04901    ast_cli_register(&show_switches_cli);
04902 
04903    /* Register builtin applications */
04904    for (x=0; x<sizeof(builtins) / sizeof(struct pbx_builtin); x++) {
04905       if (option_verbose)
04906          ast_verbose( VERBOSE_PREFIX_1 "[%s]\n", builtins[x].name);
04907       if (ast_register_application(builtins[x].name, builtins[x].execute, builtins[x].synopsis, builtins[x].description)) {
04908          ast_log(LOG_ERROR, "Unable to register builtin application '%s'\n", builtins[x].name);
04909          return -1;
04910       }
04911    }
04912    return 0;
04913 }

int reload_logger ( int   ) 

Definition at line 296 of file logger.c.

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

int term_init ( void   ) 

Definition at line 32 of file term.c.

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 Wed Oct 28 17:00:49 2009 for Asterisk by  doxygen 1.5.6