#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"
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_comment * | ALLOC_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_variable * | ast_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_category * | ast_category_get (const struct ast_config *config, const char *category_name) |
Retrieve a category if it exists. | |
ast_category * | ast_category_new (const char *name) |
void | ast_category_rename (struct ast_category *cat, const char *name) |
ast_variable * | ast_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_category * | ast_config_get_current_category (const struct ast_config *cfg) |
ast_config * | ast_config_internal_load (const char *filename, struct ast_config *cfg, int withcomments) |
ast_config * | ast_config_load (const char *filename) |
Load a config file. | |
ast_config * | ast_config_load_with_comments (const char *filename) |
ast_config * | ast_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_variable * | ast_load_realtime (const char *family,...) |
Retrieve realtime configuration. | |
ast_config * | ast_load_realtime_multientry (const char *family,...) |
Retrieve realtime configuration. | |
int | ast_realtime_enabled (void) |
Check if realtime engine is enabled returns 1 if realtime is enabled. | |
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_variable * | ast_variable_browse (const struct ast_config *config, const char *category) |
Goes through variables Somewhat similar in intent as the ast_category_browse. List variables of config file category. | |
int | ast_variable_delete (struct ast_category *category, char *variable, char *match) |
ast_variable * | ast_variable_new (const char *name, const char *value) |
ast_variable * | ast_variable_next (struct ast_config *config, char *category, struct ast_variable *prev) |
Iterates through variables. | |
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_category * | category_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_config * | config_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_engine * | find_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_category * | next_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_variable * | variable_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_engine * | config_engine_list |
static ast_mutex_t | config_lock = { PTHREAD_MUTEX_INITIALIZER , 1, { NULL }, { 0 }, 0, { NULL }, { 0 }, PTHREAD_MUTEX_INITIALIZER } |
static struct ast_config_map * | config_maps |
static char * | extconfig_conf = "extconfig.conf" |
static char | show_config_help [] |
static struct ast_config_engine | text_file_engine |
Definition in file config.c.
#define CB_INCR 250 |
#define COMMENT_META ';' |
#define COMMENT_TAG '-' |
#define MAX_INCLUDE_LEVEL 10 |
#define MAX_NESTED_COMMENTS 128 |
static struct ast_comment* ALLOC_COMMENT | ( | const char * | buffer | ) | [static] |
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 1180 of file config.c.
References ast_calloc, ast_verbose(), config_maps, map, option_verbose, and VERBOSE_PREFIX_2.
Referenced by read_config_maps().
01181 { 01182 struct ast_config_map *map; 01183 int length; 01184 01185 length = sizeof(*map); 01186 length += strlen(name) + 1; 01187 length += strlen(driver) + 1; 01188 length += strlen(database) + 1; 01189 if (table) 01190 length += strlen(table) + 1; 01191 01192 if (!(map = ast_calloc(1, length))) 01193 return -1; 01194 01195 map->name = map->stuff; 01196 strcpy(map->name, name); 01197 map->driver = map->name + strlen(map->name) + 1; 01198 strcpy(map->driver, driver); 01199 map->database = map->driver + strlen(map->driver) + 1; 01200 strcpy(map->database, database); 01201 if (table) { 01202 map->table = map->database + strlen(map->database) + 1; 01203 strcpy(map->table, table); 01204 } 01205 map->next = config_maps; 01206 01207 if (option_verbose > 1) 01208 ast_verbose(VERBOSE_PREFIX_2 "Binding %s to %s/%s/%s\n", 01209 map->name, map->driver, map->database, map->table ? map->table : map->name); 01210 01211 config_maps = map; 01212 return 0; 01213 }
void ast_category_append | ( | struct ast_config * | config, | |
struct ast_category * | category | |||
) |
Definition at line 355 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().
00356 { 00357 if (config->last) 00358 config->last->next = category; 00359 else 00360 config->root = category; 00361 category->include_level = config->include_level; 00362 config->last = category; 00363 config->current = category; 00364 }
char* ast_category_browse | ( | struct ast_config * | config, | |
const char * | prev | |||
) |
Goes through categories.
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. |
Definition at line 414 of file config.c.
References config, ast_category::name, ast_category::next, 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().
00415 { 00416 struct ast_category *cat = NULL; 00417 00418 if (prev && config->last_browse && (config->last_browse->name == prev)) 00419 cat = config->last_browse->next; 00420 else if (!prev && config->root) 00421 cat = config->root; 00422 else if (prev) { 00423 for (cat = config->root; cat; cat = cat->next) { 00424 if (cat->name == prev) { 00425 cat = cat->next; 00426 break; 00427 } 00428 } 00429 if (!cat) { 00430 for (cat = config->root; cat; cat = cat->next) { 00431 if (!strcasecmp(cat->name, prev)) { 00432 cat = cat->next; 00433 break; 00434 } 00435 } 00436 } 00437 } 00438 00439 if (cat) 00440 cat = next_available_category(cat); 00441 00442 config->last_browse = cat; 00443 return (cat) ? cat->name : NULL; 00444 }
int ast_category_delete | ( | struct ast_config * | cfg, | |
char * | category | |||
) |
Definition at line 569 of file config.c.
References ast_category_destroy(), ast_config::last, ast_category::next, and ast_config::root.
Referenced by handle_updates().
00570 { 00571 struct ast_category *prev=NULL, *cat; 00572 cat = cfg->root; 00573 while(cat) { 00574 if (cat->name == category) { 00575 if (prev) { 00576 prev->next = cat->next; 00577 if (cat == cfg->last) 00578 cfg->last = prev; 00579 } else { 00580 cfg->root = cat->next; 00581 if (cat == cfg->last) 00582 cfg->last = NULL; 00583 } 00584 ast_category_destroy(cat); 00585 return 0; 00586 } 00587 prev = cat; 00588 cat = cat->next; 00589 } 00590 00591 prev = NULL; 00592 cat = cfg->root; 00593 while(cat) { 00594 if (!strcasecmp(cat->name, category)) { 00595 if (prev) { 00596 prev->next = cat->next; 00597 if (cat == cfg->last) 00598 cfg->last = prev; 00599 } else { 00600 cfg->root = cat->next; 00601 if (cat == cfg->last) 00602 cfg->last = NULL; 00603 } 00604 ast_category_destroy(cat); 00605 return 0; 00606 } 00607 prev = cat; 00608 cat = cat->next; 00609 } 00610 return -1; 00611 }
void ast_category_destroy | ( | struct ast_category * | cat | ) |
Definition at line 391 of file config.c.
References ast_destroy_comments(), ast_destroy_template_list(), ast_variables_destroy(), free, and ast_category::root.
Referenced by ast_category_delete(), ast_config_destroy(), process_text_line(), and realtime_multi_odbc().
00392 { 00393 ast_variables_destroy(cat->root); 00394 ast_destroy_comments(cat); 00395 ast_destroy_template_list(cat); 00396 free(cat); 00397 }
struct ast_variable* ast_category_detach_variables | ( | struct ast_category * | cat | ) |
Definition at line 446 of file config.c.
References ast_category::last, and ast_category::root.
Referenced by realtime_switch_common().
00447 { 00448 struct ast_variable *v; 00449 00450 v = cat->root; 00451 cat->root = NULL; 00452 cat->last = NULL; 00453 00454 return v; 00455 }
int ast_category_exist | ( | const struct ast_config * | config, | |
const char * | category_name | |||
) |
Check for category duplicates.
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. |
Definition at line 350 of file config.c.
References ast_category_get(), and config.
00351 { 00352 return !!ast_category_get(config, category_name); 00353 }
struct ast_category* ast_category_get | ( | const struct ast_config * | config, | |
const char * | category_name | |||
) |
Retrieve a category if it exists.
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. |
Definition at line 345 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().
00346 { 00347 return category_get(config, category_name, 0); 00348 }
struct ast_category* ast_category_new | ( | const char * | name | ) |
Definition at line 318 of file config.c.
References ast_calloc, and ast_copy_string().
Referenced by config_odbc(), config_pgsql(), handle_updates(), process_text_line(), realtime_directory(), realtime_multi_odbc(), and realtime_multi_pgsql().
00319 { 00320 struct ast_category *category; 00321 00322 if ((category = ast_calloc(1, sizeof(*category)))) 00323 ast_copy_string(category->name, name, sizeof(category->name)); 00324 return category; 00325 }
void ast_category_rename | ( | struct ast_category * | cat, | |
const char * | name | |||
) |
Definition at line 457 of file config.c.
References ast_copy_string(), and ast_category::name.
Referenced by handle_updates(), realtime_multi_odbc(), and realtime_multi_pgsql().
00458 { 00459 ast_copy_string(cat->name, name, sizeof(cat->name)); 00460 }
struct ast_variable* ast_category_root | ( | struct ast_config * | config, | |
char * | cat | |||
) |
returns the root ast_variable of a config
config | pointer to an ast_config data structure | |
cat | name of the category for which you want the root |
Definition at line 406 of file config.c.
References ast_category_get(), config, and ast_category::root.
00407 { 00408 struct ast_category *category = ast_category_get(config, cat); 00409 if (category) 00410 return category->root; 00411 return NULL; 00412 }
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.
family | which family/config to be checked |
Definition at line 1454 of file config.c.
References find_engine().
Referenced by __queues_show(), _sip_show_peer(), _sip_show_peers(), and sip_show_settings().
01455 { 01456 struct ast_config_engine *eng; 01457 01458 eng = find_engine(family, NULL, 0, NULL, 0); 01459 if (eng) 01460 return 1; 01461 return 0; 01462 01463 }
void ast_config_destroy | ( | struct ast_config * | config | ) |
Destroys a config.
config | pointer to config data structure Free memory associated with a given config |
Definition at line 613 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_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_realtime_queue(), load_rpt_vars(), loadconfigurationfile(), make_email_file(), my_load_module(), node_lookup(), odbc_load_module(), osp_load(), parse_config(), pbx_load_users(), play_message(), prep_email_sub_vars(), 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().
00614 { 00615 struct ast_category *cat, *catn; 00616 00617 if (!cfg) 00618 return; 00619 00620 cat = cfg->root; 00621 while(cat) { 00622 catn = cat; 00623 cat = cat->next; 00624 ast_category_destroy(catn); 00625 } 00626 free(cfg); 00627 }
int ast_config_engine_deregister | ( | struct ast_config_engine * | del | ) |
Deegister config engine.
Definition at line 1302 of file config.c.
References ast_mutex_lock, ast_mutex_unlock, config_engine_list, config_lock, last, and ast_config_engine::next.
Referenced by unload_module().
01303 { 01304 struct ast_config_engine *ptr, *last=NULL; 01305 01306 ast_mutex_lock(&config_lock); 01307 01308 for (ptr = config_engine_list; ptr; ptr=ptr->next) { 01309 if (ptr == del) { 01310 if (last) 01311 last->next = ptr->next; 01312 else 01313 config_engine_list = ptr->next; 01314 break; 01315 } 01316 last = ptr; 01317 } 01318 01319 ast_mutex_unlock(&config_lock); 01320 01321 return 0; 01322 }
int ast_config_engine_register | ( | struct ast_config_engine * | new | ) |
Register config engine.
Definition at line 1283 of file config.c.
References ast_log(), ast_mutex_lock, ast_mutex_unlock, config_engine_list, config_lock, LOG_NOTICE, ast_config_engine::name, and ast_config_engine::next.
Referenced by load_module().
01284 { 01285 struct ast_config_engine *ptr; 01286 01287 ast_mutex_lock(&config_lock); 01288 01289 if (!config_engine_list) { 01290 config_engine_list = new; 01291 } else { 01292 for (ptr = config_engine_list; ptr->next; ptr=ptr->next); 01293 ptr->next = new; 01294 } 01295 01296 ast_mutex_unlock(&config_lock); 01297 ast_log(LOG_NOTICE,"Registered Config Engine %s\n", new->name); 01298 01299 return 1; 01300 }
struct ast_category* ast_config_get_current_category | ( | const struct ast_config * | cfg | ) |
Definition at line 629 of file config.c.
References ast_config::current.
Referenced by config_odbc(), and config_text_file_load().
00630 { 00631 return cfg->current; 00632 }
struct ast_config* ast_config_internal_load | ( | const char * | filename, | |
struct ast_config * | cfg, | |||
int | withcomments | |||
) |
Definition at line 1364 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().
01365 { 01366 char db[256]; 01367 char table[256]; 01368 struct ast_config_engine *loader = &text_file_engine; 01369 struct ast_config *result; 01370 01371 /* The config file itself bumps include_level by 1 */ 01372 if (cfg->max_include_level > 0 && cfg->include_level == cfg->max_include_level + 1) { 01373 ast_log(LOG_WARNING, "Maximum Include level (%d) exceeded\n", cfg->max_include_level); 01374 return NULL; 01375 } 01376 01377 cfg->include_level++; 01378 01379 if (strcmp(filename, extconfig_conf) && strcmp(filename, "asterisk.conf") && config_engine_list) { 01380 struct ast_config_engine *eng; 01381 01382 eng = find_engine(filename, db, sizeof(db), table, sizeof(table)); 01383 01384 01385 if (eng && eng->load_func) { 01386 loader = eng; 01387 } else { 01388 eng = find_engine("global", db, sizeof(db), table, sizeof(table)); 01389 if (eng && eng->load_func) 01390 loader = eng; 01391 } 01392 } 01393 01394 result = loader->load_func(db, table, filename, cfg, withcomments); 01395 01396 if (result) 01397 result->include_level--; 01398 else 01399 cfg->include_level--; 01400 01401 return result; 01402 }
struct ast_config* ast_config_load | ( | const char * | filename | ) |
Load a config file.
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. |
Definition at line 1404 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(), 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().
01405 { 01406 struct ast_config *cfg; 01407 struct ast_config *result; 01408 01409 cfg = ast_config_new(); 01410 if (!cfg) 01411 return NULL; 01412 01413 result = ast_config_internal_load(filename, cfg, 0); 01414 if (!result) 01415 ast_config_destroy(cfg); 01416 01417 return result; 01418 }
struct ast_config* ast_config_load_with_comments | ( | const char * | filename | ) |
Definition at line 1420 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().
01421 { 01422 struct ast_config *cfg; 01423 struct ast_config *result; 01424 01425 cfg = ast_config_new(); 01426 if (!cfg) 01427 return NULL; 01428 01429 result = ast_config_internal_load(filename, cfg, 1); 01430 if (!result) 01431 ast_config_destroy(cfg); 01432 01433 return result; 01434 }
struct ast_config* ast_config_new | ( | void | ) |
Definition at line 473 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().
00474 { 00475 struct ast_config *config; 00476 00477 if ((config = ast_calloc(1, sizeof(*config)))) 00478 config->max_include_level = MAX_INCLUDE_LEVEL; 00479 return config; 00480 }
const char* ast_config_option | ( | struct ast_config * | cfg, | |
const char * | cat, | |||
const char * | var | |||
) |
Definition at line 237 of file config.c.
References ast_variable_retrieve().
Referenced by do_directory(), load_config(), and pbx_load_users().
00238 { 00239 const char *tmp; 00240 tmp = ast_variable_retrieve(cfg, cat, var); 00241 if (!tmp) 00242 tmp = ast_variable_retrieve(cfg, "general", var); 00243 return tmp; 00244 }
void ast_config_set_current_category | ( | struct ast_config * | cfg, | |
const struct ast_category * | cat | |||
) |
Definition at line 634 of file config.c.
References ast_config::current.
00635 { 00636 /* cast below is just to silence compiler warning about dropping "const" */ 00637 cfg->current = (struct ast_category *) cat; 00638 }
static void ast_destroy_comments | ( | struct ast_category * | cat | ) | [static] |
Definition at line 366 of file config.c.
References free, ast_comment::next, ast_category::precomments, and ast_category::sameline.
Referenced by ast_category_destroy().
00367 { 00368 struct ast_comment *n, *p; 00369 for (p=cat->precomments; p; p=n) { 00370 n = p->next; 00371 free(p); 00372 } 00373 for (p=cat->sameline; p; p=n) { 00374 n = p->next; 00375 free(p); 00376 } 00377 cat->precomments = NULL; 00378 cat->sameline = NULL; 00379 }
static void ast_destroy_template_list | ( | struct ast_category * | cat | ) | [static] |
Definition at line 381 of file config.c.
References AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, free, ast_category_template_instance::next, and ast_category::template_instances.
Referenced by ast_category_destroy().
00382 { 00383 struct ast_category_template_instance *x; 00384 AST_LIST_TRAVERSE_SAFE_BEGIN(&cat->template_instances, x, next) { 00385 AST_LIST_REMOVE_CURRENT(&cat->template_instances, next); 00386 free(x); 00387 } 00388 AST_LIST_TRAVERSE_SAFE_END; 00389 }
struct ast_variable* ast_load_realtime | ( | const char * | family, | |
... | ||||
) |
Retrieve realtime configuration.
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 1436 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().
01437 { 01438 struct ast_config_engine *eng; 01439 char db[256]=""; 01440 char table[256]=""; 01441 struct ast_variable *res=NULL; 01442 va_list ap; 01443 01444 va_start(ap, family); 01445 eng = find_engine(family, db, sizeof(db), table, sizeof(table)); 01446 if (eng && eng->realtime_func) 01447 res = eng->realtime_func(db, table, ap); 01448 va_end(ap); 01449 01450 return res; 01451 }
struct ast_config* ast_load_realtime_multientry | ( | const char * | family, | |
... | ||||
) |
Retrieve realtime configuration.
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 1471 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().
01472 { 01473 struct ast_config_engine *eng; 01474 char db[256]=""; 01475 char table[256]=""; 01476 struct ast_config *res=NULL; 01477 va_list ap; 01478 01479 va_start(ap, family); 01480 eng = find_engine(family, db, sizeof(db), table, sizeof(table)); 01481 if (eng && eng->realtime_multi_func) 01482 res = eng->realtime_multi_func(db, table, ap); 01483 va_end(ap); 01484 01485 return res; 01486 }
int ast_realtime_enabled | ( | void | ) |
Check if realtime engine is enabled returns 1 if realtime is enabled.
Definition at line 1466 of file config.c.
References config_maps.
Referenced by action_coresettings(), and handle_show_settings().
01467 { 01468 return config_maps ? 1 : 0; 01469 }
int ast_update_realtime | ( | const char * | family, | |
const char * | keyfield, | |||
const char * | lookup, | |||
... | ||||
) |
Update realtime configuration.
family | which family/config to be updated | |
keyfield | which field to use as the key | |
lookup | which value to look for in the key field to match the entry. This function is used to update a parameter in realtime configuration space. |
Definition at line 1488 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().
01489 { 01490 struct ast_config_engine *eng; 01491 int res = -1; 01492 char db[256]=""; 01493 char table[256]=""; 01494 va_list ap; 01495 01496 va_start(ap, lookup); 01497 eng = find_engine(family, db, sizeof(db), table, sizeof(table)); 01498 if (eng && eng->update_func) 01499 res = eng->update_func(db, table, keyfield, lookup, ap); 01500 va_end(ap); 01501 01502 return res; 01503 }
void ast_variable_append | ( | struct ast_category * | category, | |
struct ast_variable * | variable | |||
) |
Definition at line 201 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().
00202 { 00203 if (!variable) 00204 return; 00205 if (category->last) 00206 category->last->next = variable; 00207 else 00208 category->root = variable; 00209 category->last = variable; 00210 while (category->last->next) 00211 category->last = category->last->next; 00212 }
struct ast_variable* ast_variable_browse | ( | const struct ast_config * | config, | |
const char * | category | |||
) |
Goes through variables Somewhat similar in intent as the ast_category_browse. List variables of config file category.
Returns ast_variable list on success, or NULL on failure
Definition at line 225 of file config.c.
References ast_category_get(), config, and ast_category::root.
Referenced by __ast_http_load(), action_getconfig(), adsi_load(), aji_load_config(), ast_enum_init(), ast_readconfig(), ast_variable_next(), 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().
00226 { 00227 struct ast_category *cat = NULL; 00228 00229 if (category && config->last_browse && (config->last_browse->name == category)) 00230 cat = config->last_browse; 00231 else 00232 cat = ast_category_get(config, category); 00233 00234 return (cat) ? cat->root : NULL; 00235 }
int ast_variable_delete | ( | struct ast_category * | category, | |
char * | variable, | |||
char * | match | |||
) |
Definition at line 482 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().
00483 { 00484 struct ast_variable *cur, *prev=NULL, *curn; 00485 int res = -1; 00486 cur = category->root; 00487 while (cur) { 00488 if (cur->name == variable) { 00489 if (prev) { 00490 prev->next = cur->next; 00491 if (cur == category->last) 00492 category->last = prev; 00493 } else { 00494 category->root = cur->next; 00495 if (cur == category->last) 00496 category->last = NULL; 00497 } 00498 cur->next = NULL; 00499 ast_variables_destroy(cur); 00500 return 0; 00501 } 00502 prev = cur; 00503 cur = cur->next; 00504 } 00505 00506 prev = NULL; 00507 cur = category->root; 00508 while (cur) { 00509 curn = cur->next; 00510 if (!strcasecmp(cur->name, variable) && (ast_strlen_zero(match) || !strcasecmp(cur->value, match))) { 00511 if (prev) { 00512 prev->next = cur->next; 00513 if (cur == category->last) 00514 category->last = prev; 00515 } else { 00516 category->root = cur->next; 00517 if (cur == category->last) 00518 category->last = NULL; 00519 } 00520 cur->next = NULL; 00521 ast_variables_destroy(cur); 00522 res = 0; 00523 } else 00524 prev = cur; 00525 00526 cur = curn; 00527 } 00528 return res; 00529 }
struct ast_variable* ast_variable_new | ( | const char * | name, | |
const char * | value | |||
) |
Definition at line 186 of file config.c.
References ast_calloc, and ast_variable::name.
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().
00187 { 00188 struct ast_variable *variable; 00189 int name_len = strlen(name) + 1; 00190 00191 if ((variable = ast_calloc(1, name_len + strlen(value) + 1 + sizeof(*variable)))) { 00192 variable->name = variable->stuff; 00193 variable->value = variable->stuff + name_len; 00194 strcpy(variable->name,name); 00195 strcpy(variable->value,value); 00196 } 00197 00198 return variable; 00199 }
struct ast_variable* ast_variable_next | ( | struct ast_config * | config, | |
char * | category, | |||
struct ast_variable * | prev | |||
) |
Iterates through variables.
Somewhat similar in intent as the ast_category_browse. The prev variable MUST be an actual pointer to an actual variable (such as one obtained by using ast_variable_browse() or ast_variable_next() itself). List variables of config file Returns next variable on the list, or NULL on failure
Definition at line 247 of file config.c.
References ast_variable_browse(), and config.
00248 { 00249 struct ast_variable *v = NULL; 00250 v = ast_variable_browse(config, category); 00251 if(v) { 00252 if(prev) { 00253 while (v) { 00254 if (v == prev) 00255 return v->next; 00256 v=v->next; 00257 } 00258 } else { 00259 return v; 00260 } 00261 } 00262 return NULL; 00263 }
const char* ast_variable_retrieve | ( | const struct ast_config * | config, | |
const char * | category, | |||
const char * | variable | |||
) |
Gets a variable.
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 |
Definition at line 266 of file config.c.
References ast_variable_browse(), config, ast_variable::name, ast_variable::next, ast_category::next, ast_category::root, and ast_variable::value.
Referenced by advanced_options(), aji_load_config(), ast_config_option(), ast_rtp_reload(), ast_udptl_reload(), directory_exec(), do_directory(), do_reload(), do_scheduler(), festival_exec(), 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_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(), 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().
00267 { 00268 struct ast_variable *v; 00269 00270 if (category) { 00271 for (v = ast_variable_browse(config, category); v; v = v->next) { 00272 if (!strcasecmp(variable, v->name)) 00273 return v->value; 00274 } 00275 } else { 00276 struct ast_category *cat; 00277 00278 for (cat = config->root; cat; cat = cat->next) 00279 for (v = cat->root; v; v = v->next) 00280 if (!strcasecmp(variable, v->name)) 00281 return v->value; 00282 } 00283 00284 return NULL; 00285 }
int ast_variable_update | ( | struct ast_category * | category, | |
const char * | variable, | |||
const char * | value, | |||
const char * | match, | |||
unsigned int | object | |||
) |
Definition at line 531 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().
00533 { 00534 struct ast_variable *cur, *prev=NULL, *newer; 00535 00536 if (!(newer = ast_variable_new(variable, value))) 00537 return -1; 00538 00539 newer->object = object; 00540 00541 for (cur = category->root; cur; prev = cur, cur = cur->next) { 00542 if (strcasecmp(cur->name, variable) || 00543 (!ast_strlen_zero(match) && strcasecmp(cur->value, match))) 00544 continue; 00545 00546 newer->next = cur->next; 00547 newer->object = cur->object || object; 00548 if (prev) 00549 prev->next = newer; 00550 else 00551 category->root = newer; 00552 if (category->last == cur) 00553 category->last = newer; 00554 00555 cur->next = NULL; 00556 ast_variables_destroy(cur); 00557 00558 return 0; 00559 } 00560 00561 if (prev) 00562 prev->next = newer; 00563 else 00564 category->root = newer; 00565 00566 return 0; 00567 }
void ast_variables_destroy | ( | struct ast_variable * | var | ) |
Free variable list.
var | the linked list of variables to free This function frees a list of variables. |
Definition at line 214 of file config.c.
References free, and ast_variable::next.
Referenced by ast_category_destroy(), ast_httpd_helper_thread(), ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), ast_variable_delete(), ast_variable_update(), build_peer(), build_user(), cli_realtime_load(), find_conf_realtime(), find_user_realtime(), function_realtime_read(), handle_uri(), load_realtime_queue(), pvt_destructor(), queue_function_queuewaitingcount(), realtime_alias(), realtime_canmatch(), realtime_exec(), realtime_exists(), realtime_matchmore(), realtime_odbc(), realtime_peer(), realtime_user(), sip_alloc(), sip_destroy_peer(), sip_destroy_user(), update_realtime_member_field(), and user_destructor().
00215 { 00216 struct ast_variable *vn; 00217 00218 while(v) { 00219 vn = v; 00220 v = v->next; 00221 free(vn); 00222 } 00223 }
static struct ast_category* category_get | ( | const struct ast_config * | config, | |
const char * | category_name, | |||
int | ignored | |||
) | [static] |
Definition at line 327 of file config.c.
References config, ast_category::ignored, ast_category::name, and ast_category::next.
Referenced by ast_category_get(), and process_text_line().
00328 { 00329 struct ast_category *cat; 00330 00331 /* try exact match first, then case-insensitive match */ 00332 for (cat = config->root; cat; cat = cat->next) { 00333 if (cat->name == category_name && (ignored || !cat->ignored)) 00334 return cat; 00335 } 00336 00337 for (cat = config->root; cat; cat = cat->next) { 00338 if (!strcasecmp(cat->name, category_name) && (ignored || !cat->ignored)) 00339 return cat; 00340 } 00341 00342 return NULL; 00343 }
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] |
static void clear_config_maps | ( | void | ) | [static] |
Definition at line 1165 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().
01166 { 01167 struct ast_config_map *map; 01168 01169 ast_mutex_lock(&config_lock); 01170 01171 while (config_maps) { 01172 map = config_maps; 01173 config_maps = config_maps->next; 01174 free(map); 01175 } 01176 01177 ast_mutex_unlock(&config_lock); 01178 }
static int config_command | ( | int | fd, | |
int | argc, | |||
char ** | argv | |||
) | [static] |
Definition at line 1505 of file config.c.
References ast_cli(), ast_mutex_lock, config_engine_list, config_lock, config_maps, map, ast_config_engine::name, and ast_config_engine::next.
01506 { 01507 struct ast_config_engine *eng; 01508 struct ast_config_map *map; 01509 01510 ast_mutex_lock(&config_lock); 01511 01512 ast_cli(fd, "\n\n"); 01513 for (eng = config_engine_list; eng; eng = eng->next) { 01514 ast_cli(fd, "\nConfig Engine: %s\n", eng->name); 01515 for (map = config_maps; map; map = map->next) 01516 if (!strcasecmp(map->driver, eng->name)) { 01517 ast_cli(fd, "===> %s (db=%s, table=%s)\n", map->name, map->database, 01518 map->table ? map->table : map->name); 01519 } 01520 } 01521 ast_cli(fd,"\n\n"); 01522 01523 ast_mutex_unlock(&config_lock); 01524 01525 return 0; 01526 }
static struct ast_config* config_text_file_load | ( | const char * | database, | |
const char * | table, | |||
const char * | filename, | |||
struct ast_config * | cfg, | |||
int | withcomments | |||
) | [static] |
Definition at line 837 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, 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.
00838 { 00839 char fn[256]; 00840 #if defined(LOW_MEMORY) 00841 char buf[512]; 00842 #else 00843 char buf[8192]; 00844 #endif 00845 char *new_buf, *comment_p, *process_buf; 00846 FILE *f; 00847 int lineno=0; 00848 int comment = 0, nest[MAX_NESTED_COMMENTS]; 00849 struct ast_category *cat = NULL; 00850 int count = 0; 00851 struct stat statbuf; 00852 /*! Growable string buffer */ 00853 char *comment_buffer=0; /*!< this will be a comment collector.*/ 00854 int comment_buffer_size=0; /*!< the amount of storage so far alloc'd for the comment_buffer */ 00855 00856 char *lline_buffer=0; /*!< A buffer for stuff behind the ; */ 00857 int lline_buffer_size=0; 00858 00859 00860 cat = ast_config_get_current_category(cfg); 00861 00862 if (filename[0] == '/') { 00863 ast_copy_string(fn, filename, sizeof(fn)); 00864 } else { 00865 snprintf(fn, sizeof(fn), "%s/%s", (char *)ast_config_AST_CONFIG_DIR, filename); 00866 } 00867 00868 if (withcomments) { 00869 CB_INIT(&comment_buffer, &comment_buffer_size, &lline_buffer, &lline_buffer_size); 00870 if (!lline_buffer || !comment_buffer) { 00871 ast_log(LOG_ERROR, "Failed to initialize the comment buffer!\n"); 00872 return NULL; 00873 } 00874 } 00875 #ifdef AST_INCLUDE_GLOB 00876 { 00877 int glob_ret; 00878 glob_t globbuf; 00879 globbuf.gl_offs = 0; /* initialize it to silence gcc */ 00880 glob_ret = glob(fn, MY_GLOB_FLAGS, NULL, &globbuf); 00881 if (glob_ret == GLOB_NOSPACE) 00882 ast_log(LOG_WARNING, 00883 "Glob Expansion of pattern '%s' failed: Not enough memory\n", fn); 00884 else if (glob_ret == GLOB_ABORTED) 00885 ast_log(LOG_WARNING, 00886 "Glob Expansion of pattern '%s' failed: Read error\n", fn); 00887 else { 00888 /* loop over expanded files */ 00889 int i; 00890 for (i=0; i<globbuf.gl_pathc; i++) { 00891 ast_copy_string(fn, globbuf.gl_pathv[i], sizeof(fn)); 00892 #endif 00893 do { 00894 if (stat(fn, &statbuf)) 00895 continue; 00896 00897 if (!S_ISREG(statbuf.st_mode)) { 00898 ast_log(LOG_WARNING, "'%s' is not a regular file, ignoring\n", fn); 00899 continue; 00900 } 00901 if (option_verbose > 1) { 00902 ast_verbose(VERBOSE_PREFIX_2 "Parsing '%s': ", fn); 00903 fflush(stdout); 00904 } 00905 if (!(f = fopen(fn, "r"))) { 00906 if (option_debug) 00907 ast_log(LOG_DEBUG, "No file to parse: %s\n", fn); 00908 if (option_verbose > 1) 00909 ast_verbose( "Not found (%s)\n", strerror(errno)); 00910 continue; 00911 } 00912 count++; 00913 if (option_debug) 00914 ast_log(LOG_DEBUG, "Parsing %s\n", fn); 00915 if (option_verbose > 1) 00916 ast_verbose("Found\n"); 00917 while(!feof(f)) { 00918 lineno++; 00919 if (fgets(buf, sizeof(buf), f)) { 00920 if ( withcomments ) { 00921 CB_ADD(&comment_buffer, &comment_buffer_size, lline_buffer); /* add the current lline buffer to the comment buffer */ 00922 lline_buffer[0] = 0; /* erase the lline buffer */ 00923 } 00924 00925 new_buf = buf; 00926 if (comment) 00927 process_buf = NULL; 00928 else 00929 process_buf = buf; 00930 00931 while ((comment_p = strchr(new_buf, COMMENT_META))) { 00932 if ((comment_p > new_buf) && (*(comment_p-1) == '\\')) { 00933 /* Escaped semicolons aren't comments. */ 00934 new_buf = comment_p + 1; 00935 } else if(comment_p[1] == COMMENT_TAG && comment_p[2] == COMMENT_TAG && (comment_p[3] != '-')) { 00936 /* Meta-Comment start detected ";--" */ 00937 if (comment < MAX_NESTED_COMMENTS) { 00938 *comment_p = '\0'; 00939 new_buf = comment_p + 3; 00940 comment++; 00941 nest[comment-1] = lineno; 00942 } else { 00943 ast_log(LOG_ERROR, "Maximum nest limit of %d reached.\n", MAX_NESTED_COMMENTS); 00944 } 00945 } else if ((comment_p >= new_buf + 2) && 00946 (*(comment_p - 1) == COMMENT_TAG) && 00947 (*(comment_p - 2) == COMMENT_TAG)) { 00948 /* Meta-Comment end detected */ 00949 comment--; 00950 new_buf = comment_p + 1; 00951 if (!comment) { 00952 /* Back to non-comment now */ 00953 if (process_buf) { 00954 /* Actually have to move what's left over the top, then continue */ 00955 char *oldptr; 00956 oldptr = process_buf + strlen(process_buf); 00957 if ( withcomments ) { 00958 CB_ADD(&comment_buffer, &comment_buffer_size, ";"); 00959 CB_ADD_LEN(&comment_buffer, &comment_buffer_size, oldptr+1, new_buf-oldptr-1); 00960 } 00961 00962 memmove(oldptr, new_buf, strlen(new_buf) + 1); 00963 new_buf = oldptr; 00964 } else 00965 process_buf = new_buf; 00966 } 00967 } else { 00968 if (!comment) { 00969 /* If ; is found, and we are not nested in a comment, 00970 we immediately stop all comment processing */ 00971 if ( withcomments ) { 00972 LLB_ADD(&lline_buffer, &lline_buffer_size, comment_p); 00973 } 00974 *comment_p = '\0'; 00975 new_buf = comment_p; 00976 } else 00977 new_buf = comment_p + 1; 00978 } 00979 } 00980 if( withcomments && comment && !process_buf ) 00981 { 00982 CB_ADD(&comment_buffer, &comment_buffer_size, buf); /* the whole line is a comment, store it */ 00983 } 00984 00985 if (process_buf) { 00986 char *buf = ast_strip(process_buf); 00987 if (!ast_strlen_zero(buf)) { 00988 if (process_text_line(cfg, &cat, buf, lineno, fn, withcomments, &comment_buffer, &comment_buffer_size, &lline_buffer, &lline_buffer_size)) { 00989 cfg = NULL; 00990 break; 00991 } 00992 } 00993 } 00994 } 00995 } 00996 fclose(f); 00997 } while(0); 00998 if (comment) { 00999 ast_log(LOG_WARNING,"Unterminated comment detected beginning on line %d\n", nest[comment - 1]); 01000 } 01001 #ifdef AST_INCLUDE_GLOB 01002 if (!cfg) 01003 break; 01004 } 01005 globfree(&globbuf); 01006 } 01007 } 01008 #endif 01009 01010 if (cfg && cfg->include_level == 1 && withcomments && comment_buffer) { 01011 free(comment_buffer); 01012 free(lline_buffer); 01013 comment_buffer = NULL; 01014 lline_buffer = NULL; 01015 comment_buffer_size = 0; 01016 lline_buffer_size = 0; 01017 } 01018 01019 if (count == 0) 01020 return NULL; 01021 01022 return cfg; 01023 }
int config_text_file_save | ( | const char * | configfile, | |
const struct ast_config * | cfg, | |||
const char * | generator | |||
) |
Definition at line 1025 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_comment::cmt, errno, f, ast_category::ignored, ast_category_template_instance::inst, LOG_DEBUG, ast_category::name, ast_category_template_instance::name, ast_variable::name, ast_comment::next, ast_category_template_instance::next, ast_variable::next, ast_category::next, option_debug, option_verbose, ast_category::precomments, ast_config::root, ast_category::root, 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().
01026 { 01027 FILE *f = NULL; 01028 int fd = -1; 01029 char fn[256], fntmp[256]; 01030 char date[256]=""; 01031 time_t t; 01032 struct ast_variable *var; 01033 struct ast_category *cat; 01034 struct ast_comment *cmt; 01035 struct stat s; 01036 int blanklines = 0; 01037 int stat_result = 0; 01038 01039 if (configfile[0] == '/') { 01040 snprintf(fntmp, sizeof(fntmp), "%s.XXXXXX", configfile); 01041 ast_copy_string(fn, configfile, sizeof(fn)); 01042 } else { 01043 snprintf(fntmp, sizeof(fntmp), "%s/%s.XXXXXX", ast_config_AST_CONFIG_DIR, configfile); 01044 snprintf(fn, sizeof(fn), "%s/%s", ast_config_AST_CONFIG_DIR, configfile); 01045 } 01046 time(&t); 01047 ast_copy_string(date, ctime(&t), sizeof(date)); 01048 if ((fd = mkstemp(fntmp)) > 0 && (f = fdopen(fd, "w")) != NULL) { 01049 if (option_verbose > 1) 01050 ast_verbose(VERBOSE_PREFIX_2 "Saving '%s': ", fn); 01051 fprintf(f, ";!\n"); 01052 fprintf(f, ";! Automatically generated configuration file\n"); 01053 if (strcmp(configfile, fn)) 01054 fprintf(f, ";! Filename: %s (%s)\n", configfile, fn); 01055 else 01056 fprintf(f, ";! Filename: %s\n", configfile); 01057 fprintf(f, ";! Generator: %s\n", generator); 01058 fprintf(f, ";! Creation Date: %s", date); 01059 fprintf(f, ";!\n"); 01060 cat = cfg->root; 01061 while(cat) { 01062 /* Dump section with any appropriate comment */ 01063 for (cmt = cat->precomments; cmt; cmt=cmt->next) 01064 { 01065 if (cmt->cmt[0] != ';' || cmt->cmt[1] != '!') 01066 fprintf(f,"%s", cmt->cmt); 01067 } 01068 if (!cat->precomments) 01069 fprintf(f,"\n"); 01070 fprintf(f, "[%s]", cat->name); 01071 if (cat->ignored || !AST_LIST_EMPTY(&cat->template_instances)) { 01072 fprintf(f, "("); 01073 if (cat->ignored) { 01074 fprintf(f, "!"); 01075 } 01076 if (cat->ignored && !AST_LIST_EMPTY(&cat->template_instances)) { 01077 fprintf(f, ","); 01078 } 01079 if (!AST_LIST_EMPTY(&cat->template_instances)) { 01080 struct ast_category_template_instance *x; 01081 AST_LIST_TRAVERSE(&cat->template_instances, x, next) { 01082 fprintf(f,"%s",x->name); 01083 if (x != AST_LIST_LAST(&cat->template_instances)) 01084 fprintf(f,","); 01085 } 01086 } 01087 fprintf(f, ")"); 01088 } 01089 for(cmt = cat->sameline; cmt; cmt=cmt->next) 01090 { 01091 fprintf(f,"%s", cmt->cmt); 01092 } 01093 if (!cat->sameline) 01094 fprintf(f,"\n"); 01095 var = cat->root; 01096 while(var) { 01097 struct ast_category_template_instance *x; 01098 struct ast_variable *v2; 01099 int found = 0; 01100 AST_LIST_TRAVERSE(&cat->template_instances, x, next) { 01101 01102 for (v2 = x->inst->root; v2; v2 = v2->next) { 01103 if (!strcasecmp(var->name, v2->name)) 01104 break; 01105 } 01106 if (v2 && v2->value && !strcmp(v2->value, var->value)) { 01107 found = 1; 01108 break; 01109 } 01110 } 01111 if (found) { 01112 var = var->next; 01113 continue; 01114 } 01115 for (cmt = var->precomments; cmt; cmt=cmt->next) 01116 { 01117 if (cmt->cmt[0] != ';' || cmt->cmt[1] != '!') 01118 fprintf(f,"%s", cmt->cmt); 01119 } 01120 if (var->sameline) 01121 fprintf(f, "%s %s %s %s", var->name, (var->object ? "=>" : "="), var->value, var->sameline->cmt); 01122 else 01123 fprintf(f, "%s %s %s\n", var->name, (var->object ? "=>" : "="), var->value); 01124 if (var->blanklines) { 01125 blanklines = var->blanklines; 01126 while (blanklines--) 01127 fprintf(f, "\n"); 01128 } 01129 01130 var = var->next; 01131 } 01132 #if 0 01133 /* Put an empty line */ 01134 fprintf(f, "\n"); 01135 #endif 01136 cat = cat->next; 01137 } 01138 if ((option_verbose > 1) && !option_debug) 01139 ast_verbose("Saved\n"); 01140 } else { 01141 if (option_debug) 01142 ast_log(LOG_DEBUG, "Unable to open for writing: %s (%s)\n", fn, strerror(errno)); 01143 if (option_verbose > 1) 01144 ast_verbose(VERBOSE_PREFIX_2 "Unable to write %s (%s)", fn, strerror(errno)); 01145 if (fd > -1) 01146 close(fd); 01147 return -1; 01148 } 01149 if (!(stat_result = stat(fn, &s))) { 01150 fchmod(fd, s.st_mode); 01151 } 01152 fclose(f); 01153 if ((!stat_result && unlink(fn)) || link(fntmp, fn)) { 01154 if (option_debug) 01155 ast_log(LOG_DEBUG, "Unable to open for writing: %s (%s)\n", fn, strerror(errno)); 01156 if (option_verbose > 1) 01157 ast_verbose(VERBOSE_PREFIX_2 "Unable to write %s (%s)", fn, strerror(errno)); 01158 unlink(fntmp); 01159 return -1; 01160 } 01161 unlink(fntmp); 01162 return 0; 01163 }
static struct ast_config_engine* find_engine | ( | const char * | family, | |
char * | database, | |||
int | dbsiz, | |||
char * | table, | |||
int | tabsiz | |||
) | [static] |
Find realtime engine for realtime family.
Definition at line 1325 of file config.c.
References ast_copy_string(), ast_mutex_lock, config_lock, config_maps, and map.
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().
01326 { 01327 struct ast_config_engine *eng, *ret = NULL; 01328 struct ast_config_map *map; 01329 01330 ast_mutex_lock(&config_lock); 01331 01332 for (map = config_maps; map; map = map->next) { 01333 if (!strcasecmp(family, map->name)) { 01334 if (database) 01335 ast_copy_string(database, map->database, dbsiz); 01336 if (table) 01337 ast_copy_string(table, map->table ? map->table : family, tabsiz); 01338 break; 01339 } 01340 } 01341 01342 /* Check if the required driver (engine) exist */ 01343 if (map) { 01344 for (eng = config_engine_list; !ret && eng; eng = eng->next) { 01345 if (!strcasecmp(eng->name, map->driver)) 01346 ret = eng; 01347 } 01348 } 01349 01350 ast_mutex_unlock(&config_lock); 01351 01352 /* if we found a mapping, but the engine is not available, then issue a warning */ 01353 if (map && !ret) 01354 ast_log(LOG_WARNING, "Realtime mapping for '%s' found to engine '%s', but the engine is not available\n", map->name, map->driver); 01355 01356 return ret; 01357 }
static void inherit_category | ( | struct ast_category * | new, | |
const struct ast_category * | base | |||
) | [static] |
Definition at line 462 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_category_template_instance::next, ast_category::root, ast_category::template_instances, var, and variable_clone().
Referenced by process_text_line().
00463 { 00464 struct ast_variable *var; 00465 struct ast_category_template_instance *x = ast_calloc(1,sizeof(struct ast_category_template_instance)); 00466 strcpy(x->name, base->name); 00467 x->inst = base; 00468 AST_LIST_INSERT_TAIL(&new->template_instances, x, next); 00469 for (var = base->root; var; var = var->next) 00470 ast_variable_append(new, variable_clone(var)); 00471 }
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 301 of file config.c.
References ast_variable_append(), ast_category_template_instance::next, ast_category::root, and var.
Referenced by process_text_line().
00302 { 00303 struct ast_variable *var = old->root; 00304 old->root = NULL; 00305 #if 1 00306 /* we can just move the entire list in a single op */ 00307 ast_variable_append(new, var); 00308 #else 00309 while (var) { 00310 struct ast_variable *next = var->next; 00311 var->next = NULL; 00312 ast_variable_append(new, var); 00313 var = next; 00314 } 00315 #endif 00316 }
static struct ast_category* next_available_category | ( | struct ast_category * | cat | ) | [static] |
Definition at line 399 of file config.c.
References ast_category::ignored, and ast_category::next.
Referenced by ast_category_browse().
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 640 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_skip_blanks(), 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().
00642 { 00643 char *c; 00644 char *cur = buf; 00645 struct ast_variable *v; 00646 char cmd[512], exec_file[512]; 00647 int object, do_exec, do_include; 00648 00649 /* Actually parse the entry */ 00650 if (cur[0] == '[') { 00651 struct ast_category *newcat = NULL; 00652 char *catname; 00653 00654 /* A category header */ 00655 c = strchr(cur, ']'); 00656 if (!c) { 00657 ast_log(LOG_WARNING, "parse error: no closing ']', line %d of %s\n", lineno, configfile); 00658 return -1; 00659 } 00660 *c++ = '\0'; 00661 cur++; 00662 if (*c++ != '(') 00663 c = NULL; 00664 catname = cur; 00665 if (!(*cat = newcat = ast_category_new(catname))) { 00666 return -1; 00667 } 00668 /* add comments */ 00669 if (withcomments && *comment_buffer && (*comment_buffer)[0] ) { 00670 newcat->precomments = ALLOC_COMMENT(*comment_buffer); 00671 } 00672 if (withcomments && *lline_buffer && (*lline_buffer)[0] ) { 00673 newcat->sameline = ALLOC_COMMENT(*lline_buffer); 00674 } 00675 if( withcomments ) 00676 CB_RESET(comment_buffer, lline_buffer); 00677 00678 /* If there are options or categories to inherit from, process them now */ 00679 if (c) { 00680 if (!(cur = strchr(c, ')'))) { 00681 ast_log(LOG_WARNING, "parse error: no closing ')', line %d of %s\n", lineno, configfile); 00682 return -1; 00683 } 00684 *cur = '\0'; 00685 while ((cur = strsep(&c, ","))) { 00686 if (!strcasecmp(cur, "!")) { 00687 (*cat)->ignored = 1; 00688 } else if (!strcasecmp(cur, "+")) { 00689 *cat = category_get(cfg, catname, 1); 00690 if (!(*cat)) { 00691 if (newcat) 00692 ast_category_destroy(newcat); 00693 ast_log(LOG_WARNING, "Category addition requested, but category '%s' does not exist, line %d of %s\n", catname, lineno, configfile); 00694 return -1; 00695 } 00696 if (newcat) { 00697 move_variables(newcat, *cat); 00698 ast_category_destroy(newcat); 00699 newcat = NULL; 00700 } 00701 } else { 00702 struct ast_category *base; 00703 00704 base = category_get(cfg, cur, 1); 00705 if (!base) { 00706 ast_log(LOG_WARNING, "Inheritance requested, but category '%s' does not exist, line %d of %s\n", cur, lineno, configfile); 00707 return -1; 00708 } 00709 inherit_category(*cat, base); 00710 } 00711 } 00712 } 00713 if (newcat) 00714 ast_category_append(cfg, *cat); 00715 } else if (cur[0] == '#') { 00716 /* A directive */ 00717 cur++; 00718 c = cur; 00719 while(*c && (*c > 32)) c++; 00720 if (*c) { 00721 *c = '\0'; 00722 /* Find real argument */ 00723 c = ast_skip_blanks(c + 1); 00724 if (!(*c)) 00725 c = NULL; 00726 } else 00727 c = NULL; 00728 do_include = !strcasecmp(cur, "include"); 00729 if(!do_include) 00730 do_exec = !strcasecmp(cur, "exec"); 00731 else 00732 do_exec = 0; 00733 if (do_exec && !ast_opt_exec_includes) { 00734 ast_log(LOG_WARNING, "Cannot perform #exec unless execincludes option is enabled in asterisk.conf (options section)!\n"); 00735 do_exec = 0; 00736 } 00737 if (do_include || do_exec) { 00738 if (c) { 00739 cur = c; 00740 /* Strip off leading and trailing "'s and <>'s */ 00741 if (*c == '"') { 00742 /* Dequote */ 00743 while (*c) { 00744 if (*c == '"') { 00745 strcpy(c, c + 1); /* SAFE */ 00746 c--; 00747 } else if (*c == '\\') { 00748 strcpy(c, c + 1); /* SAFE */ 00749 } 00750 c++; 00751 } 00752 } else if (*c == '<') { 00753 /* C-style include */ 00754 if (*(c + strlen(c) - 1) == '>') { 00755 cur++; 00756 *(c + strlen(c) - 1) = '\0'; 00757 } 00758 } 00759 /* #exec </path/to/executable> 00760 We create a tmp file, then we #include it, then we delete it. */ 00761 if (do_exec) { 00762 snprintf(exec_file, sizeof(exec_file), "/var/tmp/exec.%d.%ld", (int)time(NULL), (long)pthread_self()); 00763 snprintf(cmd, sizeof(cmd), "%s > %s 2>&1", cur, exec_file); 00764 ast_safe_system(cmd); 00765 cur = exec_file; 00766 } else 00767 exec_file[0] = '\0'; 00768 /* A #include */ 00769 do_include = ast_config_internal_load(cur, cfg, withcomments) ? 1 : 0; 00770 if(!ast_strlen_zero(exec_file)) 00771 unlink(exec_file); 00772 if (!do_include) { 00773 ast_log(LOG_ERROR, "*********************************************************\n"); 00774 ast_log(LOG_ERROR, "*********** YOU SHOULD REALLY READ THIS ERROR ***********\n"); 00775 ast_log(LOG_ERROR, "Future versions of Asterisk will treat a #include of a " 00776 "file that does not exist as an error, and will fail to " 00777 "load that configuration file. Please ensure that the " 00778 "file '%s' exists, even if it is empty.\n", cur); 00779 ast_log(LOG_ERROR, "*********** YOU SHOULD REALLY READ THIS ERROR ***********\n"); 00780 ast_log(LOG_ERROR, "*********************************************************\n"); 00781 return 0; 00782 } 00783 00784 } else { 00785 ast_log(LOG_WARNING, "Directive '#%s' needs an argument (%s) at line %d of %s\n", 00786 do_exec ? "exec" : "include", 00787 do_exec ? "/path/to/executable" : "filename", 00788 lineno, 00789 configfile); 00790 } 00791 } 00792 else 00793 ast_log(LOG_WARNING, "Unknown directive '#%s' at line %d of %s\n", cur, lineno, configfile); 00794 } else { 00795 /* Just a line (variable = value) */ 00796 if (!(*cat)) { 00797 ast_log(LOG_WARNING, 00798 "parse error: No category context for line %d of %s\n", lineno, configfile); 00799 return -1; 00800 } 00801 c = strchr(cur, '='); 00802 if (c) { 00803 *c = 0; 00804 c++; 00805 /* Ignore > in => */ 00806 if (*c== '>') { 00807 object = 1; 00808 c++; 00809 } else 00810 object = 0; 00811 if ((v = ast_variable_new(ast_strip(cur), ast_strip(c)))) { 00812 v->lineno = lineno; 00813 v->object = object; 00814 /* Put and reset comments */ 00815 v->blanklines = 0; 00816 ast_variable_append(*cat, v); 00817 /* add comments */ 00818 if (withcomments && *comment_buffer && (*comment_buffer)[0] ) { 00819 v->precomments = ALLOC_COMMENT(*comment_buffer); 00820 } 00821 if (withcomments && *lline_buffer && (*lline_buffer)[0] ) { 00822 v->sameline = ALLOC_COMMENT(*lline_buffer); 00823 } 00824 if( withcomments ) 00825 CB_RESET(comment_buffer, lline_buffer); 00826 00827 } else { 00828 return -1; 00829 } 00830 } else { 00831 ast_log(LOG_WARNING, "No '=' (equal sign) in line %d of %s\n", lineno, configfile); 00832 } 00833 } 00834 return 0; 00835 }
int read_config_maps | ( | void | ) |
Definition at line 1215 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().
01216 { 01217 struct ast_config *config, *configtmp; 01218 struct ast_variable *v; 01219 char *driver, *table, *database, *stringp, *tmp; 01220 01221 clear_config_maps(); 01222 01223 configtmp = ast_config_new(); 01224 configtmp->max_include_level = 1; 01225 config = ast_config_internal_load(extconfig_conf, configtmp, 0); 01226 if (!config) { 01227 ast_config_destroy(configtmp); 01228 return 0; 01229 } 01230 01231 for (v = ast_variable_browse(config, "settings"); v; v = v->next) { 01232 stringp = v->value; 01233 driver = strsep(&stringp, ","); 01234 01235 if ((tmp = strchr(stringp, '\"'))) 01236 stringp = tmp; 01237 01238 /* check if the database text starts with a double quote */ 01239 if (*stringp == '"') { 01240 stringp++; 01241 database = strsep(&stringp, "\""); 01242 strsep(&stringp, ","); 01243 } else { 01244 /* apparently this text has no quotes */ 01245 database = strsep(&stringp, ","); 01246 } 01247 01248 table = strsep(&stringp, ","); 01249 01250 if (!strcmp(v->name, extconfig_conf)) { 01251 ast_log(LOG_WARNING, "Cannot bind '%s'!\n", extconfig_conf); 01252 continue; 01253 } 01254 01255 if (!strcmp(v->name, "asterisk.conf")) { 01256 ast_log(LOG_WARNING, "Cannot bind 'asterisk.conf'!\n"); 01257 continue; 01258 } 01259 01260 if (!strcmp(v->name, "logger.conf")) { 01261 ast_log(LOG_WARNING, "Cannot bind 'logger.conf'!\n"); 01262 continue; 01263 } 01264 01265 if (!driver || !database) 01266 continue; 01267 if (!strcasecmp(v->name, "sipfriends")) { 01268 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"); 01269 append_mapping("sipusers", driver, database, table ? table : "sipfriends"); 01270 append_mapping("sippeers", driver, database, table ? table : "sipfriends"); 01271 } else if (!strcasecmp(v->name, "iaxfriends")) { 01272 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"); 01273 append_mapping("iaxusers", driver, database, table ? table : "iaxfriends"); 01274 append_mapping("iaxpeers", driver, database, table ? table : "iaxfriends"); 01275 } else 01276 append_mapping(v->name, driver, database, table); 01277 } 01278 01279 ast_config_destroy(config); 01280 return 0; 01281 }
int register_config_cli | ( | void | ) |
Definition at line 1543 of file config.c.
References ast_cli_register_multiple(), and cli_config.
Referenced by main().
01544 { 01545 ast_cli_register_multiple(cli_config, sizeof(cli_config) / sizeof(struct ast_cli_entry)); 01546 return 0; 01547 }
static struct ast_variable* variable_clone | ( | const struct ast_variable * | old | ) | [static] |
Definition at line 287 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().
00288 { 00289 struct ast_variable *new = ast_variable_new(old->name, old->value); 00290 00291 if (new) { 00292 new->lineno = old->lineno; 00293 new->object = old->object; 00294 new->blanklines = old->blanklines; 00295 /* TODO: clone comments? */ 00296 } 00297 00298 return new; 00299 }
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 1537 of file config.c.
Referenced by register_config_cli().
struct ast_cli_entry cli_show_config_mappings_deprecated [static] |
Initial value:
{ { "show", "config", "mappings", NULL }, config_command, NULL, NULL }
struct ast_config_engine* config_engine_list [static] |
Definition at line 155 of file config.c.
Referenced by ast_config_engine_deregister(), ast_config_engine_register(), ast_config_internal_load(), and config_command().
ast_mutex_t config_lock = { PTHREAD_MUTEX_INITIALIZER , 1, { NULL }, { 0 }, 0, { NULL }, { 0 }, PTHREAD_MUTEX_INITIALIZER } [static] |
Definition at line 154 of file config.c.
Referenced by ast_config_engine_deregister(), ast_config_engine_register(), clear_config_maps(), config_command(), and find_engine().
struct ast_config_map * config_maps [static] |
Referenced by append_mapping(), ast_realtime_enabled(), clear_config_maps(), config_command(), and find_engine().
char* extconfig_conf = "extconfig.conf" [static] |
char show_config_help[] [static] |
struct ast_config_engine text_file_engine [static] |
Initial value:
{ .name = "text", .load_func = config_text_file_load, }
Definition at line 1359 of file config.c.
Referenced by ast_config_internal_load().