Sat Sep 16 07:28:17 2006

Asterisk developer's documentation


config.c File Reference

Configuration File Parser. More...

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <time.h>
#include <sys/stat.h>
#include <glob.h>
#include "asterisk.h"
#include "asterisk/config.h"
#include "asterisk/cli.h"
#include "asterisk/lock.h"
#include "asterisk/options.h"
#include "asterisk/logger.h"
#include "asterisk/utils.h"
#include "asterisk/channel.h"
#include "asterisk/app.h"

Go to the source code of this file.

Data Structures

struct  ast_category
struct  ast_comment
struct  ast_config
struct  ast_config_map

Defines

#define AST_INCLUDE_GLOB   1
#define COMMENT_END   "--;"
#define COMMENT_META   ';'
#define COMMENT_START   ";--"
#define COMMENT_TAG   '-'
#define MAX_INCLUDE_LEVEL   10
#define MAX_NESTED_COMMENTS   128

Functions

static int append_mapping (char *name, char *driver, char *database, char *table)
void ast_category_append (struct ast_config *config, struct ast_category *category)
char * ast_category_browse (struct ast_config *config, const char *prev)
 Goes through categories.
void ast_category_destroy (struct ast_category *cat)
ast_variableast_category_detach_variables (struct ast_category *cat)
int ast_category_exist (const struct ast_config *config, const char *category_name)
 Check for category duplicates.
ast_categoryast_category_get (const struct ast_config *config, const char *category_name)
 Retrieve a category if it exists.
ast_categoryast_category_new (const char *name)
void ast_category_rename (struct ast_category *cat, const char *name)
int ast_check_realtime (const char *family)
 Check if realtime engine is configured for family returns 1 if family is configured in realtime and engine exists.
void ast_config_destroy (struct ast_config *cfg)
 Destroys a config.
int ast_config_engine_deregister (struct ast_config_engine *del)
 Deegister config engine.
int ast_config_engine_register (struct ast_config_engine *new)
 Register config engine.
ast_categoryast_config_get_current_category (const struct ast_config *cfg)
ast_configast_config_internal_load (const char *filename, struct ast_config *cfg)
ast_configast_config_load (const char *filename)
 Load a config file.
ast_configast_config_new (void)
void ast_config_set_current_category (struct ast_config *cfg, const struct ast_category *cat)
ast_variableast_load_realtime (const char *family,...)
 Retrieve realtime configuration.
ast_configast_load_realtime_multientry (const char *family,...)
 Retrieve realtime configuration.
 AST_MUTEX_DEFINE_STATIC (config_lock)
int ast_update_realtime (const char *family, const char *keyfield, const char *lookup,...)
 Update realtime configuration.
void ast_variable_append (struct ast_category *category, struct ast_variable *variable)
ast_variableast_variable_browse (const struct ast_config *config, const char *category)
 Goes through variables Somewhat similar in intent as the ast_category_browse. List variables of config file category.
ast_variableast_variable_new (const char *name, const char *value)
char * ast_variable_retrieve (const struct ast_config *config, const char *category, const char *variable)
 Gets a variable.
void ast_variables_destroy (struct ast_variable *v)
 Free variable list.
static struct ast_categorycategory_get (const struct ast_config *config, const char *category_name, int ignored)
static void clear_config_maps (void)
static int config_command (int fd, int argc, char **argv)
static struct ast_configconfig_text_file_load (const char *database, const char *table, const char *filename, struct ast_config *cfg)
int config_text_file_save (const char *configfile, const struct ast_config *cfg, const char *generator)
static struct ast_config_enginefind_engine (const char *family, char *database, int dbsiz, char *table, int tabsiz)
static void inherit_category (struct ast_category *new, const struct ast_category *base)
static void move_variables (struct ast_category *old, struct ast_category *new)
static struct ast_categorynext_available_category (struct ast_category *cat)
static int process_text_line (struct ast_config *cfg, struct ast_category **cat, char *buf, int lineno, const char *configfile)
void read_config_maps (void)
int register_config_cli ()
static struct ast_variablevariable_clone (const struct ast_variable *old)

Variables

static struct ast_cli_entry config_command_struct
static struct ast_config_engineconfig_engine_list
static struct ast_config_mapconfig_maps
static char * extconfig_conf = "extconfig.conf"
static char show_config_help []
static struct ast_config_engine text_file_engine


Detailed Description

Configuration File Parser.

Includes the Asterisk Realtime API - ARA See README.realtime

Definition in file config.c.


Define Documentation

#define AST_INCLUDE_GLOB   1

Definition at line 34 of file config.c.

#define COMMENT_END   "--;"

Definition at line 57 of file config.c.

#define COMMENT_META   ';'

Definition at line 58 of file config.c.

Referenced by config_text_file_load().

#define COMMENT_START   ";--"

Definition at line 56 of file config.c.

#define COMMENT_TAG   '-'

Definition at line 59 of file config.c.

Referenced by config_text_file_load().

#define MAX_INCLUDE_LEVEL   10

Definition at line 75 of file config.c.

Referenced by ast_config_new().

#define MAX_NESTED_COMMENTS   128

Definition at line 55 of file config.c.

Referenced by config_text_file_load().


Function Documentation

static int append_mapping ( char *  name,
char *  driver,
char *  database,
char *  table 
) [static]

Definition at line 758 of file config.c.

References ast_verbose(), config_maps, malloc, map, option_verbose, and VERBOSE_PREFIX_2.

Referenced by read_config_maps().

00759 {
00760    struct ast_config_map *map;
00761    int length;
00762 
00763    length = sizeof(*map);
00764    length += strlen(name) + 1;
00765    length += strlen(driver) + 1;
00766    length += strlen(database) + 1;
00767    if (table)
00768       length += strlen(table) + 1;
00769    map = malloc(length);
00770 
00771    if (!map)
00772       return -1;
00773 
00774    memset(map, 0, length);
00775    map->name = map->stuff;
00776    strcpy(map->name, name);
00777    map->driver = map->name + strlen(map->name) + 1;
00778    strcpy(map->driver, driver);
00779    map->database = map->driver + strlen(map->driver) + 1;
00780    strcpy(map->database, database);
00781    if (table) {
00782       map->table = map->database + strlen(map->database) + 1;
00783       strcpy(map->table, table);
00784    }
00785    map->next = config_maps;
00786 
00787    if (option_verbose > 1)
00788       ast_verbose(VERBOSE_PREFIX_2 "Binding %s to %s/%s/%s\n",
00789              map->name, map->driver, map->database, map->table ? map->table : map->name);
00790 
00791    config_maps = map;
00792    return 0;
00793 }

void ast_category_append ( struct ast_config config,
struct ast_category category 
)

Definition at line 240 of file config.c.

References config.

Referenced by config_odbc(), process_text_line(), realtime_directory(), and realtime_multi_odbc().

00241 {
00242    if (config->last)
00243       config->last->next = category;
00244    else
00245       config->root = category;
00246    config->last = category;
00247    config->current = category;
00248 }

char* ast_category_browse ( struct ast_config config,
const char *  prev 
)

Goes through categories.

Parameters:
config Which config structure you wish to "browse"
prev A pointer to a previous category. This funtion is kind of non-intuitive in it's use. To begin, one passes NULL as the second arguement. It will return a pointer to the string of the first category in the file. From here on after, one must then pass the previous usage's return value as the second pointer, and it will return a pointer to the category name afterwards.
Returns a category on success, or NULL on failure/no-more-categories

Definition at line 263 of file config.c.

References config, ast_category::name, ast_category::next, and next_available_category().

Referenced by authenticate(), complete_sipnotify(), config_load(), iax_provision_reload(), ind_load_module(), load_config(), load_module(), load_moh_classes(), load_odbc_config(), loadconfigurationfile(), misdn_cfg_init(), pbx_load_module(), realtime_directory(), realtime_switch_common(), reload_config(), reload_queues(), rpt_master(), and set_config().

00264 {  
00265    struct ast_category *cat = NULL;
00266 
00267    if (prev && config->last_browse && (config->last_browse->name == prev))
00268       cat = config->last_browse->next;
00269    else if (!prev && config->root)
00270          cat = config->root;
00271    else if (prev) {
00272       for (cat = config->root; cat; cat = cat->next) {
00273          if (cat->name == prev) {
00274             cat = cat->next;
00275             break;
00276          }
00277       }
00278       if (!cat) {
00279          for (cat = config->root; cat; cat = cat->next) {
00280             if (!strcasecmp(cat->name, prev)) {
00281                cat = cat->next;
00282                break;
00283             }
00284          }
00285       }
00286    }
00287    
00288    if (cat)
00289       cat = next_available_category(cat);
00290 
00291    config->last_browse = cat;
00292    if (cat)
00293       return cat->name;
00294    else
00295       return NULL;
00296 }

void ast_category_destroy ( struct ast_category cat  ) 

Definition at line 250 of file config.c.

References ast_variables_destroy(), free, and ast_category::root.

Referenced by process_text_line(), and realtime_multi_odbc().

00251 {
00252    ast_variables_destroy(cat->root);
00253    free(cat);
00254 }

struct ast_variable* ast_category_detach_variables ( struct ast_category cat  ) 

Definition at line 298 of file config.c.

References ast_category::root.

Referenced by realtime_switch_common().

00299 {
00300    struct ast_variable *v;
00301 
00302    v = cat->root;
00303    cat->root = NULL;
00304 
00305    return v;
00306 }

int ast_category_exist ( const struct ast_config config,
const char *  category_name 
)

Check for category duplicates.

Parameters:
config which config to use
category_name name of the category you're looking for This will search through the categories within a given config file for a match.
Return non-zero if found

Definition at line 235 of file config.c.

References ast_category_get(), and config.

00236 {
00237    return !!ast_category_get(config, category_name);
00238 }

struct ast_category* ast_category_get ( const struct ast_config config,
const char *  category_name 
)

Retrieve a category if it exists.

Parameters:
config which config to use
category_name name of the category you're looking for This will search through the categories within a given config file for a match.
Returns pointer to category if found, NULL if not.

Definition at line 230 of file config.c.

References category_get(), and config.

Referenced by ast_category_exist(), ast_variable_browse(), realtime_directory(), and realtime_switch_common().

00231 {
00232    return category_get(config, category_name, 0);
00233 }

struct ast_category* ast_category_new ( const char *  name  ) 

Definition at line 200 of file config.c.

References malloc.

Referenced by config_odbc(), process_text_line(), realtime_directory(), and realtime_multi_odbc().

00201 {
00202    struct ast_category *category;
00203 
00204    category = malloc(sizeof(struct ast_category));
00205    if (category) {
00206       memset(category, 0, sizeof(struct ast_category));
00207       ast_copy_string(category->name, name, sizeof(category->name));
00208    }
00209 
00210    return category;
00211 }

void ast_category_rename ( struct ast_category cat,
const char *  name 
)

Definition at line 308 of file config.c.

References ast_category::name.

Referenced by realtime_multi_odbc().

00309 {
00310    ast_copy_string(cat->name, name, sizeof(cat->name));
00311 }

int ast_check_realtime ( const char *  family  ) 

Check if realtime engine is configured for family returns 1 if family is configured in realtime and engine exists.

Parameters:
family which family/config to be checked

Definition at line 1001 of file config.c.

References find_engine().

Referenced by sip_show_settings().

01002 {
01003    struct ast_config_engine *eng;
01004 
01005    eng = find_engine(family, NULL, 0, NULL, 0);
01006    if (eng)
01007       return 1;
01008    return 0;
01009 
01010 }

void ast_config_destroy ( struct ast_config config  ) 

Destroys a config.

Parameters:
config pointer to config data structure Free memory associated with a given config

Definition at line 339 of file config.c.

References ast_variables_destroy(), cfg, free, ast_category::next, ast_config::root, and ast_category::root.

Referenced by adsi_load(), advanced_options(), ast_config_load(), ast_enum_init(), ast_load_resource(), ast_readconfig(), ast_rtp_reload(), authenticate(), conf_exec(), config_load(), directory_exec(), do_reload(), festival_exec(), find_conf(), forward_message(), handle_save_dialplan(), iax_provision_reload(), ind_load_module(), init_logger_chain(), init_manager(), load_config(), load_module(), load_modules(), load_moh_classes(), load_odbc_config(), loadconfigurationfile(), my_load_module(), odbc_load_module(), parse_config(), pbx_load_module(), play_message(), privacy_exec(), process_text_line(), read_agent_config(), read_config_maps(), realtime_directory(), realtime_switch_common(), reload_config(), reload_queues(), rpt_master(), set_config(), setup_zap(), and tds_load_module().

00340 {
00341    struct ast_category *cat, *catn;
00342 
00343    if (!cfg)
00344       return;
00345 
00346    cat = cfg->root;
00347    while(cat) {
00348       ast_variables_destroy(cat->root);
00349       catn = cat;
00350       cat = cat->next;
00351       free(catn);
00352    }
00353    free(cfg);
00354 }

int ast_config_engine_deregister ( struct ast_config_engine del  ) 

Deegister config engine.

Definition at line 868 of file config.c.

References ast_mutex_lock(), ast_mutex_unlock(), config_engine_list, last, and ast_config_engine::next.

Referenced by unload_module().

00869 {
00870    struct ast_config_engine *ptr, *last=NULL;
00871 
00872    ast_mutex_lock(&config_lock);
00873 
00874    for (ptr = config_engine_list; ptr; ptr=ptr->next) {
00875       if (ptr == del) {
00876          if (last)
00877             last->next = ptr->next;
00878          else
00879             config_engine_list = ptr->next;
00880          break;
00881       }
00882       last = ptr;
00883    }
00884 
00885    ast_mutex_unlock(&config_lock);
00886 
00887    return 0;
00888 }

int ast_config_engine_register ( struct ast_config_engine new  ) 

Register config engine.

Definition at line 849 of file config.c.

References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), config_engine_list, LOG_NOTICE, ast_config_engine::name, and ast_config_engine::next.

Referenced by load_module().

00850 {
00851    struct ast_config_engine *ptr;
00852 
00853    ast_mutex_lock(&config_lock);
00854 
00855    if (!config_engine_list) {
00856       config_engine_list = new;
00857    } else {
00858       for (ptr = config_engine_list; ptr->next; ptr=ptr->next);
00859       ptr->next = new;
00860    }
00861 
00862    ast_mutex_unlock(&config_lock);
00863    ast_log(LOG_NOTICE,"Registered Config Engine %s\n", new->name);
00864 
00865    return 1;
00866 }

struct ast_category* ast_config_get_current_category ( const struct ast_config cfg  ) 

Definition at line 356 of file config.c.

References cfg, and ast_config::current.

Referenced by config_odbc(), and config_text_file_load().

00357 {
00358    return cfg->current;
00359 }

struct ast_config* ast_config_internal_load ( const char *  filename,
struct ast_config cfg 
)

Definition at line 930 of file config.c.

References ast_log(), cfg, config_engine_list, db, extconfig_conf, find_engine(), ast_config::include_level, ast_config_engine::load_func, LOG_WARNING, ast_config::max_include_level, result, table, and text_file_engine.

Referenced by ast_config_load(), config_odbc(), process_text_line(), and read_config_maps().

00931 {
00932    char db[256];
00933    char table[256];
00934    struct ast_config_engine *loader = &text_file_engine;
00935    struct ast_config *result;
00936 
00937    if (cfg->include_level == cfg->max_include_level) {
00938       ast_log(LOG_WARNING, "Maximum Include level (%d) exceeded\n", cfg->max_include_level);
00939       return NULL;
00940    }
00941 
00942    cfg->include_level++;
00943 
00944    if (strcmp(filename, extconfig_conf) && strcmp(filename, "asterisk.conf") && config_engine_list) {
00945       struct ast_config_engine *eng;
00946 
00947       eng = find_engine(filename, db, sizeof(db), table, sizeof(table));
00948 
00949 
00950       if (eng && eng->load_func) {
00951          loader = eng;
00952       } else {
00953          eng = find_engine("global", db, sizeof(db), table, sizeof(table));
00954          if (eng && eng->load_func)
00955             loader = eng;
00956       }
00957    }
00958 
00959    result = loader->load_func(db, table, filename, cfg);
00960 
00961    if (result)
00962       result->include_level--;
00963 
00964    return result;
00965 }

struct ast_config* ast_config_load ( const char *  filename  ) 

Load a config file.

Parameters:
filename path of file to open. If no preceding '/' character, path is considered relative to AST_CONFIG_DIR Create a config structure from a given configuration file.
Returns NULL on error, or an ast_config data structure on success

Definition at line 967 of file config.c.

References ast_config_destroy(), ast_config_internal_load(), ast_config_new(), cfg, and result.

Referenced by adsi_load(), advanced_options(), ast_enum_init(), ast_load_resource(), ast_readconfig(), ast_rtp_reload(), authenticate(), conf_exec(), config_load(), do_reload(), festival_exec(), find_conf(), forward_message(), handle_save_dialplan(), iax_provision_reload(), ind_load_module(), init_logger_chain(), init_manager(), load_config(), load_module(), load_modules(), load_moh_classes(), load_odbc_config(), loadconfigurationfile(), my_load_module(), odbc_load_module(), parse_config(), pbx_load_module(), play_message(), privacy_exec(), read_agent_config(), realtime_directory(), reload_config(), reload_queues(), rpt_master(), set_config(), setup_zap(), and tds_load_module().

00968 {
00969    struct ast_config *cfg;
00970    struct ast_config *result;
00971 
00972    cfg = ast_config_new();
00973    if (!cfg)
00974       return NULL;
00975 
00976    result = ast_config_internal_load(filename, cfg);
00977    if (!result)
00978       ast_config_destroy(cfg);
00979 
00980    return result;
00981 }

struct ast_config* ast_config_new ( void   ) 

Definition at line 326 of file config.c.

References config, malloc, and MAX_INCLUDE_LEVEL.

Referenced by ast_config_load(), read_config_maps(), and realtime_multi_odbc().

00327 {
00328    struct ast_config *config;
00329 
00330    config = malloc(sizeof(*config));
00331    if (config) {
00332       memset(config, 0, sizeof(*config));
00333       config->max_include_level = MAX_INCLUDE_LEVEL;
00334    }
00335 
00336    return config;
00337 }

void ast_config_set_current_category ( struct ast_config cfg,
const struct ast_category cat 
)

Definition at line 361 of file config.c.

References cfg, and ast_config::current.

00362 {
00363    /* cast below is just to silence compiler warning about dropping "const" */
00364    cfg->current = (struct ast_category *) cat;
00365 }

struct ast_variable* ast_load_realtime ( const char *  family,
  ... 
)

Retrieve realtime configuration.

Parameters:
family which family/config to lookup This will use builtin configuration backends to look up a particular entity in realtime and return a variable list of its parameters. Note that unlike the variables in ast_config, the resulting list of variables MUST be fred with ast_free_runtime() as there is no container.

Definition at line 983 of file config.c.

References db, find_engine(), ast_config_engine::realtime_func, and table.

Referenced by cli_load_realtime(), find_user_realtime(), realtime_exec(), realtime_peer(), realtime_switch_common(), and realtime_user().

00984 {
00985    struct ast_config_engine *eng;
00986    char db[256]="";
00987    char table[256]="";
00988    struct ast_variable *res=NULL;
00989    va_list ap;
00990 
00991    va_start(ap, family);
00992    eng = find_engine(family, db, sizeof(db), table, sizeof(table));
00993    if (eng && eng->realtime_func) 
00994       res = eng->realtime_func(db, table, ap);
00995    va_end(ap);
00996 
00997    return res;
00998 }

struct ast_config* ast_load_realtime_multientry ( const char *  family,
  ... 
)

Retrieve realtime configuration.

Parameters:
family which family/config to lookup This will use builtin configuration backends to look up a particular entity in realtime and return a variable list of its parameters. Unlike the ast_load_realtime, this function can return more than one entry and is thus stored inside a taditional ast_config structure rather than just returning a linked list of variables.

Definition at line 1012 of file config.c.

References db, find_engine(), ast_config_engine::realtime_multi_func, and table.

Referenced by realtime_directory(), and realtime_switch_common().

01013 {
01014    struct ast_config_engine *eng;
01015    char db[256]="";
01016    char table[256]="";
01017    struct ast_config *res=NULL;
01018    va_list ap;
01019 
01020    va_start(ap, family);
01021    eng = find_engine(family, db, sizeof(db), table, sizeof(table));
01022    if (eng && eng->realtime_multi_func) 
01023       res = eng->realtime_multi_func(db, table, ap);
01024    va_end(ap);
01025 
01026    return res;
01027 }

AST_MUTEX_DEFINE_STATIC ( config_lock   ) 

int ast_update_realtime ( const char *  family,
const char *  keyfield,
const char *  lookup,
  ... 
)

Update realtime configuration.

Parameters:
family which family/config to be updated
keyfield which field to use as the key
lookup which value to look for in the key field to match the entry. This function is used to update a parameter in realtime configuration space.

Definition at line 1029 of file config.c.

References db, find_engine(), table, and ast_config_engine::update_func.

Referenced by change_password_realtime(), cli_update_realtime(), destroy_association(), realtime_update_exec(), and realtime_update_peer().

01030 {
01031    struct ast_config_engine *eng;
01032    int res = -1;
01033    char db[256]="";
01034    char table[256]="";
01035    va_list ap;
01036 
01037    va_start(ap, lookup);
01038    eng = find_engine(family, db, sizeof(db), table, sizeof(table));
01039    if (eng && eng->update_func) 
01040       res = eng->update_func(db, table, keyfield, lookup, ap);
01041    va_end(ap);
01042 
01043    return res;
01044 }

void ast_variable_append ( struct ast_category category,
struct ast_variable variable 
)

Definition at line 116 of file config.c.

References ast_category::last, ast_variable::next, and ast_category::root.

Referenced by config_odbc(), inherit_category(), move_variables(), process_text_line(), realtime_directory(), and realtime_multi_odbc().

00117 {
00118    if (category->last)
00119       category->last->next = variable;
00120    else
00121       category->root = variable;
00122    category->last = variable;
00123 }

struct ast_variable* ast_variable_browse ( const struct ast_config config,
const char *  category 
)

Goes through variables Somewhat similar in intent as the ast_category_browse. List variables of config file category.

Returns ast_variable list on success, or NULL on failure

Definition at line 136 of file config.c.

References ast_category_get(), config, and ast_category::root.

Referenced by adsi_load(), ast_enum_init(), ast_readconfig(), ast_variable_retrieve(), authenticate(), collect_function_digits(), conf_exec(), do_directory(), find_conf(), handle_save_dialplan(), iax_template_parse(), ind_load_module(), init_logger_chain(), load_config(), load_module(), load_modules(), load_moh_classes(), load_odbc_config(), loadconfigurationfile(), misdn_cfg_init(), odbc_load_module(), osp_build(), parse_config(), pbx_load_module(), process_my_load_module(), read_agent_config(), read_config_maps(), reload_config(), reload_queues(), rpt_master(), set_config(), setup_zap(), sip_notify(), store_config(), and tds_load_module().

00137 {
00138    struct ast_category *cat = NULL;
00139 
00140    if (category && config->last_browse && (config->last_browse->name == category))
00141       cat = config->last_browse;
00142    else
00143       cat = ast_category_get(config, category);
00144 
00145    if (cat)
00146       return cat->root;
00147    else
00148       return NULL;
00149 }

struct ast_variable* ast_variable_new ( const char *  name,
const char *  value 
)

Definition at line 99 of file config.c.

References malloc.

Referenced by apply_outgoing(), astman_get_variables(), build_peer(), build_user(), check_access(), check_user_full(), config_odbc(), launch_page(), process_text_line(), realtime_directory(), realtime_multi_odbc(), realtime_odbc(), and variable_clone().

00100 {
00101    struct ast_variable *variable;
00102 
00103    int length = strlen(name) + strlen(value) + 2 + sizeof(struct ast_variable);
00104    variable = malloc(length);
00105    if (variable) {
00106       memset(variable, 0, length);
00107       variable->name = variable->stuff;
00108       variable->value = variable->stuff + strlen(name) + 1;    
00109       strcpy(variable->name,name);
00110       strcpy(variable->value,value);
00111    }
00112 
00113    return variable;
00114 }

char* ast_variable_retrieve ( const struct ast_config config,
const char *  category,
const char *  variable 
)

Gets a variable.

Parameters:
config which (opened) config to use
category category under which the variable lies
variable which variable you wish to get the data for Goes through a given config file in the given category and searches for the given variable
Returns the variable value on success, or NULL if unable to find it.

Definition at line 151 of file config.c.

References ast_variable_browse(), config, ast_variable::name, ast_variable::next, ast_category::next, ast_category::root, and ast_variable::value.

Referenced by __load_resource(), advanced_options(), ast_rtp_reload(), attempt_reconnect(), authenticate(), config_load(), directory_exec(), do_reload(), festival_exec(), forward_message(), function_ilink(), function_remote(), get_wait_interval(), iax_template_parse(), ind_load_module(), init_logger_chain(), init_manager(), load_config(), load_module(), odbc_load_module(), pbx_load_module(), play_message(), privacy_exec(), process_my_load_module(), read_agent_config(), realtime_directory(), reload_config(), reload_queues(), retrieve_astcfgint(), rpt(), rpt_exec(), rpt_master(), rpt_tele_thread(), set_config(), tds_load_module(), and telem_lookup().

00152 {
00153    struct ast_variable *v;
00154 
00155    if (category) {
00156       for (v = ast_variable_browse(config, category); v; v = v->next) {
00157          if (!strcasecmp(variable, v->name))
00158             return v->value;
00159       }
00160    } else {
00161       struct ast_category *cat;
00162 
00163       for (cat = config->root; cat; cat = cat->next)
00164          for (v = cat->root; v; v = v->next)
00165             if (!strcasecmp(variable, v->name))
00166                return v->value;
00167    }
00168 
00169    return NULL;
00170 }

void ast_variables_destroy ( struct ast_variable var  ) 

Free variable list.

Parameters:
var the linked list of variables to free This function frees a list of variables.

Definition at line 125 of file config.c.

References free, and ast_variable::next.

Referenced by __sip_destroy(), ast_category_destroy(), ast_config_destroy(), ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), build_peer(), destroy_user(), find_user_realtime(), iax2_destroy(), realtime_canmatch(), realtime_exec(), realtime_exists(), realtime_matchmore(), realtime_odbc(), realtime_peer(), realtime_user(), sip_alloc(), sip_destroy_peer(), sip_destroy_user(), and unload_module().

00126 {
00127    struct ast_variable *vn;
00128 
00129    while(v) {
00130       vn = v;
00131       v = v->next;
00132       free(vn);
00133    }
00134 }

static struct ast_category* category_get ( const struct ast_config config,
const char *  category_name,
int  ignored 
) [static]

Definition at line 213 of file config.c.

References config, ast_category::ignored, ast_category::name, and ast_category::next.

Referenced by ast_category_get(), and process_text_line().

00214 {
00215    struct ast_category *cat;
00216 
00217    for (cat = config->root; cat; cat = cat->next) {
00218       if (cat->name == category_name && (ignored || !cat->ignored))
00219          return cat;
00220    }
00221 
00222    for (cat = config->root; cat; cat = cat->next) {
00223       if (!strcasecmp(cat->name, category_name) && (ignored || !cat->ignored))
00224          return cat;
00225    }
00226 
00227    return NULL;
00228 }

static void clear_config_maps ( void   )  [static]

Definition at line 743 of file config.c.

References ast_mutex_lock(), ast_mutex_unlock(), config_maps, free, map, and ast_config_map::next.

Referenced by read_config_maps().

00744 {
00745    struct ast_config_map *map;
00746 
00747    ast_mutex_lock(&config_lock);
00748 
00749    while (config_maps) {
00750       map = config_maps;
00751       config_maps = config_maps->next;
00752       free(map);
00753    }
00754       
00755    ast_mutex_unlock(&config_lock);
00756 }

static int config_command ( int  fd,
int  argc,
char **  argv 
) [static]

Definition at line 1046 of file config.c.

References ast_cli(), ast_mutex_lock(), config_engine_list, config_maps, map, ast_config_engine::name, and ast_config_engine::next.

01047 {
01048    struct ast_config_engine *eng;
01049    struct ast_config_map *map;
01050    
01051    ast_mutex_lock(&config_lock);
01052 
01053    ast_cli(fd, "\n\n");
01054    for (eng = config_engine_list; eng; eng = eng->next) {
01055       ast_cli(fd, "\nConfig Engine: %s\n", eng->name);
01056       for (map = config_maps; map; map = map->next)
01057          if (!strcasecmp(map->driver, eng->name)) {
01058             ast_cli(fd, "===> %s (db=%s, table=%s)\n", map->name, map->database,
01059                map->table ? map->table : map->name);
01060          }
01061    }
01062    ast_cli(fd,"\n\n");
01063    
01064    ast_mutex_unlock(&config_lock);
01065 
01066    return 0;
01067 }

static struct ast_config* config_text_file_load ( const char *  database,
const char *  table,
const char *  filename,
struct ast_config cfg 
) [static]

Definition at line 532 of file config.c.

References ast_config_AST_CONFIG_DIR, ast_config_get_current_category(), ast_log(), ast_strlen_zero(), ast_verbose(), cfg, COMMENT_META, COMMENT_TAG, LOG_DEBUG, LOG_ERROR, LOG_WARNING, MAX_NESTED_COMMENTS, option_debug, option_verbose, process_text_line(), and VERBOSE_PREFIX_2.

00533 {
00534    char fn[256];
00535    char buf[8192];
00536    char *new_buf, *comment_p, *process_buf;
00537    FILE *f;
00538    int lineno=0;
00539    int comment = 0, nest[MAX_NESTED_COMMENTS];
00540    struct ast_category *cat = NULL;
00541    int count = 0;
00542    struct stat statbuf;
00543    
00544    cat = ast_config_get_current_category(cfg);
00545 
00546    if (filename[0] == '/') {
00547       ast_copy_string(fn, filename, sizeof(fn));
00548    } else {
00549       snprintf(fn, sizeof(fn), "%s/%s", (char *)ast_config_AST_CONFIG_DIR, filename);
00550    }
00551 
00552 #ifdef AST_INCLUDE_GLOB
00553    {
00554       int glob_ret;
00555       glob_t globbuf;
00556       globbuf.gl_offs = 0; /* initialize it to silence gcc */
00557 #ifdef SOLARIS
00558       glob_ret = glob(fn, GLOB_NOCHECK, NULL, &globbuf);
00559 #else
00560       glob_ret = glob(fn, GLOB_NOMAGIC|GLOB_BRACE, NULL, &globbuf);
00561 #endif
00562       if (glob_ret == GLOB_NOSPACE)
00563          ast_log(LOG_WARNING,
00564             "Glob Expansion of pattern '%s' failed: Not enough memory\n", fn);
00565       else if (glob_ret  == GLOB_ABORTED)
00566          ast_log(LOG_WARNING,
00567             "Glob Expansion of pattern '%s' failed: Read error\n", fn);
00568       else  {
00569          /* loop over expanded files */
00570          int i;
00571          for (i=0; i<globbuf.gl_pathc; i++) {
00572             ast_copy_string(fn, globbuf.gl_pathv[i], sizeof(fn));
00573 #endif
00574    do {
00575       if (stat(fn, &statbuf))
00576          continue;
00577 
00578       if (!S_ISREG(statbuf.st_mode)) {
00579          ast_log(LOG_WARNING, "'%s' is not a regular file, ignoring\n", fn);
00580          continue;
00581       }
00582       if ((option_verbose > 1) && !option_debug) {
00583          ast_verbose(VERBOSE_PREFIX_2 "Parsing '%s': ", fn);
00584          fflush(stdout);
00585       }
00586       if (!(f = fopen(fn, "r"))) {
00587          if (option_debug)
00588             ast_log(LOG_DEBUG, "No file to parse: %s\n", fn);
00589          else if (option_verbose > 1)
00590             ast_verbose( "Not found (%s)\n", strerror(errno));
00591          continue;
00592       }
00593       count++;
00594       if (option_debug)
00595          ast_log(LOG_DEBUG, "Parsing %s\n", fn);
00596       else if (option_verbose > 1)
00597          ast_verbose("Found\n");
00598       while(!feof(f)) {
00599          lineno++;
00600          if (fgets(buf, sizeof(buf), f)) {
00601             new_buf = buf;
00602             if (comment)
00603                process_buf = NULL;
00604             else
00605                process_buf = buf;
00606             while ((comment_p = strchr(new_buf, COMMENT_META))) {
00607                if ((comment_p > new_buf) && (*(comment_p-1) == '\\')) {
00608                   /* Yuck, gotta memmove */
00609                   memmove(comment_p - 1, comment_p, strlen(comment_p) + 1);
00610                   new_buf = comment_p;
00611                } else if(comment_p[1] == COMMENT_TAG && comment_p[2] == COMMENT_TAG && (comment_p[3] != '-')) {
00612                   /* Meta-Comment start detected ";--" */
00613                   if (comment < MAX_NESTED_COMMENTS) {
00614                      *comment_p = '\0';
00615                      new_buf = comment_p + 3;
00616                      comment++;
00617                      nest[comment-1] = lineno;
00618                   } else {
00619                      ast_log(LOG_ERROR, "Maximum nest limit of %d reached.\n", MAX_NESTED_COMMENTS);
00620                   }
00621                } else if ((comment_p >= new_buf + 2) &&
00622                      (*(comment_p - 1) == COMMENT_TAG) &&
00623                      (*(comment_p - 2) == COMMENT_TAG)) {
00624                   /* Meta-Comment end detected */
00625                   comment--;
00626                   new_buf = comment_p + 1;
00627                   if (!comment) {
00628                      /* Back to non-comment now */
00629                      if (process_buf) {
00630                         /* Actually have to move what's left over the top, then continue */
00631                         char *oldptr;
00632                         oldptr = process_buf + strlen(process_buf);
00633                         memmove(oldptr, new_buf, strlen(new_buf) + 1);
00634                         new_buf = oldptr;
00635                      } else
00636                         process_buf = new_buf;
00637                   }
00638                } else {
00639                   if (!comment) {
00640                      /* If ; is found, and we are not nested in a comment, 
00641                         we immediately stop all comment processing */
00642                      *comment_p = '\0'; 
00643                      new_buf = comment_p;
00644                   } else
00645                      new_buf = comment_p + 1;
00646                }
00647             }
00648             if (process_buf) {
00649                char *buf = ast_strip(process_buf);
00650                if (!ast_strlen_zero(buf)) {
00651                   if (process_text_line(cfg, &cat, buf, lineno, filename)) {
00652                      cfg = NULL;
00653                      break;
00654                   }
00655                }
00656             }
00657          }
00658       }
00659       fclose(f);     
00660    } while(0);
00661    if (comment) {
00662       ast_log(LOG_WARNING,"Unterminated comment detected beginning on line %d\n", nest[comment]);
00663    }
00664 #ifdef AST_INCLUDE_GLOB
00665                if (!cfg)
00666                   break;
00667             }
00668             globfree(&globbuf);
00669          }
00670       }
00671 #endif
00672    if (count == 0)
00673       return NULL;
00674 
00675    return cfg;
00676 }

int config_text_file_save ( const char *  configfile,
const struct ast_config cfg,
const char *  generator 
)

Definition at line 678 of file config.c.

References ast_config_AST_CONFIG_DIR, ast_verbose(), cfg, ast_category::name, ast_category::next, option_debug, option_verbose, ast_config::root, ast_category::root, t, var, and VERBOSE_PREFIX_2.

00679 {
00680    FILE *f;
00681    char fn[256];
00682    char date[256]="";
00683    time_t t;
00684    struct ast_variable *var;
00685    struct ast_category *cat;
00686    int blanklines = 0;
00687 
00688    if (configfile[0] == '/') {
00689       ast_copy_string(fn, configfile, sizeof(fn));
00690    } else {
00691       snprintf(fn, sizeof(fn), "%s/%s", ast_config_AST_CONFIG_DIR, configfile);
00692    }
00693    time(&t);
00694    ast_copy_string(date, ctime(&t), sizeof(date));
00695 #ifdef __CYGWIN__ 
00696    if ((f = fopen(fn, "w+"))) {
00697 #else
00698    if ((f = fopen(fn, "w"))) {
00699 #endif       
00700       if ((option_verbose > 1) && !option_debug)
00701          ast_verbose(  VERBOSE_PREFIX_2 "Saving '%s': ", fn);
00702       fprintf(f, ";!\n");
00703       fprintf(f, ";! Automatically generated configuration file\n");
00704       fprintf(f, ";! Filename: %s (%s)\n", configfile, fn);
00705       fprintf(f, ";! Generator: %s\n", generator);
00706       fprintf(f, ";! Creation Date: %s", date);
00707       fprintf(f, ";!\n");
00708       cat = cfg->root;
00709       while(cat) {
00710          /* Dump section with any appropriate comment */
00711          fprintf(f, "[%s]\n", cat->name);
00712          var = cat->root;
00713          while(var) {
00714             if (var->sameline) 
00715                fprintf(f, "%s %s %s  ; %s\n", var->name, (var->object ? "=>" : "="), var->value, var->sameline->cmt);
00716             else  
00717                fprintf(f, "%s %s %s\n", var->name, (var->object ? "=>" : "="), var->value);
00718             if (var->blanklines) {
00719                blanklines = var->blanklines;
00720                while (blanklines--)
00721                   fprintf(f, "\n");
00722             }
00723                
00724             var = var->next;
00725          }
00726 #if 0
00727          /* Put an empty line */
00728          fprintf(f, "\n");
00729 #endif
00730          cat = cat->next;
00731       }
00732    } else {
00733       if (option_debug)
00734          printf("Unable to open for writing: %s\n", fn);
00735       else if (option_verbose > 1)
00736          printf( "Unable to write (%s)", strerror(errno));
00737       return -1;
00738    }
00739    fclose(f);
00740    return 0;
00741 }

static struct ast_config_engine* find_engine ( const char *  family,
char *  database,
int  dbsiz,
char *  table,
int  tabsiz 
) [static]

Definition at line 891 of file config.c.

References ast_mutex_lock(), config_maps, and map.

Referenced by ast_check_realtime(), ast_config_internal_load(), ast_load_realtime(), ast_load_realtime_multientry(), and ast_update_realtime().

00892 {
00893    struct ast_config_engine *eng, *ret = NULL;
00894    struct ast_config_map *map;
00895 
00896    ast_mutex_lock(&config_lock);
00897 
00898    for (map = config_maps; map; map = map->next) {
00899       if (!strcasecmp(family, map->name)) {
00900          if (database)
00901             ast_copy_string(database, map->database, dbsiz);
00902          if (table)
00903             ast_copy_string(table, map->table ? map->table : family, tabsiz);
00904          break;
00905       }
00906    }
00907 
00908    /* Check if the required driver (engine) exist */
00909    if (map) {
00910       for (eng = config_engine_list; !ret && eng; eng = eng->next) {
00911          if (!strcasecmp(eng->name, map->driver))
00912             ret = eng;
00913       }
00914    }
00915 
00916    ast_mutex_unlock(&config_lock);
00917    
00918    /* if we found a mapping, but the engine is not available, then issue a warning */
00919    if (map && !ret)
00920       ast_log(LOG_WARNING, "Realtime mapping for '%s' found to engine '%s', but the engine is not available\n", map->name, map->driver);
00921 
00922    return ret;
00923 }

static void inherit_category ( struct ast_category new,
const struct ast_category base 
) [static]

Definition at line 313 of file config.c.

References ast_variable_append(), ast_category::root, var, and variable_clone().

Referenced by process_text_line().

00314 {
00315    struct ast_variable *var;
00316 
00317    for (var = base->root; var; var = var->next) {
00318       struct ast_variable *v;
00319       
00320       v = variable_clone(var);
00321       if (v)
00322          ast_variable_append(new, v);
00323    }
00324 }

static void move_variables ( struct ast_category old,
struct ast_category new 
) [static]

Definition at line 186 of file config.c.

References ast_variable_append(), ast_variable::next, ast_category::root, and var.

Referenced by process_text_line().

00187 {
00188    struct ast_variable *var;
00189    struct ast_variable *next;
00190 
00191    next = old->root;
00192    old->root = NULL;
00193    for (var = next; var; var = next) {
00194       next = var->next;
00195       var->next = NULL;
00196       ast_variable_append(new, var);
00197    }
00198 }

static struct ast_category* next_available_category ( struct ast_category cat  )  [static]

Definition at line 256 of file config.c.

References ast_category::ignored, and ast_category::next.

Referenced by ast_category_browse().

00257 {
00258    for (; cat && cat->ignored; cat = cat->next);
00259 
00260    return cat;
00261 }

static int process_text_line ( struct ast_config cfg,
struct ast_category **  cat,
char *  buf,
int  lineno,
const char *  configfile 
) [static]

Definition at line 367 of file config.c.

References ast_category_append(), ast_category_destroy(), ast_category_new(), ast_config_destroy(), ast_config_internal_load(), ast_log(), ast_safe_system(), ast_strlen_zero(), ast_variable_append(), ast_variable_new(), ast_variable::blanklines, category_get(), cfg, inherit_category(), ast_variable::lineno, LOG_WARNING, move_variables(), ast_variable::object, option_exec_includes, and strsep().

Referenced by config_text_file_load().

00368 {
00369    char *c;
00370    char *cur = buf;
00371    struct ast_variable *v;
00372    char cmd[512], exec_file[512];
00373    int object, do_exec, do_include;
00374 
00375    /* Actually parse the entry */
00376    if (cur[0] == '[') {
00377       struct ast_category *newcat = NULL;
00378       char *catname;
00379 
00380       /* A category header */
00381       c = strchr(cur, ']');
00382       if (!c) {
00383          ast_log(LOG_WARNING, "parse error: no closing ']', line %d of %s\n", lineno, configfile);
00384          return -1;
00385       }
00386       *c++ = '\0';
00387       cur++;
00388       if (*c++ != '(')
00389          c = NULL;
00390       catname = cur;
00391       *cat = newcat = ast_category_new(catname);
00392       if (!newcat) {
00393          ast_log(LOG_WARNING, "Out of memory, line %d of %s\n", lineno, configfile);
00394          return -1;
00395       }
00396       /* If there are options or categories to inherit from, process them now */
00397       if (c) {
00398          if (!(cur = strchr(c, ')'))) {
00399             ast_log(LOG_WARNING, "parse error: no closing ')', line %d of %s\n", lineno, configfile);
00400             return -1;
00401          }
00402          *cur = '\0';
00403          while ((cur = strsep(&c, ","))) {
00404             if (!strcasecmp(cur, "!")) {
00405                (*cat)->ignored = 1;
00406             } else if (!strcasecmp(cur, "+")) {
00407                *cat = category_get(cfg, catname, 1);
00408                if (!*cat) {
00409                   ast_config_destroy(cfg);
00410                   if (newcat)
00411                      ast_category_destroy(newcat);
00412                   ast_log(LOG_WARNING, "Category addition requested, but category '%s' does not exist, line %d of %s\n", catname, lineno, configfile);
00413                   return -1;
00414                }
00415                if (newcat) {
00416                   move_variables(newcat, *cat);
00417                   ast_category_destroy(newcat);
00418                   newcat = NULL;
00419                }
00420             } else {
00421                struct ast_category *base;
00422             
00423                base = category_get(cfg, cur, 1);
00424                if (!base) {
00425                   ast_log(LOG_WARNING, "Inheritance requested, but category '%s' does not exist, line %d of %s\n", cur, lineno, configfile);
00426                   return -1;
00427                }
00428                inherit_category(*cat, base);
00429             }
00430          }
00431       }
00432       if (newcat)
00433          ast_category_append(cfg, *cat);
00434    } else if (cur[0] == '#') {
00435       /* A directive */
00436       cur++;
00437       c = cur;
00438       while(*c && (*c > 32)) c++;
00439       if (*c) {
00440          *c = '\0';
00441          c++;
00442          /* Find real argument */
00443          while(*c  && (*c < 33)) c++;
00444          if (!*c)
00445             c = NULL;
00446       } else 
00447          c = NULL;
00448       do_include = !strcasecmp(cur, "include");
00449       if(!do_include)
00450          do_exec = !strcasecmp(cur, "exec");
00451       else
00452          do_exec = 0;
00453       if (do_exec && !option_exec_includes) {
00454          ast_log(LOG_WARNING, "Cannot perform #exec unless execincludes option is enabled in asterisk.conf (options section)!\n");
00455          do_exec = 0;
00456       }
00457       if (do_include || do_exec) {
00458          if (c) {
00459             /* Strip off leading and trailing "'s and <>'s */
00460             while((*c == '<') || (*c == '>') || (*c == '\"')) c++;
00461             /* Get rid of leading mess */
00462             cur = c;
00463             while (!ast_strlen_zero(cur)) {
00464                c = cur + strlen(cur) - 1;
00465                if ((*c == '>') || (*c == '<') || (*c == '\"'))
00466                   *c = '\0';
00467                else
00468                   break;
00469             }
00470             /* #exec </path/to/executable>
00471                We create a tmp file, then we #include it, then we delete it. */
00472             if (do_exec) { 
00473                snprintf(exec_file, sizeof(exec_file), "/var/tmp/exec.%d.%ld", (int)time(NULL), (long)pthread_self());
00474                snprintf(cmd, sizeof(cmd), "%s > %s 2>&1", cur, exec_file);
00475                ast_safe_system(cmd);
00476                cur = exec_file;
00477             } else
00478                exec_file[0] = '\0';
00479             /* A #include */
00480             do_include = ast_config_internal_load(cur, cfg) ? 1 : 0;
00481             if(!ast_strlen_zero(exec_file))
00482                unlink(exec_file);
00483             if(!do_include)
00484                return 0;
00485 
00486          } else {
00487             ast_log(LOG_WARNING, "Directive '#%s' needs an argument (%s) at line %d of %s\n", 
00488                   do_exec ? "exec" : "include",
00489                   do_exec ? "/path/to/executable" : "filename",
00490                   lineno,
00491                   configfile);
00492          }
00493       }
00494       else 
00495          ast_log(LOG_WARNING, "Unknown directive '%s' at line %d of %s\n", cur, lineno, configfile);
00496    } else {
00497       /* Just a line (variable = value) */
00498       if (!*cat) {
00499          ast_log(LOG_WARNING,
00500             "parse error: No category context for line %d of %s\n", lineno, configfile);
00501          return -1;
00502       }
00503       c = strchr(cur, '=');
00504       if (c) {
00505          *c = 0;
00506          c++;
00507          /* Ignore > in => */
00508          if (*c== '>') {
00509             object = 1;
00510             c++;
00511          } else
00512             object = 0;
00513          v = ast_variable_new(ast_strip(cur), ast_strip(c));
00514          if (v) {
00515             v->lineno = lineno;
00516             v->object = object;
00517             /* Put and reset comments */
00518             v->blanklines = 0;
00519             ast_variable_append(*cat, v);
00520          } else {
00521             ast_log(LOG_WARNING, "Out of memory, line %d\n", lineno);
00522             return -1;
00523          }
00524       } else {
00525          ast_log(LOG_WARNING, "No '=' (equal sign) in line %d of %s\n", lineno, configfile);
00526       }
00527 
00528    }
00529    return 0;
00530 }

void read_config_maps ( void   ) 

Definition at line 795 of file config.c.

References append_mapping(), ast_config_destroy(), ast_config_internal_load(), ast_config_new(), ast_log(), ast_variable_browse(), clear_config_maps(), config, extconfig_conf, LOG_WARNING, ast_config::max_include_level, ast_variable::name, ast_variable::next, strsep(), table, and ast_variable::value.

Referenced by ast_module_reload(), and main().

00796 {
00797    struct ast_config *config, *configtmp;
00798    struct ast_variable *v;
00799    char *driver, *table, *database, *stringp;
00800 
00801    clear_config_maps();
00802 
00803    configtmp = ast_config_new();
00804    configtmp->max_include_level = 1;
00805    config = ast_config_internal_load(extconfig_conf, configtmp);
00806    if (!config) {
00807       ast_config_destroy(configtmp);
00808       return;
00809    }
00810 
00811    for (v = ast_variable_browse(config, "settings"); v; v = v->next) {
00812       stringp = v->value;
00813       driver = strsep(&stringp, ",");
00814       database = strsep(&stringp, ",");
00815       table = strsep(&stringp, ",");
00816          
00817       if (!strcmp(v->name, extconfig_conf)) {
00818          ast_log(LOG_WARNING, "Cannot bind '%s'!\n", extconfig_conf);
00819          continue;
00820       }
00821 
00822       if (!strcmp(v->name, "asterisk.conf")) {
00823          ast_log(LOG_WARNING, "Cannot bind 'asterisk.conf'!\n");
00824          continue;
00825       }
00826 
00827       if (!strcmp(v->name, "logger.conf")) {
00828          ast_log(LOG_WARNING, "Cannot bind 'logger.conf'!\n");
00829          continue;
00830       }
00831 
00832       if (!driver || !database)
00833          continue;
00834       if (!strcasecmp(v->name, "sipfriends")) {
00835          ast_log(LOG_WARNING, "The 'sipfriends' table is obsolete, update your config to use sipusers and sippeers, though they can point to the same table.\n");
00836          append_mapping("sipusers", driver, database, table ? table : "sipfriends");
00837          append_mapping("sippeers", driver, database, table ? table : "sipfriends");
00838       } else if (!strcasecmp(v->name, "iaxfriends")) {
00839          ast_log(LOG_WARNING, "The 'iaxfriends' table is obsolete, update your config to use iaxusers and iaxpeers, though they can point to the same table.\n");
00840          append_mapping("iaxusers", driver, database, table ? table : "iaxfriends");
00841          append_mapping("iaxpeers", driver, database, table ? table : "iaxfriends");
00842       } else 
00843          append_mapping(v->name, driver, database, table);
00844    }
00845       
00846    ast_config_destroy(config);
00847 }

int register_config_cli ( void   ) 

Definition at line 1077 of file config.c.

References ast_cli_register(), and config_command_struct.

Referenced by main().

01078 {
01079    return ast_cli_register(&config_command_struct);
01080 }

static struct ast_variable* variable_clone ( const struct ast_variable old  )  [static]

Definition at line 172 of file config.c.

References ast_variable_new(), ast_variable::blanklines, ast_variable::lineno, ast_variable::name, ast_variable::object, and ast_variable::value.

Referenced by inherit_category().

00173 {
00174    struct ast_variable *new = ast_variable_new(old->name, old->value);
00175 
00176    if (new) {
00177       new->lineno = old->lineno;
00178       new->object = old->object;
00179       new->blanklines = old->blanklines;
00180       /* TODO: clone comments? */
00181    }
00182 
00183    return new;
00184 }


Variable Documentation

struct ast_cli_entry config_command_struct [static]

Initial value:

 {
   { "show", "config", "mappings", NULL }, config_command, "Show Config mappings (file names to config engines)", show_config_help, NULL
}

Definition at line 1073 of file config.c.

Referenced by register_config_cli().

struct ast_config_engine* config_engine_list [static]

Definition at line 73 of file config.c.

Referenced by ast_config_engine_deregister(), ast_config_engine_register(), ast_config_internal_load(), and config_command().

struct ast_config_map * config_maps [static]

Referenced by append_mapping(), clear_config_maps(), config_command(), and find_engine().

char* extconfig_conf = "extconfig.conf" [static]

Definition at line 61 of file config.c.

Referenced by ast_config_internal_load(), and read_config_maps().

char show_config_help[] [static]

Initial value:

   "Usage: show config mappings\n"
   "  Shows the filenames to config engines.\n"

Definition at line 1069 of file config.c.

struct ast_config_engine text_file_engine [static]

Initial value:

 {
   .name = "text",
   .load_func = config_text_file_load,
}

Definition at line 925 of file config.c.

Referenced by ast_config_internal_load().


Generated on Sat Sep 16 07:28:17 2006 for Asterisk - the Open Source PBX by  doxygen 1.4.7