Wed Oct 28 15:48:45 2009

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"

Include dependency graph for config.c:

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)
struct 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.
struct ast_categoryast_category_get (const struct ast_config *config, const char *category_name)
 Retrieve a category if it exists.
struct 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.
struct ast_categoryast_config_get_current_category (const struct ast_config *cfg)
struct ast_configast_config_internal_load (const char *filename, struct ast_config *cfg)
struct ast_configast_config_load (const char *filename)
 Load a config file.
struct ast_configast_config_new (void)
void ast_config_set_current_category (struct ast_config *cfg, const struct ast_category *cat)
struct ast_variableast_load_realtime (const char *family,...)
 Retrieve realtime configuration.
struct 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)
struct 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.
struct 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 763 of file config.c.

References ast_verbose(), config_maps, ast_config_map::database, ast_config_map::driver, malloc, map, ast_config_map::name, ast_config_map::next, option_verbose, ast_config_map::stuff, ast_config_map::table, and VERBOSE_PREFIX_2.

Referenced by read_config_maps().

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

void ast_category_append ( struct ast_config config,
struct ast_category category 
)

Definition at line 242 of file config.c.

References ast_config::current, ast_config::last, ast_category::next, and ast_config::root.

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

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

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 265 of file config.c.

References ast_config::last_browse, ast_category::name, ast_category::next, next_available_category(), and ast_config::root.

Referenced by authenticate(), complete_sipnotify(), config_load(), find_queue_by_name_rt(), 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().

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

void ast_category_destroy ( struct ast_category cat  ) 

Definition at line 252 of file config.c.

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

Referenced by process_text_line(), and realtime_multi_odbc().

00253 {
00254    ast_variables_destroy(cat->root);
00255    free(cat);
00256 }

struct ast_variable* ast_category_detach_variables ( struct ast_category cat  )  [read]

Definition at line 300 of file config.c.

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

Referenced by realtime_switch_common(), and vm_forwardoptions().

00301 {
00302    struct ast_variable *v;
00303 
00304    v = cat->root;
00305    cat->root = NULL;
00306    cat->last = NULL;
00307 
00308    return v;
00309 }

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 237 of file config.c.

References ast_category_get().

00238 {
00239    return !!ast_category_get(config, category_name);
00240 }

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

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 232 of file config.c.

References category_get().

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

00233 {
00234    return category_get(config, category_name, 0);
00235 }

struct ast_category* ast_category_new ( const char *  name  )  [read]

Definition at line 202 of file config.c.

References malloc, and ast_category::name.

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

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

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

Definition at line 311 of file config.c.

References ast_category::name.

Referenced by realtime_multi_odbc().

00312 {
00313    ast_copy_string(cat->name, name, sizeof(cat->name));
00314 }

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 1008 of file config.c.

References find_engine().

Referenced by sip_show_settings().

01009 {
01010    struct ast_config_engine *eng;
01011 
01012    eng = find_engine(family, NULL, 0, NULL, 0);
01013    if (eng)
01014       return 1;
01015    return 0;
01016 
01017 }

void ast_config_destroy ( struct ast_config config  ) 

int ast_config_engine_deregister ( struct ast_config_engine del  ) 

Deegister config engine.

Definition at line 873 of file config.c.

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

Referenced by unload_module().

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

int ast_config_engine_register ( struct ast_config_engine new  ) 

Register config engine.

Definition at line 854 of file config.c.

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

Referenced by load_module().

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

struct ast_category* ast_config_get_current_category ( const struct ast_config cfg  )  [read]

Definition at line 359 of file config.c.

References ast_config::current.

Referenced by config_odbc(), and config_text_file_load().

00360 {
00361    return cfg->current;
00362 }

struct ast_config* ast_config_internal_load ( const char *  filename,
struct ast_config cfg 
) [read]

Definition at line 935 of file config.c.

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

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

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

struct ast_config* ast_config_load ( const char *  filename  )  [read]

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 974 of file config.c.

References ast_config_destroy(), ast_config_internal_load(), ast_config_new(), 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(), 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(), tds_load_module(), and vm_forwardoptions().

00975 {
00976    struct ast_config *cfg;
00977    struct ast_config *result;
00978 
00979    cfg = ast_config_new();
00980    if (!cfg)
00981       return NULL;
00982 
00983    result = ast_config_internal_load(filename, cfg);
00984    if (!result)
00985       ast_config_destroy(cfg);
00986 
00987    return result;
00988 }

struct ast_config* ast_config_new ( void   )  [read]

Definition at line 329 of file config.c.

References config, malloc, MAX_INCLUDE_LEVEL, and ast_config::max_include_level.

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

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

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

Definition at line 364 of file config.c.

References ast_config::current.

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

struct ast_variable* ast_load_realtime ( const char *  family,
  ... 
) [read]

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 990 of file config.c.

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

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

00991 {
00992    struct ast_config_engine *eng;
00993    char db[256]="";
00994    char table[256]="";
00995    struct ast_variable *res=NULL;
00996    va_list ap;
00997 
00998    va_start(ap, family);
00999    eng = find_engine(family, db, sizeof(db), table, sizeof(table));
01000    if (eng && eng->realtime_func) 
01001       res = eng->realtime_func(db, table, ap);
01002    va_end(ap);
01003 
01004    return res;
01005 }

struct ast_config* ast_load_realtime_multientry ( const char *  family,
  ... 
) [read]

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 1019 of file config.c.

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

Referenced by load_realtime_queue(), realtime_directory(), and realtime_switch_common().

01020 {
01021    struct ast_config_engine *eng;
01022    char db[256]="";
01023    char table[256]="";
01024    struct ast_config *res=NULL;
01025    va_list ap;
01026 
01027    va_start(ap, family);
01028    eng = find_engine(family, db, sizeof(db), table, sizeof(table));
01029    if (eng && eng->realtime_multi_func) 
01030       res = eng->realtime_multi_func(db, table, ap);
01031    va_end(ap);
01032 
01033    return res;
01034 }

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

01037 {
01038    struct ast_config_engine *eng;
01039    int res = -1;
01040    char db[256]="";
01041    char table[256]="";
01042    va_list ap;
01043 
01044    va_start(ap, lookup);
01045    eng = find_engine(family, db, sizeof(db), table, sizeof(table));
01046    if (eng && eng->update_func) 
01047       res = eng->update_func(db, table, keyfield, lookup, ap);
01048    va_end(ap);
01049 
01050    return res;
01051 }

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

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

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

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 138 of file config.c.

References ast_category_get(), ast_config::last_browse, ast_category::name, 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().

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

struct ast_variable* ast_variable_new ( const char *  name,
const char *  value 
) [read]

Definition at line 99 of file config.c.

References malloc, ast_variable::name, ast_variable::stuff, and ast_variable::value.

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

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 153 of file config.c.

References ast_variable_browse(), ast_variable::name, ast_category::next, ast_variable::next, ast_category::root, ast_config::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(), find_queue_by_name_rt(), function_ilink(), function_remote(), get_wait_interval(), iax_template_parse(), ind_load_module(), init_logger_chain(), init_manager(), load_config(), load_module(), load_modules(), 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(), telem_lookup(), and vm_forwardoptions().

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

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 127 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(), load_realtime_queue(), pvt_destructor(), realtime_canmatch(), realtime_exec(), realtime_exists(), realtime_matchmore(), realtime_odbc(), realtime_peer(), realtime_user(), sip_alloc(), sip_destroy_peer(), and sip_destroy_user().

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

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

Definition at line 215 of file config.c.

References ast_category::ignored, ast_category::name, ast_category::next, and ast_config::root.

Referenced by ast_category_get(), and process_text_line().

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

static void clear_config_maps ( void   )  [static]

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

00749 {
00750    struct ast_config_map *map;
00751 
00752    ast_mutex_lock(&config_lock);
00753 
00754    while (config_maps) {
00755       map = config_maps;
00756       config_maps = config_maps->next;
00757       free(map);
00758    }
00759       
00760    ast_mutex_unlock(&config_lock);
00761 }

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

Definition at line 1053 of file config.c.

References ast_cli(), ast_mutex_lock(), ast_mutex_unlock(), config_maps, ast_config_map::database, ast_config_map::driver, map, ast_config_map::name, ast_config_engine::name, ast_config_map::next, ast_config_engine::next, and ast_config_map::table.

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

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

Definition at line 534 of file config.c.

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

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

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

Definition at line 680 of file config.c.

References ast_config_AST_CONFIG_DIR, ast_log(), ast_verbose(), ast_variable::blanklines, ast_comment::cmt, LOG_DEBUG, ast_variable::name, ast_category::name, ast_category::next, ast_variable::next, ast_variable::object, option_debug, option_verbose, ast_category::root, ast_config::root, ast_variable::sameline, t, ast_variable::value, var, and VERBOSE_PREFIX_2.

Referenced by vm_forwardoptions().

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

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

Definition at line 896 of file config.c.

References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), config_maps, ast_config_map::database, ast_config_map::driver, LOG_WARNING, map, ast_config_map::name, ast_config_engine::next, ast_config_map::next, and ast_config_map::table.

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

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

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

Definition at line 316 of file config.c.

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

Referenced by process_text_line().

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

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

Definition at line 188 of file config.c.

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

Referenced by process_text_line().

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

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

Definition at line 258 of file config.c.

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

Referenced by ast_category_browse().

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

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

Definition at line 370 of file config.c.

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

Referenced by config_text_file_load().

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

void read_config_maps ( void   ) 

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

00801 {
00802    struct ast_config *config, *configtmp;
00803    struct ast_variable *v;
00804    char *driver, *table, *database, *stringp;
00805 
00806    clear_config_maps();
00807 
00808    configtmp = ast_config_new();
00809    configtmp->max_include_level = 1;
00810    config = ast_config_internal_load(extconfig_conf, configtmp);
00811    if (!config) {
00812       ast_config_destroy(configtmp);
00813       return;
00814    }
00815 
00816    for (v = ast_variable_browse(config, "settings"); v; v = v->next) {
00817       stringp = v->value;
00818       driver = strsep(&stringp, ",");
00819       database = strsep(&stringp, ",");
00820       table = strsep(&stringp, ",");
00821          
00822       if (!strcmp(v->name, extconfig_conf)) {
00823          ast_log(LOG_WARNING, "Cannot bind '%s'!\n", extconfig_conf);
00824          continue;
00825       }
00826 
00827       if (!strcmp(v->name, "asterisk.conf")) {
00828          ast_log(LOG_WARNING, "Cannot bind 'asterisk.conf'!\n");
00829          continue;
00830       }
00831 
00832       if (!strcmp(v->name, "logger.conf")) {
00833          ast_log(LOG_WARNING, "Cannot bind 'logger.conf'!\n");
00834          continue;
00835       }
00836 
00837       if (!driver || !database)
00838          continue;
00839       if (!strcasecmp(v->name, "sipfriends")) {
00840          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");
00841          append_mapping("sipusers", driver, database, table ? table : "sipfriends");
00842          append_mapping("sippeers", driver, database, table ? table : "sipfriends");
00843       } else if (!strcasecmp(v->name, "iaxfriends")) {
00844          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");
00845          append_mapping("iaxusers", driver, database, table ? table : "iaxfriends");
00846          append_mapping("iaxpeers", driver, database, table ? table : "iaxfriends");
00847       } else 
00848          append_mapping(v->name, driver, database, table);
00849    }
00850       
00851    ast_config_destroy(config);
00852 }

int register_config_cli ( void   ) 

Definition at line 1084 of file config.c.

References ast_cli_register().

Referenced by main().

01085 {
01086    return ast_cli_register(&config_command_struct);
01087 }

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

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

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


Variable Documentation

Initial value:

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

Definition at line 1080 of file config.c.

Definition at line 73 of file config.c.

struct ast_config_map * config_maps [static]

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

Definition at line 61 of file config.c.

char show_config_help[] [static]

Initial value:

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

Definition at line 1076 of file config.c.

Initial value:

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

Definition at line 930 of file config.c.


Generated on Wed Oct 28 15:48:45 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.6