Sun Aug 6 15:05:02 2006

Asterisk developer's documentation


Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

asterisk.h File Reference

Asterisk main include file. File version handling, generic pbx functions. More...

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

Go to the source code of this file.

Defines

#define AST_CONFIG_MAX_PATH   255
#define ASTERISK_FILE_VERSION(file, version)
 Register/unregister a source code file with the core.
#define DEFAULT_LANGUAGE   "en"

Functions

void ast_channels_init (void)
void ast_register_file_version (const char *file, const char *version)
 Register the version of a source code file with the core.
int ast_set_priority (int)
void ast_unregister_file_version (const char *file)
 Unregister a source code file from the core.
int astdb_init (void)
void close_logger (void)
int dnsmgr_init (void)
void dnsmgr_reload (void)
void dnsmgr_start_refresh (void)
int init_framer (void)
int init_logger (void)
int load_modules (const int preload_only)
int load_pbx (void)
int reload_logger (int)
int term_init (void)

Variables

char ast_config_AST_AGI_DIR [AST_CONFIG_MAX_PATH]
char ast_config_AST_CONFIG_DIR [AST_CONFIG_MAX_PATH]
char ast_config_AST_CONFIG_FILE [AST_CONFIG_MAX_PATH]
char ast_config_AST_CTL [AST_CONFIG_MAX_PATH]
char ast_config_AST_CTL_GROUP [AST_CONFIG_MAX_PATH]
char ast_config_AST_CTL_OWNER [AST_CONFIG_MAX_PATH]
char ast_config_AST_CTL_PERMISSIONS [AST_CONFIG_MAX_PATH]
char ast_config_AST_DATA_DIR [AST_CONFIG_MAX_PATH]
char ast_config_AST_DB [AST_CONFIG_MAX_PATH]
char ast_config_AST_KEY_DIR [AST_CONFIG_MAX_PATH]
char ast_config_AST_LOG_DIR [AST_CONFIG_MAX_PATH]
char ast_config_AST_MODULE_DIR [AST_CONFIG_MAX_PATH]
char ast_config_AST_MONITOR_DIR [AST_CONFIG_MAX_PATH]
char ast_config_AST_PID [AST_CONFIG_MAX_PATH]
char ast_config_AST_RUN_DIR [AST_CONFIG_MAX_PATH]
char ast_config_AST_SOCKET [AST_CONFIG_MAX_PATH]
char ast_config_AST_SPOOL_DIR [AST_CONFIG_MAX_PATH]
char ast_config_AST_VAR_DIR [AST_CONFIG_MAX_PATH]


Detailed Description

Asterisk main include file. File version handling, generic pbx functions.

Definition in file asterisk.h.


Define Documentation

#define AST_CONFIG_MAX_PATH   255
 

Definition at line 23 of file asterisk.h.

Referenced by add_module(), build_filename(), csv_log(), file_ok_sel(), reload_logger(), vm_change_password(), and writefile().

#define ASTERISK_FILE_VERSION file,
version   ) 
 

Register/unregister a source code file with the core.

Parameters:
file the source file name
version the version string (typically a CVS revision keyword string)
This macro will place a file-scope constructor and destructor into the source of the module using it; this will cause the version of this file to registered with the Asterisk core (and unregistered) at the appropriate times.

Example:

 ASTERISK_FILE_VERSION(__FILE__, "\$Revision\$")

Note:
The dollar signs above have been protected with backslashes to keep SVN from modifying them in this file; under normal circumstances they would not be present and SVN would expand the Revision keyword into the file's revision number.

Definition at line 113 of file asterisk.h.

#define DEFAULT_LANGUAGE   "en"
 

Definition at line 21 of file asterisk.h.


Function Documentation

void ast_channels_init void   ) 
 

Definition at line 3829 of file channel.c.

References ast_cli_register().

Referenced by main().

03830 {
03831    ast_cli_register(&cli_show_channeltypes);
03832 }

void ast_register_file_version const char *  file,
const char *  version
 

Register the version of a source code file with the core.

Parameters:
file the source file name
version the version string (typically a CVS revision keyword string)
Returns:
nothing
This function should not be called directly, but instead the ASTERISK_FILE_VERSION macro should be used to register a file with the core.

Definition at line 248 of file asterisk.c.

References AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_UNLOCK, ast_strdupa, ast_strip_quoted(), calloc, and list.

00249 {
00250    struct file_version *new;
00251    char *work;
00252    size_t version_length;
00253 
00254    work = ast_strdupa(version);
00255    work = ast_strip(ast_strip_quoted(work, "$", "$"));
00256    version_length = strlen(work) + 1;
00257 
00258    new = calloc(1, sizeof(*new) + version_length);
00259    if (!new)
00260       return;
00261 
00262    new->file = file;
00263    new->version = (char *) new + sizeof(*new);
00264    memcpy(new->version, work, version_length);
00265    AST_LIST_LOCK(&file_versions);
00266    AST_LIST_INSERT_HEAD(&file_versions, new, list);
00267    AST_LIST_UNLOCK(&file_versions);
00268 }

int ast_set_priority int  pri  ) 
 

We set ourselves to a high priority, that we might pre-empt everything else. If your PBX has heavy activity on it, this is a good thing.

Definition at line 787 of file asterisk.c.

References ast_log(), ast_verbose(), LOG_WARNING, and option_verbose.

Referenced by app_exec(), ast_safe_system(), icesencode(), launch_script(), main(), mp3play(), NBScatplay(), send_waveform_to_fd(), spawn_mp3(), and spawn_ras().

00788 {
00789    struct sched_param sched;
00790    memset(&sched, 0, sizeof(sched));
00791 #ifdef __linux__
00792    if (pri) {  
00793       sched.sched_priority = 10;
00794       if (sched_setscheduler(0, SCHED_RR, &sched)) {
00795          ast_log(LOG_WARNING, "Unable to set high priority\n");
00796          return -1;
00797       } else
00798          if (option_verbose)
00799             ast_verbose("Set to realtime thread\n");
00800    } else {
00801       sched.sched_priority = 0;
00802       if (sched_setscheduler(0, SCHED_OTHER, &sched)) {
00803          ast_log(LOG_WARNING, "Unable to set normal priority\n");
00804          return -1;
00805       }
00806    }
00807 #else
00808    if (pri) {
00809       if (setpriority(PRIO_PROCESS, 0, -10) == -1) {
00810          ast_log(LOG_WARNING, "Unable to set high priority\n");
00811          return -1;
00812       } else
00813          if (option_verbose)
00814             ast_verbose("Set to high priority\n");
00815    } else {
00816       if (setpriority(PRIO_PROCESS, 0, 0) == -1) {
00817          ast_log(LOG_WARNING, "Unable to set normal priority\n");
00818          return -1;
00819       }
00820    }
00821 #endif
00822    return 0;
00823 }

void ast_unregister_file_version const char *  file  ) 
 

Unregister a source code file from the core.

Parameters:
file the source file name
Returns:
nothing
This function should not be called directly, but instead the ASTERISK_FILE_VERSION macro should be used to automatically unregister the file when the module is unloaded.

Definition at line 270 of file asterisk.c.

References AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, free, and list.

00271 {
00272    struct file_version *find;
00273 
00274    AST_LIST_LOCK(&file_versions);
00275    AST_LIST_TRAVERSE_SAFE_BEGIN(&file_versions, find, list) {
00276       if (!strcasecmp(find->file, file)) {
00277          AST_LIST_REMOVE_CURRENT(&file_versions, list);
00278          break;
00279       }
00280    }
00281    AST_LIST_TRAVERSE_SAFE_END;
00282    AST_LIST_UNLOCK(&file_versions);
00283    if (find)
00284       free(find);
00285 }

int astdb_init void   ) 
 

Definition at line 585 of file db.c.

References ast_cli_register(), ast_manager_register, dbinit(), EVENT_FLAG_SYSTEM, manager_dbget(), and manager_dbput().

Referenced by main().

void close_logger void   ) 
 

Definition at line 640 of file logger.c.

References ast_mutex_lock(), ast_mutex_unlock(), free, last, list, msglist::msg, msgcnt, and msglist::next.

Referenced by quit_handler().

00641 {
00642    struct msglist *m, *tmp;
00643 
00644    ast_mutex_lock(&msglist_lock);
00645    m = list;
00646    while(m) {
00647       if (m->msg) {
00648          free(m->msg);
00649       }
00650       tmp = m->next;
00651       free(m);
00652       m = tmp;
00653    }
00654    list = last = NULL;
00655    msgcnt = 0;
00656    ast_mutex_unlock(&msglist_lock);
00657    return;
00658 }

int dnsmgr_init void   ) 
 

Definition at line 285 of file dnsmgr.c.

References ast_cli_register(), ast_log(), do_reload(), LOG_ERROR, and sched_context_create().

Referenced by main().

00286 {
00287    sched = sched_context_create();
00288    if (!sched) {
00289       ast_log(LOG_ERROR, "Unable to create schedule context.\n");
00290       return -1;
00291    }
00292    ast_cli_register(&cli_reload);
00293    ast_cli_register(&cli_status);
00294    return do_reload(1);
00295 }

void dnsmgr_reload void   ) 
 

Definition at line 297 of file dnsmgr.c.

References do_reload().

Referenced by ast_module_reload().

00298 {
00299    do_reload(0);
00300 }

void dnsmgr_start_refresh void   ) 
 

Definition at line 194 of file dnsmgr.c.

References ast_sched_add_variable(), ast_sched_del(), refresh_list(), and refresh_sched.

Referenced by main().

00195 {
00196    if (refresh_sched > -1) {
00197       ast_sched_del(sched, refresh_sched);
00198       refresh_sched = ast_sched_add_variable(sched, 100, refresh_list, &master_refresh_info, 1);
00199    }
00200 }

int init_framer void   ) 
 

Definition at line 868 of file frame.c.

References ast_cli_register_multiple().

Referenced by main().

00869 {
00870    ast_cli_register_multiple(my_clis, sizeof(my_clis)/sizeof(my_clis[0]) );
00871    return 0;   
00872 }

int init_logger void   ) 
 

Definition at line 599 of file logger.c.

References ast_cli_register(), ast_config_AST_LOG_DIR, ast_log(), ast_queue_log(), ast_verbose(), eventlog, EVENTLOG, handle_SIGXFSZ(), init_logger_chain(), LOG_ERROR, LOG_EVENT, logfiles, option_verbose, qlog, and QUEUELOG.

Referenced by main().

00600 {
00601    char tmp[256];
00602    int res = 0;
00603 
00604    /* auto rotate if sig SIGXFSZ comes a-knockin */
00605    (void) signal(SIGXFSZ,(void *) handle_SIGXFSZ);
00606 
00607    /* register the relaod logger cli command */
00608    ast_cli_register(&reload_logger_cli);
00609    ast_cli_register(&rotate_logger_cli);
00610    ast_cli_register(&logger_show_channels_cli);
00611 
00612    mkdir((char *)ast_config_AST_LOG_DIR, 0755);
00613   
00614    /* create log channels */
00615    init_logger_chain();
00616 
00617    /* create the eventlog */
00618    if (logfiles.event_log) {
00619       mkdir((char *)ast_config_AST_LOG_DIR, 0755);
00620       snprintf(tmp, sizeof(tmp), "%s/%s", (char *)ast_config_AST_LOG_DIR, EVENTLOG);
00621       eventlog = fopen((char *)tmp, "a");
00622       if (eventlog) {
00623          ast_log(LOG_EVENT, "Started Asterisk Event Logger\n");
00624          if (option_verbose)
00625             ast_verbose("Asterisk Event Logger Started %s\n",(char *)tmp);
00626       } else {
00627          ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno));
00628          res = -1;
00629       }
00630    }
00631 
00632    if (logfiles.queue_log) {
00633       snprintf(tmp, sizeof(tmp), "%s/%s", (char *)ast_config_AST_LOG_DIR, QUEUELOG);
00634       qlog = fopen(tmp, "a");
00635       ast_queue_log("NONE", "NONE", "NONE", "QUEUESTART", "%s", "");
00636    }
00637    return res;
00638 }

int load_modules const int  preload_only  ) 
 

Definition at line 465 of file loader.c.

References __load_resource(), ast_config_AST_MODULE_DIR, ast_config_destroy(), ast_config_load(), ast_log(), AST_MODULE_CONFIG, ast_resource_exists(), ast_true(), ast_variable_browse(), ast_variable_retrieve(), ast_verbose(), cfg, COLOR_BRWHITE, loadorder, LOG_DEBUG, LOG_WARNING, ast_variable::name, ast_variable::next, option_debug, option_quiet, option_verbose, term_color(), ast_variable::value, and VERBOSE_PREFIX_1.

Referenced by main().

00466 {
00467    struct ast_config *cfg;
00468    struct ast_variable *v;
00469    char tmp[80];
00470 
00471    if (option_verbose) {
00472       if (preload_only)
00473          ast_verbose("Asterisk Dynamic Loader loading preload modules:\n");
00474       else
00475          ast_verbose("Asterisk Dynamic Loader Starting:\n");
00476    }
00477 
00478    cfg = ast_config_load(AST_MODULE_CONFIG);
00479    if (cfg) {
00480       int doload;
00481 
00482       /* Load explicitly defined modules */
00483       for (v = ast_variable_browse(cfg, "modules"); v; v = v->next) {
00484          doload = 0;
00485 
00486          if (preload_only)
00487             doload = !strcasecmp(v->name, "preload");
00488          else
00489             doload = !strcasecmp(v->name, "load");
00490 
00491              if (doload) {
00492             if (option_debug && !option_verbose)
00493                ast_log(LOG_DEBUG, "Loading module %s\n", v->value);
00494             if (option_verbose) {
00495                ast_verbose(VERBOSE_PREFIX_1 "[%s]", term_color(tmp, v->value, COLOR_BRWHITE, 0, sizeof(tmp)));
00496                fflush(stdout);
00497             }
00498             if (__load_resource(v->value, cfg)) {
00499                ast_log(LOG_WARNING, "Loading module %s failed!\n", v->value);
00500                ast_config_destroy(cfg);
00501                return -1;
00502             }
00503          }
00504       }
00505    }
00506 
00507    if (preload_only) {
00508       ast_config_destroy(cfg);
00509       return 0;
00510    }
00511 
00512    if (!cfg || ast_true(ast_variable_retrieve(cfg, "modules", "autoload"))) {
00513       /* Load all modules */
00514       DIR *mods;
00515       struct dirent *d;
00516       int x;
00517 
00518       /* Loop through each order */
00519       for (x=0; x<sizeof(loadorder) / sizeof(loadorder[0]); x++) {
00520          mods = opendir((char *)ast_config_AST_MODULE_DIR);
00521          if (mods) {
00522             while((d = readdir(mods))) {
00523                /* Must end in .so to load it.  */
00524                if ((strlen(d->d_name) > 3) && 
00525                    (!loadorder[x] || !strncasecmp(d->d_name, loadorder[x], strlen(loadorder[x]))) && 
00526                    !strcasecmp(d->d_name + strlen(d->d_name) - 3, ".so") &&
00527                   !ast_resource_exists(d->d_name)) {
00528                   /* It's a shared library -- Just be sure we're allowed to load it -- kinda
00529                      an inefficient way to do it, but oh well. */
00530                   if (cfg) {
00531                      v = ast_variable_browse(cfg, "modules");
00532                      while(v) {
00533                         if (!strcasecmp(v->name, "noload") &&
00534                             !strcasecmp(v->value, d->d_name)) 
00535                            break;
00536                         v = v->next;
00537                      }
00538                      if (v) {
00539                         if (option_verbose) {
00540                            ast_verbose( VERBOSE_PREFIX_1 "[skipping %s]\n", d->d_name);
00541                            fflush(stdout);
00542                         }
00543                         continue;
00544                      }
00545                      
00546                   }
00547                   if (option_debug && !option_verbose)
00548                      ast_log(LOG_DEBUG, "Loading module %s\n", d->d_name);
00549                   if (option_verbose) {
00550                      ast_verbose( VERBOSE_PREFIX_1 "[%s]", term_color(tmp, d->d_name, COLOR_BRWHITE, 0, sizeof(tmp)));
00551                      fflush(stdout);
00552                   }
00553                   if (__load_resource(d->d_name, cfg)) {
00554                      ast_log(LOG_WARNING, "Loading module %s failed!\n", d->d_name);
00555                      if (cfg)
00556                         ast_config_destroy(cfg);
00557                      return -1;
00558                   }
00559                }
00560             }
00561             closedir(mods);
00562          } else {
00563             if (!option_quiet)
00564                ast_log(LOG_WARNING, "Unable to open modules directory %s.\n", (char *)ast_config_AST_MODULE_DIR);
00565          }
00566       }
00567    } 
00568    ast_config_destroy(cfg);
00569    return 0;
00570 }

int load_pbx void   ) 
 

Definition at line 6240 of file pbx.c.

References ast_cli_register_multiple(), AST_LIST_HEAD_INIT_NOLOCK, ast_log(), ast_register_application(), ast_verbose(), builtins, description, LOG_ERROR, name, option_verbose, synopsis, and VERBOSE_PREFIX_1.

Referenced by main().

06241 {
06242    int x;
06243 
06244    /* Initialize the PBX */
06245    if (option_verbose) {
06246       ast_verbose( "Asterisk PBX Core Initializing\n");
06247       ast_verbose( "Registering builtin applications:\n");
06248    }
06249    AST_LIST_HEAD_INIT_NOLOCK(&globals);
06250    ast_cli_register_multiple(pbx_cli, sizeof(pbx_cli) / sizeof(pbx_cli[0]));
06251 
06252    /* Register builtin applications */
06253    for (x=0; x<sizeof(builtins) / sizeof(struct pbx_builtin); x++) {
06254       if (option_verbose)
06255          ast_verbose( VERBOSE_PREFIX_1 "[%s]\n", builtins[x].name);
06256       if (ast_register_application(builtins[x].name, builtins[x].execute, builtins[x].synopsis, builtins[x].description)) {
06257          ast_log(LOG_ERROR, "Unable to register builtin application '%s'\n", builtins[x].name);
06258          return -1;
06259       }
06260    }
06261    return 0;
06262 }

int reload_logger int   ) 
 

Definition at line 378 of file logger.c.

References ast_config_AST_LOG_DIR, AST_CONFIG_MAX_PATH, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_queue_log(), ast_verbose(), logchannel::disabled, EVENT_FLAG_SYSTEM, EVENTLOG, eventlog, logchannel::filename, logchannel::fileptr, filesize_reload_needed, init_logger_chain(), LOG_ERROR, LOG_EVENT, logfiles, manager_event(), logchannel::next, option_verbose, qlog, and QUEUELOG.

Referenced by ast_log(), handle_logger_reload(), handle_logger_rotate(), and main().

00379 {
00380    char old[AST_CONFIG_MAX_PATH] = "";
00381    char new[AST_CONFIG_MAX_PATH];
00382    int event_rotate = rotate, queue_rotate = rotate;
00383    struct logchannel *f;
00384    FILE *myf;
00385    int x, res = 0;
00386 
00387    ast_mutex_lock(&msglist_lock);   /* to avoid deadlock */
00388    ast_mutex_lock(&loglock);
00389    if (eventlog) 
00390       fclose(eventlog);
00391    else 
00392       event_rotate = 0;
00393    eventlog = NULL;
00394 
00395    if (qlog) 
00396       fclose(qlog);
00397    else 
00398       queue_rotate = 0;
00399    qlog = NULL;
00400 
00401    mkdir((char *)ast_config_AST_LOG_DIR, 0755);
00402 
00403    f = logchannels;
00404    while(f) {
00405       if (f->disabled) {
00406          f->disabled = 0;  /* Re-enable logging at reload */
00407          manager_event(EVENT_FLAG_SYSTEM, "LogChannel", "Channel: %s\r\nEnabled: Yes\r\n", f->filename);
00408       }
00409       if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) {
00410          fclose(f->fileptr);  /* Close file */
00411          f->fileptr = NULL;
00412          if(rotate) {
00413             ast_copy_string(old, f->filename, sizeof(old));
00414    
00415             for(x=0;;x++) {
00416                snprintf(new, sizeof(new), "%s.%d", f->filename, x);
00417                myf = fopen((char *)new, "r");
00418                if (myf) {
00419                   fclose(myf);
00420                } else {
00421                   break;
00422                }
00423             }
00424        
00425             /* do it */
00426             if (rename(old,new))
00427                fprintf(stderr, "Unable to rename file '%s' to '%s'\n", old, new);
00428          }
00429       }
00430       f = f->next;
00431    }
00432 
00433    filesize_reload_needed = 0;
00434 
00435    init_logger_chain();
00436 
00437    if (logfiles.event_log) {
00438       snprintf(old, sizeof(old), "%s/%s", (char *)ast_config_AST_LOG_DIR, EVENTLOG);
00439       if (event_rotate) {
00440          for (x=0;;x++) {
00441             snprintf(new, sizeof(new), "%s/%s.%d", (char *)ast_config_AST_LOG_DIR, EVENTLOG,x);
00442             myf = fopen((char *)new, "r");
00443             if (myf)    /* File exists */
00444                fclose(myf);
00445             else
00446                break;
00447          }
00448    
00449          /* do it */
00450          if (rename(old,new))
00451             ast_log(LOG_ERROR, "Unable to rename file '%s' to '%s'\n", old, new);
00452       }
00453 
00454       eventlog = fopen(old, "a");
00455       if (eventlog) {
00456          ast_log(LOG_EVENT, "Restarted Asterisk Event Logger\n");
00457          if (option_verbose)
00458             ast_verbose("Asterisk Event Logger restarted\n");
00459       } else {
00460          ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno));
00461          res = -1;
00462       }
00463    }
00464 
00465    if (logfiles.queue_log) {
00466       snprintf(old, sizeof(old), "%s/%s", (char *)ast_config_AST_LOG_DIR, QUEUELOG);
00467       if (queue_rotate) {
00468          for (x = 0; ; x++) {
00469             snprintf(new, sizeof(new), "%s/%s.%d", (char *)ast_config_AST_LOG_DIR, QUEUELOG, x);
00470             myf = fopen((char *)new, "r");
00471             if (myf)    /* File exists */
00472                fclose(myf);
00473             else
00474                break;
00475          }
00476    
00477          /* do it */
00478          if (rename(old, new))
00479             ast_log(LOG_ERROR, "Unable to rename file '%s' to '%s'\n", old, new);
00480       }
00481 
00482       qlog = fopen(old, "a");
00483       if (qlog) {
00484          ast_queue_log("NONE", "NONE", "NONE", "CONFIGRELOAD", "%s", "");
00485          ast_log(LOG_EVENT, "Restarted Asterisk Queue Logger\n");
00486          if (option_verbose)
00487             ast_verbose("Asterisk Queue Logger restarted\n");
00488       } else {
00489          ast_log(LOG_ERROR, "Unable to create queue log: %s\n", strerror(errno));
00490          res = -1;
00491       }
00492    }
00493    ast_mutex_unlock(&loglock);
00494    ast_mutex_unlock(&msglist_lock);
00495 
00496    return res;
00497 }

int term_init void   ) 
 

Definition at line 74 of file term.c.

References ATTR_BRIGHT, ATTR_RESET, COLOR_BLACK, COLOR_BROWN, COLOR_WHITE, convshort(), enddata, ESC, option_console, option_nocolor, option_nofork, prepdata, quitdata, termpath, and vt100compat.

Referenced by main().

00075 {
00076    char *term = getenv("TERM");
00077    char termfile[256] = "";
00078    char buffer[512] = "";
00079    int termfd = -1, parseokay = 0, i;
00080 
00081    if (!term)
00082       return 0;
00083    if (!option_console || option_nocolor || !option_nofork)
00084       return 0;
00085 
00086    for (i=0 ;; i++) {
00087       if (termpath[i] == NULL) {
00088          break;
00089       }
00090       snprintf(termfile, sizeof(termfile), "%s/%c/%s", termpath[i], *term, term);
00091       termfd = open(termfile, O_RDONLY);
00092       if (termfd > -1) {
00093          break;
00094       }
00095    }
00096    if (termfd > -1) {
00097       int actsize = read(termfd, buffer, sizeof(buffer) - 1);
00098       short sz_names = convshort(buffer + 2);
00099       short sz_bools = convshort(buffer + 4);
00100       short n_nums   = convshort(buffer + 6);
00101 
00102       /* if ((sz_names + sz_bools) & 1)
00103          sz_bools++; */
00104 
00105       if (sz_names + sz_bools + n_nums < actsize) {
00106          /* Offset 13 is defined in /usr/include/term.h, though we do not
00107           * include it here, as it conflicts with include/asterisk/term.h */
00108          short max_colors = convshort(buffer + 12 + sz_names + sz_bools + 13 * 2);
00109          if (max_colors > 0) {
00110             vt100compat = 1;
00111          }
00112          parseokay = 1;
00113       }
00114       close(termfd);
00115    }
00116 
00117    if (!parseokay) {
00118       /* These comparisons should not be substrings nor case-insensitive, as
00119        * terminal types are very particular about how they treat suffixes and
00120        * capitalization.  For example, terminal type 'linux-m' does NOT
00121        * support color, while 'linux' does.  Not even all vt100* terminals
00122        * support color, either (e.g. 'vt100+fnkeys'). */
00123       if (!strcmp(term, "linux")) {
00124          vt100compat = 1;
00125       } else if (!strcmp(term, "xterm")) {
00126          vt100compat = 1;
00127       } else if (!strcmp(term, "xterm-color")) {
00128          vt100compat = 1;
00129       } else if (!strncmp(term, "Eterm", 5)) {
00130          /* Both entries which start with Eterm support color */
00131          vt100compat = 1;
00132       } else if (!strcmp(term, "vt100")) {
00133          vt100compat = 1;
00134       } else if (!strncmp(term, "crt", 3)) {
00135          /* Both crt terminals support color */
00136          vt100compat = 1;
00137       }
00138    }
00139 
00140    if (vt100compat) {
00141       /* Make commands show up in nice colors */
00142       snprintf(prepdata, sizeof(prepdata), "%c[%d;%d;%dm", ESC, ATTR_BRIGHT, COLOR_BROWN, COLOR_BLACK + 10);
00143       snprintf(enddata, sizeof(enddata), "%c[%d;%d;%dm", ESC, ATTR_RESET, COLOR_WHITE, COLOR_BLACK + 10);
00144       snprintf(quitdata, sizeof(quitdata), "%c[0m", ESC);
00145    }
00146    return 0;
00147 }


Variable Documentation

char ast_config_AST_AGI_DIR[AST_CONFIG_MAX_PATH]
 

Definition at line 221 of file asterisk.c.

Referenced by ast_readconfig(), and launch_script().

char ast_config_AST_CONFIG_DIR[AST_CONFIG_MAX_PATH]
 

Definition at line 213 of file asterisk.c.

Referenced by ast_ael_compile(), ast_readconfig(), compile_script(), config_text_file_load(), config_text_file_save(), handle_save_dialplan(), ices_exec(), and vm_change_password().

char ast_config_AST_CONFIG_FILE[AST_CONFIG_MAX_PATH]
 

Definition at line 214 of file asterisk.c.

Referenced by ast_readconfig(), and main().

char ast_config_AST_CTL[AST_CONFIG_MAX_PATH]
 

Definition at line 232 of file asterisk.c.

Referenced by ast_readconfig().

char ast_config_AST_CTL_GROUP[AST_CONFIG_MAX_PATH]
 

Definition at line 231 of file asterisk.c.

Referenced by ast_makesocket(), and ast_readconfig().

char ast_config_AST_CTL_OWNER[AST_CONFIG_MAX_PATH]
 

Definition at line 230 of file asterisk.c.

Referenced by ast_makesocket(), and ast_readconfig().

char ast_config_AST_CTL_PERMISSIONS[AST_CONFIG_MAX_PATH]
 

Definition at line 229 of file asterisk.c.

Referenced by ast_makesocket(), and ast_readconfig().

char ast_config_AST_DATA_DIR[AST_CONFIG_MAX_PATH]
 

Definition at line 219 of file asterisk.c.

Referenced by ast_readconfig(), build_filename(), make_filename(), and reload_firmware().

char ast_config_AST_DB[AST_CONFIG_MAX_PATH]
 

Definition at line 222 of file asterisk.c.

Referenced by ast_readconfig(), and dbinit().

char ast_config_AST_KEY_DIR[AST_CONFIG_MAX_PATH]
 

Definition at line 223 of file asterisk.c.

char ast_config_AST_LOG_DIR[AST_CONFIG_MAX_PATH]
 

Definition at line 220 of file asterisk.c.

Referenced by ast_readconfig(), csv_log(), init_logger(), load_config(), load_module(), make_logchannel(), reload_logger(), testclient_exec(), testserver_exec(), and writefile().

char ast_config_AST_MODULE_DIR[AST_CONFIG_MAX_PATH]
 

Definition at line 215 of file asterisk.c.

Referenced by __load_resource(), add_module(), ast_readconfig(), complete_fn(), file_ok_sel(), and load_modules().

char ast_config_AST_MONITOR_DIR[AST_CONFIG_MAX_PATH]
 

Definition at line 217 of file asterisk.c.

Referenced by ast_monitor_change_fname(), ast_monitor_start(), ast_monitor_stop(), ast_readconfig(), chanspy_exec(), and mixmonitor_exec().

char ast_config_AST_PID[AST_CONFIG_MAX_PATH]
 

Definition at line 224 of file asterisk.c.

Referenced by ast_readconfig(), main(), and quit_handler().

char ast_config_AST_RUN_DIR[AST_CONFIG_MAX_PATH]
 

Definition at line 226 of file asterisk.c.

Referenced by ast_readconfig().

char ast_config_AST_SOCKET[AST_CONFIG_MAX_PATH]
 

Definition at line 225 of file asterisk.c.

Referenced by ast_makesocket(), ast_readconfig(), ast_tryconnect(), main(), and quit_handler().

char ast_config_AST_SPOOL_DIR[AST_CONFIG_MAX_PATH]
 

Definition at line 216 of file asterisk.c.

Referenced by ast_readconfig(), conf_run(), dictate_exec(), hasvoicemail_internal(), load_module(), and play_mailbox_owner().

char ast_config_AST_VAR_DIR[AST_CONFIG_MAX_PATH]
 

Definition at line 218 of file asterisk.c.

Referenced by ast_linear_stream(), and ast_readconfig().


Generated on Sun Aug 6 15:05:06 2006 for Asterisk - the Open Source PBX by  doxygen 1.4.2