Sat Mar 24 22:55:49 2007

Asterisk developer's documentation


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 3905 of file channel.c.

References ast_cli_register(), and cli_show_channeltypes.

Referenced by main().

03906 {
03907    ast_cli_register(&cli_show_channeltypes);
03908 }

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

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, cli_database_del, cli_database_deltree, cli_database_get, cli_database_put, cli_database_show, cli_database_showkey, dbinit(), EVENT_FLAG_SYSTEM, manager_dbget(), and manager_dbput().

Referenced by main().

void close_logger ( void   ) 

Definition at line 644 of file logger.c.

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

Referenced by quit_handler().

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

int dnsmgr_init ( void   ) 

Definition at line 285 of file dnsmgr.c.

References ast_cli_register(), ast_log(), cli_reload, cli_status, do_reload(), LOG_ERROR, sched, 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(), master_refresh_info, refresh_list(), and 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 867 of file frame.c.

References ast_cli_register_multiple(), and my_clis.

Referenced by main().

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

int init_logger ( void   ) 

Definition at line 603 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, logger_show_channels_cli, option_verbose, qlog, QUEUELOG, reload_logger_cli, and rotate_logger_cli.

Referenced by main().

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

int load_modules ( const int  preload_only  ) 

Definition at line 465 of file loader.c.

References __load_resource(), ast_config_destroy(), ast_config_load(), ast_log(), AST_MODULE_CONFIG, ast_variable_browse(), ast_verbose(), cfg, COLOR_BRWHITE, LOG_DEBUG, LOG_WARNING, ast_variable::name, ast_variable::next, option_debug, 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 6238 of file pbx.c.

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

Referenced by main().

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

int reload_logger ( int   ) 

Definition at line 382 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, logchannels, logfiles, manager_event(), logchannel::next, option_verbose, qlog, and QUEUELOG.

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

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

int term_init ( void   ) 

Definition at line 74 of file term.c.

References ATTR_BRIGHT, ATTR_RESET, COLOR_BLACK, COLOR_BROWN, COLOR_WHITE, convshort(), ESC, option_console, option_nocolor, and option_nofork.

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

char ast_config_AST_CTL[AST_CONFIG_MAX_PATH]

Definition at line 232 of file asterisk.c.

char ast_config_AST_CTL_GROUP[AST_CONFIG_MAX_PATH]

Definition at line 231 of file asterisk.c.

char ast_config_AST_CTL_OWNER[AST_CONFIG_MAX_PATH]

Definition at line 230 of file asterisk.c.

char ast_config_AST_CTL_PERMISSIONS[AST_CONFIG_MAX_PATH]

Definition at line 229 of file asterisk.c.

char ast_config_AST_DATA_DIR[AST_CONFIG_MAX_PATH]

Definition at line 219 of file asterisk.c.

Referenced by 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 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 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(), complete_fn(), and file_ok_sel().

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

char ast_config_AST_PID[AST_CONFIG_MAX_PATH]

Definition at line 224 of file asterisk.c.

char ast_config_AST_RUN_DIR[AST_CONFIG_MAX_PATH]

Definition at line 226 of file asterisk.c.

char ast_config_AST_SOCKET[AST_CONFIG_MAX_PATH]

Definition at line 225 of file asterisk.c.

char ast_config_AST_SPOOL_DIR[AST_CONFIG_MAX_PATH]

Definition at line 216 of file asterisk.c.

Referenced by 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 dial_exec_full().


Generated on Sat Mar 24 22:55:50 2007 for Asterisk - the Open Source PBX by  doxygen 1.4.7