Sat Nov 1 06:29:01 2008

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
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)
ast_variableast_category_detach_variables (struct ast_category *cat)
int ast_category_exist (const struct ast_config *config, const char *category_name)
 Check for category duplicates.
ast_categoryast_category_get (const struct ast_config *config, const char *category_name)
 Retrieve a category if it exists.
ast_categoryast_category_new (const char *name)
void ast_category_rename (struct ast_category *cat, const char *name)
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 returns 1 if family is configured in realtime and engine exists.
void ast_config_destroy (struct ast_config *cfg)
 Destroys a config.
int ast_config_engine_deregister (struct ast_config_engine *del)
 Deegister config engine.
int ast_config_engine_register (struct ast_config_engine *new)
 Register config engine.
ast_categoryast_config_get_current_category (const struct ast_config *cfg)
ast_configast_config_internal_load (const char *filename, struct ast_config *cfg, int withcomments)
ast_configast_config_load (const char *filename)
 Load a config file.
ast_configast_config_load_with_comments (const char *filename)
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_comments (struct ast_category *cat)
static void ast_destroy_template_list (struct ast_category *cat)
ast_variableast_load_realtime (const char *family,...)
 Retrieve realtime configuration.
ast_configast_load_realtime_multientry (const char *family,...)
 Retrieve realtime configuration.
 AST_MUTEX_DEFINE_STATIC (config_lock)
int ast_update_realtime (const char *family, const char *keyfield, const char *lookup,...)
 Update realtime configuration.
void ast_variable_append (struct ast_category *category, struct ast_variable *variable)
ast_variableast_variable_browse (const struct ast_config *config, const char *category)
 Goes through variables Somewhat similar in intent as the ast_category_browse. List variables of config file category.
int ast_variable_delete (struct ast_category *category, char *variable, char *match)
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 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 72 of file config.c.

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

#define COMMENT_END   "--;"

Definition at line 59 of file config.c.

#define COMMENT_META   ';'

Definition at line 60 of file config.c.

Referenced by config_text_file_load().

#define COMMENT_START   ";--"

Definition at line 58 of file config.c.

#define COMMENT_TAG   '-'

Definition at line 61 of file config.c.

Referenced by config_text_file_load().

#define MAX_INCLUDE_LEVEL   10

Definition at line 160 of file config.c.

Referenced by ast_config_new().

#define MAX_NESTED_COMMENTS   128

Definition at line 57 of file config.c.

Referenced by config_text_file_load().


Function Documentation

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

Definition at line 140 of file config.c.

References ast_calloc, and ast_comment::cmt.

Referenced by process_text_line().

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

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

Definition at line 1159 of file config.c.

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

Referenced by read_config_maps().

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

void ast_category_append ( struct ast_config config,
struct ast_category category 
)

Definition at line 339 of file config.c.

References config, and ast_category::include_level.

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

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

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

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

Referenced by __queues_show(), action_getconfig(), aji_load_config(), authenticate(), complete_sipnotify(), do_directory(), 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_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().

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

int ast_category_delete ( struct ast_config cfg,
char *  category 
)

Definition at line 553 of file config.c.

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

Referenced by handle_updates().

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

void ast_category_destroy ( struct ast_category cat  ) 

Definition at line 375 of file config.c.

References ast_destroy_comments(), ast_destroy_template_list(), ast_variables_destroy(), and free.

Referenced by ast_category_delete(), ast_config_destroy(), process_text_line(), and realtime_multi_odbc().

00376 {
00377    ast_variables_destroy(cat->root);
00378    ast_destroy_comments(cat);
00379    ast_destroy_template_list(cat);
00380    free(cat);
00381 }

struct ast_variable* ast_category_detach_variables ( struct ast_category cat  ) 

Definition at line 430 of file config.c.

Referenced by realtime_switch_common().

00431 {
00432    struct ast_variable *v;
00433 
00434    v = cat->root;
00435    cat->root = NULL;
00436    cat->last = NULL;
00437 
00438    return v;
00439 }

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

References ast_category_get(), and config.

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

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

Retrieve a category if it exists.

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

Definition at line 329 of file config.c.

References category_get(), and config.

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

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

struct ast_category* ast_category_new ( const char *  name  ) 

Definition at line 302 of file config.c.

References ast_calloc.

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

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

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

Definition at line 441 of file config.c.

References ast_category::name.

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

00442 {
00443    ast_copy_string(cat->name, name, sizeof(cat->name));
00444 }

struct ast_variable* ast_category_root ( struct ast_config config,
char *  cat 
)

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

References ast_category_get(), and config.

00391 {
00392    struct ast_category *category = ast_category_get(config, cat);
00393    if (category)
00394       return category->root;
00395    return NULL;
00396 }

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

References find_engine().

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

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

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

References ast_category_destroy(), free, 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_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(), load_config(), load_config_meetme(), load_module(), load_moh_classes(), load_realtime_queue(), load_rpt_vars(), loadconfigurationfile(), my_load_module(), node_lookup(), odbc_load_module(), osp_load(), parse_config(), pbx_load_users(), play_message(), privacy_exec(), read_agent_config(), read_config_maps(), realtime_directory(), realtime_switch_common(), reload(), reload_config(), reload_followme(), rpt_master(), set_config(), setup_dahdi(), sla_load_config(), tds_load_module(), unload_module(), update_realtime_members(), and vm_forwardoptions().

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

int ast_config_engine_deregister ( struct ast_config_engine del  ) 

Deegister config engine.

Definition at line 1281 of file config.c.

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

Referenced by unload_module().

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

int ast_config_engine_register ( struct ast_config_engine new  ) 

Register config engine.

Definition at line 1262 of file config.c.

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

Referenced by load_module().

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

struct ast_category* ast_config_get_current_category ( const struct ast_config cfg  ) 

Definition at line 613 of file config.c.

References ast_config::current.

Referenced by config_odbc(), and config_text_file_load().

00614 {
00615    return cfg->current;
00616 }

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

Definition at line 1343 of file config.c.

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

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

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

struct ast_config* ast_config_load ( const char *  filename  ) 

Load a config file.

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

Definition at line 1383 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_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(), my_load_module(), node_lookup(), odbc_load_module(), osp_load(), parse_config(), pbx_load_config(), pbx_load_users(), play_message(), 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().

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

struct ast_config* ast_config_load_with_comments ( const char *  filename  ) 

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

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

struct ast_config* ast_config_new ( void   ) 

Definition at line 457 of file config.c.

References ast_calloc, config, and MAX_INCLUDE_LEVEL.

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

00458 {
00459    struct ast_config *config;
00460 
00461    if ((config = ast_calloc(1, sizeof(*config))))
00462       config->max_include_level = MAX_INCLUDE_LEVEL;
00463    return config;
00464 }

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

Definition at line 240 of file config.c.

References ast_variable_retrieve().

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

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

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

Definition at line 618 of file config.c.

References ast_config::current.

00619 {
00620    /* cast below is just to silence compiler warning about dropping "const" */
00621    cfg->current = (struct ast_category *) cat;
00622 }

static void ast_destroy_comments ( struct ast_category cat  )  [static]

Definition at line 350 of file config.c.

References free, and ast_comment::next.

Referenced by ast_category_destroy().

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

static void ast_destroy_template_list ( struct ast_category cat  )  [static]

Definition at line 365 of file config.c.

References AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, and free.

Referenced by ast_category_destroy().

00366 {
00367    struct ast_category_template_instance *x;
00368    AST_LIST_TRAVERSE_SAFE_BEGIN(&cat->template_instances, x, next) {
00369       AST_LIST_REMOVE_CURRENT(&cat->template_instances, next);
00370       free(x);
00371    }
00372    AST_LIST_TRAVERSE_SAFE_END;
00373 }

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

Retrieve realtime configuration.

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

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

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

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

Retrieve realtime configuration.

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

Definition at line 1444 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_switch_common(), and update_realtime_members().

01445 {
01446    struct ast_config_engine *eng;
01447    char db[256]="";
01448    char table[256]="";
01449    struct ast_config *res=NULL;
01450    va_list ap;
01451 
01452    va_start(ap, family);
01453    eng =