Thu Oct 11 06:43:21 2012

Asterisk developer's documentation


config.c File Reference

Configuration File Parser. More...

#include "asterisk.h"
#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/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_category::template_instance_list
struct  ast_category_template_instance
struct  ast_comment
 Structure to keep comments for rewriting configuration files. More...
struct  ast_config
struct  ast_config_map

Defines

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

Functions

static struct ast_commentALLOC_COMMENT (const char *buffer)
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.
int ast_category_delete (struct ast_config *cfg, char *category)
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)
struct ast_variableast_category_root (struct ast_config *config, char *cat)
 returns the root ast_variable of a config
int ast_check_realtime (const char *family)
 Check if realtime engine is configured for family.
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, int withcomments)
struct ast_configast_config_load (const char *filename)
 Load a config file.
struct ast_configast_config_load_with_comments (const char *filename)
struct ast_configast_config_new (void)
const char * ast_config_option (struct ast_config *cfg, const char *cat, const char *var)
void ast_config_set_current_category (struct ast_config *cfg, const struct ast_category *cat)
static void ast_destroy_comment (struct ast_comment **comment)
static void ast_destroy_comments (struct ast_category *cat)
static void ast_destroy_template_list (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.
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.
int ast_variable_delete (struct ast_category *category, char *variable, char *match)
struct ast_variableast_variable_new (const char *name, const char *value)
const char * ast_variable_retrieve (const struct ast_config *config, const char *category, const char *variable)
 Gets a variable.
int ast_variable_update (struct ast_category *category, const char *variable, const char *value, const char *match, unsigned int object)
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 CB_ADD (char **comment_buffer, int *comment_buffer_size, char *str)
static void CB_ADD_LEN (char **comment_buffer, int *comment_buffer_size, char *str, int len)
static void CB_INIT (char **comment_buffer, int *comment_buffer_size, char **lline_buffer, int *lline_buffer_size)
static void CB_RESET (char **comment_buffer, char **lline_buffer)
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 withcomments)
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)
 Find realtime engine for realtime family.
static void inherit_category (struct ast_category *new, const struct ast_category *base)
static void LLB_ADD (char **lline_buffer, int *lline_buffer_size, char *str)
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, int withcomments, char **comment_buffer, int *comment_buffer_size, char **lline_buffer, int *lline_buffer_size)
int read_config_maps (void)
int register_config_cli ()
static struct ast_variablevariable_clone (const struct ast_variable *old)

Variables

static struct ast_cli_entry cli_config []
static struct ast_cli_entry cli_show_config_mappings_deprecated
static struct ast_config_engineconfig_engine_list
static ast_mutex_t config_lock = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER )
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.

Author:
Mark Spencer <markster@digium.com>
Includes the Asterisk Realtime API - ARA See doc/realtime.txt and doc/extconfig.txt

Definition in file config.c.


Define Documentation

#define AST_INCLUDE_GLOB   1

Definition at line 40 of file config.c.

#define CB_INCR   250

Definition at line 69 of file config.c.

Referenced by CB_ADD(), CB_ADD_LEN(), CB_INIT(), and LLB_ADD().

#define COMMENT_END   "--;"

Definition at line 56 of file config.c.

#define COMMENT_META   ';'

Definition at line 57 of file config.c.

Referenced by config_text_file_load().

#define COMMENT_START   ";--"

Definition at line 55 of file config.c.

#define COMMENT_TAG   '-'

Definition at line 58 of file config.c.

Referenced by config_text_file_load().

#define MAX_INCLUDE_LEVEL   10

Definition at line 157 of file config.c.

Referenced by ast_config_new().

#define MAX_NESTED_COMMENTS   128

Definition at line 54 of file config.c.

Referenced by config_text_file_load().


Function Documentation

static struct ast_comment* ALLOC_COMMENT ( const char *  buffer  )  [static, read]

Definition at line 137 of file config.c.

References ast_calloc, and ast_comment::cmt.

Referenced by process_text_line().

00138 { 
00139    struct ast_comment *x = ast_calloc(1,sizeof(struct ast_comment)+strlen(buffer)+1);
00140    strcpy(x->cmt, buffer);
00141    return x;
00142 }

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

Definition at line 1161 of file config.c.

References ast_calloc, ast_verbose(), config_maps, ast_config_map::database, ast_config_map::driver, 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().

01162 {
01163    struct ast_config_map *map;
01164    int length;
01165 
01166    length = sizeof(*map);
01167    length += strlen(name) + 1;
01168    length += strlen(driver) + 1;
01169    length += strlen(database) + 1;
01170    if (table)
01171       length += strlen(table) + 1;
01172 
01173    if (!(map = ast_calloc(1, length)))
01174       return -1;
01175 
01176    map->name = map->stuff;
01177    strcpy(map->name, name);
01178    map->driver = map->name + strlen(map->name) + 1;
01179    strcpy(map->driver, driver);
01180    map->database = map->driver + strlen(map->driver) + 1;
01181    strcpy(map->database, database);
01182    if (table) {
01183       map->table = map->database + strlen(map->database) + 1;
01184       strcpy(map->table, table);
01185    }
01186    map->next = config_maps;
01187 
01188    if (option_verbose > 1)
01189       ast_verbose(VERBOSE_PREFIX_2 "Binding %s to %s/%s/%s\n",
01190              map->name, map->driver, map->database, map->table ? map->table : map->name);
01191 
01192    config_maps = map;
01193    return 0;
01194 }

void ast_category_append ( struct ast_config config,
struct ast_category category 
)

Definition at line 340 of file config.c.

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

Referenced by config_odbc(), config_pgsql(), handle_updates(), process_text_line(), realtime_directory(), realtime_multi_odbc(), and realtime_multi_pgsql().

00341 {
00342    if (config->last)
00343       config->last->next = category;
00344    else
00345       config->root = category;
00346    category->include_level = config->include_level;
00347    config->last = category;
00348    config->current = category;
00349 }

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

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

Referenced by __queues_show(), action_getconfig(), aji_load_config(), authenticate(), complete_sipnotify(), do_directory(), find_queue_by_name_rt(), gtalk_load_config(), iax_provision_reload(), ind_load_module(), init_manager(), load_config(), load_module(), load_moh_classes(), load_odbc_config(), loadconfigurationfile(), misdn_cfg_init(), odbc_load_module(), osp_load(), pbx_load_config(), pbx_load_users(), read_agent_config(), realtime_directory(), realtime_peer(), realtime_switch_common(), reload(), reload_config(), reload_followme(), reload_queues(), rpt_master(), set_config(), setup_dahdi(), sla_load_config(), update_realtime_members(), and vm_change_password().

00403 {  
00404    struct ast_category *cat = NULL;
00405 
00406    if (prev && config->last_browse && (config->last_browse->name == prev))
00407       cat = config->last_browse->next;
00408    else if (!prev && config->root)
00409       cat = config->root;
00410    else if (prev) {
00411       for (cat = config->root; cat; cat = cat->next) {
00412          if (cat->name == prev) {
00413             cat = cat->next;
00414             break;
00415          }
00416       }
00417       if (!cat) {
00418          for (cat = config->root; cat; cat = cat->next) {
00419             if (!strcasecmp(cat->name, prev)) {
00420                cat = cat->next;
00421                break;
00422             }
00423          }
00424       }
00425    }
00426    
00427    if (cat)
00428       cat = next_available_category(cat);
00429 
00430    config->last_browse = cat;
00431    return (cat) ? cat->name : NULL;
00432 }

int ast_category_delete ( struct ast_config cfg,
char *  category 
)

Definition at line 557 of file config.c.

References ast_category_destroy(), ast_config::last, ast_category::next, and ast_config::root.

Referenced by handle_updates().

00558 {
00559    struct ast_category *prev=NULL, *cat;
00560    cat = cfg->root;
00561    while(cat) {
00562       if (cat->name == category) {
00563          if (prev) {
00564             prev->next = cat->next;
00565             if (cat == cfg->last)
00566                cfg->last = prev;
00567          } else {
00568             cfg->root = cat->next;
00569             if (cat == cfg->last)
00570                cfg->last = NULL;
00571          }
00572          ast_category_destroy(cat);
00573          return 0;
00574       }
00575       prev = cat;
00576       cat = cat->next;
00577    }
00578 
00579    prev = NULL;
00580    cat = cfg->root;
00581    while(cat) {
00582       if (!strcasecmp(cat->name, category)) {
00583          if (prev) {
00584             prev->next = cat->next;
00585             if (cat == cfg->last)
00586                cfg->last = prev;
00587          } else {
00588             cfg->root = cat->next;
00589             if (cat == cfg->last)
00590                cfg->last = NULL;
00591          }
00592          ast_category_destroy(cat);
00593          return 0;
00594       }
00595       prev = cat;
00596       cat = cat->next;
00597    }
00598    return -1;
00599 }

void ast_category_destroy ( struct ast_category cat  ) 

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

Definition at line 434 of file config.c.

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

Referenced by realtime_switch_common().

00435 {
00436    struct ast_variable *v;
00437 
00438    v = cat->root;
00439    cat->root = NULL;
00440    cat->last = NULL;
00441 
00442    return v;
00443 }

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

References ast_category_get().

00336 {
00337    return !!ast_category_get(config, category_name);
00338 }

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

References category_get().

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

00331 {
00332    return category_get(config, category_name, 0);
00333 }

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

Definition at line 303 of file config.c.

References ast_calloc, ast_copy_string(), and ast_category::name.

Referenced by config_odbc(), config_pgsql(), handle_updates(), process_text_line(), realtime_directory(), realtime_multi_odbc(), and realtime_multi_pgsql().

00304 {
00305    struct ast_category *category;
00306 
00307    if ((category = ast_calloc(1, sizeof(*category))))
00308       ast_copy_string(category->name, name, sizeof(category->name));
00309    return category;
00310 }

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

Definition at line 445 of file config.c.

References ast_copy_string(), and ast_category::name.

Referenced by handle_updates(), realtime_multi_odbc(), and realtime_multi_pgsql().

00446 {
00447    ast_copy_string(cat->name, name, sizeof(cat->name));
00448 }

struct ast_variable* ast_category_root ( struct ast_config config,
char *  cat 
) [read]

returns the root ast_variable of a config

Parameters:
config pointer to an ast_config data structure
cat name of the category for which you want the root
Returns the category specified

Definition at line 394 of file config.c.

References ast_category_get(), and ast_category::root.

Referenced by realtime_peer().

00395 {
00396    struct ast_category *category = ast_category_get(config, cat);
00397    if (category)
00398       return category->root;
00399    return NULL;
00400 }

int ast_check_realtime ( const char *  family  ) 

Check if realtime engine is configured for family.

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

Definition at line 1435 of file config.c.

References find_engine().

Referenced by __queues_show(), _sip_show_peer(), _sip_show_peers(), and sip_show_settings().

01436 {
01437    struct ast_config_engine *eng;
01438 
01439    eng = find_engine(family, NULL, 0, NULL, 0);
01440    if (eng)
01441       return 1;
01442    return 0;
01443 
01444 }

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

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

Referenced by __ast_http_load(), __queues_show(), action_getconfig(), action_updateconfig(), adsi_load(), advanced_options(), aji_load_config(), ast_config_load(), ast_config_load_with_comments(), ast_enum_init(), ast_plc_reload(), ast_readconfig(), ast_rtp_reload(), ast_udptl_reload(), authenticate(), conf_exec(), directory_exec(), do_reload(), festival_exec(), find_conf(), handle_save_dialplan(), iax_provision_reload(), ind_load_module(), init_logger_chain(), init_manager(), load_config(), load_config_meetme(), load_module(), load_modules(), load_moh_classes(), load_odbc_config(), load_realtime_queue(), load_rpt_vars(), loadconfigurationfile(), make_email_file(), my_load_module(), node_lookup(), odbc_load_module(), osp_load(), parse_config(), pbx_load_config(), pbx_load_users(), play_message(), prep_email_sub_vars(), privacy_exec(), read_agent_config(), read_config_maps(), realtime_directory(), realtime_peer(), realtime_switch_common(), reload(), reload_config(), reload_followme(), reload_queues(), rpt_master(), set_config(), setup_dahdi(), sla_load_config(), smdi_load(), tds_load_module(), unload_module(), update_realtime_members(), and vm_forwardoptions().

00602 {
00603    struct ast_category *cat, *catn;
00604 
00605    if (!cfg)
00606       return;
00607 
00608    cat = cfg->root;
00609    while(cat) {
00610       catn = cat;
00611       cat = cat->next;
00612       ast_category_destroy(catn);
00613    }
00614    free(cfg);
00615 }

int ast_config_engine_deregister ( struct ast_config_engine del  ) 

Deegister config engine.

Definition at line 1283 of file config.c.

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

Referenced by unload_module().

01284 {
01285    struct ast_config_engine *ptr, *last=NULL;
01286 
01287    ast_mutex_lock(&config_lock);
01288 
01289    for (ptr = config_engine_list; ptr; ptr=ptr->next) {
01290       if (ptr == del) {
01291          if (last)
01292             last->next = ptr->next;
01293          else
01294             config_engine_list = ptr->next;
01295          break;
01296       }
01297       last = ptr;
01298    }
01299 
01300    ast_mutex_unlock(&config_lock);
01301 
01302    return 0;
01303 }

int ast_config_engine_register ( struct ast_config_engine new  ) 

Register config engine.

Definition at line 1264 of file config.c.

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

Referenced by load_module().

01265 {
01266    struct ast_config_engine *ptr;
01267 
01268    ast_mutex_lock(&config_lock);
01269 
01270    if (!config_engine_list) {
01271       config_engine_list = new;
01272    } else {
01273       for (ptr = config_engine_list; ptr->next; ptr=ptr->next);
01274       ptr->next = new;
01275    }
01276 
01277    ast_mutex_unlock(&config_lock);
01278    ast_log(LOG_NOTICE,"Registered Config Engine %s\n", new->name);
01279 
01280    return 1;
01281 }

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

Definition at line 617 of file config.c.

References ast_config::current.

Referenced by config_odbc(), and config_text_file_load().

00618 {
00619    return cfg->current;
00620 }

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

Definition at line 1345 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, and table.

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

01346 {
01347    char db[256];
01348    char table[256];
01349    struct ast_config_engine *loader = &text_file_engine;
01350    struct ast_config *result; 
01351 
01352    /* The config file itself bumps include_level by 1 */
01353    if (cfg->max_include_level > 0 && cfg->include_level == cfg->max_include_level + 1) {
01354       ast_log(LOG_WARNING, "Maximum Include level (%d) exceeded\n", cfg->max_include_level);
01355       return NULL;
01356    }
01357 
01358    cfg->include_level++;
01359 
01360    if (strcmp(filename, extconfig_conf) && strcmp(filename, "asterisk.conf") && config_engine_list) {
01361       struct ast_config_engine *eng;
01362 
01363       eng = find_engine(filename, db, sizeof(db), table, sizeof(table));
01364 
01365 
01366       if (eng && eng->load_func) {
01367          loader = eng;
01368       } else {
01369          eng = find_engine("global", db, sizeof(db), table, sizeof(table));
01370          if (eng && eng->load_func)
01371             loader = eng;
01372       }
01373    }
01374 
01375    result = loader->load_func(db, table, filename, cfg, withcomments);
01376 
01377    if (result)
01378       result->include_level--;
01379    else
01380       cfg->include_level--;
01381 
01382    return result;
01383 }

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

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

Referenced by __ast_http_load(), __say_init(), adsi_load(), advanced_options(), aji_load_config(), ast_enum_init(), ast_plc_reload(), ast_readconfig(), ast_rtp_reload(), ast_udptl_reload(), authenticate(), conf_exec(), directory_exec(), do_reload(), festival_exec(), find_conf(), gtalk_load_config(), handle_save_dialplan(), iax_provision_reload(), ind_load_module(), init_logger_chain(), init_manager(), load_config(), load_config_meetme(), load_module(), load_modules(), load_moh_classes(), load_odbc_config(), load_rpt_vars(), loadconfigurationfile(), make_email_file(), my_load_module(), node_lookup(), odbc_load_module(), osp_load(), parse_config(), pbx_load_config(), pbx_load_users(), play_message(), prep_email_sub_vars(), privacy_exec(), read_agent_config(), realtime_directory(), reload(), reload_config(), reload_followme(), reload_queues(), rpt_master(), set_config(), setup_dahdi(), sla_load_config(), smdi_load(), tds_load_module(), and vm_forwardoptions().

01386 {
01387    struct ast_config *cfg;
01388    struct ast_config *result;
01389 
01390    cfg = ast_config_new();
01391    if (!cfg)
01392       return NULL;
01393 
01394    result = ast_config_internal_load(filename, cfg, 0);
01395    if (!result)
01396       ast_config_destroy(cfg);
01397 
01398    return result;
01399 }

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

Definition at line 1401 of file config.c.

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

Referenced by action_getconfig(), action_updateconfig(), and vm_change_password().

01402 {
01403    struct ast_config *cfg;
01404    struct ast_config *result;
01405 
01406    cfg = ast_config_new();
01407    if (!cfg)
01408       return NULL;
01409 
01410    result = ast_config_internal_load(filename, cfg, 1);
01411    if (!result)
01412       ast_config_destroy(cfg);
01413 
01414    return result;
01415 }

struct ast_config* ast_config_new ( void   )  [read]

Definition at line 461 of file config.c.

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

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

00462 {
00463    struct ast_config *config;
00464 
00465    if ((config = ast_calloc(1, sizeof(*config))))
00466       config->max_include_level = MAX_INCLUDE_LEVEL;
00467    return config;
00468 }

const char* ast_config_option ( struct ast_config cfg,
const char *  cat,
const char *  var 
)

Definition at line 241 of file config.c.

References ast_variable_retrieve().

Referenced by do_directory(), load_config(), and pbx_load_users().

00242 {
00243    const char *tmp;
00244    tmp = ast_variable_retrieve(cfg, cat, var);
00245    if (!tmp)
00246       tmp = ast_variable_retrieve(cfg, "general", var);
00247    return tmp;
00248 }

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

Definition at line 622 of file config.c.

References ast_config::current.

00623 {
00624    /* cast below is just to silence compiler warning about dropping "const" */
00625    cfg->current = (struct ast_category *) cat;
00626 }

static void ast_destroy_comment ( struct ast_comment **  comment  )  [static]

Definition at line 351 of file config.c.

References free, and ast_comment::next.

Referenced by ast_destroy_comments(), and ast_variables_destroy().

00352 {
00353    struct ast_comment *n, *p;
00354 
00355    for (p = *comment; p; p = n) {
00356       n = p->next;
00357       free(p);
00358    }
00359 
00360    *comment = NULL;
00361 }

static void ast_destroy_comments ( struct ast_category cat  )  [static]

Definition at line 363 of file config.c.

References ast_destroy_comment(), ast_category::precomments, and ast_category::sameline.

Referenced by ast_category_destroy().

00364 {
00365    ast_destroy_comment(&cat->precomments);
00366    ast_destroy_comment(&cat->sameline);
00367 }

static void ast_destroy_template_list ( struct ast_category cat  )  [static]

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 freed with ast_variables_destroy() as there is no container.

Definition at line 1417 of file config.c.

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

Referenced by cli_realtime_load(), find_conf_realtime(), find_user_realtime(), function_realtime_read(), load_realtime_queue(), queue_function_queuewaitingcount(), realtime_alias(), realtime_exec(), realtime_peer(), realtime_switch_common(), realtime_user(), and update_realtime_member_field().

01418 {
01419    struct ast_config_engine *eng;
01420    char db[256]="";
01421    char table[256]="";
01422    struct ast_variable *res=NULL;
01423    va_list ap;
01424 
01425    va_start(ap, family);
01426    eng = find_engine(family, db, sizeof(db), table, sizeof(table));
01427    if (eng && eng->realtime_func) 
01428       res = eng->realtime_func(db, table, ap);
01429    va_end(ap);
01430 
01431    return res;
01432 }

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

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

Referenced by __queues_show(), load_realtime_queue(), realtime_directory(), realtime_peer(), realtime_switch_common(), and update_realtime_members().

01447 {
01448    struct ast_config_engine *eng;
01449    char db[256]="";
01450    char table[256]="";
01451    struct ast_config *res=NULL;
01452    va_list ap;
01453 
01454    va_start(ap, family);
01455    eng = find_engine(family, db, sizeof(db), table, sizeof(table));
01456    if (eng && eng->realtime_multi_func) 
01457       res = eng->realtime_multi_func(db, table, ap);
01458    va_end(ap);
01459 
01460    return res;
01461 }

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.
Returns:
Number of rows affected, or -1 on error.

Definition at line 1463 of file config.c.

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

Referenced by change_password_realtime(), cli_realtime_update(), conf_run(), destroy_association(), function_realtime_write(), handle_response_peerpoke(), realtime_update_exec(), realtime_update_peer(), sip_poke_noanswer(), and update_realtime_member_field().

01464 {
01465    struct ast_config_engine *eng;
01466    int res = -1;
01467    char db[256]="";
01468    char table[256]="";
01469    va_list ap;
01470 
01471    va_start(ap, lookup);
01472    eng = find_engine(family, db, sizeof(db), table, sizeof(table));
01473    if (eng && eng->update_func) 
01474       res = eng->update_func(db, table, keyfield, lookup, ap);
01475    va_end(ap);
01476 
01477    return res;
01478 }

void ast_variable_append ( struct ast_category category,
struct ast_variable variable 
)

Definition at line 203 of file config.c.

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

Referenced by config_odbc(), config_pgsql(), handle_updates(), inherit_category(), move_variables(), process_text_line(), realtime_directory(), realtime_multi_odbc(), realtime_multi_pgsql(), and vm_change_password().

00204 {
00205    if (!variable)
00206       return;
00207    if (category->last)
00208       category->last->next = variable;
00209    else
00210       category->root = variable;
00211    category->last = variable;
00212    while (category->last->next)
00213       category->last = category->last->next;
00214 }

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

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

Referenced by __ast_http_load(), action_getconfig(), adsi_load(), aji_load_config(), ast_enum_init(), ast_plc_reload(), ast_readconfig(), ast_variable_retrieve(), authenticate(), check_tx_freq(), collect_function_digits(), conf_exec(), do_directory(), do_say(), do_scheduler(), find_conf(), gtalk_load_config(), handle_save_dialplan(), iax_template_parse(), ind_load_module(), init_logger_chain(), init_manager(), load_config(), load_module(), load_modules(), load_moh_classes(), load_odbc_config(), load_rpt_vars(), loadconfigurationfile(), misdn_cfg_init(), node_lookup(), odbc_load_module(), osp_create_provider(), parse_config(), pbx_load_config(), process_my_load_module(), read_agent_config(), read_config_maps(), reload(), reload_config(), reload_followme(), reload_queues(), set_config(), setup_dahdi(), sip_notify(), sla_build_station(), sla_build_trunk(), smdi_load(), store_config(), and tds_load_module().

00230 {
00231    struct ast_category *cat = NULL;
00232 
00233    if (category && config->last_browse && (config->last_browse->name == category))
00234       cat = config->last_browse;
00235    else
00236       cat = ast_category_get(config, category);
00237 
00238    return (cat) ? cat->root : NULL;
00239 }

int ast_variable_delete ( struct ast_category category,
char *  variable,
char *  match 
)

Definition at line 470 of file config.c.

References ast_strlen_zero(), ast_variables_destroy(), ast_category::last, ast_variable::name, ast_variable::next, ast_category::root, and ast_variable::value.

Referenced by handle_updates().

00471 {
00472    struct ast_variable *cur, *prev=NULL, *curn;
00473    int res = -1;
00474    cur = category->root;
00475    while (cur) {
00476       if (cur->name == variable) {
00477          if (prev) {
00478             prev->next = cur->next;
00479             if (cur == category->last)
00480                category->last = prev;
00481          } else {
00482             category->root = cur->next;
00483             if (cur == category->last)
00484                category->last = NULL;
00485          }
00486          cur->next = NULL;
00487          ast_variables_destroy(cur);
00488          return 0;
00489       }
00490       prev = cur;
00491       cur = cur->next;
00492    }
00493 
00494    prev = NULL;
00495    cur = category->root;
00496    while (cur) {
00497       curn = cur->next;
00498       if (!strcasecmp(cur->name, variable) && (ast_strlen_zero(match) || !strcasecmp(cur->value, match))) {
00499          if (prev) {
00500             prev->next = cur->next;
00501             if (cur == category->last)
00502                category->last = prev;
00503          } else {
00504             category->root = cur->next;
00505             if (cur == category->last)
00506                category->last = NULL;
00507          }
00508          cur->next = NULL;
00509          ast_variables_destroy(cur);
00510          res = 0;
00511       } else
00512          prev = cur;
00513 
00514       cur = curn;
00515    }
00516    return res;
00517 }

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

Definition at line 188 of file config.c.

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

Referenced by apply_outgoing(), ast_channeltype_list(), ast_variable_update(), astman_get_variables(), build_peer(), build_user(), check_access(), check_user_full(), config_odbc(), config_pgsql(), handle_updates(), handle_uri(), parkandannounce_exec(), parse_cookies(), process_text_line(), realtime_directory(), realtime_multi_odbc(), realtime_multi_pgsql(), realtime_odbc(), realtime_pgsql(), variable_clone(), and vm_change_password().

00189 {
00190    struct ast_variable *variable;
00191    int name_len = strlen(name) + 1; 
00192 
00193    if ((variable = ast_calloc(1, name_len + strlen(value) + 1 + sizeof(*variable)))) {
00194       variable->name = variable->stuff;
00195       variable->value = variable->stuff + name_len;      
00196       strcpy(variable->name,name);
00197       strcpy(variable->value,value);
00198    }
00199 
00200    return variable;
00201 }

const 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 251 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 advanced_options(), aji_load_config(), ast_config_option(), ast_rtp_reload(), ast_udptl_reload(), authenticate(), directory_exec(), do_directory(), do_reload(), do_scheduler(), festival_exec(), find_queue_by_name_rt(), function_macro(), get_wait_interval(), gtalk_load_config(), handle_save_dialplan(), iax_template_parse(), ind_load_module(), init_acf_query(), init_logger_chain(), init_manager(), load_config(), load_config_meetme(), load_module(), load_modules(), load_rpt_vars(), make_email_file(), node_lookup(), odbc_load_module(), osp_load(), parse_config(), pbx_load_config(), pbx_load_users(), play_message(), prep_email_sub_vars(), privacy_exec(), process_my_load_module(), read_agent_config(), realtime_directory(), realtime_peer(), reload_config(), reload_followme(), reload_queues(), retreive_memory(), retrieve_astcfgint(), rpt(), rpt_master(), rpt_tele_thread(), set_config(), setup_dahdi(), sla_build_station(), sla_build_trunk(), sla_load_config(), tds_load_module(), telem_lookup(), update_realtime_members(), vm_change_password(), and vm_forwardoptions().

00252 {
00253    struct ast_variable *v;
00254 
00255    if (category) {
00256       for (v = ast_variable_browse(config, category); v; v = v->next) {
00257          if (!strcasecmp(variable, v->name))
00258             return v->value;
00259       }
00260    } else {
00261       struct ast_category *cat;
00262 
00263       for (cat = config->root; cat; cat = cat->next)
00264          for (v = cat->root; v; v = v->next)
00265             if (!strcasecmp(variable, v->name))
00266                return v->value;
00267    }
00268 
00269    return NULL;
00270 }

int ast_variable_update ( struct ast_category category,
const char *  variable,
const char *  value,
const char *  match,
unsigned int  object 
)

Definition at line 519 of file config.c.

References ast_strlen_zero(), ast_variable_new(), ast_variables_destroy(), ast_category::last, ast_variable::name, ast_variable::next, ast_variable::object, ast_category::root, and ast_variable::value.

Referenced by handle_updates(), vm_change_password(), and vm_forwardoptions().

00521 {
00522    struct ast_variable *cur, *prev=NULL, *newer;
00523 
00524    if (!(newer = ast_variable_new(variable, value)))
00525       return -1;
00526    
00527    newer->object = object;
00528 
00529    for (cur = category->root; cur; prev = cur, cur = cur->next) {
00530       if (strcasecmp(cur->name, variable) ||
00531          (!ast_strlen_zero(match) && strcasecmp(cur->value, match)))
00532          continue;
00533 
00534       newer->next = cur->next;
00535       newer->object = cur->object || object;
00536       if (prev)
00537          prev->next = newer;
00538       else
00539          category->root = newer;
00540       if (category->last == cur)
00541          category->last = newer;
00542 
00543       cur->next = NULL;
00544       ast_variables_destroy(cur);
00545 
00546       return 0;
00547    }
00548 
00549    if (prev)
00550       prev->next = newer;
00551    else
00552       category->root = newer;
00553 
00554    return 0;
00555 }

void ast_variables_destroy ( struct ast_variable var  ) 

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

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

00313 {
00314    struct ast_category *cat;
00315 
00316    /* try exact match first, then case-insensitive match */
00317    for (cat = config->root; cat; cat = cat->next) {
00318       if (cat->name == category_name && (ignored || !cat->ignored))
00319          return cat;
00320    }
00321 
00322    for (cat = config->root; cat; cat = cat->next) {
00323       if (!strcasecmp(cat->name, category_name) && (ignored || !cat->ignored))
00324          return cat;
00325    }
00326 
00327    return NULL;
00328 }

static void CB_ADD ( char **  comment_buffer,
int *  comment_buffer_size,
char *  str 
) [static]

Definition at line 90 of file config.c.

References ast_realloc, and CB_INCR.

Referenced by config_text_file_load().

00091 {
00092    int rem = *comment_buffer_size - strlen(*comment_buffer) - 1;
00093    int siz = strlen(str);
00094    if (rem < siz+1) {
00095       *comment_buffer = ast_realloc(*comment_buffer, *comment_buffer_size + CB_INCR + siz + 1);
00096       if (!(*comment_buffer))
00097          return;
00098       *comment_buffer_size += CB_INCR+siz+1;
00099    }
00100    strcat(*comment_buffer,str);
00101 }

static void CB_ADD_LEN ( char **  comment_buffer,
int *  comment_buffer_size,
char *  str,
int  len 
) [static]

Definition at line 103 of file config.c.

References ast_realloc, and CB_INCR.

Referenced by config_text_file_load().

00104 {
00105    int cbl = strlen(*comment_buffer) + 1;
00106    int rem = *comment_buffer_size - cbl;
00107    if (rem < len+1) {
00108       *comment_buffer = ast_realloc(*comment_buffer, *comment_buffer_size + CB_INCR + len + 1);
00109       if (!(*comment_buffer))
00110          return;
00111       *comment_buffer_size += CB_INCR+len+1;
00112    }
00113    strncat(*comment_buffer,str,len);
00114    (*comment_buffer)[cbl+len-1] = 0;
00115 }

static void CB_INIT ( char **  comment_buffer,
int *  comment_buffer_size,
char **  lline_buffer,
int *  lline_buffer_size 
) [static]

Definition at line 71 of file config.c.

References ast_malloc, and CB_INCR.

Referenced by config_text_file_load().

00072 {
00073    if (!(*comment_buffer)) {
00074       *comment_buffer = ast_malloc(CB_INCR);
00075       if (!(*comment_buffer))
00076          return;
00077       (*comment_buffer)[0] = 0;
00078       *comment_buffer_size = CB_INCR;
00079       *lline_buffer = ast_malloc(CB_INCR);
00080       if (!(*lline_buffer))
00081          return;
00082       (*lline_buffer)[0] = 0;
00083       *lline_buffer_size = CB_INCR;
00084    } else {
00085       (*comment_buffer)[0] = 0;
00086       (*lline_buffer)[0] = 0;
00087    }
00088 }

static void CB_RESET ( char **  comment_buffer,
char **  lline_buffer 
) [static]

Definition at line 130 of file config.c.

Referenced by process_text_line().

00131 { 
00132    (*comment_buffer)[0] = 0; 
00133    (*lline_buffer)[0] = 0;
00134 }

static void clear_config_maps ( void   )  [static]

Definition at line 1146 of file config.c.

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

Referenced by read_config_maps().

01147 {
01148    struct ast_config_map *map;
01149 
01150    ast_mutex_lock(&config_lock);
01151 
01152    while (config_maps) {
01153       map = config_maps;
01154       config_maps = config_maps->next;
01155       free(map);
01156    }
01157       
01158    ast_mutex_unlock(&config_lock);
01159 }

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

Definition at line 1480 of file config.c.

References ast_cli(), ast_mutex_lock(), ast_mutex_unlock(), config_lock, 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.

01481 {
01482    struct ast_config_engine *eng;
01483    struct ast_config_map *map;
01484    
01485    ast_mutex_lock(&config_lock);
01486 
01487    for (eng = config_engine_list; eng; eng = eng->next) {
01488       ast_cli(fd, "Config Engine: %s\n", eng->name);
01489       for (map = config_maps; map; map = map->next)
01490          if (!strcasecmp(map->driver, eng->name)) {
01491             ast_cli(fd, "===> %s (db=%s, table=%s)\n", map->name, map->database,
01492                map->table ? map->table : map->name);
01493          }
01494    }
01495    
01496    ast_mutex_unlock(&config_lock);
01497 
01498    return 0;
01499 }

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

Growable string buffer

< this will be a comment collector.

< the amount of storage so far alloc'd for the comment_buffer

< A buffer for stuff behind the ;

Definition at line 818 of file config.c.

References ast_config_AST_CONFIG_DIR, ast_config_get_current_category(), ast_copy_string(), ast_log(), ast_strip(), ast_strlen_zero(), ast_verbose(), CB_ADD(), CB_ADD_LEN(), CB_INIT(), COMMENT_META, COMMENT_TAG, errno, f, free, ast_config::include_level, LLB_ADD(), LOG_DEBUG, LOG_ERROR, LOG_WARNING, MAX_NESTED_COMMENTS, MY_GLOB_FLAGS, option_debug, option_verbose, process_text_line(), and VERBOSE_PREFIX_2.

00819 {
00820    char fn[256];
00821 #if defined(LOW_MEMORY)
00822    char buf[512];
00823 #else
00824    char buf[8192];
00825 #endif
00826    char *new_buf, *comment_p, *process_buf;
00827    FILE *f;
00828    int lineno=0;
00829    int comment = 0, nest[MAX_NESTED_COMMENTS];
00830    struct ast_category *cat = NULL;
00831    int count = 0;
00832    struct stat statbuf;
00833    /*! Growable string buffer */
00834    char *comment_buffer=0;   /*!< this will be a comment collector.*/
00835    int   comment_buffer_size=0;  /*!< the amount of storage so far alloc'd for the comment_buffer */
00836 
00837    char *lline_buffer=0;    /*!< A buffer for stuff behind the ; */
00838    int  lline_buffer_size=0;
00839 
00840    
00841    cat = ast_config_get_current_category(cfg);
00842 
00843    if (filename[0] == '/') {
00844       ast_copy_string(fn, filename, sizeof(fn));
00845    } else {
00846       snprintf(fn, sizeof(fn), "%s/%s", (char *)ast_config_AST_CONFIG_DIR, filename);
00847    }
00848 
00849    if (withcomments) {
00850       CB_INIT(&comment_buffer, &comment_buffer_size, &lline_buffer, &lline_buffer_size);
00851       if (!lline_buffer || !comment_buffer) {
00852          ast_log(LOG_ERROR, "Failed to initialize the comment buffer!\n");
00853          return NULL;
00854       }
00855    }
00856 #ifdef AST_INCLUDE_GLOB
00857    {
00858       int glob_ret;
00859       glob_t globbuf;
00860       globbuf.gl_offs = 0; /* initialize it to silence gcc */
00861       glob_ret = glob(fn, MY_GLOB_FLAGS, NULL, &globbuf);
00862       if (glob_ret == GLOB_NOSPACE)
00863          ast_log(LOG_WARNING,
00864             "Glob Expansion of pattern '%s' failed: Not enough memory\n", fn);
00865       else if (glob_ret  == GLOB_ABORTED)
00866          ast_log(LOG_WARNING,
00867             "Glob Expansion of pattern '%s' failed: Read error\n", fn);
00868       else  {
00869          /* loop over expanded files */
00870          int i;
00871          for (i=0; i<globbuf.gl_pathc; i++) {
00872             ast_copy_string(fn, globbuf.gl_pathv[i], sizeof(fn));
00873 #endif
00874    do {
00875       if (stat(fn, &statbuf))
00876          continue;
00877 
00878       if (!S_ISREG(statbuf.st_mode)) {
00879          ast_log(LOG_WARNING, "'%s' is not a regular file, ignoring\n", fn);
00880          continue;
00881       }
00882       if (option_verbose > 1) {
00883          ast_verbose(VERBOSE_PREFIX_2 "Parsing '%s': ", fn);
00884          fflush(stdout);
00885       }
00886       if (!(f = fopen(fn, "r"))) {
00887          if (option_debug)
00888             ast_log(LOG_DEBUG, "No file to parse: %s\n", fn);
00889          if (option_verbose > 1)
00890             ast_verbose( "Not found (%s)\n", strerror(errno));
00891          continue;
00892       }
00893       count++;
00894       if (option_debug)
00895          ast_log(LOG_DEBUG, "Parsing %s\n", fn);
00896       if (option_verbose > 1)
00897          ast_verbose("Found\n");
00898       while(!feof(f)) {
00899          lineno++;
00900          if (fgets(buf, sizeof(buf), f)) {
00901             if ( withcomments ) {
00902                CB_ADD(&comment_buffer, &comment_buffer_size, lline_buffer);       /* add the current lline buffer to the comment buffer */
00903                lline_buffer[0] = 0;        /* erase the lline buffer */
00904             }
00905             
00906             new_buf = buf;
00907             if (comment) 
00908                process_buf = NULL;
00909             else
00910                process_buf = buf;
00911             
00912             while ((comment_p = strchr(new_buf, COMMENT_META))) {
00913                if ((comment_p > new_buf) && (*(comment_p-1) == '\\')) {
00914                   /* Escaped semicolons aren't comments. */
00915                   new_buf = comment_p + 1;
00916                } else if(comment_p[1] == COMMENT_TAG && comment_p[2] == COMMENT_TAG && (comment_p[3] != '-')) {
00917                   /* Meta-Comment start detected ";--" */
00918                   if (comment < MAX_NESTED_COMMENTS) {
00919                      *comment_p = '\0';
00920                      new_buf = comment_p + 3;
00921                      comment++;
00922                      nest[comment-1] = lineno;
00923                   } else {
00924                      ast_log(LOG_ERROR, "Maximum nest limit of %d reached.\n", MAX_NESTED_COMMENTS);
00925                   }
00926                } else if ((comment_p >= new_buf + 2) &&
00927                      (*(comment_p - 1) == COMMENT_TAG) &&
00928                      (*(comment_p - 2) == COMMENT_TAG)) {
00929                   /* Meta-Comment end detected */
00930                   comment--;
00931                   new_buf = comment_p + 1;
00932                   if (!comment) {
00933                      /* Back to non-comment now */
00934                      if (process_buf) {
00935                         /* Actually have to move what's left over the top, then continue */
00936                         char *oldptr;
00937                         oldptr = process_buf + strlen(process_buf);
00938                         if ( withcomments ) {
00939                            CB_ADD(&comment_buffer, &comment_buffer_size, ";");
00940                            CB_ADD_LEN(&comment_buffer, &comment_buffer_size, oldptr+1, new_buf-oldptr-1);
00941                         }
00942                         
00943                         memmove(oldptr, new_buf, strlen(new_buf) + 1);
00944                         new_buf = oldptr;
00945                      } else
00946                         process_buf = new_buf;
00947                   }
00948                } else {
00949                   if (!comment) {
00950                      /* If ; is found, and we are not nested in a comment, 
00951                         we immediately stop all comment processing */
00952                      if ( withcomments ) {
00953                         LLB_ADD(&lline_buffer, &lline_buffer_size, comment_p);
00954                      }
00955                      *comment_p = '\0'; 
00956                      new_buf = comment_p;
00957                   } else
00958                      new_buf = comment_p + 1;
00959                }
00960             }
00961             if( withcomments && comment && !process_buf )
00962             {
00963                CB_ADD(&comment_buffer, &comment_buffer_size, buf);  /* the whole line is a comment, store it */
00964             }
00965             
00966             if (process_buf) {
00967                char *buf = ast_strip(process_buf);
00968                if (!ast_strlen_zero(buf)) {
00969                   if (process_text_line(cfg, &cat, buf, lineno, fn, withcomments, &comment_buffer, &comment_buffer_size, &lline_buffer, &lline_buffer_size)) {
00970                      cfg = NULL;
00971                      break;
00972                   }
00973                }
00974             }
00975          }
00976       }
00977       fclose(f);     
00978    } while(0);
00979    if (comment) {
00980       ast_log(LOG_WARNING,"Unterminated comment detected beginning on line %d\n", nest[comment - 1]);
00981    }
00982 #ifdef AST_INCLUDE_GLOB
00983                if (!cfg)
00984                   break;
00985             }
00986             globfree(&globbuf);
00987          }
00988       }
00989 #endif
00990 
00991    if (cfg && cfg->include_level == 1 && withcomments && comment_buffer) {
00992       free(comment_buffer);
00993       free(lline_buffer);
00994       comment_buffer = NULL;
00995       lline_buffer = NULL;
00996       comment_buffer_size = 0;
00997       lline_buffer_size = 0;
00998    }
00999    
01000    if (count == 0)
01001       return NULL;
01002 
01003    return cfg;
01004 }

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

Definition at line 1006 of file config.c.

References ast_config_AST_CONFIG_DIR, ast_copy_string(), AST_LIST_EMPTY, AST_LIST_LAST, AST_LIST_TRAVERSE, ast_log(), ast_verbose(), ast_variable::blanklines, ast_comment::cmt, errno, f, ast_category::ignored, ast_category_template_instance::inst, LOG_DEBUG, ast_variable::name, ast_category_template_instance::name, ast_category::name, ast_category::next, ast_variable::next, ast_comment::next, ast_variable::object, option_debug, option_verbose, ast_variable::precomments, ast_category::precomments, ast_category::root, ast_config::root, ast_variable::sameline, ast_category::sameline, t, ast_category::template_instances, ast_variable::value, var, and VERBOSE_PREFIX_2.

Referenced by action_updateconfig(), vm_change_password(), and vm_forwardoptions().

01007 {
01008    FILE *f = NULL;
01009    int fd = -1;
01010    char fn[256], fntmp[256];
01011    char date[256]="";
01012    time_t t;
01013    struct ast_variable *var;
01014    struct ast_category *cat;
01015    struct ast_comment *cmt;
01016    struct stat s;
01017    int blanklines = 0;
01018    int stat_result = 0;
01019 
01020    if (configfile[0] == '/') {
01021       snprintf(fntmp, sizeof(fntmp), "%s.XXXXXX", configfile);
01022       ast_copy_string(fn, configfile, sizeof(fn));
01023    } else {
01024       snprintf(fntmp, sizeof(fntmp), "%s/%s.XXXXXX", ast_config_AST_CONFIG_DIR, configfile);
01025       snprintf(fn, sizeof(fn), "%s/%s", ast_config_AST_CONFIG_DIR, configfile);
01026    }
01027    time(&t);
01028    ast_copy_string(date, ctime(&t), sizeof(date));
01029    if ((fd = mkstemp(fntmp)) > 0 && (f = fdopen(fd, "w")) != NULL) {
01030       if (option_verbose > 1)
01031          ast_verbose(VERBOSE_PREFIX_2 "Saving '%s': ", fn);
01032       fprintf(f, ";!\n");
01033       fprintf(f, ";! Automatically generated configuration file\n");
01034       if (strcmp(configfile, fn))
01035          fprintf(f, ";! Filename: %s (%s)\n", configfile, fn);
01036       else
01037          fprintf(f, ";! Filename: %s\n", configfile);
01038       fprintf(f, ";! Generator: %s\n", generator);
01039       fprintf(f, ";! Creation Date: %s", date);
01040       fprintf(f, ";!\n");
01041       cat = cfg->root;
01042       while(cat) {
01043          /* Dump section with any appropriate comment */
01044          for (cmt = cat->precomments; cmt; cmt=cmt->next)
01045          {
01046             if (cmt->cmt[0] != ';' || cmt->cmt[1] != '!')
01047                fprintf(f,"%s", cmt->cmt);
01048          }
01049          if (!cat->precomments)
01050             fprintf(f,"\n");
01051          fprintf(f, "[%s]", cat->name);
01052          if (cat->ignored || !AST_LIST_EMPTY(&cat->template_instances)) {
01053             fprintf(f, "(");
01054             if (cat->ignored) {
01055                fprintf(f, "!");
01056             }
01057             if (cat->ignored && !AST_LIST_EMPTY(&cat->template_instances)) {
01058                fprintf(f, ",");
01059             }
01060             if (!AST_LIST_EMPTY(&cat->template_instances)) {
01061                struct ast_category_template_instance *x;
01062                AST_LIST_TRAVERSE(&cat->template_instances, x, next) {
01063                   fprintf(f,"%s",x->name);
01064                   if (x != AST_LIST_LAST(&cat->template_instances))
01065                      fprintf(f,",");
01066                }
01067             }
01068             fprintf(f, ")");
01069          }
01070          for(cmt = cat->sameline; cmt; cmt=cmt->next)
01071          {
01072             fprintf(f,"%s", cmt->cmt);
01073          }
01074          if (!cat->sameline)
01075             fprintf(f,"\n");
01076          var = cat->root;
01077          while(var) {
01078             struct ast_category_template_instance *x;
01079             struct ast_variable *v2;
01080             int found = 0;
01081             AST_LIST_TRAVERSE(&cat->template_instances, x, next) {
01082                
01083                for (v2 = x->inst->root; v2; v2 = v2->next) {
01084                   if (!strcasecmp(var->name, v2->name))
01085                      break;
01086                }
01087                if (v2 && v2->value && !strcmp(v2->value, var->value)) {
01088                   found = 1;
01089                   break;
01090                }
01091             }
01092             if (found) {
01093                var = var->next;
01094                continue;
01095             }
01096             for (cmt = var->precomments; cmt; cmt=cmt->next)
01097             {
01098                if (cmt->cmt[0] != ';' || cmt->cmt[1] != '!')
01099                   fprintf(f,"%s", cmt->cmt);
01100             }
01101             if (var->sameline) 
01102                fprintf(f, "%s %s %s  %s", var->name, (var->object ? "=>" : "="), var->value, var->sameline->cmt);
01103             else  
01104                fprintf(f, "%s %s %s\n", var->name, (var->object ? "=>" : "="), var->value);
01105             if (var->blanklines) {
01106                blanklines = var->blanklines;
01107                while (blanklines--)
01108                   fprintf(f, "\n");
01109             }
01110                
01111             var = var->next;
01112          }
01113 #if 0
01114          /* Put an empty line */
01115          fprintf(f, "\n");
01116 #endif
01117          cat = cat->next;
01118       }
01119       if ((option_verbose > 1) && !option_debug)
01120          ast_verbose("Saved\n");
01121    } else {
01122       if (option_debug)
01123          ast_log(LOG_DEBUG, "Unable to open for writing: %s (%s)\n", fn, strerror(errno));
01124       if (option_verbose > 1)
01125          ast_verbose(VERBOSE_PREFIX_2 "Unable to write %s (%s)", fn, strerror(errno));
01126       if (fd > -1)
01127          close(fd);
01128       return -1;
01129    }
01130    if (!(stat_result = stat(fn, &s))) {
01131       fchmod(fd, s.st_mode);
01132    }
01133    fclose(f);
01134    if ((!stat_result && unlink(fn)) || link(fntmp, fn)) {
01135       if (option_debug)
01136          ast_log(LOG_DEBUG, "Unable to open for writing: %s (%s)\n", fn, strerror(errno));
01137       if (option_verbose > 1)
01138          ast_verbose(VERBOSE_PREFIX_2 "Unable to write %s (%s)", fn, strerror(errno));
01139       unlink(fntmp);
01140       return -1;
01141    }
01142    unlink(fntmp);
01143    return 0;
01144 }

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

Find realtime engine for realtime family.

Definition at line 1306 of file config.c.

References ast_copy_string(), ast_log(), ast_mutex_lock(), ast_mutex_unlock(), config_lock, 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(), ast_speech_new(), ast_speech_register(), and ast_update_realtime().

01307 {
01308    struct ast_config_engine *eng, *ret = NULL;
01309    struct ast_config_map *map;
01310 
01311    ast_mutex_lock(&config_lock);
01312 
01313    for (map = config_maps; map; map = map->next) {
01314       if (!strcasecmp(family, map->name)) {
01315          if (database)
01316             ast_copy_string(database, map->database, dbsiz);
01317          if (table)
01318             ast_copy_string(table, map->table ? map->table : family, tabsiz);
01319          break;
01320       }
01321    }
01322 
01323    /* Check if the required driver (engine) exist */
01324    if (map) {
01325       for (eng = config_engine_list; !ret && eng; eng = eng->next) {
01326          if (!strcasecmp(eng->name, map->driver))
01327             ret = eng;
01328       }
01329    }
01330 
01331    ast_mutex_unlock(&config_lock);
01332    
01333    /* if we found a mapping, but the engine is not available, then issue a warning */
01334    if (map && !ret)
01335       ast_log(LOG_WARNING, "Realtime mapping for '%s' found to engine '%s', but the engine is not available\n", map->name, map->driver);
01336 
01337    return ret;
01338 }

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

Definition at line 450 of file config.c.

References ast_calloc, AST_LIST_INSERT_TAIL, ast_variable_append(), ast_category_template_instance::inst, ast_category::name, ast_category_template_instance::name, ast_variable::next, ast_category::root, var, and variable_clone().

Referenced by process_text_line().

00451 {
00452    struct ast_variable *var;
00453    struct ast_category_template_instance *x = ast_calloc(1,sizeof(struct ast_category_template_instance));
00454    strcpy(x->name, base->name);
00455    x->inst = base;
00456    AST_LIST_INSERT_TAIL(&new->template_instances, x, next);
00457    for (var = base->root; var; var = var->next)
00458       ast_variable_append(new, variable_clone(var));
00459 }

static void LLB_ADD ( char **  lline_buffer,
int *  lline_buffer_size,
char *  str 
) [static]

Definition at line 117 of file config.c.

References ast_realloc, and CB_INCR.

Referenced by config_text_file_load().

00118 {
00119    int rem = *lline_buffer_size - strlen(*lline_buffer) - 1;
00120    int siz = strlen(str);
00121    if (rem < siz+1) {
00122       *lline_buffer = ast_realloc(*lline_buffer, *lline_buffer_size + CB_INCR + siz + 1);
00123       if (!(*lline_buffer)) 
00124          return;
00125       *lline_buffer_size += CB_INCR + siz + 1;
00126    }
00127    strcat(*lline_buffer,str);
00128 }

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

Definition at line 286 of file config.c.

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

Referenced by process_text_line().

00287 {
00288    struct ast_variable *var = old->root;
00289    old->root = NULL;
00290 #if 1
00291    /* we can just move the entire list in a single op */
00292    ast_variable_append(new, var);
00293 #else
00294    while (var) {
00295       struct ast_variable *next = var->next;
00296       var->next = NULL;
00297       ast_variable_append(new, var);
00298       var = next;
00299    }
00300 #endif
00301 }

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

Definition at line 387 of file config.c.

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

Referenced by ast_category_browse().

00388 {
00389    for (; cat && cat->ignored; cat = cat->next);
00390 
00391    return cat;
00392 }

static int process_text_line ( struct ast_config cfg,
struct ast_category **  cat,
char *  buf,
int  lineno,
const char *  configfile,
int  withcomments,
char **  comment_buffer,
int *  comment_buffer_size,
char **  lline_buffer,
int *  lline_buffer_size 
) [static]

Definition at line 628 of file config.c.

References ALLOC_COMMENT(), ast_category_append(), ast_category_destroy(), ast_category_new(), ast_config_internal_load(), ast_log(), ast_opt_exec_includes, ast_safe_system(), ast_strip(), ast_strlen_zero(), ast_variable_append(), ast_variable_new(), ast_variable::blanklines, category_get(), CB_RESET(), inherit_category(), ast_variable::lineno, LOG_ERROR, LOG_WARNING, move_variables(), ast_variable::object, ast_variable::precomments, ast_category::precomments, ast_variable::sameline, and ast_category::sameline.

Referenced by config_text_file_load().

00630 {
00631    char *c;
00632    char *cur = buf;
00633    struct ast_variable *v;
00634    char cmd[512], exec_file[512];
00635    int object, do_exec, do_include;
00636 
00637    /* Actually parse the entry */
00638    if (cur[0] == '[') {
00639       struct ast_category *newcat = NULL;
00640       char *catname;
00641 
00642       /* A category header */
00643       c = strchr(cur, ']');
00644       if (!c) {
00645          ast_log(LOG_WARNING, "parse error: no closing ']', line %d of %s\n", lineno, configfile);
00646          return -1;
00647       }
00648       *c++ = '\0';
00649       cur++;
00650       if (*c++ != '(')
00651          c = NULL;
00652       catname = cur;
00653       if (!(*cat = newcat = ast_category_new(catname))) {
00654          return -1;
00655       }
00656       /* add comments */
00657       if (withcomments && *comment_buffer && (*comment_buffer)[0] ) {
00658          newcat->precomments = ALLOC_COMMENT(*comment_buffer);
00659       }
00660       if (withcomments && *lline_buffer && (*lline_buffer)[0] ) {
00661          newcat->sameline = ALLOC_COMMENT(*lline_buffer);
00662       }
00663       if( withcomments )
00664          CB_RESET(comment_buffer, lline_buffer);
00665       
00666       /* If there are options or categories to inherit from, process them now */
00667       if (c) {
00668          if (!(cur = strchr(c, ')'))) {
00669             ast_log(LOG_WARNING, "parse error: no closing ')', line %d of %s\n", lineno, configfile);
00670             return -1;
00671          }
00672          *cur = '\0';
00673          while ((cur = strsep(&c, ","))) {
00674             if (!strcasecmp(cur, "!")) {
00675                (*cat)->ignored = 1;
00676             } else if (!strcasecmp(cur, "+")) {
00677                *cat = category_get(cfg, catname, 1);
00678                if (!(*cat)) {
00679                   if (newcat)
00680                      ast_category_destroy(newcat);
00681                   ast_log(LOG_WARNING, "Category addition requested, but category '%s' does not exist, line %d of %s\n", catname, lineno, configfile);
00682                   return -1;
00683                }
00684                if (newcat) {
00685                   move_variables(newcat, *cat);
00686                   ast_category_destroy(newcat);
00687                   newcat = NULL;
00688                }
00689             } else {
00690                struct ast_category *base;
00691             
00692                base = category_get(cfg, cur, 1);
00693                if (!base) {
00694                   ast_log(LOG_WARNING, "Inheritance requested, but category '%s' does not exist, line %d of %s\n", cur, lineno, configfile);
00695                   return -1;
00696                }
00697                inherit_category(*cat, base);
00698             }
00699          }
00700       }
00701       if (newcat)
00702          ast_category_append(cfg, *cat);
00703    } else if (cur[0] == '#') {
00704       /* A directive */
00705       cur++;
00706       c = cur;
00707       while(*c && (*c > 32)) c++;
00708       if (*c) {
00709          *c = '\0';
00710          /* Find real argument */
00711          c = ast_strip(c + 1);
00712          if (!(*c))
00713             c = NULL;
00714       } else 
00715          c = NULL;
00716       do_include = !strcasecmp(cur, "include");
00717       if(!do_include)
00718          do_exec = !strcasecmp(cur, "exec");
00719       else
00720          do_exec = 0;
00721       if (do_exec && !ast_opt_exec_includes) {
00722          ast_log(LOG_WARNING, "Cannot perform #exec unless execincludes option is enabled in asterisk.conf (options section)!\n");
00723          do_exec = 0;
00724       }
00725       if (do_include || do_exec) {
00726          if (c) {
00727             cur = c;
00728             /* Strip off leading and trailing "'s and <>'s */
00729             if ((*c == '"') || (*c == '<')) {
00730                char quote_char = *c;
00731                if (quote_char == '<') {
00732                   quote_char = '>';
00733                }
00734 
00735                if (*(c + strlen(c) - 1) == quote_char) {
00736                   cur++;
00737                   *(c + strlen(c) - 1) = '\0';
00738                }
00739             }
00740             /* #exec </path/to/executable>
00741                We create a tmp file, then we #include it, then we delete it. */
00742             if (do_exec) { 
00743                snprintf(exec_file, sizeof(exec_file), "/var/tmp/exec.%d.%ld", (int)time(NULL), (long)pthread_self());
00744                snprintf(cmd, sizeof(cmd), "%s > %s 2>&1", cur, exec_file);
00745                ast_safe_system(cmd);
00746                cur = exec_file;
00747             } else
00748                exec_file[0] = '\0';
00749             /* A #include */
00750             do_include = ast_config_internal_load(cur, cfg, withcomments) ? 1 : 0;
00751             if(!ast_strlen_zero(exec_file))
00752                unlink(exec_file);
00753             if (!do_include) {
00754                ast_log(LOG_ERROR, "*********************************************************\n");
00755                ast_log(LOG_ERROR, "*********** YOU SHOULD REALLY READ THIS ERROR ***********\n");
00756                ast_log(LOG_ERROR, "Future versions of Asterisk will treat a #include of a "
00757                                   "file that does not exist as an error, and will fail to "
00758                                   "load that configuration file.  Please ensure that the "
00759                                   "file '%s' exists, even if it is empty.\n", cur);
00760                ast_log(LOG_ERROR, "*********** YOU SHOULD REALLY READ THIS ERROR ***********\n");
00761                ast_log(LOG_ERROR, "*********************************************************\n");
00762                return 0;
00763             }
00764 
00765          } else {
00766             ast_log(LOG_WARNING, "Directive '#%s' needs an argument (%s) at line %d of %s\n", 
00767                   do_exec ? "exec" : "include",
00768                   do_exec ? "/path/to/executable" : "filename",
00769                   lineno,
00770                   configfile);
00771          }
00772       }
00773       else 
00774          ast_log(LOG_WARNING, "Unknown directive '#%s' at line %d of %s\n", cur, lineno, configfile);
00775    } else {
00776       /* Just a line (variable = value) */
00777       if (!(*cat)) {
00778          ast_log(LOG_WARNING,
00779             "parse error: No category context for line %d of %s\n", lineno, configfile);
00780          return -1;
00781       }
00782       c = strchr(cur, '=');
00783       if (c) {
00784          *c = 0;
00785          c++;
00786          /* Ignore > in => */
00787          if (*c== '>') {
00788             object = 1;
00789             c++;
00790          } else
00791             object = 0;
00792          if ((v = ast_variable_new(ast_strip(cur), ast_strip(c)))) {
00793             v->lineno = lineno;
00794             v->object = object;
00795             /* Put and reset comments */
00796             v->blanklines = 0;
00797             ast_variable_append(*cat, v);
00798             /* add comments */
00799             if (withcomments && *comment_buffer && (*comment_buffer)[0] ) {
00800                v->precomments = ALLOC_COMMENT(*comment_buffer);
00801             }
00802             if (withcomments && *lline_buffer && (*lline_buffer)[0] ) {
00803                v->sameline = ALLOC_COMMENT(*lline_buffer);
00804             }
00805             if( withcomments )
00806                CB_RESET(comment_buffer, lline_buffer);
00807             
00808          } else {
00809             return -1;
00810          }
00811       } else {
00812          ast_log(LOG_WARNING, "No '=' (equal sign) in line %d of %s\n", lineno, configfile);
00813       }
00814    }
00815    return 0;
00816 }

int read_config_maps ( void   ) 

Definition at line 1196 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, table, and ast_variable::value.

Referenced by main().

01197 {
01198    struct ast_config *config, *configtmp;
01199    struct ast_variable *v;
01200    char *driver, *table, *database, *stringp, *tmp;
01201 
01202    clear_config_maps();
01203 
01204    configtmp = ast_config_new();
01205    configtmp->max_include_level = 1;
01206    config = ast_config_internal_load(extconfig_conf, configtmp, 0);
01207    if (!config) {
01208       ast_config_destroy(configtmp);
01209       return 0;
01210    }
01211 
01212    for (v = ast_variable_browse(config, "settings"); v; v = v->next) {
01213       stringp = v->value;
01214       driver = strsep(&stringp, ",");
01215 
01216       if ((tmp = strchr(stringp, '\"')))
01217          stringp = tmp;
01218 
01219       /* check if the database text starts with a double quote */
01220       if (*stringp == '"') {
01221          stringp++;
01222          database = strsep(&stringp, "\"");
01223          strsep(&stringp, ",");
01224       } else {
01225          /* apparently this text has no quotes */
01226          database = strsep(&stringp, ",");
01227       }
01228 
01229       table = strsep(&stringp, ",");
01230 
01231       if (!strcmp(v->name, extconfig_conf)) {
01232          ast_log(LOG_WARNING, "Cannot bind '%s'!\n", extconfig_conf);
01233          continue;
01234       }
01235 
01236       if (!strcmp(v->name, "asterisk.conf")) {
01237          ast_log(LOG_WARNING, "Cannot bind 'asterisk.conf'!\n");
01238          continue;
01239       }
01240 
01241       if (!strcmp(v->name, "logger.conf")) {
01242          ast_log(LOG_WARNING, "Cannot bind 'logger.conf'!\n");
01243          continue;
01244       }
01245 
01246       if (!driver || !database)
01247          continue;
01248       if (!strcasecmp(v->name, "sipfriends")) {
01249          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");
01250          append_mapping("sipusers", driver, database, table ? table : "sipfriends");
01251          append_mapping("sippeers", driver, database, table ? table : "sipfriends");
01252       } else if (!strcasecmp(v->name, "iaxfriends")) {
01253          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");
01254          append_mapping("iaxusers", driver, database, table ? table : "iaxfriends");
01255          append_mapping("iaxpeers", driver, database, table ? table : "iaxfriends");
01256       } else 
01257          append_mapping(v->name, driver, database, table);
01258    }
01259       
01260    ast_config_destroy(config);
01261    return 0;
01262 }

int register_config_cli ( void   ) 

Definition at line 1516 of file config.c.

References ast_cli_register_multiple().

Referenced by main().

01517 {
01518    ast_cli_register_multiple(cli_config, sizeof(cli_config) / sizeof(struct ast_cli_entry));
01519    return 0;
01520 }

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

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

00273 {
00274    struct ast_variable *new = ast_variable_new(old->name, old->value);
00275 
00276    if (new) {
00277       new->lineno = old->lineno;
00278       new->object = old->object;
00279       new->blanklines = old->blanklines;
00280       /* TODO: clone comments? */
00281    }
00282 
00283    return new;
00284 }


Variable Documentation

struct ast_cli_entry cli_config[] [static]

Initial value:

 {
   { { "core", "show", "config", "mappings", NULL },
   config_command, "Display config mappings (file names to config engines)",
   show_config_help, NULL, &cli_show_config_mappings_deprecated },
}

Definition at line 1510 of file config.c.

Initial value:

 {
   { "show", "config", "mappings", NULL },
   config_command, NULL,
   NULL }

Definition at line 1505 of file config.c.

Definition at line 155 of file config.c.

ast_mutex_t config_lock = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER ) [static]

struct ast_config_map * config_maps [static]

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

Definition at line 60 of file config.c.

char show_config_help[] [static]

Initial value:

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

Definition at line 1501 of file config.c.

Initial value:

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

Definition at line 1340 of file config.c.


Generated on Thu Oct 11 06:43:21 2012 for Asterisk - the Open Source PBX by  doxygen 1.5.6