#include "asterisk.h"
#include "asterisk/paths.h"
#include "asterisk/network.h"
#include <time.h>
#include <sys/stat.h>
#include <math.h>
#include "asterisk/config.h"
#include "asterisk/cli.h"
#include "asterisk/lock.h"
#include "asterisk/utils.h"
#include "asterisk/channel.h"
#include "asterisk/app.h"
#include "asterisk/astobj2.h"
#include "asterisk/strings.h"
#include "asterisk/netsock2.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_include |
| struct | ast_config_map |
| struct | cache_file_include |
| Hold the mtime for config files, so if we don't need to reread our config, don't. More... | |
| struct | cache_file_mtime |
| struct | cache_file_mtime::includes |
| struct | cfmtime_head |
| struct | inclfile |
Defines | |
| #define | AST_INCLUDE_GLOB 1 |
| #define | CB_SIZE 250 |
| #define | COMMENT_END "--;" |
| #define | COMMENT_META ';' |
| #define | COMMENT_START ";--" |
| #define | COMMENT_TAG '-' |
| #define | MAX_INCLUDE_LEVEL 10 |
| #define | MAX_NESTED_COMMENTS 128 |
| #define | MIN_VARIABLE_FNAME_SPACE 40 |
Enumerations | |
| enum | config_cache_attribute_enum { ATTRIBUTE_INCLUDE = 0, ATTRIBUTE_EXEC = 1 } |
Functions | |
| static void | __init_appendbuf (void) |
| static struct ast_comment * | ALLOC_COMMENT (struct ast_str *buffer) |
| static int | append_mapping (const char *name, const char *driver, const char *database, const char *table, int priority) |
| 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, const char *category) |
| void | ast_category_destroy (struct ast_category *cat) |
| struct ast_variable * | ast_category_detach_variables (struct ast_category *cat) |
| int | ast_category_empty (struct ast_config *cfg, const char *category) |
| Removes and destroys all variables within a category. | |
| int | ast_category_exist (const struct ast_config *config, const char *category_name) |
| Check for category duplicates. | |
| struct ast_variable * | ast_category_first (struct ast_category *cat) |
| given a pointer to a category, return the root variable. | |
| struct ast_category * | ast_category_get (const struct ast_config *config, const char *category_name) |
| Retrieve a category if it exists. | |
| void | ast_category_insert (struct ast_config *config, struct ast_category *cat, const char *match) |
| Inserts new category. | |
| struct ast_category * | ast_category_new (const char *name, const char *in_file, int lineno) |
| Create a category structure. | |
| 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. | |
| static void | ast_comment_destroy (struct ast_comment **comment) |
| void | ast_config_destroy (struct ast_config *cfg) |
| Destroys a config. | |
| int | ast_config_engine_deregister (struct ast_config_engine *del) |
| Deregister 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) |
| Retrieve the current category name being built. | |
| struct ast_config * | ast_config_internal_load (const char *filename, struct ast_config *cfg, struct ast_flags flags, const char *suggested_include_file, const char *who_asked) |
| struct ast_config * | ast_config_load2 (const char *filename, const char *who_asked, struct ast_flags flags) |
| Load a config file. | |
| struct ast_config * | ast_config_new (void) |
| Create a new base configuration structure. | |
| const char * | ast_config_option (struct ast_config *cfg, const char *cat, const char *var) |
| Retrieve a configuration variable within the configuration set. | |
| void | ast_config_set_current_category (struct ast_config *cfg, const struct ast_category *cat) |
| Set the category within the configuration as being current. | |
| int | ast_config_text_file_save (const char *configfile, const struct ast_config *cfg, const char *generator) |
| int | ast_destroy_realtime (const char *family, const char *keyfield, const char *lookup,...) |
| Destroy realtime configuration. | |
| static void | ast_destroy_template_list (struct ast_category *cat) |
| struct ast_config_include * | ast_include_find (struct ast_config *conf, const char *included_file) |
| struct ast_config_include * | ast_include_new (struct ast_config *conf, const char *from_file, const char *included_file, int is_exec, const char *exec_file, int from_lineno, char *real_included_file_name, int real_included_file_name_size) |
| void | ast_include_rename (struct ast_config *conf, const char *from_file, const char *to_file) |
| static void | ast_includes_destroy (struct ast_config_include *incls) |
| struct ast_variable * | ast_load_realtime (const char *family,...) |
| Retrieve realtime configuration. | |
| struct ast_variable * | ast_load_realtime_all (const char *family,...) |
| static struct ast_variable * | ast_load_realtime_helper (const char *family, va_list ap) |
| struct ast_config * | ast_load_realtime_multientry (const char *family,...) |
| Retrieve realtime configuration. | |
| int | ast_parse_arg (const char *arg, enum ast_parse_flags flags, void *p_result,...) |
| Helper function to parse arguments See documentation in config.h. | |
| char * | ast_realtime_decode_chunk (char *chunk) |
| Remove standard encoding from realtime values, which ensures that a semicolon embedded within a single value is not treated upon retrieval as multiple values. | |
| int | ast_realtime_enabled (void) |
| Check if there's any realtime engines loaded. | |
| char * | ast_realtime_encode_chunk (struct ast_str **dest, ssize_t maxlen, const char *chunk) |
| Encodes a chunk of data for realtime. | |
| int | ast_realtime_require_field (const char *family,...) |
| Inform realtime what fields that may be stored. | |
| int | ast_store_realtime (const char *family,...) |
| Create realtime configuration. | |
| int | ast_unload_realtime (const char *family) |
| Release any resources cached for a realtime family. | |
| int | ast_update2_realtime (const char *family,...) |
| Update 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. | |
| int | ast_variable_delete (struct ast_category *category, const char *variable, const char *match, const char *line) |
| static void | ast_variable_destroy (struct ast_variable *doomed) |
| void | ast_variable_insert (struct ast_category *category, struct ast_variable *variable, const char *line) |
| static void | ast_variable_move (struct ast_variable *dst_var, struct ast_variable *src_var) |
| struct ast_variable * | ast_variable_new (const char *name, const char *value, const char *filename) |
| 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) |
| Update variable value within a config. | |
| void | ast_variables_destroy (struct ast_variable *v) |
| Free variable list. | |
| struct ast_variable * | ast_variables_dup (struct ast_variable *var) |
| Duplicate variable list. | |
| static struct ast_category * | category_get (const struct ast_config *config, const char *category_name, int ignored) |
| static void | CB_ADD (struct ast_str **cb, const char *str) |
| static void | CB_ADD_LEN (struct ast_str **cb, const char *str, int len) |
| static void | CB_RESET (struct ast_str *cb, struct ast_str *llb) |
| static struct cache_file_mtime * | cfmtime_new (const char *filename, const char *who_asked) |
| static void | clear_config_maps (void) |
| static void | config_cache_attribute (const char *configfile, enum config_cache_attribute_enum attrtype, const char *filename, const char *who_asked) |
| static struct ast_config * | config_text_file_load (const char *database, const char *table, const char *filename, struct ast_config *cfg, struct ast_flags flags, const char *suggested_include_file, const char *who_asked) |
| int | config_text_file_save (const char *configfile, const struct ast_config *cfg, const char *generator) |
| static int | count_linefeeds (char *str) |
| static int | count_linefeeds_in_comments (struct ast_comment *x) |
| static struct ast_config_engine * | find_engine (const char *family, int priority, char *database, int dbsiz, char *table, int tabsiz) |
| Find realtime engine for realtime family. | |
| static void | gen_header (FILE *f1, const char *configfile, const char *fn, const char *generator) |
| static char * | handle_cli_config_list (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static char * | handle_cli_config_reload (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static char * | handle_cli_core_show_config_mappings (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static int | hash_string (const void *obj, const int flags) |
| static int | hashtab_compare_strings (void *a, void *b, int flags) |
| static void | inclfile_destroy (void *obj) |
| static void | inherit_category (struct ast_category *new, const struct ast_category *base) |
| static int | init_appendbuf (void *data) |
| static void | insert_leading_blank_lines (FILE *fp, struct inclfile *fi, struct ast_comment *precomments, int lineno) |
| 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, struct ast_flags flags, struct ast_str *comment_buffer, struct ast_str *lline_buffer, const char *suggested_include_file, struct ast_category **last_cat, struct ast_variable **last_var, const char *who_asked) |
| parse one line in the configuration. | |
| int | read_config_maps (void) |
| Exposed re-initialization method for core process. | |
| int | register_config_cli (void) |
| Exposed initialization method for core process. | |
| static struct inclfile * | set_fn (char *fn, int fn_size, const char *file, const char *configfile, struct ao2_container *fileset) |
| static struct ast_variable * | variable_clone (const struct ast_variable *old) |
Variables | |
| static struct ast_threadstorage | appendbuf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_appendbuf , .custom_init = init_appendbuf , } |
| static struct ast_cli_entry | cli_config [] |
| static struct ast_config_engine * | config_engine_list |
| static ast_mutex_t | config_lock = { PTHREAD_MUTEX_INITIALIZER , NULL, 1 } |
| static struct ast_config_map * | config_maps |
| static char * | extconfig_conf = "extconfig.conf" |
| static struct ast_config_engine | text_file_engine |
Includes the Asterisk Realtime API - ARA See http://wiki.asterisk.org
Definition in file config.c.
| #define CB_SIZE 250 |
| #define COMMENT_META ';' |
| #define COMMENT_TAG '-' |
| #define MAX_INCLUDE_LEVEL 10 |
| #define MAX_NESTED_COMMENTS 128 |
| #define MIN_VARIABLE_FNAME_SPACE 40 |
Define the minimum filename space to reserve for each ast_variable in case the filename is renamed later by ast_include_rename().
Definition at line 63 of file config.c.
Referenced by ast_variable_new().
Definition at line 1050 of file config.c.
01050 { 01051 ATTRIBUTE_INCLUDE = 0, 01052 ATTRIBUTE_EXEC = 1, 01053 };
| static struct ast_comment* ALLOC_COMMENT | ( | struct ast_str * | buffer | ) | [static, read] |
Definition at line 130 of file config.c.
References ast_calloc, ast_str_buffer(), ast_str_strlen(), and ast_comment::cmt.
Referenced by config_text_file_load(), and process_text_line().
00131 { 00132 struct ast_comment *x = NULL; 00133 if (!buffer || !ast_str_strlen(buffer)) { 00134 return NULL; 00135 } 00136 if ((x = ast_calloc(1, sizeof(*x) + ast_str_strlen(buffer) + 1))) { 00137 strcpy(x->cmt, ast_str_buffer(buffer)); /* SAFE */ 00138 } 00139 return x; 00140 }
| static int append_mapping | ( | const char * | name, | |
| const char * | driver, | |||
| const char * | database, | |||
| const char * | table, | |||
| int | priority | |||
| ) | [static] |
Definition at line 2080 of file config.c.
References ast_calloc, ast_verb, config_maps, ast_config_map::database, ast_config_map::driver, map, ast_config_map::name, ast_config_map::next, ast_config_map::priority, ast_config_map::stuff, and ast_config_map::table.
Referenced by read_config_maps().
02081 { 02082 struct ast_config_map *map; 02083 char *dst; 02084 int length; 02085 02086 length = sizeof(*map); 02087 length += strlen(name) + 1; 02088 length += strlen(driver) + 1; 02089 length += strlen(database) + 1; 02090 if (table) 02091 length += strlen(table) + 1; 02092 02093 if (!(map = ast_calloc(1, length))) 02094 return -1; 02095 02096 dst = map->stuff; /* writable space starts here */ 02097 map->name = strcpy(dst, name); 02098 dst += strlen(dst) + 1; 02099 map->driver = strcpy(dst, driver); 02100 dst += strlen(dst) + 1; 02101 map->database = strcpy(dst, database); 02102 if (table) { 02103 dst += strlen(dst) + 1; 02104 map->table = strcpy(dst, table); 02105 } 02106 map->priority = priority; 02107 map->next = config_maps; 02108 config_maps = map; 02109 02110 ast_verb(2, "Binding %s to %s/%s/%s\n", map->name, map->driver, map->database, map->table ? map->table : map->name); 02111 02112 return 0; 02113 }
| void ast_category_append | ( | struct ast_config * | config, | |
| struct ast_category * | category | |||
| ) |
Definition at line 679 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 add_cfg_entry(), add_rt_multi_cfg_entry(), append_row_to_cfg(), config_curl(), config_ldap(), config_odbc(), config_pgsql(), handle_updates(), process_text_line(), realtime_directory(), realtime_multi_curl(), realtime_multi_ldap(), realtime_multi_odbc(), realtime_multi_pgsql(), static_realtime_cb(), and write_password_to_file().
00680 { 00681 if (config->last) 00682 config->last->next = category; 00683 else 00684 config->root = category; 00685 category->include_level = config->include_level; 00686 config->last = category; 00687 config->current = category; 00688 }
| 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. |
| a | category on success | |
| NULL | on failure/no-more-categories |
Definition at line 766 of file config.c.
References ast_config::last_browse, ast_category::name, ast_category::next, next_available_category(), and ast_config::root.
Referenced by __init_manager(), __queues_show(), action_getconfig(), action_getconfigjson(), action_listcategories(), actual_load_config(), aji_load_config(), ast_cli_perms_init(), complete_sipnotify(), conf_exec(), config_load(), find_queue_by_name_rt(), find_realtime(), get_insecure_variable_from_config(), get_insecure_variable_from_sipregs(), gtalk_load_config(), iax_provision_reload(), jingle_load_config(), load_config(), load_format_config(), load_indications(), load_module(), load_moh_classes(), load_odbc_config(), load_pktccops_config(), load_tech_calendars(), misdn_cfg_init(), osp_load(), parse_config(), pbx_load_config(), pbx_load_users(), process_config(), queues_data_provider_get(), read_agent_config(), realtime_directory(), realtime_switch_common(), register_realtime_peers_with_callbackextens(), reload(), reload_config(), reload_followme(), reload_queue_rules(), reload_queues(), rpt_master(), search_directory(), search_directory_sub(), set_config(), set_member_penalty(), setup_dahdi_int(), show_users_realtime(), sla_load_config(), update_realtime_members(), and vm_change_password().
00767 { 00768 struct ast_category *cat; 00769 00770 if (!prev) { 00771 /* First time browse. */ 00772 cat = config->root; 00773 } else if (config->last_browse && (config->last_browse->name == prev)) { 00774 /* Simple last browse found. */ 00775 cat = config->last_browse->next; 00776 } else { 00777 /* 00778 * Config changed since last browse. 00779 * 00780 * First try cheap last browse search. (Rebrowsing a different 00781 * previous category?) 00782 */ 00783 for (cat = config->root; cat; cat = cat->next) { 00784 if (cat->name == prev) { 00785 /* Found it. */ 00786 cat = cat->next; 00787 break; 00788 } 00789 } 00790 if (!cat) { 00791 /* 00792 * Have to do it the hard way. (Last category was deleted and 00793 * re-added?) 00794 */ 00795 for (cat = config->root; cat; cat = cat->next) { 00796 if (!strcasecmp(cat->name, prev)) { 00797 /* Found it. */ 00798 cat = cat->next; 00799 break; 00800 } 00801 } 00802 } 00803 } 00804 00805 if (cat) 00806 cat = next_available_category(cat); 00807 00808 config->last_browse = cat; 00809 return (cat) ? cat->name : NULL; 00810 }
| int ast_category_delete | ( | struct ast_config * | cfg, | |
| const char * | category | |||
| ) |
Definition at line 932 of file config.c.
References ast_category_destroy(), ast_config::last, ast_category::next, and ast_config::root.
Referenced by handle_updates().
00933 { 00934 struct ast_category *prev=NULL, *cat; 00935 00936 cat = cfg->root; 00937 while (cat) { 00938 if (cat->name == category) { 00939 if (prev) { 00940 prev->next = cat->next; 00941 if (cat == cfg->last) 00942 cfg->last = prev; 00943 } else { 00944 cfg->root = cat->next; 00945 if (cat == cfg->last) 00946 cfg->last = NULL; 00947 } 00948 ast_category_destroy(cat); 00949 return 0; 00950 } 00951 prev = cat; 00952 cat = cat->next; 00953 } 00954 00955 prev = NULL; 00956 cat = cfg->root; 00957 while (cat) { 00958 if (!strcasecmp(cat->name, category)) { 00959 if (prev) { 00960 prev->next = cat->next; 00961 if (cat == cfg->last) 00962 cfg->last = prev; 00963 } else { 00964 cfg->root = cat->next; 00965 if (cat == cfg->last) 00966 cfg->last = NULL; 00967 } 00968 ast_category_destroy(cat); 00969 return 0; 00970 } 00971 prev = cat; 00972 cat = cat->next; 00973 } 00974 return -1; 00975 }
| void ast_category_destroy | ( | struct ast_category * | cat | ) |
Definition at line 718 of file config.c.
References ast_comment_destroy(), ast_destroy_template_list(), ast_free, ast_variables_destroy(), ast_category::file, ast_category::last, ast_category::precomments, ast_category::root, ast_category::sameline, and ast_category::trailing.
Referenced by add_cfg_entry(), ast_category_delete(), ast_category_new(), ast_config_destroy(), process_text_line(), realtime_multi_odbc(), and static_realtime_cb().
00719 { 00720 ast_variables_destroy(cat->root); 00721 cat->root = NULL; 00722 cat->last = NULL; 00723 ast_comment_destroy(&cat->precomments); 00724 ast_comment_destroy(&cat->sameline); 00725 ast_comment_destroy(&cat->trailing); 00726 ast_destroy_template_list(cat); 00727 ast_free(cat->file); 00728 ast_free(cat); 00729 }
| struct ast_variable* ast_category_detach_variables | ( | struct ast_category * | cat | ) | [read] |
Definition at line 812 of file config.c.
References ast_category::last, and ast_category::root.
Referenced by realtime_switch_common().
00813 { 00814 struct ast_variable *v; 00815 00816 v = cat->root; 00817 cat->root = NULL; 00818 cat->last = NULL; 00819 00820 return v; 00821 }
| int ast_category_empty | ( | struct ast_config * | cfg, | |
| const char * | category | |||
| ) |
Removes and destroys all variables within a category.
| 0 | if the category was found and emptied | |
| -1 | if the category was not found |
Definition at line 977 of file config.c.
References ast_variables_destroy(), ast_category::last, ast_category::name, ast_category::next, ast_category::root, and ast_config::root.
Referenced by handle_updates().
00978 { 00979 struct ast_category *cat; 00980 00981 for (cat = cfg->root; cat; cat = cat->next) { 00982 if (!strcasecmp(cat->name, category)) 00983 continue; 00984 ast_variables_destroy(cat->root); 00985 cat->root = NULL; 00986 cat->last = NULL; 00987 return 0; 00988 } 00989 00990 return -1; 00991 }
| 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 |
Definition at line 674 of file config.c.
References ast_category_get().
00675 { 00676 return !!ast_category_get(config, category_name); 00677 }
| struct ast_variable* ast_category_first | ( | struct ast_category * | cat | ) | [read] |
given a pointer to a category, return the root variable.
return the first var of a category
Definition at line 752 of file config.c.
References ast_category::root.
Referenced by process_text_line().
00753 { 00754 return (cat) ? cat->root : NULL; 00755 }
| 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 |
| pointer | to category if found | |
| NULL | if not. |
Definition at line 669 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().
00670 { 00671 return category_get(config, category_name, 0); 00672 }
| void ast_category_insert | ( | struct ast_config * | config, | |
| struct ast_category * | cat, | |||
| const char * | match | |||
| ) |
Inserts new category.
| config | which config to use | |
| cat | newly created category to insert | |
| match | which category to insert above |
Definition at line 690 of file config.c.
References ast_category::name, ast_category::next, and ast_config::root.
Referenced by handle_updates().
00691 { 00692 struct ast_category *cur_category; 00693 00694 if (!cat || !match) 00695 return; 00696 if (!strcasecmp(config->root->name, match)) { 00697 cat->next = config->root; 00698 config->root = cat; 00699 return; 00700 } 00701 for (cur_category = config->root; cur_category; cur_category = cur_category->next) { 00702 if (!strcasecmp(cur_category->next->name, match)) { 00703 cat->next = cur_category->next; 00704 cur_category->next = cat; 00705 break; 00706 } 00707 } 00708 }
| struct ast_category* ast_category_new | ( | const char * | name, | |
| const char * | in_file, | |||
| int | lineno | |||
| ) | [read] |
Create a category structure.
Definition at line 633 of file config.c.
References ast_calloc, ast_category_destroy(), ast_copy_string(), ast_strdup, ast_category::file, ast_category::lineno, and ast_category::name.
Referenced by add_cfg_entry(), add_rt_multi_cfg_entry(), append_row_to_cfg(), config_curl(), config_ldap(), config_odbc(), config_pgsql(), handle_updates(), process_text_line(), realtime_directory(), realtime_multi_curl(), realtime_multi_ldap(), realtime_multi_odbc(), realtime_multi_pgsql(), static_realtime_cb(), and write_password_to_file().
00634 { 00635 struct ast_category *category; 00636 00637 category = ast_calloc(1, sizeof(*category)); 00638 if (!category) { 00639 return NULL; 00640 } 00641 category->file = ast_strdup(in_file); 00642 if (!category->file) { 00643 ast_category_destroy(category); 00644 return NULL; 00645 } 00646 ast_copy_string(category->name, name, sizeof(category->name)); 00647 category->lineno = lineno; /* if you don't know the lineno, set it to 999999 or something real big */ 00648 return category; 00649 }
| void ast_category_rename | ( | struct ast_category * | cat, | |
| const char * | name | |||
| ) |
Definition at line 823 of file config.c.
References ast_copy_string(), and ast_category::name.
Referenced by handle_updates(), realtime_multi_curl(), realtime_multi_ldap(), realtime_multi_odbc(), and realtime_multi_pgsql().
00824 { 00825 ast_copy_string(cat->name, name, sizeof(cat->name)); 00826 }
| 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 757 of file config.c.
References ast_category_get(), and ast_category::root.
Referenced by get_insecure_variable_from_config(), get_insecure_variable_from_sipregs(), and register_realtime_peers_with_callbackextens().
00758 { 00759 struct ast_category *category = ast_category_get(config, cat); 00760 00761 if (category) 00762 return category->root; 00763 return NULL; 00764 }
| int ast_check_realtime | ( | const char * | family | ) |
Check if realtime engine is configured for family.
| family | which family/config to be checked |
Definition at line 2401 of file config.c.
References ast_realtime_enabled(), and find_engine().
Referenced by __queues_show(), _sip_show_peer(), _sip_show_peers(), ast_queue_log(), close_mailbox(), copy_plain_file(), destroy_association(), find_realtime_gw(), handle_response_peerpoke(), handle_voicemail_show_users(), leave_voicemail(), load_module(), load_moh_classes(), local_ast_moh_start(), logger_queue_rt_start(), realtime_peer(), realtime_update_peer(), register_realtime_peers_with_callbackextens(), rename_file(), set_member_penalty(), sip_poke_noanswer(), sip_show_settings(), and vm_delete().
02402 { 02403 struct ast_config_engine *eng; 02404 if (!ast_realtime_enabled()) { 02405 return 0; /* There are no engines at all so fail early */ 02406 } 02407 02408 eng = find_engine(family, 1, NULL, 0, NULL, 0); 02409 if (eng) 02410 return 1; 02411 return 0; 02412 }
| static void ast_comment_destroy | ( | struct ast_comment ** | comment | ) | [static] |
Definition at line 508 of file config.c.
References ast_free, and ast_comment::next.
Referenced by ast_category_destroy(), and ast_variable_destroy().
00509 { 00510 struct ast_comment *n, *p; 00511 00512 for (p = *comment; p; p = n) { 00513 n = p->next; 00514 ast_free(p); 00515 } 00516 00517 *comment = NULL; 00518 }
| void ast_config_destroy | ( | struct ast_config * | config | ) |
Destroys a config.
| config | pointer to config data structure |
Definition at line 993 of file config.c.
References ast_category_destroy(), ast_free, ast_includes_destroy(), ast_config::includes, ast_category::next, and ast_config::root.
Referenced by __ast_http_load(), __ast_http_post_load(), __ast_udptl_reload(), __init_manager(), __queues_show(), _dsp_init(), action_getconfig(), action_getconfigjson(), action_listcategories(), action_updateconfig(), adsi_load(), advanced_options(), aji_load_config(), ast_cli_perms_init(), ast_config_load2(), ast_load_realtime_multientry(), ast_plc_reload(), ast_readconfig(), conf_exec(), config_function_read(), config_load(), config_module(), directory_exec(), do_reload(), festival_exec(), find_conf(), find_load_queue_rt_friendly(), find_realtime(), get_insecure_variable_from_sippeers(), get_insecure_variable_from_sipregs(), handle_cli_dialplan_save(), iax_provision_reload(), init_logger_chain(), initialize_cc_devstate_map(), initialize_cc_max_requests(), load_config(), load_config_meetme(), load_format_config(), load_indications(), load_module(), load_modules(), load_moh_classes(), load_odbc_config(), load_pktccops_config(), load_rpt_vars(), make_email_file(), misdn_cfg_init(), node_lookup(), odbc_load_module(), osp_load(), parse_config(), pbx_load_config(), pbx_load_users(), play_message(), prep_email_sub_vars(), private_enum_init(), queues_data_provider_get(), read_agent_config(), read_config_maps(), realtime_directory(), realtime_multi_handler(), realtime_multi_pgsql(), realtime_sqlite3_multi(), realtime_switch_common(), register_realtime_peers_with_callbackextens(), reload(), reload_config(), reload_followme(), reload_module(), reload_queue_rules(), reload_queues(), rpt_master(), rtp_reload(), run_startup_commands(), set_config(), setup_dahdi_int(), show_users_realtime(), sla_load_config(), smdi_load(), store_config(), tds_load_module(), unload_module(), update_realtime_members(), and vm_forwardoptions().
00994 { 00995 struct ast_category *cat, *catn; 00996 00997 if (!cfg) 00998 return; 00999 01000 ast_includes_destroy(cfg->includes); 01001 01002 cat = cfg->root; 01003 while (cat) { 01004 catn = cat; 01005 cat = cat->next; 01006 ast_category_destroy(catn); 01007 } 01008 ast_free(cfg); 01009 }
| int ast_config_engine_deregister | ( | struct ast_config_engine * | del | ) |
Deregister config engine.
| 0 | Always |
Definition at line 2211 of file config.c.
References ast_mutex_lock, ast_mutex_unlock, config_lock, last, and ast_config_engine::next.
Referenced by unload_module().
02212 { 02213 struct ast_config_engine *ptr, *last=NULL; 02214 02215 ast_mutex_lock(&config_lock); 02216 02217 for (ptr = config_engine_list; ptr; ptr=ptr->next) { 02218 if (ptr == del) { 02219 if (last) 02220 last->next = ptr->next; 02221 else 02222 config_engine_list = ptr->next; 02223 break; 02224 } 02225 last = ptr; 02226 } 02227 02228 ast_mutex_unlock(&config_lock); 02229 02230 return 0; 02231 }
| int ast_config_engine_register | ( | struct ast_config_engine * | newconfig | ) |
Register config engine.
| 1 | Always |
Definition at line 2192 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().
02193 { 02194 struct ast_config_engine *ptr; 02195 02196 ast_mutex_lock(&config_lock); 02197 02198 if (!config_engine_list) { 02199 config_engine_list = new; 02200 } else { 02201 for (ptr = config_engine_list; ptr->next; ptr=ptr->next); 02202 ptr->next = new; 02203 } 02204 02205 ast_mutex_unlock(&config_lock); 02206 ast_log(LOG_NOTICE,"Registered Config Engine %s\n", new->name); 02207 02208 return 1; 02209 }
| struct ast_category* ast_config_get_current_category | ( | const struct ast_config * | cfg | ) | [read] |
Retrieve the current category name being built.
API for backend configuration engines while building a configuration set.
Definition at line 1011 of file config.c.
References ast_config::current.
Referenced by config_curl(), config_odbc(), and config_text_file_load().
01012 { 01013 return cfg->current; 01014 }
| struct ast_config* ast_config_internal_load | ( | const char * | filename, | |
| struct ast_config * | cfg, | |||
| struct ast_flags | flags, | |||
| const char * | suggested_include_file, | |||
| const char * | who_asked | |||
| ) | [read] |
Definition at line 2273 of file config.c.
References ast_log(), ast_test_flag, CONFIG_FLAG_NOREALTIME, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEUNCHANGED, db, find_engine(), ast_config::include_level, ast_config_engine::load_func, LOG_WARNING, ast_config::max_include_level, and table.
Referenced by add_cfg_entry(), ast_config_load2(), config_curl(), config_ldap(), config_odbc(), config_pgsql(), process_text_line(), read_config_maps(), and static_realtime_cb().
02274 { 02275 char db[256]; 02276 char table[256]; 02277 struct ast_config_engine *loader = &text_file_engine; 02278 struct ast_config *result; 02279 02280 /* The config file itself bumps include_level by 1 */ 02281 if (cfg->max_include_level > 0 && cfg->include_level == cfg->max_include_level + 1) { 02282 ast_log(LOG_WARNING, "Maximum Include level (%d) exceeded\n", cfg->max_include_level); 02283 return NULL; 02284 } 02285 02286 cfg->include_level++; 02287 02288 if (!ast_test_flag(&flags, CONFIG_FLAG_NOREALTIME) && config_engine_list) { 02289 struct ast_config_engine *eng; 02290 02291 eng = find_engine(filename, 1, db, sizeof(db), table, sizeof(table)); 02292 02293 02294 if (eng && eng->load_func) { 02295 loader = eng; 02296 } else { 02297 eng = find_engine("global", 1, db, sizeof(db), table, sizeof(table)); 02298 if (eng && eng->load_func) 02299 loader = eng; 02300 } 02301 } 02302 02303 result = loader->load_func(db, table, filename, cfg, flags, suggested_include_file, who_asked); 02304 02305 if (result && result != CONFIG_STATUS_FILEINVALID && result != CONFIG_STATUS_FILEUNCHANGED) 02306 result->include_level--; 02307 else if (result != CONFIG_STATUS_FILEINVALID) 02308 cfg->include_level--; 02309 02310 return result; 02311 }
| struct ast_config* ast_config_load2 | ( | const char * | filename, | |
| const char * | who_asked, | |||
| struct ast_flags | flags | |||
| ) | [read] |
Load a config file.
| filename | path of file to open. If no preceding '/' character, path is considered relative to AST_CONFIG_DIR | |
| who_asked | The module which is making this request. | |
| flags | Optional flags: CONFIG_FLAG_WITHCOMMENTS - load the file with comments intact; CONFIG_FLAG_FILEUNCHANGED - check the file mtime and return CONFIG_STATUS_FILEUNCHANGED if the mtime is the same; or CONFIG_FLAG_NOCACHE - don't cache file mtime (main purpose of this option is to save memory on temporary files). |
| NULL | on error |
Definition at line 2313 of file config.c.
References ast_config_destroy(), ast_config_internal_load(), ast_config_new(), CONFIG_STATUS_FILEINVALID, and CONFIG_STATUS_FILEUNCHANGED.
Referenced by __ast_http_load(), __ast_http_post_load(), __ast_udptl_reload(), __init_manager(), _dsp_init(), action_getconfig(), action_getconfigjson(), action_listcategories(), action_updateconfig(), ast_cli_perms_init(), ast_readconfig(), do_reload(), iax_provision_reload(), init_logger_chain(), initialize_cc_devstate_map(), initialize_cc_max_requests(), load_config(), load_indications(), load_modules(), misdn_cfg_init(), private_enum_init(), rtp_reload(), run_startup_commands(), and set_config().
02314 { 02315 struct ast_config *cfg; 02316 struct ast_config *result; 02317 02318 cfg = ast_config_new(); 02319 if (!cfg) 02320 return NULL; 02321 02322 result = ast_config_internal_load(filename, cfg, flags, "", who_asked); 02323 if (!result || result == CONFIG_STATUS_FILEUNCHANGED || result == CONFIG_STATUS_FILEINVALID) 02324 ast_config_destroy(cfg); 02325 02326 return result; 02327 }
| struct ast_config* ast_config_new | ( | void | ) | [read] |
Create a new base configuration structure.
Definition at line 844 of file config.c.
References ast_calloc, config, MAX_INCLUDE_LEVEL, and ast_config::max_include_level.
Referenced by ast_config_load2(), find_load_queue_rt_friendly(), read_config_maps(), realtime_multi_curl(), realtime_multi_handler(), realtime_multi_ldap(), realtime_multi_odbc(), realtime_multi_pgsql(), realtime_sqlite3_multi(), setup_dahdi_int(), and write_password_to_file().
00845 { 00846 struct ast_config *config; 00847 00848 if ((config = ast_calloc(1, sizeof(*config)))) 00849 config->max_include_level = MAX_INCLUDE_LEVEL; 00850 return config; 00851 }
| const char* ast_config_option | ( | struct ast_config * | cfg, | |
| const char * | cat, | |||
| const char * | var | |||
| ) |
Retrieve a configuration variable within the configuration set.
Retrieves the named variable var within category cat of configuration set cfg. If not found, attempts to retrieve the named variable var from within category general.
var, or NULL if not found. Definition at line 574 of file config.c.
References ast_variable_retrieve().
Referenced by actual_load_config(), pbx_load_users(), and search_directory_sub().
00575 { 00576 const char *tmp; 00577 tmp = ast_variable_retrieve(cfg, cat, var); 00578 if (!tmp) { 00579 tmp = ast_variable_retrieve(cfg, "general", var); 00580 } 00581 return tmp; 00582 }
| void ast_config_set_current_category | ( | struct ast_config * | cfg, | |
| const struct ast_category * | cat | |||
| ) |
Set the category within the configuration as being current.
API for backend configuration engines while building a configuration set.
Definition at line 1016 of file config.c.
References ast_config::current.
01017 { 01018 /* cast below is just to silence compiler warning about dropping "const" */ 01019 cfg->current = (struct ast_category *) cat; 01020 }
| int ast_config_text_file_save | ( | const char * | configfile, | |
| const struct ast_config * | cfg, | |||
| const char * | generator | |||
| ) |
Definition at line 1809 of file config.c.
References ao2_container_alloc, ao2_ref, ast_debug, AST_LIST_EMPTY, AST_LIST_LAST, AST_LIST_TRAVERSE, ast_verb, ast_variable::blanklines, ast_comment::cmt, errno, ast_config_include::exec, ast_config_include::exec_file, f, ast_variable::file, ast_category::file, gen_header(), hash_string(), hashtab_compare_strings(), ast_category::ignored, ast_config_include::include_location_file, ast_config_include::include_location_lineno, ast_config_include::included_file, ast_config::includes, insert_leading_blank_lines(), ast_category_template_instance::inst, ast_variable::lineno, ast_category::lineno, ast_variable::name, ast_category_template_instance::name, ast_category::name, ast_category::next, ast_variable::next, ast_comment::next, ast_config_include::next, ast_variable::object, option_debug, ast_config_include::output, ast_variable::precomments, ast_category::precomments, ast_category::root, ast_config::root, ast_variable::sameline, ast_category::sameline, set_fn(), ast_category::template_instances, ast_variable::trailing, ast_category::trailing, ast_variable::value, and var.
Referenced by action_updateconfig(), config_text_file_save(), vm_change_password(), vm_forwardoptions(), and write_password_to_file().
01810 { 01811 FILE *f; 01812 char fn[PATH_MAX]; 01813 struct ast_variable *var; 01814 struct ast_category *cat; 01815 struct ast_comment *cmt; 01816 struct ast_config_include *incl; 01817 int blanklines = 0; 01818 struct ao2_container *fileset; 01819 struct inclfile *fi; 01820 01821 fileset = ao2_container_alloc(1023, hash_string, hashtab_compare_strings); 01822 if (!fileset) { 01823 /* Container creation failed. */ 01824 return -1; 01825 } 01826 01827 /* reset all the output flags, in case this isn't our first time saving this data */ 01828 for (incl = cfg->includes; incl; incl = incl->next) { 01829 incl->output = 0; 01830 } 01831 01832 /* go thru all the inclusions and make sure all the files involved (configfile plus all its inclusions) 01833 are all truncated to zero bytes and have that nice header*/ 01834 for (incl = cfg->includes; incl; incl = incl->next) { 01835 if (!incl->exec) { /* leave the execs alone -- we'll write out the #exec directives, but won't zero out the include files or exec files*/ 01836 /* normally, fn is just set to incl->included_file, prepended with config dir if relative */ 01837 fi = set_fn(fn, sizeof(fn), incl->included_file, configfile, fileset); 01838 f = fopen(fn, "w"); 01839 if (f) { 01840 gen_header(f, configfile, fn, generator); 01841 fclose(f); /* this should zero out the file */ 01842 } else { 01843 ast_debug(1, "Unable to open for writing: %s\n", fn); 01844 ast_verb(2, "Unable to write %s (%s)\n", fn, strerror(errno)); 01845 } 01846 if (fi) { 01847 ao2_ref(fi, -1); 01848 } 01849 } 01850 } 01851 01852 /* just set fn to absolute ver of configfile */ 01853 fi = set_fn(fn, sizeof(fn), 0, configfile, fileset); 01854 if ( 01855 #ifdef __CYGWIN__ 01856 (f = fopen(fn, "w+")) 01857 #else 01858 (f = fopen(fn, "w")) 01859 #endif 01860 ) { 01861 ast_verb(2, "Saving '%s'\n", fn); 01862 gen_header(f, configfile, fn, generator); 01863 cat = cfg->root; 01864 fclose(f); 01865 if (fi) { 01866 ao2_ref(fi, -1); 01867 } 01868 01869 /* from here out, we open each involved file and concat the stuff we need to add to the end and immediately close... */ 01870 /* since each var, cat, and associated comments can come from any file, we have to be 01871 mobile, and open each file, print, and close it on an entry-by-entry basis */ 01872 01873 while (cat) { 01874 fi = set_fn(fn, sizeof(fn), cat->file, configfile, fileset); 01875 f = fopen(fn, "a"); 01876 if (!f) { 01877 ast_debug(1, "Unable to open for writing: %s\n", fn); 01878 ast_verb(2, "Unable to write %s (%s)\n", fn, strerror(errno)); 01879 if (fi) { 01880 ao2_ref(fi, -1); 01881 } 01882 ao2_ref(fileset, -1); 01883 return -1; 01884 } 01885 01886 /* dump any includes that happen before this category header */ 01887 for (incl=cfg->includes; incl; incl = incl->next) { 01888 if (strcmp(incl->include_location_file, cat->file) == 0){ 01889 if (cat->lineno > incl->include_location_lineno && !incl->output) { 01890 if (incl->exec) 01891 fprintf(f,"#exec \"%s\"\n", incl->exec_file); 01892 else 01893 fprintf(f,"#include \"%s\"\n", incl->included_file); 01894 incl->output = 1; 01895 } 01896 } 01897 } 01898 01899 insert_leading_blank_lines(f, fi, cat->precomments, cat->lineno); 01900 /* Dump section with any appropriate comment */ 01901 for (cmt = cat->precomments; cmt; cmt=cmt->next) { 01902 char *cmtp = cmt->cmt; 01903 while (*cmtp == ';' && *(cmtp+1) == '!') { 01904 char *cmtp2 = strchr(cmtp+1, '\n'); 01905 if (cmtp2) 01906 cmtp = cmtp2+1; 01907 else cmtp = 0; 01908 } 01909 if (cmtp) 01910 fprintf(f,"%s", cmtp); 01911 } 01912 fprintf(f, "[%s]", cat->name); 01913 if (cat->ignored || !AST_LIST_EMPTY(&cat->template_instances)) { 01914 fprintf(f, "("); 01915 if (cat->ignored) { 01916 fprintf(f, "!"); 01917 } 01918 if (cat->ignored && !AST_LIST_EMPTY(&cat->template_instances)) { 01919 fprintf(f, ","); 01920 } 01921 if (!AST_LIST_EMPTY(&cat->template_instances)) { 01922 struct ast_category_template_instance *x; 01923 AST_LIST_TRAVERSE(&cat->template_instances, x, next) { 01924 fprintf(f,"%s",x->name); 01925 if (x != AST_LIST_LAST(&cat->template_instances)) 01926 fprintf(f,","); 01927 } 01928 } 01929 fprintf(f, ")"); 01930 } 01931 for(cmt = cat->sameline; cmt; cmt=cmt->next) 01932 { 01933 fprintf(f,"%s", cmt->cmt); 01934 } 01935 if (!cat->sameline) 01936 fprintf(f,"\n"); 01937 for (cmt = cat->trailing; cmt; cmt=cmt->next) { 01938 if (cmt->cmt[0] != ';' || cmt->cmt[1] != '!') 01939 fprintf(f,"%s", cmt->cmt); 01940 } 01941 fclose(f); 01942 if (fi) { 01943 ao2_ref(fi, -1); 01944 } 01945 01946 var = cat->root; 01947 while (var) { 01948 struct ast_category_template_instance *x; 01949 int found = 0; 01950 AST_LIST_TRAVERSE(&cat->template_instances, x, next) { 01951 struct ast_variable *v; 01952 for (v = x->inst->root; v; v = v->next) { 01953 if (!strcasecmp(var->name, v->name) && !strcmp(var->value, v->value)) { 01954 found = 1; 01955 break; 01956 } 01957 } 01958 if (found) 01959 break; 01960 } 01961 if (found) { 01962 var = var->next; 01963 continue; 01964 } 01965 fi = set_fn(fn, sizeof(fn), var->file, configfile, fileset); 01966 f = fopen(fn, "a"); 01967 if (!f) { 01968 ast_debug(1, "Unable to open for writing: %s\n", fn); 01969 ast_verb(2, "Unable to write %s (%s)\n", fn, strerror(errno)); 01970 if (fi) { 01971 ao2_ref(fi, -1); 01972 } 01973 ao2_ref(fileset, -1); 01974 return -1; 01975 } 01976 01977 /* dump any includes that happen before this category header */ 01978 for (incl=cfg->includes; incl; incl = incl->next) { 01979 if (strcmp(incl->include_location_file, var->file) == 0){ 01980 if (var->lineno > incl->include_location_lineno && !incl->output) { 01981 if (incl->exec) 01982 fprintf(f,"#exec \"%s\"\n", incl->exec_file); 01983 else 01984 fprintf(f,"#include \"%s\"\n", incl->included_file); 01985 incl->output = 1; 01986 } 01987 } 01988 } 01989 01990 insert_leading_blank_lines(f, fi, var->precomments, var->lineno); 01991 for (cmt = var->precomments; cmt; cmt=cmt->next) { 01992 if (cmt->cmt[0] != ';' || cmt->cmt[1] != '!') 01993 fprintf(f,"%s", cmt->cmt); 01994 } 01995 if (var->sameline) 01996 fprintf(f, "%s %s %s %s", var->name, (var->object ? "=>" : "="), var->value, var->sameline->cmt); 01997 else 01998 fprintf(f, "%s %s %s\n", var->name, (var->object ? "=>" : "="), var->value); 01999 for (cmt = var->trailing; cmt; cmt=cmt->next) { 02000 if (cmt->cmt[0] != ';' || cmt->cmt[1] != '!') 02001 fprintf(f,"%s", cmt->cmt); 02002 } 02003 if (var->blanklines) { 02004 blanklines = var->blanklines; 02005 while (blanklines--) 02006 fprintf(f, "\n"); 02007 } 02008 02009 fclose(f); 02010 if (fi) { 02011 ao2_ref(fi, -1); 02012 } 02013 02014 var = var->next; 02015 } 02016 cat = cat->next; 02017 } 02018 if (!option_debug) { 02019 ast_verb(2, "Saving '%s': saved\n", fn); 02020 } 02021 } else { 02022 ast_debug(1, "Unable to open for writing: %s\n", fn); 02023 ast_verb(2, "Unable to write '%s' (%s)\n", fn, strerror(errno)); 02024 if (fi) { 02025 ao2_ref(fi, -1); 02026 } 02027 ao2_ref(fileset, -1); 02028 return -1; 02029 } 02030 02031 /* Now, for files with trailing #include/#exec statements, 02032 we have to make sure every entry is output */ 02033 for (incl=cfg->includes; incl; incl = incl->next) { 02034 if (!incl->output) { 02035 /* open the respective file */ 02036 fi = set_fn(fn, sizeof(fn), incl->include_location_file, configfile, fileset); 02037 f = fopen(fn, "a"); 02038 if (!f) { 02039 ast_debug(1, "Unable to open for writing: %s\n", fn); 02040 ast_verb(2, "Unable to write %s (%s)\n", fn, strerror(errno)); 02041 if (fi) { 02042 ao2_ref(fi, -1); 02043 } 02044 ao2_ref(fileset, -1); 02045 return -1; 02046 } 02047 02048 /* output the respective include */ 02049 if (incl->exec) 02050 fprintf(f,"#exec \"%s\"\n", incl->exec_file); 02051 else 02052 fprintf(f,"#include \"%s\"\n", incl->included_file); 02053 fclose(f); 02054 incl->output = 1; 02055 if (fi) { 02056 ao2_ref(fi, -1); 02057 } 02058 } 02059 } 02060 ao2_ref(fileset, -1); /* this should destroy the hash container */ 02061 02062 return 0; 02063 }
| int ast_destroy_realtime | ( | const char * | family, | |
| const char * | keyfield, | |||
| const char * | lookup, | |||
| ... | ||||
| ) |
Destroy realtime configuration.
| family | which family/config to be destroyed | |
| keyfield | which field to use as the key | |
| lookup | which value to look for in the key field to match the entry. |
Definition at line 2564 of file config.c.
References db, ast_config_engine::destroy_func, find_engine(), and table.
Referenced by cli_realtime_destroy(), function_realtime_readdestroy(), leave_voicemail(), and vm_delete().
02565 { 02566 struct ast_config_engine *eng; 02567 int res = -1, i; 02568 char db[256]; 02569 char table[256]; 02570 va_list ap; 02571 02572 va_start(ap, lookup); 02573 for (i = 1; ; i++) { 02574 if ((eng = find_engine(family, i, db, sizeof(db), table, sizeof(table)))) { 02575 if (eng->destroy_func && !(res = eng->destroy_func(db, table, keyfield, lookup, ap))) { 02576 break; 02577 } 02578 } else { 02579 break; 02580 } 02581 } 02582 va_end(ap); 02583 02584 return res; 02585 }
| static void ast_destroy_template_list | ( | struct ast_category * | cat | ) | [static] |
Definition at line 710 of file config.c.
References ast_free, AST_LIST_REMOVE_HEAD, and ast_category::template_instances.
Referenced by ast_category_destroy().
00711 { 00712 struct ast_category_template_instance *x; 00713 00714 while ((x = AST_LIST_REMOVE_HEAD(&cat->template_instances, next))) 00715 ast_free(x); 00716 }
| struct ast_config_include* ast_include_find | ( | struct ast_config * | conf, | |
| const char * | included_file | |||
| ) | [read] |
Definition at line 460 of file config.c.
References ast_config_include::included_file, ast_config::includes, and ast_config_include::next.
Referenced by ast_include_new().
00461 { 00462 struct ast_config_include *x; 00463 for (x=conf->includes;x;x=x->next) { 00464 if (strcmp(x->included_file,included_file) == 0) 00465 return x; 00466 } 00467 return 0; 00468 }
| struct ast_config_include* ast_include_new | ( | struct ast_config * | conf, | |
| const char * | from_file, | |||
| const char * | included_file, | |||
| int | is_exec, | |||
| const char * | exec_file, | |||
| int | from_lineno, | |||
| char * | real_included_file_name, | |||
| int | real_included_file_name_size | |||
| ) | [read] |
Definition at line 320 of file config.c.
References ast_calloc, ast_include_find(), ast_includes_destroy(), ast_log(), ast_strdup, ast_strlen_zero(), ast_config::includes, and LOG_WARNING.
Referenced by process_text_line().
00321 { 00322 /* a file should be included ONCE. Otherwise, if one of the instances is changed, 00323 * then all be changed. -- how do we know to include it? -- Handling modified 00324 * instances is possible, I'd have 00325 * to create a new master for each instance. */ 00326 struct ast_config_include *inc; 00327 struct stat statbuf; 00328 00329 inc = ast_include_find(conf, included_file); 00330 if (inc) { 00331 do { 00332 inc->inclusion_count++; 00333 snprintf(real_included_file_name, real_included_file_name_size, "%s~~%d", included_file, inc->inclusion_count); 00334 } while (stat(real_included_file_name, &statbuf) == 0); 00335 ast_log(LOG_WARNING,"'%s', line %d: Same File included more than once! This data will be saved in %s if saved back to disk.\n", from_file, from_lineno, real_included_file_name); 00336 } else 00337 *real_included_file_name = 0; 00338 00339 inc = ast_calloc(1,sizeof(struct ast_config_include)); 00340 if (!inc) { 00341 return NULL; 00342 } 00343 inc->include_location_file = ast_strdup(from_file); 00344 inc->include_location_lineno = from_lineno; 00345 if (!ast_strlen_zero(real_included_file_name)) 00346 inc->included_file = ast_strdup(real_included_file_name); 00347 else 00348 inc->included_file = ast_strdup(included_file); 00349 00350 inc->exec = is_exec; 00351 if (is_exec) 00352 inc->exec_file = ast_strdup(exec_file); 00353 00354 if (!inc->include_location_file 00355 || !inc->included_file 00356 || (is_exec && !inc->exec_file)) { 00357 ast_includes_destroy(inc); 00358 return NULL; 00359 } 00360 00361 /* attach this new struct to the conf struct */ 00362 inc->next = conf->includes; 00363 conf->includes = inc; 00364 00365 return inc; 00366 }
| void ast_include_rename | ( | struct ast_config * | conf, | |
| const char * | from_file, | |||
| const char * | to_file | |||
| ) |
Definition at line 368 of file config.c.
References ast_free, ast_strdup, ast_variable_destroy(), ast_variable_move(), ast_variable_new(), ast_variable::file, ast_category::file, ast_config_include::include_location_file, ast_config::includes, ast_category::last, ast_variable::name, ast_variable::next, ast_category::next, ast_config_include::next, ast_category::root, ast_config::root, str, and ast_variable::value.
Referenced by action_updateconfig().
00369 { 00370 struct ast_config_include *incl; 00371 struct ast_category *cat; 00372 char *str; 00373 00374 int from_len = strlen(from_file); 00375 int to_len = strlen(to_file); 00376 00377 if (strcmp(from_file, to_file) == 0) /* no use wasting time if the name is the same */ 00378 return; 00379 00380 /* the manager code allows you to read in one config file, then 00381 * write it back out under a different name. But, the new arrangement 00382 * ties output lines to the file name. So, before you try to write 00383 * the config file to disk, better riffle thru the data and make sure 00384 * the file names are changed. 00385 */ 00386 /* file names are on categories, includes (of course), and on variables. So, 00387 * traverse all this and swap names */ 00388 00389 for (incl = conf->includes; incl; incl=incl->next) { 00390 if (strcmp(incl->include_location_file,from_file) == 0) { 00391 if (from_len >= to_len) 00392 strcpy(incl->include_location_file, to_file); 00393 else { 00394 /* Keep the old filename if the allocation fails. */ 00395 str = ast_strdup(to_file); 00396 if (str) { 00397 ast_free(incl->include_location_file); 00398 incl->include_location_file = str; 00399 } 00400 } 00401 } 00402 } 00403 for (cat = conf->root; cat; cat = cat->next) { 00404 struct ast_variable **prev; 00405 struct ast_variable *v; 00406 struct ast_variable *new_var; 00407 00408 if (strcmp(cat->file,from_file) == 0) { 00409 if (from_len >= to_len) 00410 strcpy(cat->file, to_file); 00411 else { 00412 /* Keep the old filename if the allocation fails. */ 00413 str = ast_strdup(to_file); 00414 if (str) { 00415 ast_free(cat->file); 00416 cat->file = str; 00417 } 00418 } 00419 } 00420 for (prev = &cat->root, v = cat->root; v; prev = &v->next, v = v->next) { 00421 if (strcmp(v->file, from_file)) { 00422 continue; 00423 } 00424 00425 /* 00426 * Calculate actual space available. The file string is 00427 * intentionally stuffed before the name string just so we can 00428 * do this. 00429 */ 00430 if (to_len < v->name - v->file) { 00431 /* The new name will fit in the available space. */ 00432 str = (char *) v->file;/* Stupid compiler complains about discarding qualifiers even though I used a cast. */ 00433 strcpy(str, to_file);/* SAFE */ 00434 continue; 00435 } 00436 00437 /* Keep the old filename if the allocation fails. */ 00438 new_var = ast_variable_new(v->name, v->value, to_file); 00439 if (!new_var) { 00440 continue; 00441 } 00442 00443 /* Move items from the old list node to the replacement node. */ 00444 ast_variable_move(new_var, v); 00445 00446 /* Replace the old node in the list with the new node. */ 00447 new_var->next = v->next; 00448 if (cat->last == v) { 00449 cat->last = new_var; 00450 } 00451 *prev = new_var; 00452 00453 ast_variable_destroy(v); 00454 00455 v = new_var; 00456 } 00457 } 00458 }
| static void ast_includes_destroy | ( | struct ast_config_include * | incls | ) | [static] |
Definition at line 731 of file config.c.
References ast_free, ast_config_include::exec_file, ast_config_include::include_location_file, ast_config_include::included_file, and ast_config_include::next.
Referenced by ast_config_destroy(), and ast_include_new().
00732 { 00733 struct ast_config_include *incl,*inclnext; 00734 00735 for (incl=incls; incl; incl = inclnext) { 00736 inclnext = incl->next; 00737 ast_free(incl->include_location_file); 00738 ast_free(incl->exec_file); 00739 ast_free(incl->included_file); 00740 ast_free(incl); 00741 } 00742 }
| struct ast_variable* ast_load_realtime | ( | const char * | family, | |
| ... | ||||
| ) | [read] |
Retrieve realtime configuration.
| family | which family/config to lookup |
The difference between these two calls is that ast_load_realtime excludes fields whose values are NULL, while ast_load_realtime_all loads all columns.
You should use the constant SENTINEL to terminate arguments, in order to preserve cross-platform compatibility.
Definition at line 2362 of file config.c.
References ast_load_realtime_helper(), ast_strlen_zero(), ast_variable_destroy(), ast_variable::next, and ast_variable::value.
Referenced by conf_run(), copy_plain_file(), find_conf_realtime(), find_load_queue_rt_friendly(), find_realtime(), find_realtime_gw(), find_user_realtime(), leave_queue(), local_ast_moh_start(), queue_function_queuewaitingcount(), realtime_alias(), realtime_peer(), realtime_peer_by_addr(), realtime_peer_by_name(), realtime_peer_get_sippeer_helper(), realtime_switch_common(), realtime_user(), and rt_extend_conf().
02363 { 02364 struct ast_variable *res; 02365 struct ast_variable *cur; 02366 struct ast_variable **prev; 02367 va_list ap; 02368 02369 va_start(ap, family); 02370 res = ast_load_realtime_helper(family, ap); 02371 va_end(ap); 02372 02373 /* Filter the list. */ 02374 prev = &res; 02375 cur = res; 02376 while (cur) { 02377 if (ast_strlen_zero(cur->value)) { 02378 /* Eliminate empty entries */ 02379 struct ast_variable *next; 02380 02381 next = cur->next; 02382 *prev = next; 02383 ast_variable_destroy(cur); 02384 cur = next; 02385 } else { 02386 /* Make blank entries empty and keep them. */ 02387 if (cur->value[0] == ' ' && cur->value[1] == '\0') { 02388 char *vptr = (char *) cur->value; 02389 02390 vptr[0] = '\0'; 02391 } 02392 02393 prev = &cur->next; 02394 cur = cur->next; 02395 } 02396 } 02397 return res; 02398 }
| struct ast_variable* ast_load_realtime_all | ( | const char * | family, | |
| ... | ||||
| ) | [read] |
Definition at line 2350 of file config.c.
References ast_load_realtime_helper().
Referenced by cli_realtime_load(), function_realtime_read(), function_realtime_readdestroy(), and realtimefield_read().
02351 { 02352 struct ast_variable *res; 02353 va_list ap; 02354 02355 va_start(ap, family); 02356 res = ast_load_realtime_helper(family, ap); 02357 va_end(ap); 02358 02359 return res; 02360 }
| static struct ast_variable* ast_load_realtime_helper | ( | const char * | family, | |
| va_list | ap | |||
| ) | [static, read] |
Definition at line 2329 of file config.c.
References db, find_engine(), ast_config_engine::realtime_func, and table.
Referenced by ast_load_realtime(), and ast_load_realtime_all().
02330 { 02331 struct ast_config_engine *eng; 02332 char db[256]; 02333 char table[256]; 02334 struct ast_variable *res=NULL; 02335 int i; 02336 02337 for (i = 1; ; i++) { 02338 if ((eng = find_engine(family, i, db, sizeof(db), table, sizeof(table)))) { 02339 if (eng->realtime_func && (res = eng->realtime_func(db, table, ap))) { 02340 return res; 02341 } 02342 } else { 02343 return NULL; 02344 } 02345 } 02346 02347 return res; 02348 }
| struct ast_config* ast_load_realtime_multientry | ( | const char * | family, | |
| ... | ||||
| ) | [read] |
Retrieve realtime configuration.
| family | which family/config to lookup |
| NULL | Error or no results returned |
Definition at line 2464 of file config.c.
References ast_config_destroy(), db, find_engine(), ast_config_engine::realtime_multi_func, ast_config::root, and table.
Referenced by __queues_show(), conf_exec(), find_load_queue_rt_friendly(), find_realtime(), get_insecure_variable_from_sippeers(), get_insecure_variable_from_sipregs(), queues_data_provider_get(), realtime_directory(), realtime_switch_common(), register_realtime_peers_with_callbackextens(), set_member_penalty(), show_users_realtime(), and update_realtime_members().
02465 { 02466 struct ast_config_engine *eng; 02467 char db[256]; 02468 char table[256]; 02469 struct ast_config *res = NULL; 02470 va_list ap; 02471 int i; 02472 02473 va_start(ap, family); 02474 for (i = 1; ; i++) { 02475 if ((eng = find_engine(family, i, db, sizeof(db), table, sizeof(table)))) { 02476 if (eng->realtime_multi_func && (res = eng->realtime_multi_func(db, table, ap))) { 02477 /* If we were returned an empty cfg, destroy it and return NULL */ 02478 if (!res->root) { 02479 ast_config_destroy(res); 02480 res = NULL; 02481 } 02482 break; 02483 } 02484 } else { 02485 break; 02486 } 02487 } 02488 va_end(ap); 02489 02490 return res; 02491 }
| int ast_parse_arg | ( | const char * | arg, | |
| enum ast_parse_flags | flags, | |||
| void * | p_result, | |||
| ... | ||||
| ) |
Helper function to parse arguments See documentation in config.h.
The argument parsing routine.
Definition at line 2619 of file config.c.
References ast_debug, ast_gethostbyname(), ast_inet_ntoa(), ast_sockaddr_parse(), ast_sockaddr_stringify(), ast_strdupa, hp, PARSE_ADDR, PARSE_DEFAULT, PARSE_DOUBLE, PARSE_IN_RANGE, PARSE_INADDR, PARSE_INT32, PARSE_OUT_RANGE, PARSE_PORT_FORBID, PARSE_PORT_IGNORE, PARSE_PORT_MASK, PARSE_PORT_REQUIRE, PARSE_TYPE, PARSE_UINT32, and strsep().
Referenced by __ast_http_load(), ast_tls_read_conf(), check_via_response(), gtalk_load_config(), and reload_config().
02621 { 02622 va_list ap; 02623 int error = 0; 02624 02625 va_start(ap, p_result); 02626 switch (flags & PARSE_TYPE) { 02627 case PARSE_INT32: 02628 { 02629 int32_t *result = p_result; 02630 int32_t x, def = result ? *result : 0, 02631 high = (int32_t)0x7fffffff, 02632 low = (int32_t)0x80000000; 02633 /* optional argument: first default value, then range */ 02634 if (flags & PARSE_DEFAULT) 02635 def = va_arg(ap, int32_t); 02636 if (flags & (PARSE_IN_RANGE|PARSE_OUT_RANGE)) { 02637 /* range requested, update bounds */ 02638 low = va_arg(ap, int32_t); 02639 high = va_arg(ap, int32_t); 02640 } 02641 x = strtol(arg, NULL, 0); 02642 error = (x < low) || (x > high); 02643 if (flags & PARSE_OUT_RANGE) 02644 error = !error; 02645 if (result) 02646 *result = error ? def : x; 02647 ast_debug(3, 02648 "extract int from [%s] in [%d, %d] gives [%d](%d)\n", 02649 arg, low, high, 02650 result ? *result : x, error); 02651 break; 02652 } 02653 02654 case PARSE_UINT32: 02655 { 02656 uint32_t *result = p_result; 02657 uint32_t x, def = result ? *result : 0, 02658 low = 0, high = (uint32_t)~0; 02659 /* optional argument: first default value, then range */ 02660 if (flags & PARSE_DEFAULT) 02661 def = va_arg(ap, uint32_t); 02662 if (flags & (PARSE_IN_RANGE|PARSE_OUT_RANGE)) { 02663 /* range requested, update bounds */ 02664 low = va_arg(ap, uint32_t); 02665 high = va_arg(ap, uint32_t); 02666 } 02667 x = strtoul(arg, NULL, 0); 02668 error = (x < low) || (x > high); 02669 if (flags & PARSE_OUT_RANGE) 02670 error = !error; 02671 if (result) 02672 *result = error ? def : x; 02673 ast_debug(3, 02674 "extract uint from [%s] in [%u, %u] gives [%u](%d)\n", 02675 arg, low, high, 02676 result ? *result : x, error); 02677 break; 02678 } 02679 02680 case PARSE_DOUBLE: 02681 { 02682 double *result = p_result; 02683 double x, def = result ? *result : 0, 02684 low = -HUGE_VAL, high = HUGE_VAL; 02685 02686 /* optional argument: first default value, then range */ 02687 if (flags & PARSE_DEFAULT) 02688 def = va_arg(ap, double); 02689 if (flags & (PARSE_IN_RANGE|PARSE_OUT_RANGE)) { 02690 /* range requested, update bounds */ 02691 low = va_arg(ap, double); 02692 high = va_arg(ap, double); 02693 } 02694 x = strtod(arg, NULL); 02695 error = (x < low) || (x > high); 02696 if (flags & PARSE_OUT_RANGE) 02697 error = !error; 02698 if (result) 02699 *result = error ? def : x; 02700 ast_debug(3, 02701 "extract double from [%s] in [%f, %f] gives [%f](%d)\n", 02702 arg, low, high, 02703 result ? *result : x, error); 02704 break; 02705 } 02706 case PARSE_ADDR: 02707 { 02708 struct ast_sockaddr *addr = (struct ast_sockaddr *)p_result; 02709 02710 if (!ast_sockaddr_parse(addr, arg, flags & PARSE_PORT_MASK)) { 02711 error = 1; 02712 } 02713 02714 ast_debug(3, "extract addr from %s gives %s(%d)\n", 02715 arg, ast_sockaddr_stringify(addr), error); 02716 02717 break; 02718 } 02719 case PARSE_INADDR: /* TODO Remove this (use PARSE_ADDR instead). */ 02720 { 02721 char *port, *buf; 02722 struct sockaddr_in _sa_buf; /* buffer for the result */ 02723 struct sockaddr_in *sa = p_result ? 02724 (struct sockaddr_in *)p_result : &_sa_buf; 02725 /* default is either the supplied value or the result itself */ 02726 struct sockaddr_in *def = (flags & PARSE_DEFAULT) ? 02727 va_arg(ap, struct sockaddr_in *) : sa; 02728 struct hostent *hp; 02729 struct ast_hostent ahp; 02730 02731 memset(&_sa_buf, '\0', sizeof(_sa_buf)); /* clear buffer */ 02732 /* duplicate the string to strip away the :port */ 02733 port = ast_strdupa(arg); 02734 buf = strsep(&port, ":"); 02735 sa->sin_family = AF_INET; /* assign family */ 02736 /* 02737 * honor the ports flag setting, assign default value 02738 * in case of errors or field unset. 02739 */ 02740 flags &= PARSE_PORT_MASK; /* the only flags left to process */ 02741 if (port) { 02742 if (flags == PARSE_PORT_FORBID) { 02743 error = 1; /* port was forbidden */ 02744 sa->sin_port = def->sin_port; 02745 } else if (flags == PARSE_PORT_IGNORE) 02746 sa->sin_port = def->sin_port; 02747 else /* accept or require */ 02748 sa->sin_port = htons(strtol(port, NULL, 0)); 02749 } else { 02750 sa->sin_port = def->sin_port; 02751 if (flags == PARSE_PORT_REQUIRE) 02752 error = 1; 02753 } 02754 /* Now deal with host part, even if we have errors before. */ 02755 hp = ast_gethostbyname(buf, &ahp); 02756 if (hp) /* resolved successfully */ 02757 memcpy(&sa->sin_addr, hp->h_addr, sizeof(sa->sin_addr)); 02758 else { 02759 error = 1; 02760 sa->sin_addr = def->sin_addr; 02761 } 02762 ast_debug(3, 02763 "extract inaddr from [%s] gives [%s:%d](%d)\n", 02764 arg, ast_inet_ntoa(sa->sin_addr), 02765 ntohs(sa->sin_port), error); 02766 break; 02767 } 02768 } 02769 va_end(ap); 02770 return error; 02771 }
| char* ast_realtime_decode_chunk | ( | char * | chunk | ) |
Remove standard encoding from realtime values, which ensures that a semicolon embedded within a single value is not treated upon retrieval as multiple values.
| chunk | Data to be decoded |
Definition at line 2587 of file config.c.
Referenced by realtime_multi_pgsql(), and realtime_pgsql().
02588 { 02589 char *orig = chunk; 02590 for (; *chunk; chunk++) { 02591 if (*chunk == '^' && strchr("0123456789ABCDEFabcdef", chunk[1]) && strchr("0123456789ABCDEFabcdef", chunk[2])) { 02592 sscanf(chunk + 1, "%02hhX", chunk); 02593 memmove(chunk + 1, chunk + 3, strlen(chunk + 3) + 1); 02594 } 02595 } 02596 return orig; 02597 }
| int ast_realtime_enabled | ( | void | ) |
Check if there's any realtime engines loaded.
Definition at line 2415 of file config.c.
References config_maps.
Referenced by action_coresettings(), ast_check_realtime(), and handle_show_settings().
02416 { 02417 return config_maps ? 1 : 0; 02418 }
| char* ast_realtime_encode_chunk | ( | struct ast_str ** | dest, | |
| ssize_t | maxlen, | |||
| const char * | chunk | |||
| ) |
Encodes a chunk of data for realtime.
| dest | Destination buffer | |
| maxlen | Length passed through to ast_str_* functions | |
| chunk | Source data to be encoded |
Definition at line 2599 of file config.c.
References ast_str_append(), ast_str_buffer(), ast_str_reset(), and ast_str_set().
02600 { 02601 if (!strchr(chunk, ';') && !strchr(chunk, '^')) { 02602 ast_str_set(dest, maxlen, "%s", chunk); 02603 } else { 02604 ast_str_reset(*dest); 02605 for (; *chunk; chunk++) { 02606 if (strchr(";^", *chunk)) { 02607 ast_str_append(dest, maxlen, "^%02hhX", *chunk); 02608 } else { 02609 ast_str_append(dest, maxlen, "%c", *chunk); 02610 } 02611 } 02612 } 02613 return ast_str_buffer(*dest); 02614 }
| int ast_realtime_require_field | ( | const char * | family, | |
| ... | ||||
| ) |
Inform realtime what fields that may be stored.
| family | which family/config is referenced |
The arguments are specified in groups of 3: column name, column type, and column size. The column types are specified as integer constants, defined by the enum require_type. Note that the size is specified as the number of equivalent character fields that a field may take up, even if a field is otherwise specified as an integer type. This is due to the fact that some fields have historically been specified as character types, even if they contained integer values.
A family should always specify its fields to the minimum necessary requirements to fulfill all possible values (within reason; for example, a timeout value may reasonably be specified as an INTEGER2, with size 5. Even though values above 32767 seconds are possible, they are unlikely to be useful, and we should not complain about that size).
| 0 | Required fields met specified standards | |
| -1 | One or more fields was missing or insufficient |
Definition at line 2420 of file config.c.
References db, find_engine(), ast_config_engine::require_func, and table.
Referenced by ast_queue_log(), change_password_realtime(), conf_run(), load_module(), and logger_queue_rt_start().
02421 { 02422 struct ast_config_engine *eng; 02423 char db[256]; 02424 char table[256]; 02425 va_list ap; 02426 int res = -1, i; 02427 02428 va_start(ap, family); 02429 for (i = 1; ; i++) { 02430 if ((eng = find_engine(family, i, db, sizeof(db), table, sizeof(table)))) { 02431 /* If the require succeeds, it returns 0. */ 02432 if (eng->require_func && !(res = eng->require_func(db, table, ap))) { 02433 break; 02434 } 02435 } else { 02436 break; 02437 } 02438 } 02439 va_end(ap); 02440 02441 return res; 02442 }
| int ast_store_realtime | ( | const char * | family, | |
| ... | ||||
| ) |
Create realtime configuration.
| family | which family/config to be created |
You should use the constant SENTINEL to terminate arguments, in order to preserve cross-platform compatibility.
Definition at line 2540 of file config.c.
References db, find_engine(), ast_config_engine::store_func, and table.
Referenced by ast_queue_log(), cli_realtime_store(), copy_plain_file(), function_realtime_store(), and leave_voicemail().
02541 { 02542 struct ast_config_engine *eng; 02543 int res = -1, i; 02544 char db[256]; 02545 char table[256]; 02546 va_list ap; 02547 02548 va_start(ap, family); 02549 for (i = 1; ; i++) { 02550 if ((eng = find_engine(family, i, db, sizeof(db), table, sizeof(table)))) { 02551 /* If the store succeeds, it returns 0. */ 02552 if (eng->store_func && !(res = eng->store_func(db, table, ap))) { 02553 break; 02554 } 02555 } else { 02556 break; 02557 } 02558 } 02559 va_end(ap); 02560 02561 return res; 02562 }
| int ast_unload_realtime | ( | const char * | family | ) |
Release any resources cached for a realtime family.
| family | which family/config to destroy |
| 0 | If any cache was purged | |
| -1 | If no cache was found |
Definition at line 2444 of file config.c.
References db, find_engine(), table, and ast_config_engine::unload_func.
Referenced by __unload_module(), load_config(), logger_queue_init(), reload(), reload_config(), reload_logger(), and unload_module().
02445 { 02446 struct ast_config_engine *eng; 02447 char db[256]; 02448 char table[256]; 02449 int res = -1, i; 02450 02451 for (i = 1; ; i++) { 02452 if ((eng = find_engine(family, i, db, sizeof(db), table, sizeof(table)))) { 02453 if (eng->unload_func) { 02454 /* Do this for ALL engines */ 02455 res = eng->unload_func(db, table); 02456 } 02457 } else { 02458 break; 02459 } 02460 } 02461 return res; 02462 }
| int ast_update2_realtime | ( | const char * | family, | |
| ... | ||||
| ) |
Update realtime configuration.
| family | which family/config to be updated |
Definition at line 2517 of file config.c.
References db, find_engine(), table, and ast_config_engine::update2_func.
Referenced by change_password_realtime(), and cli_realtime_update2().
02518 { 02519 struct ast_config_engine *eng; 02520 int res = -1, i; 02521 char db[256]; 02522 char table[256]; 02523 va_list ap; 02524 02525 va_start(ap, family); 02526 for (i = 1; ; i++) { 02527 if ((eng = find_engine(family, i, db, sizeof(db), table, sizeof(table)))) { 02528 if (eng->update2_func && !(res = eng->update2_func(db, table, ap))) { 02529 break; 02530 } 02531 } else { 02532 break; 02533 } 02534 } 02535 va_end(ap); 02536 02537 return res; 02538 }
| 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. |
Definition at line 2493 of file config.c.
References db, find_engine(), table, and ast_config_engine::update_func.
Referenced by cli_realtime_update(), conf_run(), destroy_association(), function_realtime_write(), handle_response_peerpoke(), leave_voicemail(), realtime_update_peer(), rename_file(), rt_extend_conf(), sip_poke_noanswer(), and update_realtime_member_field().
02494 { 02495 struct ast_config_engine *eng; 02496 int res = -1, i; 02497 char db[256]; 02498 char table[256]; 02499 va_list ap; 02500 02501 va_start(ap, lookup); 02502 for (i = 1; ; i++) { 02503 if ((eng = find_engine(family, i, db, sizeof(db), table, sizeof(table)))) { 02504 /* If the update succeeds, it returns 0. */ 02505 if (eng->update_func && !(res = eng->update_func(db, table, keyfield, lookup, ap))) { 02506 break; 02507 } 02508 } else { 02509 break; 02510 } 02511 } 02512 va_end(ap); 02513 02514 return res; 02515 }
| void ast_variable_append | ( | struct ast_category * | category, | |
| struct ast_variable * | variable | |||
| ) |
Definition at line 471 of file config.c.
References ast_category::last, ast_variable::next, and ast_category::root.
Referenced by add_cfg_entry(), add_rt_multi_cfg_entry(), append_row_to_cfg(), config_curl(), config_ldap(), config_odbc(), config_pgsql(), handle_updates(), inherit_category(), move_variables(), process_text_line(), realtime_directory(), realtime_multi_curl(), realtime_multi_ldap(), realtime_multi_odbc(), realtime_multi_pgsql(), static_realtime_cb(), vm_change_password(), and write_password_to_file().
00472 { 00473 if (!variable) 00474 return; 00475 if (category->last) 00476 category->last->next = variable; 00477 else 00478 category->root = variable; 00479 category->last = variable; 00480 while (category->last->next) 00481 category->last = category->last->next; 00482 }
| 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
| ast_variable | list on success | |
| NULL | on failure |
Definition at line 561 of file config.c.
References ast_category_get(), ast_config::last_browse, ast_category::name, and ast_category::root.
Referenced by __ast_http_load(), __ast_http_post_load(), __init_manager(), _dsp_init(), action_getconfig(), action_getconfigjson(), actual_load_config(), adsi_load(), aji_load_config(), ast_cli_perms_init(), ast_plc_reload(), ast_readconfig(), ast_variable_retrieve(), build_calendar(), build_device(), caldav_load_calendar(), check_tx_freq(), collect_function_digits(), conf_exec(), config_load(), config_module(), do_reload(), do_say(), do_scheduler(), ewscal_load_calendar(), exchangecal_load_calendar(), find_conf(), gtalk_load_config(), handle_cli_dialplan_save(), iax_template_parse(), ical_load_calendar(), init_logger_chain(), jingle_load_config(), load_config(), load_format_config(), load_general_config(), load_module(), load_modules(), load_moh_classes(), load_odbc_config(), load_pktccops_config(), load_rpt_vars(), misdn_cfg_init(), new_realtime_sqlite3_db(), node_lookup(), odbc_load_module(), osp_create_provider(), parse_config(), parse_tone_zone(), pbx_load_config(), process_config(), read_agent_config(), read_config_maps(), reload(), reload_config(), reload_followme(), reload_module(), reload_queue_rules(), reload_single_queue(), run_startup_commands(), search_directory_sub(), set_config(), setup_dahdi_int(), show_users_realtime(), sip_cli_notify(), sla_build_station(), sla_build_trunk(), smdi_load(), store_config(), and tds_load_module().
00562 { 00563 struct ast_category *cat = NULL; 00564 00565 if (category && config->last_browse && (config->last_browse->name == category)) { 00566 cat = config->last_browse; 00567 } else { 00568 cat = ast_category_get(config, category); 00569 } 00570 00571 return (cat) ? cat->root : NULL; 00572 }
| int ast_variable_delete | ( | struct ast_category * | category, | |
| const char * | variable, | |||
| const char * | match, | |||
| const char * | line | |||
| ) |
Definition at line 853 of file config.c.
References ast_strlen_zero(), ast_variable_destroy(), ast_category::last, ast_variable::name, ast_variable::next, ast_category::root, and ast_variable::value.
Referenced by handle_updates().
00854 { 00855 struct ast_variable *cur, *prev=NULL, *curn; 00856 int res = -1; 00857 int num_item = 0; 00858 int req_item; 00859 00860 req_item = -1; 00861 if (!ast_strlen_zero(line)) { 00862 /* Requesting to delete by item number. */ 00863 if (sscanf(line, "%30d", &req_item) != 1 00864 || req_item < 0) { 00865 /* Invalid item number to delete. */ 00866 return -1; 00867 } 00868 } 00869 00870 prev = NULL; 00871 cur = category->root; 00872 while (cur) { 00873 curn = cur->next; 00874 /* Delete by item number or by variable name with optional value. */ 00875 if ((0 <= req_item && num_item == req_item) 00876 || (req_item < 0 && !strcasecmp(cur->name, variable) 00877 && (ast_strlen_zero(match) || !strcasecmp(cur->value, match)))) { 00878 if (prev) { 00879 prev->next = cur->next; 00880 if (cur == category->last) 00881 category->last = prev; 00882 } else { 00883 category->root = cur->next; 00884 if (cur == category->last) 00885 category->last = NULL; 00886 } 00887 ast_variable_destroy(cur); 00888 res = 0; 00889 } else 00890 prev = cur; 00891 00892 cur = curn; 00893 ++num_item; 00894 } 00895 return res; 00896 }
| static void ast_variable_destroy | ( | struct ast_variable * | doomed | ) | [static] |
Definition at line 520 of file config.c.
References ast_comment_destroy(), ast_free, ast_variable::precomments, ast_variable::sameline, and ast_variable::trailing.
Referenced by ast_include_rename(), ast_load_realtime(), ast_variable_delete(), ast_variable_update(), and ast_variables_destroy().
00521 { 00522 ast_comment_destroy(&doomed->precomments); 00523 ast_comment_destroy(&doomed->sameline); 00524 ast_comment_destroy(&doomed->trailing); 00525 ast_free(doomed); 00526 }
| void ast_variable_insert | ( | struct ast_category * | category, | |
| struct ast_variable * | variable, | |||
| const char * | line | |||
| ) |
Definition at line 484 of file config.c.
References ast_variable::next, and ast_category::root.
Referenced by handle_updates().
00485 { 00486 struct ast_variable *cur = category->root; 00487 int lineno; 00488 int insertline; 00489 00490 if (!variable || sscanf(line, "%30d", &insertline) != 1) { 00491 return; 00492 } 00493 if (!insertline) { 00494 variable->next = category->root; 00495 category->root = variable; 00496 } else { 00497 for (lineno = 1; lineno < insertline; lineno++) { 00498 cur = cur->next; 00499 if (!cur->next) { 00500 break; 00501 } 00502 } 00503 variable->next = cur->next; 00504 cur->next = variable; 00505 } 00506 }
| static void ast_variable_move | ( | struct ast_variable * | dst_var, | |
| struct ast_variable * | src_var | |||
| ) | [static] |
Definition at line 307 of file config.c.
References ast_variable::blanklines, ast_variable::lineno, ast_variable::object, ast_variable::precomments, ast_variable::sameline, and ast_variable::trailing.
Referenced by ast_include_rename(), and ast_variable_update().
00308 { 00309 dst_var->lineno = src_var->lineno; 00310 dst_var->object = src_var->object; 00311 dst_var->blanklines = src_var->blanklines; 00312 dst_var->precomments = src_var->precomments; 00313 src_var->precomments = NULL; 00314 dst_var->sameline = src_var->sameline; 00315 src_var->sameline = NULL; 00316 dst_var->trailing = src_var->trailing; 00317 src_var->trailing = NULL; 00318 }
| struct ast_variable* ast_variable_new | ( | const char * | name, | |
| const char * | value, | |||
| const char * | filename | |||
| ) | [read] |
Definition at line 266 of file config.c.
References __ast_calloc(), ast_calloc, ast_variable::file, MIN_VARIABLE_FNAME_SPACE, ast_variable::name, ast_variable::stuff, and ast_variable::value.
Referenced by add_cfg_entry(), add_rt_cfg_entry(), add_rt_multi_cfg_entry(), add_var(), append_row_to_cfg(), apply_outgoing(), ast_channeltype_list(), ast_http_get_post_vars(), ast_include_rename(), ast_variable_update(), ast_variables_dup(), build_calendar(), build_user(), check_access(), config_curl(), config_ldap(), config_odbc(), config_pgsql(), copy_vars(), create_vmaccount(), dup_vars(), handle_updates(), handle_uri(), httpd_helper_thread(), iax_parse_ies(), ldap_table_config_add_attribute(), man_do_variable_value(), manager_sipnotify(), mkintf(), parkandannounce_exec(), parse_cookies(), process_dahdi(), process_text_line(), realtime_curl(), realtime_directory(), realtime_ldap_entry_to_var(), realtime_ldap_result_to_vars(), realtime_multi_curl(), realtime_multi_odbc(), realtime_multi_pgsql(), realtime_odbc(), realtime_pgsql(), row_to_varlist(), sip_cli_notify(), static_realtime_cb(), variable_clone(), vm_change_password(), and write_password_to_file().
00268 { 00269 struct ast_variable *variable; 00270 int name_len = strlen(name) + 1; 00271 int val_len = strlen(value) + 1; 00272 int fn_len = strlen(filename) + 1; 00273 00274 /* Ensure a minimum length in case the filename is changed later. */ 00275 if (fn_len < MIN_VARIABLE_FNAME_SPACE) { 00276 fn_len = MIN_VARIABLE_FNAME_SPACE; 00277 } 00278 00279 if ( 00280 #ifdef MALLOC_DEBUG 00281 (variable = __ast_calloc(1, fn_len + name_len + val_len + sizeof(*variable), file, lineno, func)) 00282 #else 00283 (variable = ast_calloc(1, fn_len + name_len + val_len + sizeof(*variable))) 00284 #endif 00285 ) { 00286 char *dst = variable->stuff; /* writable space starts here */ 00287 00288 /* Put file first so ast_include_rename() can calculate space available. */ 00289 variable->file = strcpy(dst, filename); 00290 dst += fn_len; 00291 variable->name = strcpy(dst, name); 00292 dst += name_len; 00293 variable->value = strcpy(dst, value); 00294 } 00295 return variable; 00296 }
| 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 |
| The | variable value on success | |
| NULL | if unable to find it. |
Definition at line 585 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 __ast_udptl_reload(), __init_manager(), actual_load_config(), advanced_options(), aji_load_config(), ast_config_option(), build_extension(), conf_exec(), config_function_read(), config_module(), directory_exec(), do_reload(), do_scheduler(), festival_exec(), find_realtime(), function_macro(), get_insecure_variable_from_config(), get_insecure_variable_from_sipregs(), get_wait_interval(), gtalk_load_config(), iax_template_parse(), init_acf_query(), init_logger_chain(), initialize_cc_devstate_map_helper(), initialize_cc_max_requests(), jingle_load_config(), load_config(), load_config_meetme(), load_format_config(), load_indications(), load_module(), load_modules(), load_rpt_vars(), load_tech_calendars(), make_email_file(), node_lookup(), odbc_load_module(), osp_load(), parse_config(), pbx_load_config(), pbx_load_users(), play_message(), prep_email_sub_vars(), private_enum_init(), queue_set_global_params(), read_agent_config(), read_password_from_file(), realtime_directory(), reload_config(), reload_followme(), reload_single_queue(), retreive_memory(), retrieve_astcfgint(), rpt(), rpt_master(), rpt_tele_thread(), rpt_telemetry(), rt_handle_member_record(), rtp_reload(), saynode(), search_directory(), search_directory_sub(), set_config(), setup_dahdi_int(), sla_build_station(), sla_build_trunk(), sla_load_config(), tds_load_module(), telem_lookup(), vm_change_password(), and vm_forwardoptions().
00586 { 00587 struct ast_variable *v; 00588 00589 if (category) { 00590 for (v = ast_variable_browse(config, category); v; v = v->next) { 00591 if (!strcasecmp(variable, v->name)) { 00592 return v->value; 00593 } 00594 } 00595 } else { 00596 struct ast_category *cat; 00597 00598 for (cat = config->root; cat; cat = cat->next) { 00599 for (v = cat->root; v; v = v->next) { 00600 if (!strcasecmp(variable, v->name)) { 00601 return v->value; 00602 } 00603 } 00604 } 00605 } 00606 00607 return NULL; 00608 }
| int ast_variable_update | ( | struct ast_category * | category, | |
| const char * | variable, | |||
| const char * | value, | |||
| const char * | match, | |||
| unsigned int | object | |||
| ) |
Update variable value within a config.
| category | Category element within the config | |
| variable | Name of the variable to change | |
| value | New value of the variable | |
| match | If set, previous value of the variable (if NULL or zero-length, no matching will be done) | |
| object | Boolean of whether to make the new variable an object |
Definition at line 898 of file config.c.
References ast_strlen_zero(), ast_variable_destroy(), ast_variable_move(), ast_variable_new(), ast_variable::file, ast_category::last, ast_variable::name, ast_variable::next, ast_category::root, and ast_variable::value.
Referenced by handle_updates(), process_text_line(), vm_change_password(), and vm_forwardoptions().
00900 { 00901 struct ast_variable *cur, *prev=NULL, *newer=NULL; 00902 00903 for (cur = category->root; cur; prev = cur, cur = cur->next) { 00904 if (strcasecmp(cur->name, variable) || 00905 (!ast_strlen_zero(match) && strcasecmp(cur->value, match))) 00906 continue; 00907 00908 if (!(newer = ast_variable_new(variable, value, cur->file))) 00909 return -1; 00910 00911 ast_variable_move(newer, cur); 00912 newer->object = newer->object || object; 00913 00914 /* Replace the old node in the list with the new node. */ 00915 newer->next = cur->next; 00916 if (prev) 00917 prev->next = newer; 00918 else 00919 category->root = newer; 00920 if (category->last == cur) 00921 category->last = newer; 00922 00923 ast_variable_destroy(cur); 00924 00925 return 0; 00926 } 00927 00928 /* Could not find variable to update */ 00929 return -1; 00930 }
| void ast_variables_destroy | ( | struct ast_variable * | var | ) |
Free variable list.
| var | the linked list of variables to free |
Definition at line 550 of file config.c.
References ast_variable_destroy(), and ast_variable::next.
Referenced by __sip_destroy(), action_originate(), ast_category_destroy(), ast_category_empty(), ast_http_get_cookies(), ast_http_manid_from_vars(), ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), ast_var_channel_types(), ast_var_channel_types_table(), ast_variables_dup(), auth_http_callback(), build_gateway(), build_peer(), build_user(), calendar_destructor(), check_peer_ok(), cli_realtime_load(), conf_run(), copy_plain_file(), destroy_dahdi_pvt(), destroy_endpoint(), destroy_fast_originate_helper(), dup_vars(), find_conf_realtime(), find_load_queue_rt_friendly(), find_realtime(), find_realtime_gw(), find_user_realtime(), free_entry(), free_outgoing(), free_user(), function_realtime_read(), function_realtime_readdestroy(), generic_http_callback(), get_insecure_variable_from_sipregs(), handle_uri(), http_post_callback(), httpd_helper_thread(), httpstatus_callback(), ldap_loadentry(), leave_queue(), local_ast_moh_start(), manager_sipnotify(), mkintf(), parkandannounce_exec(), process_dahdi(), pvt_destructor(), queue_function_queuewaitingcount(), realtime_alias(), realtime_canmatch(), realtime_common(), realtime_exec(), realtime_exists(), realtime_handler(), realtime_ldap_base_ap(), realtime_ldap_result_to_vars(), realtime_matchmore(), realtime_odbc(), realtime_peer(), realtime_peer_by_addr(), realtime_peer_by_name(), realtime_peer_get_sippeer_helper(), realtime_user(), realtimefield_read(), row_to_varlist(), rt_extend_conf(), sip_destroy_peer(), socket_process(), table_configs_free(), and user_destructor().
00551 { 00552 struct ast_variable *vn; 00553 00554 while (v) { 00555 vn = v; 00556 v = v->next; 00557 ast_variable_destroy(vn); 00558 } 00559 }
| struct ast_variable* ast_variables_dup | ( | struct ast_variable * | var | ) | [read] |
Duplicate variable list.
| var | the linked list of variables to clone |
Definition at line 528 of file config.c.
References ast_variable_new(), ast_variables_destroy(), ast_variable::file, ast_variable::name, ast_variable::next, and ast_variable::value.
Referenced by get_insecure_variable_from_sippeers(), and get_insecure_variable_from_sipregs().
00529 { 00530 struct ast_variable *cloned; 00531 struct ast_variable *tmp; 00532 00533 if (!(cloned = ast_variable_new(var->name, var->value, var->file))) { 00534 return NULL; 00535 } 00536 00537 tmp = cloned; 00538 00539 while ((var = var->next)) { 00540 if (!(tmp->next = ast_variable_new(var->name, var->value, var->file))) { 00541 ast_variables_destroy(cloned); 00542 return NULL; 00543 } 00544 tmp = tmp->next; 00545 } 00546 00547 return cloned; 00548 }
| static struct ast_category* category_get | ( | const struct ast_config * | config, | |
| const char * | category_name, | |||
| int | ignored | |||
| ) | [static, read] |
Definition at line 651 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().
00652 { 00653 struct ast_category *cat; 00654 00655 /* try exact match first, then case-insensitive match */ 00656 for (cat = config->root; cat; cat = cat->next) { 00657 if (cat->name == category_name && (ignored || !cat->ignored)) 00658 return cat; 00659 } 00660 00661 for (cat = config->root; cat; cat = cat->next) { 00662 if (!strcasecmp(cat->name, category_name) && (ignored || !cat->ignored)) 00663 return cat; 00664 } 00665 00666 return NULL; 00667 }
| static void CB_ADD | ( | struct ast_str ** | cb, | |
| const char * | str | |||
| ) | [static] |
Definition at line 108 of file config.c.
References ast_str_append().
Referenced by config_text_file_load().
00109 { 00110 ast_str_append(cb, 0, "%s", str); 00111 }
| static void CB_ADD_LEN | ( | struct ast_str ** | cb, | |
| const char * | str, | |||
| int | len | |||
| ) | [static] |
Definition at line 113 of file config.c.
References ast_copy_string(), and ast_str_append().
Referenced by config_text_file_load().
00114 { 00115 char *s = alloca(len + 1); 00116 ast_copy_string(s, str, len); 00117 ast_str_append(cb, 0, "%s", str); 00118 }
Definition at line 120 of file config.c.
References ast_str_reset().
Referenced by config_text_file_load(), and process_text_line().
00121 { 00122 if (cb) { 00123 ast_str_reset(cb); 00124 } 00125 if (llb) { 00126 ast_str_reset(llb); 00127 } 00128 }
| static struct cache_file_mtime* cfmtime_new | ( | const char * | filename, | |
| const char * | who_asked | |||
| ) | [static, read] |
Definition at line 1032 of file config.c.
References ast_calloc, cache_file_mtime::filename, and cache_file_mtime::who_asked.
Referenced by config_cache_attribute(), and config_text_file_load().
01033 { 01034 struct cache_file_mtime *cfmtime; 01035 char *dst; 01036 01037 cfmtime = ast_calloc(1, 01038 sizeof(*cfmtime) + strlen(filename) + 1 + strlen(who_asked) + 1); 01039 if (!cfmtime) { 01040 return NULL; 01041 } 01042 dst = cfmtime->filename; /* writable space starts here */ 01043 strcpy(dst, filename); 01044 dst += strlen(dst) + 1; 01045 cfmtime->who_asked = strcpy(dst, who_asked); 01046 01047 return cfmtime; 01048 }
| static void clear_config_maps | ( | void | ) | [static] |
Definition at line 2065 of file config.c.
References ast_free, ast_mutex_lock, ast_mutex_unlock, config_lock, config_maps, map, and ast_config_map::next.
Referenced by read_config_maps().
02066 { 02067 struct ast_config_map *map; 02068 02069 ast_mutex_lock(&config_lock); 02070 02071 while (config_maps) { 02072 map = config_maps; 02073 config_maps = config_maps->next; 02074 ast_free(map); 02075 } 02076 02077 ast_mutex_unlock(&config_lock); 02078 }
| static void config_cache_attribute | ( | const char * | configfile, | |
| enum config_cache_attribute_enum | attrtype, | |||
| const char * | filename, | |||
| const char * | who_asked | |||
| ) | [static] |
Definition at line 1055 of file config.c.
References ast_calloc, AST_LIST_INSERT_SORTALPHA, AST_LIST_INSERT_TAIL, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ATTRIBUTE_EXEC, ATTRIBUTE_INCLUDE, cfmtime_new(), cache_file_mtime::filename, cache_file_mtime::has_exec, cache_file_include::include, cache_file_mtime::includes, cache_file_mtime::mtime, and cache_file_mtime::who_asked.
Referenced by process_text_line().
01056 { 01057 struct cache_file_mtime *cfmtime; 01058 struct cache_file_include *cfinclude; 01059 struct stat statbuf = { 0, }; 01060 01061 /* Find our cached entry for this configuration file */ 01062 AST_LIST_LOCK(&cfmtime_head); 01063 AST_LIST_TRAVERSE(&cfmtime_head, cfmtime, list) { 01064 if (!strcmp(cfmtime->filename, configfile) && !strcmp(cfmtime->who_asked, who_asked)) 01065 break; 01066 } 01067 if (!cfmtime) { 01068 cfmtime = cfmtime_new(configfile, who_asked); 01069 if (!cfmtime) { 01070 AST_LIST_UNLOCK(&cfmtime_head); 01071 return; 01072 } 01073 /* Note that the file mtime is initialized to 0, i.e. 1970 */ 01074 AST_LIST_INSERT_SORTALPHA(&cfmtime_head, cfmtime, list, filename); 01075 } 01076 01077 if (!stat(configfile, &statbuf)) 01078 cfmtime->mtime = 0; 01079 else 01080 cfmtime->mtime = statbuf.st_mtime; 01081 01082 switch (attrtype) { 01083 case ATTRIBUTE_INCLUDE: 01084 AST_LIST_TRAVERSE(&cfmtime->includes, cfinclude, list) { 01085 if (!strcmp(cfinclude->include, filename)) { 01086 AST_LIST_UNLOCK(&cfmtime_head); 01087 return; 01088 } 01089 } 01090 cfinclude = ast_calloc(1, sizeof(*cfinclude) + strlen(filename) + 1); 01091 if (!cfinclude) { 01092 AST_LIST_UNLOCK(&cfmtime_head); 01093 return; 01094 } 01095 strcpy(cfinclude->include, filename); 01096 AST_LIST_INSERT_TAIL(&cfmtime->includes, cfinclude, list); 01097 break; 01098 case ATTRIBUTE_EXEC: 01099 cfmtime->has_exec = 1; 01100 break; 01101 } 01102 AST_LIST_UNLOCK(&cfmtime_head); 01103 }
| static struct ast_config* config_text_file_load | ( | const char * | database, | |
| const char * | table, | |||
| const char * | filename, | |||
| struct ast_config * | cfg, | |||
| struct ast_flags | flags, | |||
| const char * | suggested_include_file, | |||
| const char * | who_asked | |||
| ) | [static, read] |
Growable string buffer
< this will be a comment collector.
< A buffer for stuff behind the ;
Definition at line 1364 of file config.c.
References ALLOC_COMMENT(), ast_clear_flag, ast_config_AST_CONFIG_DIR, ast_config_get_current_category(), ast_copy_string(), ast_debug, ast_free, AST_LIST_INSERT_SORTALPHA, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), ast_str_buffer(), ast_str_create(), ast_str_reset(), ast_str_strlen(), ast_strip(), ast_strlen_zero(), ast_test_flag, ast_verb, CB_ADD(), CB_ADD_LEN(), CB_RESET(), CB_SIZE, cfmtime_new(), comment, COMMENT_META, COMMENT_TAG, CONFIG_FLAG_FILEUNCHANGED, CONFIG_FLAG_NOCACHE, CONFIG_FLAG_WITHCOMMENTS, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEUNCHANGED, errno, f, cache_file_mtime::filename, GLOB_ABORTED, cache_file_mtime::has_exec, cache_file_include::include, ast_config::include_level, cache_file_mtime::includes, LOG_ERROR, LOG_WARNING, MAX_NESTED_COMMENTS, cache_file_mtime::mtime, MY_GLOB_FLAGS, process_text_line(), ast_variable::trailing, ast_category::trailing, and cache_file_mtime::who_asked.
01365 { 01366 char fn[256]; 01367 #if defined(LOW_MEMORY) 01368 char buf[512]; 01369 #else 01370 char buf[8192]; 01371 #endif 01372 char *new_buf, *comment_p, *process_buf; 01373 FILE *f; 01374 int lineno=0; 01375 int comment = 0, nest[MAX_NESTED_COMMENTS]; 01376 struct ast_category *cat = NULL; 01377 int count = 0; 01378 struct stat statbuf; 01379 struct cache_file_mtime *cfmtime = NULL; 01380 struct cache_file_include *cfinclude; 01381 struct ast_variable *last_var = 0; 01382 struct ast_category *last_cat = 0; 01383 /*! Growable string buffer */ 01384 struct ast_str *comment_buffer = NULL; /*!< this will be a comment collector.*/ 01385 struct ast_str *lline_buffer = NULL; /*!< A buffer for stuff behind the ; */ 01386 01387 if (cfg) 01388 cat = ast_config_get_current_category(cfg); 01389 01390 if (filename[0] == '/') { 01391 ast_copy_string(fn, filename, sizeof(fn)); 01392 } else { 01393 snprintf(fn, sizeof(fn), "%s/%s", ast_config_AST_CONFIG_DIR, filename); 01394 } 01395 01396 if (ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS)) { 01397 comment_buffer = ast_str_create(CB_SIZE); 01398 if (comment_buffer) 01399 lline_buffer = ast_str_create(CB_SIZE); 01400 if (!lline_buffer) { 01401 ast_free(comment_buffer); 01402 ast_log(LOG_ERROR, "Failed to initialize the comment buffer!\n"); 01403 return NULL; 01404 } 01405 } 01406 #ifdef AST_INCLUDE_GLOB 01407 { 01408 int glob_ret; 01409 glob_t globbuf; 01410 globbuf.gl_offs = 0; /* initialize it to silence gcc */ 01411 glob_ret = glob(fn, MY_GLOB_FLAGS, NULL, &globbuf); 01412 if (glob_ret == GLOB_NOSPACE) 01413 ast_log(LOG_WARNING, 01414 "Glob Expansion of pattern '%s' failed: Not enough memory\n", fn); 01415 else if (glob_ret == GLOB_ABORTED) 01416 ast_log(LOG_WARNING, 01417 "Glob Expansion of pattern '%s' failed: Read error\n", fn); 01418 else { 01419 /* loop over expanded files */ 01420 int i; 01421 for (i=0; i<globbuf.gl_pathc; i++) { 01422 ast_copy_string(fn, globbuf.gl_pathv[i], sizeof(fn)); 01423 #endif 01424 /* 01425 * The following is not a loop, but just a convenient way to define a block 01426 * (using do { } while(0) ), and be able to exit from it with 'continue' 01427 * or 'break' in case of errors. Nice trick. 01428 */ 01429 do { 01430 if (stat(fn, &statbuf)) 01431 continue; 01432 01433 if (!S_ISREG(statbuf.st_mode)) { 01434 ast_log(LOG_WARNING, "'%s' is not a regular file, ignoring\n", fn); 01435 continue; 01436 } 01437 01438 if (!ast_test_flag(&flags, CONFIG_FLAG_NOCACHE)) { 01439 /* Find our cached entry for this configuration file */ 01440 AST_LIST_LOCK(&cfmtime_head); 01441 AST_LIST_TRAVERSE(&cfmtime_head, cfmtime, list) { 01442 if (!strcmp(cfmtime->filename, fn) && !strcmp(cfmtime->who_asked, who_asked)) 01443 break; 01444 } 01445 if (!cfmtime) { 01446 cfmtime = cfmtime_new(fn, who_asked); 01447 if (!cfmtime) 01448 continue; 01449 /* Note that the file mtime is initialized to 0, i.e. 1970 */ 01450 AST_LIST_INSERT_SORTALPHA(&cfmtime_head, cfmtime, list, filename); 01451 } 01452 } 01453 01454 if (cfmtime && (!cfmtime->has_exec) && (cfmtime->mtime == statbuf.st_mtime) && ast_test_flag(&flags, CONFIG_FLAG_FILEUNCHANGED)) { 01455 /* File is unchanged, what about the (cached) includes (if any)? */ 01456 int unchanged = 1; 01457 AST_LIST_TRAVERSE(&cfmtime->includes, cfinclude, list) { 01458 /* We must glob here, because if we did not, then adding a file to globbed directory would 01459 * incorrectly cause no reload to be necessary. */ 01460 char fn2[256]; 01461 #ifdef AST_INCLUDE_GLOB 01462 int glob_return; 01463 glob_t glob_buf = { .gl_offs = 0 }; 01464 glob_return = glob(cfinclude->include, MY_GLOB_FLAGS, NULL, &glob_buf); 01465 /* On error, we reparse */ 01466 if (glob_return == GLOB_NOSPACE || glob_return == GLOB_ABORTED) 01467 unchanged = 0; 01468 else { 01469 /* loop over expanded files */ 01470 int j; 01471 for (j = 0; j < glob_buf.gl_pathc; j++) { 01472 ast_copy_string(fn2, glob_buf.gl_pathv[j], sizeof(fn2)); 01473 #else 01474 ast_copy_string(fn2, cfinclude->include); 01475 #endif 01476 if (config_text_file_load(NULL, NULL, fn2, NULL, flags, "", who_asked) == NULL) { 01477 /* that second-to-last field needs to be looked at in this case... TODO */ 01478 unchanged = 0; 01479 /* One change is enough to short-circuit and reload the whole shebang */ 01480 break; 01481 } 01482 #ifdef AST_INCLUDE_GLOB 01483 } 01484 } 01485 #endif 01486 } 01487 01488 if (unchanged) { 01489 AST_LIST_UNLOCK(&cfmtime_head); 01490 return CONFIG_STATUS_FILEUNCHANGED; 01491 } 01492 } 01493 if (!ast_test_flag(&flags, CONFIG_FLAG_NOCACHE)) 01494 AST_LIST_UNLOCK(&cfmtime_head); 01495 01496 /* If cfg is NULL, then we just want an answer */ 01497 if (cfg == NULL) { 01498 ast_free(comment_buffer); 01499 ast_free(lline_buffer); 01500 return NULL; 01501 } 01502 01503 if (cfmtime) 01504 cfmtime->mtime = statbuf.st_mtime; 01505 01506 ast_verb(2, "Parsing '%s': ", fn); 01507 fflush(stdout); 01508 if (!(f = fopen(fn, "r"))) { 01509 ast_debug(1, "No file to parse: %s\n", fn); 01510 ast_verb(2, "Parsing '%s': Not found (%s)\n", fn, strerror(errno)); 01511 continue; 01512 } 01513 count++; 01514 /* If we get to this point, then we're loading regardless */ 01515 ast_clear_flag(&flags, CONFIG_FLAG_FILEUNCHANGED); 01516 ast_debug(1, "Parsing %s\n", fn); 01517 ast_verb(2, "Parsing '%s': Found\n", fn); 01518 while (!feof(f)) { 01519 lineno++; 01520 if (fgets(buf, sizeof(buf), f)) { 01521 if (ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS) && lline_buffer && ast_str_strlen(lline_buffer)) { 01522 CB_ADD(&comment_buffer, ast_str_buffer(lline_buffer)); /* add the current lline buffer to the comment buffer */ 01523 ast_str_reset(lline_buffer); /* erase the lline buffer */ 01524 } 01525 01526 new_buf = buf; 01527 if (comment) 01528 process_buf = NULL; 01529 else 01530 process_buf = buf; 01531 01532 if (ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS) && comment_buffer && ast_str_strlen(comment_buffer) && (ast_strlen_zero(buf) || strlen(buf) == strspn(buf," \t\n\r"))) { 01533 /* blank line? really? Can we add it to an existing comment and maybe preserve inter- and post- comment spacing? */ 01534 CB_ADD(&comment_buffer, "\n"); /* add a newline to the comment buffer */ 01535 continue; /* go get a new line, then */ 01536 } 01537 01538 while ((comment_p = strchr(new_buf, COMMENT_META))) { 01539 if ((comment_p > new_buf) && (*(comment_p - 1) == '\\')) { 01540 /* Escaped semicolons aren't comments. */ 01541 new_buf = comment_p; 01542 /* write over the \ and bring the null terminator with us */ 01543 memmove(comment_p - 1, comment_p, strlen(comment_p) + 1); 01544 } else if (comment_p[1] == COMMENT_TAG && comment_p[2] == COMMENT_TAG && (comment_p[3] != '-')) { 01545 /* Meta-Comment start detected ";--" */ 01546 if (comment < MAX_NESTED_COMMENTS) { 01547 *comment_p = '\0'; 01548 new_buf = comment_p + 3; 01549 comment++; 01550 nest[comment-1] = lineno; 01551 } else { 01552 ast_log(LOG_ERROR, "Maximum nest limit of %d reached.\n", MAX_NESTED_COMMENTS); 01553 } 01554 } else if ((comment_p >= new_buf + 2) && 01555 (*(comment_p - 1) == COMMENT_TAG) && 01556 (*(comment_p - 2) == COMMENT_TAG)) { 01557 /* Meta-Comment end detected */ 01558 comment--; 01559 new_buf = comment_p + 1; 01560 if (!comment) { 01561 /* Back to non-comment now */ 01562 if (process_buf) { 01563 /* Actually have to move what's left over the top, then continue */ 01564 char *oldptr; 01565 oldptr = process_buf + strlen(process_buf); 01566 if (ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS)) { 01567 CB_ADD(&comment_buffer, ";"); 01568 CB_ADD_LEN(&comment_buffer, oldptr+1, new_buf-oldptr-1); 01569 } 01570 01571 memmove(oldptr, new_buf, strlen(new_buf) + 1); 01572 new_buf = oldptr; 01573 } else 01574 process_buf = new_buf; 01575 } 01576 } else { 01577 if (!comment) { 01578 /* If ; is found, and we are not nested in a comment, 01579 we immediately stop all comment processing */ 01580 if (ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS)) { 01581 CB_ADD(&lline_buffer, comment_p); 01582 } 01583 *comment_p = '\0'; 01584 new_buf = comment_p; 01585 } else 01586 new_buf = comment_p + 1; 01587 } 01588 } 01589 if (ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS) && comment && !process_buf ) { 01590 CB_ADD(&comment_buffer, buf); /* the whole line is a comment, store it */ 01591 } 01592 01593 if (process_buf) { 01594 char *buffer = ast_strip(process_buf); 01595 if (!ast_strlen_zero(buffer)) { 01596 if (process_text_line(cfg, &cat, buffer, lineno, fn, flags, comment_buffer, lline_buffer, suggested_include_file, &last_cat, &last_var, who_asked)) { 01597 cfg = CONFIG_STATUS_FILEINVALID; 01598 break; 01599 } 01600 } 01601 } 01602 } 01603 } 01604 /* end of file-- anything in a comment buffer? */ 01605 if (last_cat) { 01606 if (ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS) && comment_buffer && ast_str_strlen(comment_buffer)) { 01607 if (lline_buffer && ast_str_strlen(lline_buffer)) { 01608 CB_ADD(&comment_buffer, ast_str_buffer(lline_buffer)); /* add the current lline buffer to the comment buffer */ 01609 ast_str_reset(lline_buffer); /* erase the lline buffer */ 01610 } 01611 last_cat->trailing = ALLOC_COMMENT(comment_buffer); 01612 } 01613 } else if (last_var) { 01614 if (ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS) && comment_buffer && ast_str_strlen(comment_buffer)) { 01615 if (lline_buffer && ast_str_strlen(lline_buffer)) { 01616 CB_ADD(&comment_buffer, ast_str_buffer(lline_buffer)); /* add the current lline buffer to the comment buffer */ 01617 ast_str_reset(lline_buffer); /* erase the lline buffer */ 01618 } 01619 last_var->trailing = ALLOC_COMMENT(comment_buffer); 01620 } 01621 } else { 01622 if (ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS) && comment_buffer && ast_str_strlen(comment_buffer)) { 01623 ast_debug(1, "Nothing to attach comments to, discarded: %s\n", ast_str_buffer(comment_buffer)); 01624 } 01625 } 01626 if (ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS)) 01627 CB_RESET(comment_buffer, lline_buffer); 01628 01629 fclose(f); 01630 } while (0); 01631 if (comment) { 01632 ast_log(LOG_WARNING,"Unterminated comment detected beginning on line %d\n", nest[comment - 1]); 01633 } 01634 #ifdef AST_INCLUDE_GLOB 01635 if (cfg == NULL || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) { 01636 break; 01637 } 01638 } 01639 globfree(&globbuf); 01640 } 01641 } 01642 #endif 01643 01644 if (cfg && cfg != CONFIG_STATUS_FILEUNCHANGED && cfg != CONFIG_STATUS_FILEINVALID && cfg->include_level == 1 && ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS)) { 01645 ast_free(comment_buffer); 01646 ast_free(lline_buffer); 01647 comment_buffer = NULL; 01648 lline_buffer = NULL; 01649 } 01650 01651 if (count == 0) 01652 return NULL; 01653 01654 return cfg; 01655 }
| int config_text_file_save | ( | const char * | configfile, | |
| const struct ast_config * | cfg, | |||
| const char * | generator | |||
| ) |
Definition at line 1804 of file config.c.
References ast_config_text_file_save().
01805 { 01806 return ast_config_text_file_save(configfile, cfg, generator); 01807 }
| static int count_linefeeds | ( | char * | str | ) | [static] |
| static int count_linefeeds_in_comments | ( | struct ast_comment * | x | ) | [static] |
Definition at line 1757 of file config.c.
References ast_comment::cmt, count_linefeeds(), and ast_comment::next.
Referenced by insert_leading_blank_lines().
01758 { 01759 int count = 0; 01760 01761 while (x) { 01762 count += count_linefeeds(x->cmt); 01763 x = x->next; 01764 } 01765 return count; 01766 }
| static struct ast_config_engine* find_engine | ( | const char * | family, | |
| int | priority, | |||
| char * | database, | |||
| int | dbsiz, | |||
| char * | table, | |||
| int | tabsiz | |||
| ) | [static, read] |
Find realtime engine for realtime family.
Definition at line 2234 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, ast_config_map::priority, and ast_config_map::table.
Referenced by ast_check_realtime(), ast_config_internal_load(), ast_destroy_realtime(), ast_load_realtime_helper(), ast_load_realtime_multientry(), ast_realtime_require_field(), ast_speech_new(), ast_speech_register(), ast_store_realtime(), ast_unload_realtime(), ast_update2_realtime(), and ast_update_realtime().
02235 { 02236 struct ast_config_engine *eng, *ret = NULL; 02237 struct ast_config_map *map; 02238 02239 ast_mutex_lock(&config_lock); 02240 02241 for (map = config_maps; map; map = map->next) { 02242 if (!strcasecmp(family, map->name) && (priority == map->priority)) { 02243 if (database) 02244 ast_copy_string(database, map->database, dbsiz); 02245 if (table) 02246 ast_copy_string(table, map->table ? map->table : family, tabsiz); 02247 break; 02248 } 02249 } 02250 02251 /* Check if the required driver (engine) exist */ 02252 if (map) { 02253 for (eng = config_engine_list; !ret && eng; eng = eng->next) { 02254 if (!strcasecmp(eng->name, map->driver)) 02255 ret = eng; 02256 } 02257 } 02258 02259 ast_mutex_unlock(&config_lock); 02260 02261 /* if we found a mapping, but the engine is not available, then issue a warning */ 02262 if (map && !ret) 02263 ast_log(LOG_WARNING, "Realtime mapping for '%s' found to engine '%s', but the engine is not available\n", map->name, map->driver); 02264 02265 return ret; 02266 }
| static void gen_header | ( | FILE * | f1, | |
| const char * | configfile, | |||
| const char * | fn, | |||
| const char * | generator | |||
| ) | [static] |
Definition at line 1678 of file config.c.
References ast_copy_string().
Referenced by ast_config_text_file_save().
01679 { 01680 char date[256]=""; 01681 time_t t; 01682 01683 time(&t); 01684 ast_copy_string(date, ctime(&t), sizeof(date)); 01685 01686 fprintf(f1, ";!\n"); 01687 fprintf(f1, ";! Automatically generated configuration file\n"); 01688 if (strcmp(configfile, fn)) 01689 fprintf(f1, ";! Filename: %s (%s)\n", configfile, fn); 01690 else 01691 fprintf(f1, ";! Filename: %s\n", configfile); 01692 fprintf(f1, ";! Generator: %s\n", generator); 01693 fprintf(f1, ";! Creation Date: %s", date); 01694 fprintf(f1, ";!\n"); 01695 }
| static char* handle_cli_config_list | ( | struct ast_cli_entry * | e, | |
| int | cmd, | |||
| struct ast_cli_args * | a | |||
| ) | [static] |
Definition at line 2872 of file config.c.
References ast_cli(), AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, cache_file_mtime::filename, S_OR, ast_cli_entry::usage, and cache_file_mtime::who_asked.
02873 { 02874 struct cache_file_mtime *cfmtime; 02875 02876 switch (cmd) { 02877 case CLI_INIT: 02878 e->command = "config list"; 02879 e->usage = 02880 "Usage: config list\n" 02881 " Show all modules that have loaded a configuration file\n"; 02882 return NULL; 02883 case CLI_GENERATE: 02884 return NULL; 02885 } 02886 02887 AST_LIST_LOCK(&cfmtime_head); 02888 AST_LIST_TRAVERSE(&cfmtime_head, cfmtime, list) { 02889 ast_cli(a->fd, "%-20.20s %-50s\n", S_OR(cfmtime->who_asked, "core"), cfmtime->filename); 02890 } 02891 AST_LIST_UNLOCK(&cfmtime_head); 02892 02893 return CLI_SUCCESS; 02894 }
| static char* handle_cli_config_reload | ( | struct ast_cli_entry * | e, | |
| int | cmd, | |||
| struct ast_cli_args * | a | |||
| ) | [static] |
Definition at line 2810 of file config.c.
References ast_cli_args::argc, ast_cli_args::argv, ast_cli_command, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_strdup, ast_strlen_zero(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, cache_file_mtime::filename, ast_cli_args::n, ast_cli_args::pos, ast_cli_entry::usage, cache_file_mtime::who_asked, and ast_cli_args::word.
02811 { 02812 struct cache_file_mtime *cfmtime; 02813 char *prev = "", *completion_value = NULL; 02814 int wordlen, which = 0; 02815 02816 switch (cmd) { 02817 case CLI_INIT: 02818 e->command = "config reload"; 02819 e->usage = 02820 "Usage: config reload <filename.conf>\n" 02821 " Reloads all modules that reference <filename.conf>\n"; 02822 return NULL; 02823 case CLI_GENERATE: 02824 if (a->pos > 2) { 02825 return NULL; 02826 } 02827 02828 wordlen = strlen(a->word); 02829 02830 AST_LIST_LOCK(&cfmtime_head); 02831 AST_LIST_TRAVERSE(&cfmtime_head, cfmtime, list) { 02832 /* Skip duplicates - this only works because the list is sorted by filename */ 02833 if (strcmp(cfmtime->filename, prev) == 0) { 02834 continue; 02835 } 02836 02837 /* Core configs cannot be reloaded */ 02838 if (ast_strlen_zero(cfmtime->who_asked)) { 02839 continue; 02840 } 02841 02842 if (++which > a->n && strncmp(cfmtime->filename, a->word, wordlen) == 0) { 02843 completion_value = ast_strdup(cfmtime->filename); 02844 break; 02845 } 02846 02847 /* Otherwise save that we've seen this filename */ 02848 prev = cfmtime->filename; 02849 } 02850 AST_LIST_UNLOCK(&cfmtime_head); 02851 02852 return completion_value; 02853 } 02854 02855 if (a->argc != 3) { 02856 return CLI_SHOWUSAGE; 02857 } 02858 02859 AST_LIST_LOCK(&cfmtime_head); 02860 AST_LIST_TRAVERSE(&cfmtime_head, cfmtime, list) { 02861 if (!strcmp(cfmtime->filename, a->argv[2])) { 02862 char *buf = alloca(strlen("module reload ") + strlen(cfmtime->who_asked) + 1); 02863 sprintf(buf, "module reload %s", cfmtime->who_asked); 02864 ast_cli_command(a->fd, buf); 02865 } 02866 } 02867 AST_LIST_UNLOCK(&cfmtime_head); 02868 02869 return CLI_SUCCESS; 02870 }
| static char* handle_cli_core_show_config_mappings | ( | struct ast_cli_entry * | e, | |
| int | cmd, | |||
| struct ast_cli_args * | a | |||
| ) | [static] |
Definition at line 2773 of file config.c.
References ast_cli(), ast_mutex_lock, ast_mutex_unlock, CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, config_lock, config_maps, ast_config_map::database, ast_config_map::driver, ast_cli_args::fd, map, ast_config_map::name, ast_config_engine::name, ast_config_map::next, ast_config_engine::next, ast_config_map::table, and ast_cli_entry::usage.
02774 { 02775 struct ast_config_engine *eng; 02776 struct ast_config_map *map; 02777 02778 switch (cmd) { 02779 case CLI_INIT: 02780 e->command = "core show config mappings"; 02781 e->usage = 02782 "Usage: core show config mappings\n" 02783 " Shows the filenames to config engines.\n"; 02784 return NULL; 02785 case CLI_GENERATE: 02786 return NULL; 02787 } 02788 02789 ast_mutex_lock(&config_lock); 02790 02791 if (!config_engine_list) { 02792 ast_cli(a->fd, "No config mappings found.\n"); 02793 } else { 02794 for (eng = config_engine_list; eng; eng = eng->next) { 02795 ast_cli(a->fd, "Config Engine: %s\n", eng->name); 02796 for (map = config_maps; map; map = map->next) { 02797 if (!strcasecmp(map->driver, eng->name)) { 02798 ast_cli(a->fd, "===> %s (db=%s, table=%s)\n", map->name, map->database, 02799 map->table ? map->table : map->name); 02800 } 02801 } 02802 } 02803 } 02804 02805 ast_mutex_unlock(&config_lock); 02806 02807 return CLI_SUCCESS; 02808 }
| static int hash_string | ( | const void * | obj, | |
| const int | flags | |||
| ) | [static] |
Definition at line 150 of file config.c.
Referenced by ast_config_text_file_save().
00151 { 00152 char *str = ((struct inclfile *) obj)->fname; 00153 int total; 00154 00155 for (total = 0; *str; str++) { 00156 unsigned int tmp = total; 00157 total <<= 1; /* multiply by 2 */ 00158 total += tmp; /* multiply by 3 */ 00159 total <<= 2; /* multiply by 12 */ 00160 total += tmp; /* multiply by 13 */ 00161 00162 total += ((unsigned int) (*str)); 00163 } 00164 if (total < 0) { 00165 total = -total; 00166 } 00167 return total; 00168 }
| static int hashtab_compare_strings | ( | void * | a, | |
| void * | b, | |||
| int | flags | |||
| ) | [static] |
Definition at line 170 of file config.c.
References CMP_MATCH, CMP_STOP, and inclfile::fname.
Referenced by ast_config_text_file_save().
00171 { 00172 const struct inclfile *ae = a, *be = b; 00173 return !strcmp(ae->fname, be->fname) ? CMP_MATCH | CMP_STOP : 0; 00174 }
| static void inclfile_destroy | ( | void * | obj | ) | [static] |
| static void inherit_category | ( | struct ast_category * | new, | |
| const struct ast_category * | base | |||
| ) | [static] |
Definition at line 828 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().
00829 { 00830 struct ast_variable *var; 00831 struct ast_category_template_instance *x; 00832 00833 x = ast_calloc(1, sizeof(*x)); 00834 if (!x) { 00835 return; 00836 } 00837 strcpy(x->name, base->name); 00838 x->inst = base; 00839 AST_LIST_INSERT_TAIL(&new->template_instances, x, next); 00840 for (var = base->root; var; var = var->next) 00841 ast_variable_append(new, variable_clone(var)); 00842 }
| static int init_appendbuf | ( | void * | data | ) | [static] |
Definition at line 96 of file config.c.
References ast_str_create(), and str.
00097 { 00098 struct ast_str **str = data; 00099 *str = ast_str_create(16); 00100 return *str ? 0 : -1; 00101 }
| static void insert_leading_blank_lines | ( | FILE * | fp, | |
| struct inclfile * | fi, | |||
| struct ast_comment * | precomments, | |||
| int | lineno | |||
| ) | [static] |
Definition at line 1768 of file config.c.
References count_linefeeds_in_comments(), and inclfile::lineno.
Referenced by ast_config_text_file_save().
01769 { 01770 int precomment_lines; 01771 int i; 01772 01773 if (!fi) { 01774 /* No file scratch pad object so insert no blank lines. */ 01775 return; 01776 } 01777 01778 precomment_lines = count_linefeeds_in_comments(precomments); 01779 01780 /* I don't have to worry about those ;! comments, they are 01781 stored in the precomments, but not printed back out. 01782 I did have to make sure that comments following 01783 the ;! header comments were not also deleted in the process */ 01784 if (lineno - precomment_lines - fi->lineno < 0) { /* insertions can mess up the line numbering and produce negative numbers that mess things up */ 01785 return; 01786 } else if (lineno == 0) { 01787 /* Line replacements also mess things up */ 01788 return; 01789 } else if (lineno - precomment_lines - fi->lineno < 5) { 01790 /* Only insert less than 5 blank lines; if anything more occurs, 01791 * it's probably due to context deletion. */ 01792 for (i = fi->lineno; i < lineno - precomment_lines; i++) { 01793 fprintf(fp, "\n"); 01794 } 01795 } else { 01796 /* Deletion occurred - insert a single blank line, for separation of 01797 * contexts. */ 01798 fprintf(fp, "\n"); 01799 } 01800 01801 fi->lineno = lineno + 1; /* Advance the file lineno */ 01802 }
| static void move_variables | ( | struct ast_category * | old, | |
| struct ast_category * | new | |||
| ) | [static] |
Definition at line 624 of file config.c.
References ast_variable_append(), ast_category::root, and var.
Referenced by process_text_line().
00625 { 00626 struct ast_variable *var = old->root; 00627 00628 old->root = NULL; 00629 /* we can just move the entire list in a single op */ 00630 ast_variable_append(new, var); 00631 }
| static struct ast_category* next_available_category | ( | struct ast_category * | cat | ) | [static, read] |
Definition at line 744 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, | |||
| struct ast_flags | flags, | |||
| struct ast_str * | comment_buffer, | |||
| struct ast_str * | lline_buffer, | |||
| const char * | suggested_include_file, | |||
| struct ast_category ** | last_cat, | |||
| struct ast_variable ** | last_var, | |||
| const char * | who_asked | |||
| ) | [static] |
parse one line in the configuration.
* We can have a category header [foo](...) * a directive #include / #exec * or a regular line name = value *
Definition at line 1112 of file config.c.
References ALLOC_COMMENT(), appendbuf, ast_category_append(), ast_category_destroy(), ast_category_first(), ast_category_new(), ast_config_internal_load(), ast_include_new(), ast_log(), ast_opt_exec_includes, ast_safe_system(), ast_skip_blanks(), ast_str_append(), ast_str_buffer(), ast_str_set(), ast_str_trim_blanks(), ast_strip(), ast_strlen_zero(), ast_test_flag, ast_threadstorage_get(), ast_tvnow(), ast_variable_append(), ast_variable_new(), ast_variable_update(), ATTRIBUTE_EXEC, ATTRIBUTE_INCLUDE, ast_variable::blanklines, category_get(), CB_RESET(), config_cache_attribute(), CONFIG_FLAG_NOCACHE, CONFIG_FLAG_WITHCOMMENTS, ast_config::include_level, inherit_category(), ast_variable::lineno, LOG_ERROR, LOG_WARNING, move_variables(), ast_variable::name, ast_variable::next, ast_variable::object, ast_variable::precomments, ast_category::precomments, replace(), S_OR, ast_variable::sameline, ast_category::sameline, str, strsep(), ast_variable::value, and var.
Referenced by config_text_file_load().
01118 { 01119 char *c; 01120 char *cur = buf; 01121 struct ast_variable *v; 01122 char cmd[512], exec_file[512]; 01123 01124 /* Actually parse the entry */ 01125 if (cur[0] == '[') { /* A category header */ 01126 /* format is one of the following: 01127 * [foo] define a new category named 'foo' 01128 * [foo](!) define a new template category named 'foo' 01129 * [foo](+) append to category 'foo', error if foo does not exist. 01130 * [foo](a) define a new category and inherit from category or template a. 01131 * You can put a comma-separated list of categories and templates 01132 * and '!' and '+' between parentheses, with obvious meaning. 01133 */ 01134 struct ast_category *newcat = NULL; 01135 char *catname; 01136 01137 c = strchr(cur, ']'); 01138 if (!c) { 01139 ast_log(LOG_WARNING, "parse error: no closing ']', line %d of %s\n", lineno, configfile); 01140 return -1; 01141 } 01142 *c++ = '\0'; 01143 cur++; 01144 if (*c++ != '(') 01145 c = NULL; 01146 catname = cur; 01147 if (!(*cat = newcat = ast_category_new(catname, 01148 S_OR(suggested_include_file, cfg->include_level == 1 ? "" : configfile), 01149 lineno))) { 01150 return -1; 01151 } 01152 (*cat)->lineno = lineno; 01153 *last_var = 0; 01154 *last_cat = newcat; 01155 01156 /* add comments */ 01157 if (ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS)) 01158 newcat->precomments = ALLOC_COMMENT(comment_buffer); 01159 if (ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS)) 01160 newcat->sameline = ALLOC_COMMENT(lline_buffer); 01161 if (ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS)) 01162 CB_RESET(comment_buffer, lline_buffer); 01163 01164 /* If there are options or categories to inherit from, process them now */ 01165 if (c) { 01166 if (!(cur = strchr(c, ')'))) { 01167 ast_log(LOG_WARNING, "parse error: no closing ')', line %d of %s\n", lineno, configfile); 01168 return -1; 01169 } 01170 *cur = '\0'; 01171 while ((cur = strsep(&c, ","))) { 01172 if (!strcasecmp(cur, "!")) { 01173 (*cat)->ignored = 1; 01174 } else if (!strcasecmp(cur, "+")) { 01175 *cat = category_get(cfg, catname, 1); 01176 if (!(*cat)) { 01177 if (newcat) 01178 ast_category_destroy(newcat); 01179 ast_log(LOG_WARNING, "Category addition requested, but category '%s' does not exist, line %d of %s\n", catname, lineno, configfile); 01180 return -1; 01181 } 01182 if (newcat) { 01183 move_variables(newcat, *cat); 01184 ast_category_destroy(newcat); 01185 newcat = NULL; 01186 } 01187 } else { 01188 struct ast_category *base; 01189 01190 base = category_get(cfg, cur, 1); 01191 if (!base) { 01192 ast_log(LOG_WARNING, "Inheritance requested, but category '%s' does not exist, line %d of %s\n", cur, lineno, configfile); 01193 return -1; 01194 } 01195 inherit_category(*cat, base); 01196 } 01197 } 01198 } 01199 if (newcat) 01200 ast_category_append(cfg, *cat); 01201 } else if (cur[0] == '#') { /* A directive - #include or #exec */ 01202 char *cur2; 01203 char real_inclusion_name[256]; 01204 int do_include = 0; /* otherwise, it is exec */ 01205 int try_include = 0; 01206 01207 cur++; 01208 c = cur; 01209 while (*c && (*c > 32)) { 01210 c++; 01211 } 01212 01213 if (*c) { 01214 *c = '\0'; 01215 /* Find real argument */ 01216 c = ast_strip(c + 1); 01217 if (!(*c)) { 01218 c = NULL; 01219 } 01220 } else { 01221 c = NULL; 01222 } 01223 if (!strcasecmp(cur, "include")) { 01224 do_include = 1; 01225 } else if (!strcasecmp(cur, "tryinclude")) { 01226 do_include = 1; 01227 try_include = 1; 01228 } else if (!strcasecmp(cur, "exec")) { 01229 if (!ast_opt_exec_includes) { 01230 ast_log(LOG_WARNING, "Cannot perform #exec unless execincludes option is enabled in asterisk.conf (options section)!\n"); 01231 return 0; /* XXX is this correct ? or we should return -1 ? */ 01232 } 01233 } else { 01234 ast_log(LOG_WARNING, "Unknown directive '#%s' at line %d of %s\n", cur, lineno, configfile); 01235 return 0; /* XXX is this correct ? or we should return -1 ? */ 01236 } 01237 01238 if (c == NULL) { 01239 ast_log(LOG_WARNING, "Directive '#%s' needs an argument (%s) at line %d of %s\n", 01240 do_include ? "include / tryinclude" : "exec", 01241 do_include ? "filename" : "/path/to/executable", 01242 lineno, 01243 configfile); 01244 return 0; /* XXX is this correct ? or we should return -1 ? */ 01245 } 01246 01247 cur = c; 01248 /* Strip off leading and trailing "'s and <>'s */ 01249 /* Dequote */ 01250 if ((*c == '"') || (*c == '<')) { 01251 char quote_char = *c; 01252 if (quote_char == '<') { 01253 quote_char = '>'; 01254 } 01255 01256 if (*(c + strlen(c) - 1) == quote_char) { 01257 cur++; 01258 *(c + strlen(c) - 1) = '\0'; 01259 } 01260 } 01261 cur2 = cur; 01262 01263 /* #exec </path/to/executable> 01264 We create a tmp file, then we #include it, then we delete it. */ 01265 if (!do_include) { 01266 struct timeval now = ast_tvnow(); 01267 if (!ast_test_flag(&flags, CONFIG_FLAG_NOCACHE)) 01268 config_cache_attribute(configfile, ATTRIBUTE_EXEC, NULL, who_asked); 01269 snprintf(exec_file, sizeof(exec_file), "/var/tmp/exec.%d%d.%ld", (int)now.tv_sec, (int)now.tv_usec, (long)pthread_self()); 01270 snprintf(cmd, sizeof(cmd), "%s > %s 2>&1", cur, exec_file); 01271 ast_safe_system(cmd); 01272 cur = exec_file; 01273 } else { 01274 if (!ast_test_flag(&flags, CONFIG_FLAG_NOCACHE)) 01275 config_cache_attribute(configfile, ATTRIBUTE_INCLUDE, cur, who_asked); 01276 exec_file[0] = '\0'; 01277 } 01278 /* A #include */ 01279 /* record this inclusion */ 01280 ast_include_new(cfg, cfg->include_level == 1 ? "" : configfile, cur, !do_include, cur2, lineno, real_inclusion_name, sizeof(real_inclusion_name)); 01281 01282 do_include = ast_config_internal_load(cur, cfg, flags, real_inclusion_name, who_asked) ? 1 : 0; 01283 if (!ast_strlen_zero(exec_file)) 01284 unlink(exec_file); 01285 if (!do_include && !try_include) { 01286 ast_log(LOG_ERROR, "The file '%s' was listed as a #include but it does not exist.\n", cur); 01287 return -1; 01288 } 01289 /* XXX otherwise what ? the default return is 0 anyways */ 01290 01291 } else { 01292 /* Just a line (variable = value) */ 01293 int object = 0; 01294 if (!(*cat)) { 01295 ast_log(LOG_WARNING, 01296 "parse error: No category context for line %d of %s\n", lineno, configfile); 01297 return -1; 01298 } 01299 c = strchr(cur, '='); 01300 01301 if (c && c > cur && (*(c - 1) == '+')) { 01302 struct ast_variable *var, *replace = NULL; 01303 struct ast_str **str = ast_threadstorage_get(&appendbuf, sizeof(*str)); 01304 01305 if (!str || !*str) { 01306 return -1; 01307 } 01308 01309 *(c - 1) = '\0'; 01310 c++; 01311 cur = ast_strip(cur); 01312 01313 /* Must iterate through category until we find last variable of same name (since there could be multiple) */ 01314 for (var = ast_category_first(*cat); var; var = var->next) { 01315 if (!strcmp(var->name, cur)) { 01316 replace = var; 01317 } 01318 } 01319 01320 if (!replace) { 01321 /* Nothing to replace; just set a variable normally. */ 01322 goto set_new_variable; 01323 } 01324 01325 ast_str_set(str, 0, "%s", replace->value); 01326 ast_str_append(str, 0, "%s", c); 01327 ast_str_trim_blanks(*str); 01328 ast_variable_update(*cat, replace->name, ast_skip_blanks(ast_str_buffer(*str)), replace->value, object); 01329 } else if (c) { 01330 *c = 0; 01331 c++; 01332 /* Ignore > in => */ 01333 if (*c== '>') { 01334 object = 1; 01335 c++; 01336 } 01337 set_new_variable: 01338 if ((v = ast_variable_new(ast_strip(cur), ast_strip(c), S_OR(suggested_include_file, cfg->include_level == 1 ? "" : configfile)))) { 01339 v->lineno = lineno; 01340 v->object = object; 01341 *last_cat = 0; 01342 *last_var = v; 01343 /* Put and reset comments */ 01344 v->blanklines = 0; 01345 ast_variable_append(*cat, v); 01346 /* add comments */ 01347 if (ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS)) 01348 v->precomments = ALLOC_COMMENT(comment_buffer); 01349 if (ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS)) 01350 v->sameline = ALLOC_COMMENT(lline_buffer); 01351 if (ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS)) 01352 CB_RESET(comment_buffer, lline_buffer); 01353 01354 } else { 01355 return -1; 01356 } 01357 } else { 01358 ast_log(LOG_WARNING, "No '=' (equal sign) in line %d of %s\n", lineno, configfile); 01359 } 01360 } 01361 return 0; 01362 }
| int read_config_maps | ( | void | ) |
Exposed re-initialization method for core process.
This method is intended for use only with the core re-initialization and is not designed to be called from any user applications.
Definition at line 2115 of file config.c.
References append_mapping(), ast_config_destroy(), ast_config_internal_load(), ast_config_new(), ast_copy_string(), ast_log(), ast_variable_browse(), clear_config_maps(), config, CONFIG_FLAG_NOREALTIME, CONFIG_STATUS_FILEINVALID, LOG_WARNING, ast_config::max_include_level, ast_variable::name, ast_variable::next, strsep(), table, and ast_variable::value.
Referenced by main().
02116 { 02117 struct ast_config *config, *configtmp; 02118 struct ast_variable *v; 02119 char *driver, *table, *database, *textpri, *stringp, *tmp; 02120 struct ast_flags flags = { CONFIG_FLAG_NOREALTIME }; 02121 int pri; 02122 02123 clear_config_maps(); 02124 02125 configtmp = ast_config_new(); 02126 configtmp->max_include_level = 1; 02127 config = ast_config_internal_load(extconfig_conf, configtmp, flags, "", "extconfig"); 02128 if (config == CONFIG_STATUS_FILEINVALID) { 02129 return -1; 02130 } else if (!config) { 02131 ast_config_destroy(configtmp); 02132 return 0; 02133 } 02134 02135 for (v = ast_variable_browse(config, "settings"); v; v = v->next) { 02136 char buf[512]; 02137 ast_copy_string(buf, v->value, sizeof(buf)); 02138 stringp = buf; 02139 driver = strsep(&stringp, ","); 02140 02141 if ((tmp = strchr(stringp, '\"'))) 02142 stringp = tmp; 02143 02144 /* check if the database text starts with a double quote */ 02145 if (*stringp == '"') { 02146 stringp++; 02147 database = strsep(&stringp, "\""); 02148 strsep(&stringp, ","); 02149 } else { 02150 /* apparently this text has no quotes */ 02151 database = strsep(&stringp, ","); 02152 } 02153 02154 table = strsep(&stringp, ","); 02155 textpri = strsep(&stringp, ","); 02156 if (!textpri || !(pri = atoi(textpri))) { 02157 pri = 1; 02158 } 02159 02160 if (!strcmp(v->name, extconfig_conf)) { 02161 ast_log(LOG_WARNING, "Cannot bind '%s'!\n", extconfig_conf); 02162 continue; 02163 } 02164 02165 if (!strcmp(v->name, "asterisk.conf")) { 02166 ast_log(LOG_WARNING, "Cannot bind 'asterisk.conf'!\n"); 02167 continue; 02168 } 02169 02170 if (!strcmp(v->name, "logger.conf")) { 02171 ast_log(LOG_WARNING, "Cannot bind 'logger.conf'!\n"); 02172 continue; 02173 } 02174 02175 if (!driver || !database) 02176 continue; 02177 if (!strcasecmp(v->name, "sipfriends")) { 02178 ast_log(LOG_WARNING, "The 'sipfriends' table is obsolete, update your config to use sippeers instead.\n"); 02179 append_mapping("sippeers", driver, database, table ? table : "sipfriends", pri); 02180 } else if (!strcasecmp(v->name, "iaxfriends")) { 02181 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"); 02182 append_mapping("iaxusers", driver, database, table ? table : "iaxfriends", pri); 02183 append_mapping("iaxpeers", driver, database, table ? table : "iaxfriends", pri); 02184 } else 02185 append_mapping(v->name, driver, database, table, pri); 02186 } 02187 02188 ast_config_destroy(config); 02189 return 0; 02190 }
| int register_config_cli | ( | void | ) |
Exposed initialization method for core process.
This method is intended for use only with the core initialization and is not designed to be called from any user applications.
Definition at line 2902 of file config.c.
References ARRAY_LEN, and ast_cli_register_multiple().
Referenced by main().
02903 { 02904 ast_cli_register_multiple(cli_config, ARRAY_LEN(cli_config)); 02905 return 0; 02906 }
| static struct inclfile* set_fn | ( | char * | fn, | |
| int | fn_size, | |||
| const char * | file, | |||
| const char * | configfile, | |||
| struct ao2_container * | fileset | |||
| ) | [static, read] |
Definition at line 1705 of file config.c.
References ao2_alloc, ao2_find, ao2_link, ao2_ref, ast_config_AST_CONFIG_DIR, ast_copy_string(), ast_strdup, ast_strlen_zero(), inclfile::fname, inclfile_destroy(), inclfile::lineno, and OBJ_POINTER.
Referenced by ast_config_text_file_save().
01706 { 01707 struct inclfile lookup; 01708 struct inclfile *fi; 01709 01710 if (ast_strlen_zero(file)) { 01711 if (configfile[0] == '/') 01712 ast_copy_string(fn, configfile, fn_size); 01713 else 01714 snprintf(fn, fn_size, "%s/%s", ast_config_AST_CONFIG_DIR, configfile); 01715 } else if (file[0] == '/') 01716 ast_copy_string(fn, file, fn_size); 01717 else 01718 snprintf(fn, fn_size, "%s/%s", ast_config_AST_CONFIG_DIR, file); 01719 lookup.fname = fn; 01720 fi = ao2_find(fileset, &lookup, OBJ_POINTER); 01721 if (fi) { 01722 /* Found existing include file scratch pad. */ 01723 return fi; 01724 } 01725 01726 /* set up a file scratch pad */ 01727 fi = ao2_alloc(sizeof(struct inclfile), inclfile_destroy); 01728 if (!fi) { 01729 /* Scratch pad creation failed. */ 01730 return NULL; 01731 } 01732 fi->fname = ast_strdup(fn); 01733 if (!fi->fname) { 01734 /* Scratch pad creation failed. */ 01735 ao2_ref(fi, -1); 01736 return NULL; 01737 } 01738 fi->lineno = 1; 01739 01740 ao2_link(fileset, fi); 01741 01742 return fi; 01743 }
| static struct ast_variable* variable_clone | ( | const struct ast_variable * | old | ) | [static, read] |
Definition at line 610 of file config.c.
References ast_variable_new(), ast_variable::blanklines, ast_variable::file, ast_variable::lineno, ast_variable::name, ast_variable::object, and ast_variable::value.
Referenced by inherit_category().
00611 { 00612 struct ast_variable *new = ast_variable_new(old->name, old->value, old->file); 00613 00614 if (new) { 00615 new->lineno = old->lineno; 00616 new->object = old->object; 00617 new->blanklines = old->blanklines; 00618 /* TODO: clone comments? */ 00619 } 00620 00621 return new; 00622 }
struct ast_threadstorage appendbuf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_appendbuf , .custom_init = init_appendbuf , } [static] |
struct ast_cli_entry cli_config[] [static] |
Initial value:
{
AST_CLI_DEFINE(handle_cli_core_show_config_mappings, "Display config mappings (file names to config engines)"),
AST_CLI_DEFINE(handle_cli_config_reload, "Force a reload on modules using a particular configuration file"),
AST_CLI_DEFINE(handle_cli_config_list, "Show all files that have loaded a configuration file"),
}
struct ast_config_engine* config_engine_list [static] |
ast_mutex_t config_lock = { PTHREAD_MUTEX_INITIALIZER , NULL, 1 } [static] |
Definition at line 191 of file config.c.
Referenced by ast_calendar_config_release(), ast_config_engine_deregister(), ast_config_engine_register(), clear_config_maps(), find_engine(), handle_cli_core_show_config_mappings(), load_config(), load_tech_calendars(), parse_config(), and unload_module().
struct ast_config_map * config_maps [static] |
Referenced by append_mapping(), ast_realtime_enabled(), clear_config_maps(), find_engine(), and handle_cli_core_show_config_mappings().
char* extconfig_conf = "extconfig.conf" [static] |
struct ast_config_engine text_file_engine [static] |
Initial value:
{
.name = "text",
.load_func = config_text_file_load,
}
1.5.6