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)
int init_framer (void)
int reload_logger (void)
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 415 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().

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

int init_framer void   ) 
 

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

00703 {
00704 #ifdef TRACE_FRAMES
00705    ast_cli_register(&cli_frame_stats);
00706 #endif
00707    ast_cli_register(&cli_show_codecs);
00708    ast_cli_register(&cli_show_codecs_audio);
00709    ast_cli_register(&cli_show_codecs_video);
00710    ast_cli_register(&cli_show_codecs_image);
00711    ast_cli_register(&cli_show_codec_n);
00712    return 0;   
00713 }

int init_logger void   ) 
 

Definition at line 181 of file logger.c.

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

Referenced by main().

00182 {
00183    char tmp[AST_CONFIG_MAX_PATH];
00184    mkdir((char *)ast_config_AST_LOG_DIR, 0755);
00185    snprintf(tmp, sizeof(tmp), "%s/%s", (char *)ast_config_AST_LOG_DIR, EVENTLOG);
00186    eventlog = fopen((char *)tmp, "a");
00187    if (eventlog) {
00188       init_logger_chain();
00189       ast_log(LOG_EVENT, "Started Asterisk Event Logger\n");
00190       if (option_verbose)
00191          ast_verbose("Asterisk Event Logger Started %s\n",(char *)tmp);
00192       return 0;
00193    } else 
00194       ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno));
00195    init_logger_chain();
00196    return -1;
00197 }

int load_modules void   ) 
 

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

00328 {
00329    struct ast_config *cfg;
00330    struct ast_variable *v;
00331    char tmp[80];
00332    if (option_verbose) 
00333       ast_verbose( "Asterisk Dynamic Loader Starting:\n");
00334    cfg = ast_load(AST_MODULE_CONFIG);
00335    if (cfg) {
00336       /* Load explicitly defined modules */
00337       v = ast_variable_browse(cfg, "modules");
00338       while(v) {
00339          if (!strcasecmp(v->name, "load")) {
00340             if (option_debug && !option_verbose)
00341                ast_log(LOG_DEBUG, "Loading module %s\n", v->value);
00342             if (option_verbose) {
00343                ast_verbose( VERBOSE_PREFIX_1 "[%s]", term_color(tmp, v->value, COLOR_BRWHITE, 0, sizeof(tmp)));
00344                fflush(stdout);
00345             }
00346             if (ast_load_resource(v->value)) {
00347                ast_log(LOG_WARNING, "Loading module %s failed!\n", v->value);
00348                if (cfg)
00349                   ast_destroy(cfg);
00350                return -1;
00351             }
00352          }
00353          v=v->next;
00354       }
00355    }
00356    if (!cfg || ast_true(ast_variable_retrieve(cfg, "modules", "autoload"))) {
00357       /* Load all modules */
00358       DIR *mods;
00359       struct dirent *d;
00360       int x;
00361       /* Make two passes.  First, load any resource modules, then load the others. */
00362       for (x=0;x<2;x++) {
00363          mods = opendir((char *)ast_config_AST_MODULE_DIR);
00364          if (mods) {
00365             while((d = readdir(mods))) {
00366                /* Must end in .so to load it.  */
00367                if ((strlen(d->d_name) > 3) && (x || !strncasecmp(d->d_name, "res_", 4)) && 
00368                    !strcasecmp(d->d_name + strlen(d->d_name) - 3, ".so") &&
00369                   !ast_resource_exists(d->d_name)) {
00370                   /* It's a shared library -- Just be sure we're allowed to load it -- kinda
00371                      an inefficient way to do it, but oh well. */
00372                   if (cfg) {
00373                      v = ast_variable_browse(cfg, "modules");
00374                      while(v) {
00375                         if (!strcasecmp(v->name, "noload") &&
00376                             !strcasecmp(v->value, d->d_name)) 
00377                            break;
00378                         v = v->next;
00379                      }
00380                      if (v) {
00381                         if (option_verbose) {
00382                            ast_verbose( VERBOSE_PREFIX_1 "[skipping %s]\n", d->d_name);
00383                            fflush(stdout);
00384                         }
00385                         continue;
00386                      }
00387                      
00388                   }
00389                    if (option_debug && !option_verbose)
00390                      ast_log(LOG_DEBUG, "Loading module %s\n", d->d_name);
00391                   if (option_verbose) {
00392                      ast_verbose( VERBOSE_PREFIX_1 "[%s]", term_color(tmp, d->d_name, COLOR_BRWHITE, 0, sizeof(tmp)));
00393                      fflush(stdout);
00394                   }
00395                   if (ast_load_resource(d->d_name)) {
00396                      ast_log(LOG_WARNING, "Loading module %s failed!\n", d->d_name);
00397                      if (cfg)
00398                         ast_destroy(cfg);
00399                      return -1;
00400                   }
00401                }
00402             }
00403             closedir(mods);
00404          } else {
00405             if (!option_quiet)
00406                ast_log(LOG_WARNING, "Unable to open modules directory %s.\n", (char *)ast_config_AST_MODULE_DIR);
00407          }
00408       }
00409    } 
00410    ast_destroy(cfg);
00411    return 0;
00412 }

int load_pbx void   ) 
 

Definition at line 4445 of file pbx.c.

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

Referenced by main().

04446 {
04447    int x;
04448    /* Initialize the PBX */
04449    if (option_verbose) {
04450       ast_verbose( "Asterisk PBX Core Initializing\n");
04451       ast_verbose( "Registering builtin applications:\n");
04452    }
04453    ast_cli_register(&show_applications_cli);
04454    ast_cli_register(&show_application_cli);
04455    ast_cli_register(&show_dialplan_cli);
04456    ast_cli_register(&show_switches_cli);
04457    for (x=0;x<sizeof(builtins) / sizeof(struct pbx_builtin); x++) {
04458       if (option_verbose)
04459          ast_verbose( VERBOSE_PREFIX_1 "[%s]\n", builtins[x].name);
04460       if (ast_register_application(builtins[x].name, builtins[x].execute, builtins[x].synopsis, builtins[x].description)) {
04461          ast_log(LOG_ERROR, "Unable to register builtin application '%s'\n", builtins[x].name);
04462          return -1;
04463       }
04464    }
04465    return 0;
04466 }

int reload_logger void   ) 
 

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

00200 {
00201    char tmp[AST_CONFIG_MAX_PATH];
00202    ast_mutex_lock(&loglock);
00203    if (eventlog)
00204       fclose(eventlog);
00205    mkdir((char *)ast_config_AST_LOG_DIR, 0755);
00206    snprintf(tmp, sizeof(tmp), "%s/%s", (char *)ast_config_AST_LOG_DIR, EVENTLOG);
00207    eventlog = fopen((char *)tmp, "a");
00208    ast_mutex_unlock(&loglock);
00209 
00210    if (eventlog) {
00211       init_logger_chain();
00212       ast_log(LOG_EVENT, "Restarted Asterisk Event Logger\n");
00213       if (option_verbose)
00214          ast_verbose("Asterisk Event Logger restarted\n");
00215       return 0;
00216    } else 
00217       ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno));
00218    init_logger_chain();
00219    return -1;
00220 }

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


Generated on Fri Oct 31 07:05:09 2003 for Asterisk by doxygen 1.3.4