#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 |
| struct | ast_comment |
| Structure to keep comments for rewriting configuration files. More... | |
| struct | ast_config |
| struct | ast_config_map |
| struct | template_instance_list |
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) |
| struct 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. | |
| struct ast_category * | ast_category_get (const struct ast_config *config, const char *category_name) |
| Retrieve a category if it exists. | |
| struct ast_category * | ast_category_new (const char *name) |
| void | ast_category_rename (struct ast_category *cat, const char *name) |
| struct 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. | |
| void | ast_config_destroy (struct ast_config *cfg) |
| Destroys a config. | |
| int | ast_config_engine_deregister (struct ast_config_engine *del) |
| Deegister config engine. | |
| int | ast_config_engine_register (struct ast_config_engine *new) |
| Register config engine. | |
| struct ast_category * | ast_config_get_current_category (const struct ast_config *cfg) |
| struct ast_config * | ast_config_internal_load (const char *filename, struct ast_config *cfg, int withcomments) |
| struct ast_config * | ast_config_load (const char *filename) |
| Load a config file. | |
| struct ast_config * | ast_config_load_with_comments (const char *filename) |
| struct 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) |
| struct ast_variable * | ast_load_realtime (const char *family,...) |
| Retrieve realtime configuration. | |
| struct ast_config * | ast_load_realtime_multientry (const char *family,...) |
| Retrieve realtime configuration. | |
| int | ast_update_realtime (const char *family, const char *keyfield, const char *lookup,...) |
| Update realtime configuration. | |
| void | ast_variable_append (struct ast_category *category, struct ast_variable *variable) |
| struct ast_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) |
| struct ast_variable * | ast_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_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 = ((ast_mutex_t) 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 |
Includes the Asterisk Realtime API - ARA See doc/realtime.txt and doc/extconfig.txt
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, read] |
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, ast_config_map::database, ast_config_map::driver, map, ast_config_map::name, ast_config_map::next, option_verbose, ast_config_map::stuff, ast_config_map::table, and VERBOSE_PREFIX_2.
Referenced by read_config_maps().
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 ast_config::current, ast_config::include_level, ast_category::include_level, ast_config::last, ast_category::next, and ast_config::root.
Referenced by config_mysql(), config_odbc(), config_pgsql(), handle_updates(), process_text_line(), realtime_directory(), realtime_multi_mysql(), 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.
| 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 398 of file config.c.
References ast_config::last_browse, ast_category::name, ast_category::next, next_available_category(), and ast_config::root.
Referenced by __queues_show(), action_getconfig(), aji_load_config(), authenticate(), complete_sipnotify(), do_directory(), find_queue_by_name_rt(), gtalk_load_config(), iax_provision_reload(), ind_load_module(), init_manager(), load_config(), load_module(), load_moh_classes(), load_odbc_config(), loadconfigurationfile(), misdn_cfg_init(), odbc_load_module(), osp_load(), pbx_load_config(), pbx_load_users(), read_agent_config(), realtime_directory(), realtime_peer(), realtime_switch_common(), reload(), reload_config(), reload_followme(), reload_queues(), rpt_master(), set_config(), setup_dahdi(), sla_load_config(), update_realtime_members(), and vm_change_password().
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, ast_category::next, 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(), free, and ast_category::root.
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 | ) | [read] |
Definition at line 430 of file config.c.
References ast_category::last, and ast_category::root.
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.
| 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 334 of file config.c.
References ast_category_get().
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 | |||
| ) | [read] |
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 329 of file config.c.
References category_get().
Referenced by ast_category_exist(), ast_category_root(), ast_variable_browse(), handle_updates(), realtime_directory(), realtime_switch_common(), vm_change_password(), and vm_forwardoptions().
00330 { 00331 return category_get(config, category_name, 0); 00332 }
| struct ast_category* ast_category_new | ( | const char * | name | ) | [read] |
Definition at line 302 of file config.c.
References ast_calloc, ast_copy_string(), and ast_category::name.
Referenced by config_mysql(), config_odbc(), config_pgsql(), handle_updates(), process_text_line(), realtime_directory(), realtime_multi_mysql(), 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_copy_string(), and ast_category::name.
Referenced by handle_updates(), realtime_multi_mysql(), 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 | |||
| ) | [read] |
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 390 of file config.c.
References ast_category_get(), and ast_category::root.
Referenced by realtime_peer().
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.
Check if realtime engine is configured for family returns 1 if family is configured in realtime and engine exists.
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.
| 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, 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_readconfig(), ast_rtp_reload(), ast_udptl_reload(), authenticate(), conf_exec(), directory_exec(), do_reload(), festival_exec(), find_conf(), handle_save_dialplan(), iax_provision_reload(), ind_load_module(), init_logger_chain(), init_manager(), load_config(), load_config_meetme(), load_module(), load_modules(), load_moh_classes(), load_odbc_config(), load_realtime_queue(), load_rpt_vars(), loadconfigurationfile(), 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(), read_config_maps(), realtime_directory(), realtime_multi_mysql(), realtime_peer(), realtime_switch_common(), reload(), reload_config(), reload_followme(), reload_queues(), rpt_master(), set_config(), setup_dahdi(), sla_load_config(), smdi_load(), tds_load_module(), unload_module(), update_realtime_members(), and vm_forwardoptions().
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_lock, 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_lock, LOG_NOTICE, 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 | ) | [read] |
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 | |||
| ) | [read] |
Definition at line 1343 of file config.c.
References ast_log(), db, find_engine(), ast_config::include_level, ast_config_engine::load_func, LOG_WARNING, ast_config::max_include_level, result, and table.
Referenced by ast_config_load(), ast_config_load_with_comments(), config_mysql(), 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 | ) | [read] |
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 1383 of file config.c.
References ast_config_destroy(), ast_config_internal_load(), ast_config_new(), and result.
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 | ) | [read] |
Definition at line 1399 of file config.c.
References ast_config_destroy(), ast_config_internal_load(), ast_config_new(), and result.
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 | ) | [read] |
Definition at line 457 of file config.c.
References ast_calloc, config, MAX_INCLUDE_LEVEL, and ast_config::max_include_level.
Referenced by ast_config_load(), ast_config_load_with_comments(), read_config_maps(), realtime_multi_mysql(), 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, ast_comment::next, ast_category::precomments, and ast_category::sameline.
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, free, and ast_category::template_instances.
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, | |
| ... | ||||
| ) | [read] |
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 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, | |
| ... | ||||
| ) | [read] |
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 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_peer(), 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 = find_engine(family, db, sizeof(db), table, sizeof(table)); 01454 if (eng && eng->realtime_multi_func) 01455 res = eng->realtime_multi_func(db, table, ap); 01456 va_end(ap); 01457 01458 return res; 01459 }
| 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 1461 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(), realtime_update_exec(), realtime_update_peer(), and update_realtime_member_field().
01462 { 01463 struct ast_config_engine *eng; 01464 int res = -1; 01465 char db[256]=""; 01466 char table[256]=""; 01467 va_list ap; 01468 01469 va_start(ap, lookup); 01470 eng = find_engine(family, db, sizeof(db), table, sizeof(table)); 01471 if (eng && eng->update_func) 01472 res = eng->update_func(db, table, keyfield, lookup, ap); 01473 va_end(ap); 01474 01475 return res; 01476 }
| void ast_variable_append | ( | struct ast_category * | category, | |
| struct ast_variable * | variable | |||
| ) |
Definition at line 204 of file config.c.
References ast_category::last, ast_variable::next, and ast_category::root.
Referenced by config_mysql(), config_odbc(), config_pgsql(), handle_updates(), inherit_category(), move_variables(), process_text_line(), realtime_directory(), realtime_multi_mysql(), realtime_multi_odbc(), realtime_multi_pgsql(), and vm_change_password().
00205 { 00206 if (!variable) 00207 return; 00208 if (category->last) 00209 category->last->next = variable; 00210 else 00211 category->root = variable; 00212 category->last = variable; 00213 while (category->last->next) 00214 category->last = category->last->next; 00215 }
| struct ast_variable* ast_variable_browse | ( | const struct ast_config * | config, | |
| const char * | category | |||
| ) | [read] |
Goes through variables Somewhat similar in intent as the ast_category_browse. List variables of config file category.
Returns ast_variable list on success, or NULL on failure
Definition at line 228 of file config.c.
References ast_category_get(), ast_config::last_browse, ast_category::name, and ast_category::root.
Referenced by __ast_http_load(), action_getconfig(), adsi_load(), aji_load_config(), ast_enum_init(), ast_readconfig(), ast_variable_retrieve(), authenticate(), check_tx_freq(), collect_function_digits(), conf_exec(), database_first_connect(), 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(), my_load_module(), 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().
00229 { 00230 struct ast_category *cat = NULL; 00231 00232 if (category && config->last_browse && (config->last_browse->name == category)) 00233 cat = config->last_browse; 00234 else 00235 cat = ast_category_get(config, category); 00236 00237 return (cat) ? cat->root : NULL; 00238 }
| int ast_variable_delete | ( | struct ast_category * | category, | |
| char * | variable, | |||
| char * | match | |||
| ) |
Definition at line 466 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().
00467 { 00468 struct ast_variable *cur, *prev=NULL, *curn; 00469 int res = -1; 00470 cur = category->root; 00471 while (cur) { 00472 if (cur->name == variable) { 00473 if (prev) { 00474 prev->next = cur->next; 00475 if (cur == category->last) 00476 category->last = prev; 00477 } else { 00478 category->root = cur->next; 00479 if (cur == category->last) 00480 category->last = NULL; 00481 } 00482 cur->next = NULL; 00483 ast_variables_destroy(cur); 00484 return 0; 00485 } 00486 prev = cur; 00487 cur = cur->next; 00488 } 00489 00490 prev = NULL; 00491 cur = category->root; 00492 while (cur) { 00493 curn = cur->next; 00494 if (!strcasecmp(cur->name, variable) && (ast_strlen_zero(match) || !strcasecmp(cur->value, match))) { 00495 if (prev) { 00496 prev->next = cur->next; 00497 if (cur == category->last) 00498 category->last = prev; 00499 } else { 00500 category->root = cur->next; 00501 if (cur == category->last) 00502 category->last = NULL; 00503 } 00504 cur->next = NULL; 00505 ast_variables_destroy(cur); 00506 res = 0; 00507 } else 00508 prev = cur; 00509 00510 cur = curn; 00511 } 00512 return res; 00513 }
| struct ast_variable* ast_variable_new | ( | const char * | name, | |
| const char * | value | |||
| ) | [read] |
Definition at line 189 of file config.c.
References ast_calloc, ast_variable::name, ast_variable::stuff, and ast_variable::value.
Referenced by apply_outgoing(), ast_channeltype_list(), ast_variable_update(), astman_get_variables(), build_peer(), build_user(), check_access(), check_user_full(), config_mysql(), config_odbc(), config_pgsql(), handle_updates(), handle_uri(), parkandannounce_exec(), parse_cookies(), process_text_line(), realtime_directory(), realtime_multi_mysql(), realtime_multi_odbc(), realtime_multi_pgsql(), realtime_mysql(), realtime_odbc(), realtime_pgsql(), variable_clone(), and vm_change_password().
00190 { 00191 struct ast_variable *variable; 00192 int name_len = strlen(name) + 1; 00193 00194 if ((variable = ast_calloc(1, name_len + strlen(value) + 1 + sizeof(*variable)))) { 00195 variable->name = variable->stuff; 00196 variable->value = variable->stuff + name_len; 00197 strcpy(variable->name,name); 00198 strcpy(variable->value,value); 00199 } 00200 00201 return variable; 00202 }
| 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 250 of file config.c.
References ast_variable_browse(), ast_variable::name, ast_category::next, ast_variable::next, ast_category::root, ast_config::root, and ast_variable::value.
Referenced by advanced_options(), aji_load_config(), ast_config_option(), ast_rtp_reload(), ast_udptl_reload(), authenticate(), cdr_pgsql_read_config(), directory_exec(), do_directory(), do_reload(), do_scheduler(), festival_exec(), find_queue_by_name_rt(), function_macro(), get_wait_interval(), gtalk_load_config(), handle_save_dialplan(), iax_template_parse(), ind_load_module(), init_acf_query(), init_logger_chain(), init_manager(), load_config(), load_config_meetme(), load_module(), load_modules(), load_rpt_vars(), my_load_module(), node_lookup(), odbc_load_module(), osp_load(), parse_config(), pbx_load_config(), pbx_load_users(), play_message(), privacy_exec(), process_my_load_module(), read_agent_config(), realtime_directory(), realtime_peer(), reload_config(), reload_followme(), reload_queues(), retreive_memory(), retrieve_astcfgint(), rpt(), rpt_master(), rpt_tele_thread(), set_config(), setup_dahdi(), sla_build_station(), sla_build_trunk(), sla_load_config(), tds_load_module(), telem_lookup(), update_realtime_members(), vm_change_password(), and vm_forwardoptions().
00251 { 00252 struct ast_variable *v; 00253 00254 if (category) { 00255 for (v = ast_variable_browse(config, category); v; v = v->next) { 00256 if (!strcasecmp(variable, v->name)) 00257 return v->value; 00258 } 00259 } else { 00260 struct ast_category *cat; 00261 00262 for (cat = config->root; cat; cat = cat->next) 00263 for (v = cat->root; v; v = v->next) 00264 if (!strcasecmp(variable, v->name)) 00265 return v->value; 00266 } 00267 00268 return NULL; 00269 }
| int ast_variable_update | ( | struct ast_category * | category, | |
| const char * | variable, | |||
| const char * | value, | |||
| const char * | match, | |||
| unsigned int | object | |||
| ) |
Definition at line 515 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().
00517 { 00518 struct ast_variable *cur, *prev=NULL, *newer; 00519 00520 if (!(newer = ast_variable_new(variable, value))) 00521 return -1; 00522 00523 newer->object = object; 00524 00525 for (cur = category->root; cur; prev = cur, cur = cur->next) { 00526 if (strcasecmp(cur->name, variable) || 00527 (!ast_strlen_zero(match) && strcasecmp(cur->value, match))) 00528 continue; 00529 00530 newer->next = cur->next; 00531 newer->object = cur->object || object; 00532 if (prev) 00533 prev->next = newer; 00534 else 00535 category->root = newer; 00536 if (category->last == cur) 00537 category->last = newer; 00538 00539 cur->next = NULL; 00540 ast_variables_destroy(cur); 00541 00542 return 0; 00543 } 00544 00545 if (prev) 00546 prev->next = newer; 00547 else 00548 category->root = newer; 00549 00550 return 0; 00551 }
| 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 217 of file config.c.
References free, and ast_variable::next.
Referenced by __sip_destroy(), 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(), 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().
00218 { 00219 struct ast_variable *vn; 00220 00221 while(v) { 00222 vn = v; 00223 v = v->next; 00224 free(vn); 00225 } 00226 }
| static struct ast_category* category_get | ( | const struct ast_config * | config, | |
| const char * | category_name, | |||
| int | ignored | |||
| ) | [static, read] |
Definition at line 311 of file config.c.
References ast_category::ignored, ast_category::name, ast_category::next, and ast_config::root.
Referenced by ast_category_get(), and process_text_line().
00312 { 00313 struct ast_category *cat; 00314 00315 /* try exact match first, then case-insensitive match */ 00316 for (cat = config->root; cat; cat = cat->next) { 00317 if (cat->name == category_name && (ignored || !cat->ignored)) 00318 return cat; 00319 } 00320 00321 for (cat = config->root; cat; cat = cat->next) { 00322 if (!strcasecmp(cat->name, category_name) && (ignored || !cat->ignored)) 00323 return cat; 00324 } 00325 00326 return NULL; 00327 }
| static void CB_ADD | ( | char ** | comment_buffer, | |
| int * | comment_buffer_size, | |||
| char * | str | |||
| ) | [static] |
Definition at line 93 of file config.c.
References ast_realloc, and CB_INCR.
Referenced by config_text_file_load().
00094 { 00095 int rem = *comment_buffer_size - strlen(*comment_buffer) - 1; 00096 int siz = strlen(str); 00097 if (rem < siz+1) { 00098 *comment_buffer = ast_realloc(*comment_buffer, *comment_buffer_size + CB_INCR + siz + 1); 00099 if (!(*comment_buffer)) 00100 return; 00101 *comment_buffer_size += CB_INCR+siz+1; 00102 } 00103 strcat(*comment_buffer,str); 00104 }
| static void CB_ADD_LEN | ( | char ** | comment_buffer, | |
| int * | comment_buffer_size, | |||
| char * | str, | |||
| int | len | |||
| ) | [static] |
Definition at line 106 of file config.c.
References ast_realloc, and CB_INCR.
Referenced by config_text_file_load().
00107 { 00108 int cbl = strlen(*comment_buffer) + 1; 00109 int rem = *comment_buffer_size - cbl; 00110 if (rem < len+1) { 00111 *comment_buffer = ast_realloc(*comment_buffer, *comment_buffer_size + CB_INCR + len + 1); 00112 if (!(*comment_buffer)) 00113 return; 00114 *comment_buffer_size += CB_INCR+len+1; 00115 } 00116 strncat(*comment_buffer,str,len); 00117 (*comment_buffer)[cbl+len-1] = 0; 00118 }
| static void CB_INIT | ( | char ** | comment_buffer, | |
| int * | comment_buffer_size, | |||
| char ** | lline_buffer, | |||
| int * | lline_buffer_size | |||
| ) | [static] |
Definition at line 74 of file config.c.
References ast_malloc, and CB_INCR.
Referenced by config_text_file_load().
00075 { 00076 if (!(*comment_buffer)) { 00077 *comment_buffer = ast_malloc(CB_INCR); 00078 if (!(*comment_buffer)) 00079 return; 00080 (*comment_buffer)[0] = 0; 00081 *comment_buffer_size = CB_INCR; 00082 *lline_buffer = ast_malloc(CB_INCR); 00083 if (!(*lline_buffer)) 00084 return; 00085 (*lline_buffer)[0] = 0; 00086 *lline_buffer_size = CB_INCR; 00087 } else { 00088 (*comment_buffer)[0] = 0; 00089 (*lline_buffer)[0] = 0; 00090 } 00091 }
| static void CB_RESET | ( | char ** | comment_buffer, | |
| char ** | lline_buffer | |||
| ) | [static] |
| static void clear_config_maps | ( | void | ) | [static] |
Definition at line 1144 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().
01145 { 01146 struct ast_config_map *map; 01147 01148 ast_mutex_lock(&config_lock); 01149 01150 while (config_maps) { 01151 map = config_maps; 01152 config_maps = config_maps->next; 01153 free(map); 01154 } 01155 01156 ast_mutex_unlock(&config_lock); 01157 }
| static int config_command | ( | int | fd, | |
| int | argc, | |||
| char ** | argv | |||
| ) | [static] |
Definition at line 1478 of file config.c.
References ast_cli(), ast_mutex_lock(), ast_mutex_unlock(), config_lock, config_maps, ast_config_map::database, ast_config_map::driver, map, ast_config_map::name, ast_config_engine::name, ast_config_map::next, ast_config_engine::next, and ast_config_map::table.
01479 { 01480 struct ast_config_engine *eng; 01481 struct ast_config_map *map; 01482 01483 ast_mutex_lock(&config_lock); 01484 01485 ast_cli(fd, "\n\n"); 01486 for (eng = config_engine_list; eng; eng = eng->next) { 01487 ast_cli(fd, "\nConfig Engine: %s\n", eng->name); 01488 for (map = config_maps; map; map = map->next) 01489 if (!strcasecmp(map->driver, eng->name)) { 01490 ast_cli(fd, "===> %s (db=%s, table=%s)\n", map->name, map->database, 01491 map->table ? map->table : map->name); 01492 } 01493 } 01494 ast_cli(fd,"\n\n"); 01495 01496 ast_mutex_unlock(&config_lock); 01497 01498 return 0; 01499 }
| static struct ast_config* config_text_file_load | ( | const char * | database, | |
| const char * | table, | |||
| const char * | filename, | |||
| struct ast_config * | cfg, | |||
| int | withcomments | |||
| ) | [static, read] |
Growable string buffer
< this will be a comment collector.
< the amount of storage so far alloc'd for the comment_buffer
< A buffer for stuff behind the ;
Definition at line 812 of file config.c.
References ast_config_AST_CONFIG_DIR, ast_config_get_current_category(), ast_copy_string(), ast_log(), ast_strip(), ast_strlen_zero(), ast_verbose(), CB_ADD(), CB_ADD_LEN(), CB_INIT(), COMMENT_META, COMMENT_TAG, errno, f, free, ast_config::include_level, LLB_ADD(), LOG_DEBUG, LOG_ERROR, LOG_WARNING, MAX_NESTED_COMMENTS, option_debug, option_verbose, process_text_line(), and VERBOSE_PREFIX_2.
00813 { 00814 char fn[256]; 00815 #if defined(LOW_MEMORY) 00816 char buf[512]; 00817 #else 00818 char buf[8192]; 00819 #endif 00820 char *new_buf, *comment_p, *process_buf; 00821 FILE *f; 00822 int lineno=0; 00823 int comment = 0, nest[MAX_NESTED_COMMENTS]; 00824 struct ast_category *cat = NULL; 00825 int count = 0; 00826 struct stat statbuf; 00827 /*! Growable string buffer */ 00828 char *comment_buffer=0; /*!< this will be a comment collector.*/ 00829 int comment_buffer_size=0; /*!< the amount of storage so far alloc'd for the comment_buffer */ 00830 00831 char *lline_buffer=0; /*!< A buffer for stuff behind the ; */ 00832 int lline_buffer_size=0; 00833 00834 00835 cat = ast_config_get_current_category(cfg); 00836 00837 if (filename[0] == '/') { 00838 ast_copy_string(fn, filename, sizeof(fn)); 00839 } else { 00840 snprintf(fn, sizeof(fn), "%s/%s", (char *)ast_config_AST_CONFIG_DIR, filename); 00841 } 00842 00843 if (withcomments) { 00844 CB_INIT(&comment_buffer, &comment_buffer_size, &lline_buffer, &lline_buffer_size); 00845 if (!lline_buffer || !comment_buffer) { 00846 ast_log(LOG_ERROR, "Failed to initialize the comment buffer!\n"); 00847 return NULL; 00848 } 00849 } 00850 #ifdef AST_INCLUDE_GLOB 00851 { 00852 int glob_ret; 00853 glob_t globbuf; 00854 globbuf.gl_offs = 0; /* initialize it to silence gcc */ 00855 #ifdef SOLARIS 00856 glob_ret = glob(fn, GLOB_NOCHECK, NULL, &globbuf); 00857 #else 00858 glob_ret = glob(fn, GLOB_NOMAGIC|GLOB_BRACE, NULL, &globbuf); 00859 #endif 00860 if (glob_ret == GLOB_NOSPACE) 00861 ast_log(LOG_WARNING, 00862 "Glob Expansion of pattern '%s' failed: Not enough memory\n", fn); 00863 else if (glob_ret == GLOB_ABORTED) 00864 ast_log(LOG_WARNING, 00865 "Glob Expansion of pattern '%s' failed: Read error\n", fn); 00866 else { 00867 /* loop over expanded files */ 00868 int i; 00869 for (i=0; i<globbuf.gl_pathc; i++) { 00870 ast_copy_string(fn, globbuf.gl_pathv[i], sizeof(fn)); 00871 #endif 00872 do { 00873 if (stat(fn, &statbuf)) 00874 continue; 00875 00876 if (!S_ISREG(statbuf.st_mode)) { 00877 ast_log(LOG_WARNING, "'%s' is not a regular file, ignoring\n", fn); 00878 continue; 00879 } 00880 if (option_verbose > 1) { 00881 ast_verbose(VERBOSE_PREFIX_2 "Parsing '%s': ", fn); 00882 fflush(stdout); 00883 } 00884 if (!(f = fopen(fn, "r"))) { 00885 if (option_debug) 00886 ast_log(LOG_DEBUG, "No file to parse: %s\n", fn); 00887 if (option_verbose > 1) 00888 ast_verbose( "Not found (%s)\n", strerror(errno)); 00889 continue; 00890 } 00891 count++; 00892 if (option_debug) 00893 ast_log(LOG_DEBUG, "Parsing %s\n", fn); 00894 if (option_verbose > 1) 00895 ast_verbose("Found\n"); 00896 while(!feof(f)) { 00897 lineno++; 00898 if (fgets(buf, sizeof(buf), f)) { 00899 if ( withcomments ) { 00900 CB_ADD(&comment_buffer, &comment_buffer_size, lline_buffer); /* add the current lline buffer to the comment buffer */ 00901 lline_buffer[0] = 0; /* erase the lline buffer */ 00902 } 00903 00904 new_buf = buf; 00905 if (comment) 00906 process_buf = NULL; 00907 else 00908 process_buf = buf; 00909 00910 while ((comment_p = strchr(new_buf, COMMENT_META))) { 00911 if ((comment_p > new_buf) && (*(comment_p-1) == '\\')) { 00912 /* Escaped semicolons aren't comments. */ 00913 new_buf = comment_p + 1; 00914 } else if(comment_p[1] == COMMENT_TAG && comment_p[2] == COMMENT_TAG && (comment_p[3] != '-')) { 00915 /* Meta-Comment start detected ";--" */ 00916 if (comment < MAX_NESTED_COMMENTS) { 00917 *comment_p = '\0'; 00918 new_buf = comment_p + 3; 00919 comment++; 00920 nest[comment-1] = lineno; 00921 } else { 00922 ast_log(LOG_ERROR, "Maximum nest limit of %d reached.\n", MAX_NESTED_COMMENTS); 00923 } 00924 } else if ((comment_p >= new_buf + 2) && 00925 (*(comment_p - 1) == COMMENT_TAG) && 00926 (*(comment_p - 2) == COMMENT_TAG)) { 00927 /* Meta-Comment end detected */ 00928 comment--; 00929 new_buf = comment_p + 1; 00930 if (!comment) { 00931 /* Back to non-comment now */ 00932 if (process_buf) { 00933 /* Actually have to move what's left over the top, then continue */ 00934 char *oldptr; 00935 oldptr = process_buf + strlen(process_buf); 00936 if ( withcomments ) { 00937 CB_ADD(&comment_buffer, &comment_buffer_size, ";"); 00938 CB_ADD_LEN(&comment_buffer, &comment_buffer_size, oldptr+1, new_buf-oldptr-1); 00939 } 00940 00941 memmove(oldptr, new_buf, strlen(new_buf) + 1); 00942 new_buf = oldptr; 00943 } else 00944 process_buf = new_buf; 00945 } 00946 } else { 00947 if (!comment) { 00948 /* If ; is found, and we are not nested in a comment, 00949 we immediately stop all comment processing */ 00950 if ( withcomments ) { 00951 LLB_ADD(&lline_buffer, &lline_buffer_size, comment_p); 00952 } 00953 *comment_p = '\0'; 00954 new_buf = comment_p; 00955 } else 00956 new_buf = comment_p + 1; 00957 } 00958 } 00959 if( withcomments && comment && !process_buf ) 00960 { 00961 CB_ADD(&comment_buffer, &comment_buffer_size, buf); /* the whole line is a comment, store it */ 00962 } 00963 00964 if (process_buf) { 00965 char *buf = ast_strip(process_buf); 00966 if (!ast_strlen_zero(buf)) { 00967 if (process_text_line(cfg, &cat, buf, lineno, fn, withcomments, &comment_buffer, &comment_buffer_size, &lline_buffer, &lline_buffer_size)) { 00968 cfg = NULL; 00969 break; 00970 } 00971 } 00972 } 00973 } 00974 } 00975 fclose(f); 00976 } while(0); 00977 if (comment) { 00978 ast_log(LOG_WARNING,"Unterminated comment detected beginning on line %d\n", nest[comment - 1]); 00979 } 00980 #ifdef AST_INCLUDE_GLOB 00981 if (!cfg) 00982 break; 00983 } 00984 globfree(&globbuf); 00985 } 00986 } 00987 #endif 00988 00989 if (cfg && cfg->include_level == 1 && withcomments && comment_buffer) { 00990 free(comment_buffer); 00991 free(lline_buffer); 00992 comment_buffer = NULL; 00993 lline_buffer = NULL; 00994 comment_buffer_size = 0; 00995 lline_buffer_size = 0; 00996 } 00997 00998 if (count == 0) 00999 return NULL; 01000 01001 return cfg; 01002 }
| int config_text_file_save | ( | const char * | configfile, | |
| const struct ast_config * | cfg, | |||
| const char * | generator | |||
| ) |
Definition at line 1004 of file config.c.
References ast_config_AST_CONFIG_DIR, ast_copy_string(), AST_LIST_EMPTY, AST_LIST_LAST, AST_LIST_TRAVERSE, ast_log(), ast_verbose(), ast_variable::blanklines, ast_comment::cmt, errno, f, ast_category::ignored, ast_category_template_instance::inst, LOG_DEBUG, ast_variable::name, ast_category_template_instance::name, ast_category::name, ast_category::next, ast_variable::next, ast_comment::next, ast_variable::object, option_debug, option_verbose, ast_variable::precomments, ast_category::precomments, ast_category::root, ast_config::root, ast_variable::sameline, ast_category::sameline, t, ast_category::template_instances, ast_variable::value, var, and VERBOSE_PREFIX_2.
Referenced by action_updateconfig(), vm_change_password(), and vm_forwardoptions().
01005 { 01006 FILE *f = NULL; 01007 int fd = -1; 01008 char fn[256], fntmp[256]; 01009 char date[256]=""; 01010 time_t t; 01011 struct ast_variable *var; 01012 struct ast_category *cat; 01013 struct ast_comment *cmt; 01014 struct stat s; 01015 int blanklines = 0; 01016 int stat_result = 0; 01017 01018 if (configfile[0] == '/') { 01019 snprintf(fntmp, sizeof(fntmp), "%s.XXXXXX", configfile); 01020 ast_copy_string(fn, configfile, sizeof(fn)); 01021 } else { 01022 snprintf(fntmp, sizeof(fntmp), "%s/%s.XXXXXX", ast_config_AST_CONFIG_DIR, configfile); 01023 snprintf(fn, sizeof(fn), "%s/%s", ast_config_AST_CONFIG_DIR, configfile); 01024 } 01025 time(&t); 01026 ast_copy_string(date, ctime(&t), sizeof(date)); 01027 if ((fd = mkstemp(fntmp)) > 0 && (f = fdopen(fd, "w")) != NULL) { 01028 if (option_verbose > 1) 01029 ast_verbose(VERBOSE_PREFIX_2 "Saving '%s': ", fn); 01030 fprintf(f, ";!\n"); 01031 fprintf(f, ";! Automatically generated configuration file\n"); 01032 if (strcmp(configfile, fn)) 01033 fprintf(f, ";! Filename: %s (%s)\n", configfile, fn); 01034 else 01035 fprintf(f, ";! Filename: %s\n", configfile); 01036 fprintf(f, ";! Generator: %s\n", generator); 01037 fprintf(f, ";! Creation Date: %s", date); 01038 fprintf(f, ";!\n"); 01039 cat = cfg->root; 01040 while(cat) { 01041 /* Dump section with any appropriate comment */ 01042 for (cmt = cat->precomments; cmt; cmt=cmt->next) 01043 { 01044 if (cmt->cmt[0] != ';' || cmt->cmt[1] != '!') 01045 fprintf(f,"%s", cmt->cmt); 01046 } 01047 if (!cat->precomments) 01048 fprintf(f,"\n"); 01049 fprintf(f, "[%s]", cat->name); 01050 if (cat->ignored || !AST_LIST_EMPTY(&cat->template_instances)) { 01051 fprintf(f, "("); 01052 if (cat->ignored) { 01053 fprintf(f, "!"); 01054 } 01055 if (cat->ignored && !AST_LIST_EMPTY(&cat->template_instances)) { 01056 fprintf(f, ","); 01057 } 01058 if (!AST_LIST_EMPTY(&cat->template_instances)) { 01059 struct ast_category_template_instance *x; 01060 AST_LIST_TRAVERSE(&cat->template_instances, x, next) { 01061 fprintf(f,"%s",x->name); 01062 if (x != AST_LIST_LAST(&cat->template_instances)) 01063 fprintf(f,","); 01064 } 01065 } 01066 fprintf(f, ")"); 01067 } 01068 for(cmt = cat->sameline; cmt; cmt=cmt->next) 01069 { 01070 fprintf(f,"%s", cmt->cmt); 01071 } 01072 if (!cat->sameline) 01073 fprintf(f,"\n"); 01074 var = cat->root; 01075 while(var) { 01076 struct ast_category_template_instance *x; 01077 struct ast_variable *v2; 01078 int found = 0; 01079 AST_LIST_TRAVERSE(&cat->template_instances, x, next) { 01080 01081 for (v2 = x->inst->root; v2; v2 = v2->next) { 01082 if (!strcasecmp(var->name, v2->name)) 01083 break; 01084 } 01085 if (v2 && v2->value && !strcmp(v2->value, var->value)) { 01086 found = 1; 01087 break; 01088 } 01089 } 01090 if (found) { 01091 var = var->next; 01092 continue; 01093 } 01094 for (cmt = var->precomments; cmt; cmt=cmt->next) 01095 { 01096 if (cmt->cmt[0] != ';' || cmt->cmt[1] != '!') 01097 fprintf(f,"%s", cmt->cmt); 01098 } 01099 if (var->sameline) 01100 fprintf(f, "%s %s %s %s", var->name, (var->object ? "=>" : "="), var->value, var->sameline->cmt); 01101 else 01102 fprintf(f, "%s %s %s\n", var->name, (var->object ? "=>" : "="), var->value); 01103 if (var->blanklines) { 01104 blanklines = var->blanklines; 01105 while (blanklines--) 01106 fprintf(f, "\n"); 01107 } 01108 01109 var = var->next; 01110 } 01111 #if 0 01112 /* Put an empty line */ 01113 fprintf(f, "\n"); 01114 #endif 01115 cat = cat->next; 01116 } 01117 if ((option_verbose > 1) && !option_debug) 01118 ast_verbose("Saved\n"); 01119 } else { 01120 if (option_debug) 01121 ast_log(LOG_DEBUG, "Unable to open for writing: %s (%s)\n", fn, strerror(errno)); 01122 if (option_verbose > 1) 01123 ast_verbose(VERBOSE_PREFIX_2 "Unable to write %s (%s)", fn, strerror(errno)); 01124 if (fd > -1) 01125 close(fd); 01126 return -1; 01127 } 01128 if (!(stat_result = stat(fn, &s))) { 01129 fchmod(fd, s.st_mode); 01130 } 01131 fclose(f); 01132 if ((!stat_result && unlink(fn)) || link(fntmp, fn)) { 01133 if (option_debug) 01134 ast_log(LOG_DEBUG, "Unable to open for writing: %s (%s)\n", fn, strerror(errno)); 01135 if (option_verbose > 1) 01136 ast_verbose(VERBOSE_PREFIX_2 "Unable to write %s (%s)", fn, strerror(errno)); 01137 unlink(fntmp); 01138 return -1; 01139 } 01140 unlink(fntmp); 01141 return 0; 01142 }
| static struct ast_config_engine* find_engine | ( | const char * | family, | |
| char * | database, | |||
| int | dbsiz, | |||
| char * | table, | |||
| int | tabsiz | |||
| ) | [static, read] |
Find realtime engine for realtime family.
Definition at line 1304 of file config.c.
References ast_copy_string(), ast_log(), ast_mutex_lock(), ast_mutex_unlock(), config_lock, config_maps, ast_config_map::database, ast_config_map::driver, LOG_WARNING, map, ast_config_map::name, ast_config_engine::next, ast_config_map::next, and ast_config_map::table.
Referenced by ast_check_realtime(), ast_config_internal_load(), ast_load_realtime(), ast_load_realtime_multientry(), and ast_update_realtime().
01305 { 01306 struct ast_config_engine *eng, *ret = NULL; 01307 struct ast_config_map *map; 01308 01309 ast_mutex_lock(&config_lock); 01310 01311 for (map = config_maps; map; map = map->next) { 01312 if (!strcasecmp(family, map->name)) { 01313 if (database) 01314 ast_copy_string(database, map->database, dbsiz); 01315 if (table) 01316 ast_copy_string(table, map->table ? map->table : family, tabsiz); 01317 break; 01318 } 01319 } 01320 01321 /* Check if the required driver (engine) exist */ 01322 if (map) { 01323 for (eng = config_engine_list; !ret && eng; eng = eng->next) { 01324 if (!strcasecmp(eng->name, map->driver)) 01325 ret = eng; 01326 } 01327 } 01328 01329 ast_mutex_unlock(&config_lock); 01330 01331 /* if we found a mapping, but the engine is not available, then issue a warning */ 01332 if (map && !ret) 01333 ast_log(LOG_WARNING, "Realtime mapping for '%s' found to engine '%s', but the engine is not available\n", map->name, map->driver); 01334 01335 return ret; 01336 }
| static void inherit_category | ( | struct ast_category * | new, | |
| const struct ast_category * | base | |||
| ) | [static] |
Definition at line 446 of file config.c.
References ast_calloc, AST_LIST_INSERT_TAIL, ast_variable_append(), ast_category_template_instance::inst, ast_category::name, ast_category_template_instance::name, ast_variable::next, ast_category::root, var, and variable_clone().
Referenced by process_text_line().
00447 { 00448 struct ast_variable *var; 00449 struct ast_category_template_instance *x = ast_calloc(1,sizeof(struct ast_category_template_instance)); 00450 strcpy(x->name, base->name); 00451 x->inst = base; 00452 AST_LIST_INSERT_TAIL(&new->template_instances, x, next); 00453 for (var = base->root; var; var = var->next) 00454 ast_variable_append(new, variable_clone(var)); 00455 }
| static void LLB_ADD | ( | char ** | lline_buffer, | |
| int * | lline_buffer_size, | |||
| char * | str | |||
| ) | [static] |
Definition at line 120 of file config.c.
References ast_realloc, and CB_INCR.
Referenced by config_text_file_load().
00121 { 00122 int rem = *lline_buffer_size - strlen(*lline_buffer) - 1; 00123 int siz = strlen(str); 00124 if (rem < siz+1) { 00125 *lline_buffer = ast_realloc(*lline_buffer, *lline_buffer_size + CB_INCR + siz + 1); 00126 if (!(*lline_buffer)) 00127 return; 00128 *lline_buffer_size += CB_INCR + siz + 1; 00129 } 00130 strcat(*lline_buffer,str); 00131 }
| static void move_variables | ( | struct ast_category * | old, | |
| struct ast_category * | new | |||
| ) | [static] |
Definition at line 285 of file config.c.
References ast_variable_append(), ast_variable::next, ast_category::root, and var.
Referenced by process_text_line().
00286 { 00287 struct ast_variable *var = old->root; 00288 old->root = NULL; 00289 #if 1 00290 /* we can just move the entire list in a single op */ 00291 ast_variable_append(new, var); 00292 #else 00293 while (var) { 00294 struct ast_variable *next = var->next; 00295 var->next = NULL; 00296 ast_variable_append(new, var); 00297 var = next; 00298 } 00299 #endif 00300 }
| static struct ast_category* next_available_category | ( | struct ast_category * | cat | ) | [static, read] |
Definition at line 383 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 624 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().
00626 { 00627 char *c; 00628 char *cur = buf; 00629 struct ast_variable *v; 00630 char cmd[512], exec_file[512]; 00631 int object, do_exec, do_include; 00632 00633 /* Actually parse the entry */ 00634 if (cur[0] == '[') { 00635 struct ast_category *newcat = NULL; 00636 char *catname; 00637 00638 /* A category header */ 00639 c = strchr(cur, ']'); 00640 if (!c) { 00641 ast_log(LOG_WARNING, "parse error: no closing ']', line %d of %s\n", lineno, configfile); 00642 return -1; 00643 } 00644 *c++ = '\0'; 00645 cur++; 00646 if (*c++ != '(') 00647 c = NULL; 00648 catname = cur; 00649 if (!(*cat = newcat = ast_category_new(catname))) { 00650 return -1; 00651 } 00652 /* add comments */ 00653 if (withcomments && *comment_buffer && (*comment_buffer)[0] ) { 00654 newcat->precomments = ALLOC_COMMENT(*comment_buffer); 00655 } 00656 if (withcomments && *lline_buffer && (*lline_buffer)[0] ) { 00657 newcat->sameline = ALLOC_COMMENT(*lline_buffer); 00658 } 00659 if( withcomments ) 00660 CB_RESET(comment_buffer, lline_buffer); 00661 00662 /* If there are options or categories to inherit from, process them now */ 00663 if (c) { 00664 if (!(cur = strchr(c, ')'))) { 00665 ast_log(LOG_WARNING, "parse error: no closing ')', line %d of %s\n", lineno, configfile); 00666 return -1; 00667 } 00668 *cur = '\0'; 00669 while ((cur = strsep(&c, ","))) { 00670 if (!strcasecmp(cur, "!")) { 00671 (*cat)->ignored = 1; 00672 } else if (!strcasecmp(cur, "+")) { 00673 *cat = category_get(cfg, catname, 1); 00674 if (!(*cat)) { 00675 if (newcat) 00676 ast_category_destroy(newcat); 00677 ast_log(LOG_WARNING, "Category addition requested, but category '%s' does not exist, line %d of %s\n", catname, lineno, configfile); 00678 return -1; 00679 } 00680 if (newcat) { 00681 move_variables(newcat, *cat); 00682 ast_category_destroy(newcat); 00683 newcat = NULL; 00684 } 00685 } else { 00686 struct ast_category *base; 00687 00688 base = category_get(cfg, cur, 1); 00689 if (!base) { 00690 ast_log(LOG_WARNING, "Inheritance requested, but category '%s' does not exist, line %d of %s\n", cur, lineno, configfile); 00691 return -1; 00692 } 00693 inherit_category(*cat, base); 00694 } 00695 } 00696 } 00697 if (newcat) 00698 ast_category_append(cfg, *cat); 00699 } else if (cur[0] == '#') { 00700 /* A directive */ 00701 cur++; 00702 c = cur; 00703 while(*c && (*c > 32)) c++; 00704 if (*c) { 00705 *c = '\0'; 00706 /* Find real argument */ 00707 c = ast_skip_blanks(c + 1); 00708 if (!(*c)) 00709 c = NULL; 00710 } else 00711 c = NULL; 00712 do_include = !strcasecmp(cur, "include"); 00713 if(!do_include) 00714 do_exec = !strcasecmp(cur, "exec"); 00715 else 00716 do_exec = 0; 00717 if (do_exec && !ast_opt_exec_includes) { 00718 ast_log(LOG_WARNING, "Cannot perform #exec unless execincludes option is enabled in asterisk.conf (options section)!\n"); 00719 do_exec = 0; 00720 } 00721 if (do_include || do_exec) { 00722 if (c) { 00723 /* Strip off leading and trailing "'s and <>'s */ 00724 while((*c == '<') || (*c == '>') || (*c == '\"')) c++; 00725 /* Get rid of leading mess */ 00726 cur = c; 00727 while (!ast_strlen_zero(cur)) { 00728 c = cur + strlen(cur) - 1; 00729 if ((*c == '>') || (*c == '<') || (*c == '\"')) 00730 *c = '\0'; 00731 else 00732 break; 00733 } 00734 /* #exec </path/to/executable> 00735 We create a tmp file, then we #include it, then we delete it. */ 00736 if (do_exec) { 00737 snprintf(exec_file, sizeof(exec_file), "/var/tmp/exec.%d.%ld", (int)time(NULL), (long)pthread_self()); 00738 snprintf(cmd, sizeof(cmd), "%s > %s 2>&1", cur, exec_file); 00739 ast_safe_system(cmd); 00740 cur = exec_file; 00741 } else 00742 exec_file[0] = '\0'; 00743 /* A #include */ 00744 do_include = ast_config_internal_load(cur, cfg, withcomments) ? 1 : 0; 00745 if(!ast_strlen_zero(exec_file)) 00746 unlink(exec_file); 00747 if (!do_include) { 00748 ast_log(LOG_ERROR, "*********************************************************\n"); 00749 ast_log(LOG_ERROR, "*********** YOU SHOULD REALLY READ THIS ERROR ***********\n"); 00750 ast_log(LOG_ERROR, "Future versions of Asterisk will treat a #include of a " 00751 "file that does not exist as an error, and will fail to " 00752 "load that configuration file. Please ensure that the " 00753 "file '%s' exists, even if it is empty.\n", cur); 00754 ast_log(LOG_ERROR, "*********** YOU SHOULD REALLY READ THIS ERROR ***********\n"); 00755 ast_log(LOG_ERROR, "*********************************************************\n"); 00756 return 0; 00757 } 00758 00759 } else { 00760 ast_log(LOG_WARNING, "Directive '#%s' needs an argument (%s) at line %d of %s\n", 00761 do_exec ? "exec" : "include", 00762 do_exec ? "/path/to/executable" : "filename", 00763 lineno, 00764 configfile); 00765 } 00766 } 00767 else 00768 ast_log(LOG_WARNING, "Unknown directive '#%s' at line %d of %s\n", cur, lineno, configfile); 00769 } else { 00770 /* Just a line (variable = value) */ 00771 if (!(*cat)) { 00772 ast_log(LOG_WARNING, 00773 "parse error: No category context for line %d of %s\n", lineno, configfile); 00774 return -1; 00775 } 00776 c = strchr(cur, '='); 00777 if (c) { 00778 *c = 0; 00779 c++; 00780 /* Ignore > in => */ 00781 if (*c== '>') { 00782 object = 1; 00783 c++; 00784 } else 00785 object = 0; 00786 if ((v = ast_variable_new(ast_strip(cur), ast_strip(c)))) { 00787 v->lineno = lineno; 00788 v->object = object; 00789 /* Put and reset comments */ 00790 v->blanklines = 0; 00791 ast_variable_append(*cat, v); 00792 /* add comments */ 00793 if (withcomments && *comment_buffer && (*comment_buffer)[0] ) { 00794 v->precomments = ALLOC_COMMENT(*comment_buffer); 00795 } 00796 if (withcomments && *lline_buffer && (*lline_buffer)[0] ) { 00797 v->sameline = ALLOC_COMMENT(*lline_buffer); 00798 } 00799 if( withcomments ) 00800 CB_RESET(comment_buffer, lline_buffer); 00801 00802 } else { 00803 return -1; 00804 } 00805 } else { 00806 ast_log(LOG_WARNING, "No '=' (equal sign) in line %d of %s\n", lineno, configfile); 00807 } 00808 } 00809 return 0; 00810 }
| int read_config_maps | ( | void | ) |
Definition at line 1194 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().
01195 { 01196 struct ast_config *config, *configtmp; 01197 struct ast_variable *v; 01198 char *driver, *table, *database, *stringp, *tmp; 01199 01200 clear_config_maps(); 01201 01202 configtmp = ast_config_new(); 01203 configtmp->max_include_level = 1; 01204 config = ast_config_internal_load(extconfig_conf, configtmp, 0); 01205 if (!config) { 01206 ast_config_destroy(configtmp); 01207 return 0; 01208 } 01209 01210 for (v = ast_variable_browse(config, "settings"); v; v = v->next) { 01211 stringp = v->value; 01212 driver = strsep(&stringp, ","); 01213 01214 if ((tmp = strchr(stringp, '\"'))) 01215 stringp = tmp; 01216 01217 /* check if the database text starts with a double quote */ 01218 if (*stringp == '"') { 01219 stringp++; 01220 database = strsep(&stringp, "\""); 01221 strsep(&stringp, ","); 01222 } else { 01223 /* apparently this text has no quotes */ 01224 database = strsep(&stringp, ","); 01225 } 01226 01227 table = strsep(&stringp, ","); 01228 01229 if (!strcmp(v->name, extconfig_conf)) { 01230 ast_log(LOG_WARNING, "Cannot bind '%s'!\n", extconfig_conf); 01231 continue; 01232 } 01233 01234 if (!strcmp(v->name, "asterisk.conf")) { 01235 ast_log(LOG_WARNING, "Cannot bind 'asterisk.conf'!\n"); 01236 continue; 01237 } 01238 01239 if (!strcmp(v->name, "logger.conf")) { 01240 ast_log(LOG_WARNING, "Cannot bind 'logger.conf'!\n"); 01241 continue; 01242 } 01243 01244 if (!driver || !database) 01245 continue; 01246 if (!strcasecmp(v->name, "sipfriends")) { 01247 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"); 01248 append_mapping("sipusers", driver, database, table ? table : "sipfriends"); 01249 append_mapping("sippeers", driver, database, table ? table : "sipfriends"); 01250 } else if (!strcasecmp(v->name, "iaxfriends")) { 01251 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"); 01252 append_mapping("iaxusers", driver, database, table ? table : "iaxfriends"); 01253 append_mapping("iaxpeers", driver, database, table ? table : "iaxfriends"); 01254 } else 01255 append_mapping(v->name, driver, database, table); 01256 } 01257 01258 ast_config_destroy(config); 01259 return 0; 01260 }
| int register_config_cli | ( | void | ) |
Definition at line 1516 of file config.c.
References ast_cli_register_multiple().
Referenced by main().
01517 { 01518 ast_cli_register_multiple(cli_config, sizeof(cli_config) / sizeof(struct ast_cli_entry)); 01519 return 0; 01520 }
| static struct ast_variable* variable_clone | ( | const struct ast_variable * | old | ) | [static, read] |
Definition at line 271 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().
00272 { 00273 struct ast_variable *new = ast_variable_new(old->name, old->value); 00274 00275 if (new) { 00276 new->lineno = old->lineno; 00277 new->object = old->object; 00278 new->blanklines = old->blanklines; 00279 /* TODO: clone comments? */ 00280 } 00281 00282 return new; 00283 }
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 },
}
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] |
ast_mutex_t config_lock = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER ) [static] |
Definition at line 157 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(), 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,
}
1.5.9