23 #ifndef _ASTERISK_CONFIG_H
24 #define _ASTERISK_CONFIG_H
26 #if defined(__cplusplus) || defined(c_plusplus)
53 CONFIG_SAVE_FLAG_NONE = (0),
58 #define CONFIG_STATUS_FILEMISSING (void *)0
59 #define CONFIG_STATUS_FILEUNCHANGED (void *)-1
60 #define CONFIG_STATUS_FILEINVALID (void *)-2
109 typedef struct ast_config *config_load_func(
const char *database,
const char *table,
const char *configfile,
struct ast_config *config,
struct ast_flags flags,
const char *suggested_include_file,
const char *who_asked);
110 typedef struct ast_variable *realtime_var_get(
const char *database,
const char *table,
const struct ast_variable *fields);
111 typedef struct ast_config *realtime_multi_get(
const char *database,
const char *table,
const struct ast_variable *fields);
112 typedef int realtime_update(
const char *database,
const char *table,
const char *keyfield,
const char *entity,
const struct ast_variable *fields);
113 typedef int realtime_update2(
const char *database,
const char *table,
const struct ast_variable *lookup_fields,
const struct ast_variable *update_fields);
114 typedef int realtime_store(
const char *database,
const char *table,
const struct ast_variable *fields);
115 typedef int realtime_destroy(
const char *database,
const char *table,
const char *keyfield,
const char *entity,
const struct ast_variable *fields);
132 config_load_func *load_func;
133 realtime_var_get *realtime_func;
134 realtime_multi_get *realtime_multi_func;
135 realtime_update *update_func;
136 realtime_update2 *update2_func;
137 realtime_store *store_func;
138 realtime_destroy *destroy_func;
179 #define ast_config_load(filename, flags) ast_config_load2(filename, AST_MODULE, flags)
276 const char *category_name,
const char *
filter);
278 const char *category_name);
305 const char *category,
const char *variable,
const char *
filter);
306 const char *ast_variable_retrieve(
struct ast_config *config,
307 const char *category,
const char *variable);
388 const char *category_name,
const char *
filter);
462 struct ast_variable *ast_load_realtime(
const char *family, ...) attribute_sentinel;
464 struct
ast_variable *ast_load_realtime_all(const
char *family, ...) attribute_sentinel;
596 int ast_update_realtime(const
char *family, const
char *keyfield, const
char *lookup, ...) attribute_sentinel;
703 int ast_destroy_realtime(const
char *family, const
char *keyfield, const
char *lookup, ...) attribute_sentinel;
766 #ifdef TEST_FRAMEWORK
776 int ast_realtime_append_mapping(
const char *
name,
const char *driver,
const char *database,
const char *table,
int priority);
833 #define ast_category_new_dynamic(name) ast_category_new(name, "", -1)
838 #define ast_category_new_anonymous() ast_category_new_dynamic("")
914 struct ast_variable *_ast_variable_new(
const char *
name,
const char *
value,
const char *filename,
const char *
file,
const char *
function,
int lineno);
915 #define ast_variable_new(name, value, filename) _ast_variable_new(name, value, filename, __FILE__, __PRETTY_FUNCTION__, __LINE__)
919 void ast_include_rename(
struct ast_config *
conf,
const char *from_file,
const char *to_file);
922 int ast_variable_delete(
struct ast_category *category,
const char *variable,
const char *match,
const char *line);
950 #define ast_variable_list_append(head, new_var) ast_variable_list_append_hint(head, NULL, new_var)
1007 const char *name_value_separator,
const char *quote_char,
struct ast_str **str);
1024 const char *name_value_separator);
1044 const char *name_value_separator,
const char *quote_str);
1058 const char *
value,
const char *match,
unsigned int object);
1086 struct ast_config *ast_config_internal_load(
const char *configfile,
struct ast_config *cfg,
struct ast_flags flags,
const char *suggested_incl_file,
const char *who_asked);
1132 const char *filename,
1161 PARSE_TYPE = 0x000f,
1165 PARSE_INT32 = 0x0001,
1166 PARSE_UINT32 = 0x0002,
1167 PARSE_DOUBLE = 0x0003,
1169 PARSE_INT16 = 0x0004,
1170 PARSE_UINT16 = 0x0005,
1176 PARSE_TIMELEN = 0x0006,
1183 PARSE_ADDR = 0x000e,
1189 PARSE_INADDR = 0x000f,
1197 PARSE_DEFAULT = 0x0010,
1204 PARSE_IN_RANGE = 0x0020,
1205 PARSE_OUT_RANGE = 0x0040,
1206 PARSE_RANGE_DEFAULTS = 0x0080,
1211 PARSE_PORT_MASK = 0x0300,
1212 PARSE_PORT_IGNORE = 0x0100,
1213 PARSE_PORT_REQUIRE = 0x0200,
1214 PARSE_PORT_FORBID = 0x0300,
1256 void *p_result, ...);
1278 #define CV_START(__in_var, __in_val) \
1280 const char *__var = __in_var; \
1281 const char *__val = __in_val;
1284 #define CV_END } while (0)
1287 #define CV_F(__pattern, __body) if (!strcasecmp((__var), __pattern)) { __body; break; }
1293 #define CV_BOOL(__x, __dst) CV_F(__x, (__dst) = ast_true(__val) )
1294 #define CV_UINT(__x, __dst) CV_F(__x, (__dst) = strtoul(__val, NULL, 0) )
1295 #define CV_STR(__x, __dst) CV_F(__x, ast_copy_string(__dst, __val, sizeof(__dst)))
1296 #define CV_DSTR(__x, __dst) CV_F(__x, ast_free(__dst); __dst = ast_strdup(__val))
1297 #define CV_STRFIELD(__x, __obj, __field) CV_F(__x, ast_string_field_set(__obj, __field, __val))
1402 #if defined(__cplusplus) || defined(c_plusplus)
int ast_category_is_template(const struct ast_category *category)
Check if category is a template.
struct ast_category * ast_category_new(const char *name, const char *in_file, int lineno)
Create a category.
struct ast_variable * next
struct ast_variable * ast_variables_reverse(struct ast_variable *var)
Reverse a variable list.
require_type
Types used in ast_realtime_require_field.
char * ast_realtime_decode_chunk(char *chunk)
Remove standard encoding from realtime values, which ensures that a semicolon embedded within a singl...
struct ast_variable * ast_variable_list_sort(struct ast_variable *head)
Performs an in-place sort on the variable list by ascending name.
int ast_config_text_file_save(const char *filename, const struct ast_config *cfg, const char *generator)
Save a config text file preserving the pre 13.2 behavior.
int ast_parse_arg(const char *arg, enum ast_parse_flags flags, void *p_result,...)
The argument parsing routine.
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
int register_config_cli(void)
Exposed initialization method for core process.
int ast_unload_realtime(const char *family)
Release any resources cached for a realtime family.
int ast_config_text_file_save2(const char *filename, const struct ast_config *cfg, const char *generator, uint32_t flags)
Save a config text file.
int ast_check_realtime(const char *family)
Check if realtime engine is configured for family.
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
Structure for variables, used for configurations and for channel variables.
struct ast_category * ast_category_delete(struct ast_config *cfg, struct ast_category *cat)
Delete a category.
struct ast_config * ast_load_realtime_multientry_fields(const char *family, const struct ast_variable *fields)
Retrieve realtime configuration.
int ast_category_exist(const struct ast_config *config, const char *category_name, const char *filter)
Check for category duplicates.
int ast_config_engine_deregister(struct ast_config_engine *del)
Deregister config engine.
struct ast_category * ast_config_get_current_category(const struct ast_config *cfg)
Retrieve the current category name being built.
struct ast_category * prev
int ast_config_engine_register(struct ast_config_engine *newconfig)
Register config engine.
int(* config_hook_cb)(struct ast_config *cfg)
Callback when configuration is updated.
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
const char * ast_variable_find_last_in_list(const struct ast_variable *list, const char *variable)
Gets the value of the LAST occurrence of a variable from a variable list.
char * exec_file
if it's an exec, you'll have both the /var/tmp to read, and the original script
int ast_update_realtime(const char *family, const char *keyfield, const char *lookup,...) attribute_sentinel
Update realtime configuration.
int realtime_unload(const char *database, const char *table)
Function pointer called to clear the database cache and free resources used for such.
struct ast_category * ast_category_browse_filtered(struct ast_config *config, const char *category_name, struct ast_category *prev, const char *filter)
Browse categories with filters.
struct ast_str * ast_category_get_templates(const struct ast_category *category)
Return the template names this category inherits from.
Configuration engine structure, used to define realtime drivers.
int ast_category_inherit(struct ast_category *existing, const struct ast_category *base)
Applies base (template) to category.
const char * ast_variable_retrieve_filtered(struct ast_config *config, const char *category, const char *variable, const char *filter)
Gets a variable by context and variable names.
int ast_realtime_enabled(void)
Check if there's any realtime engines loaded.
int ast_update2_realtime(const char *family,...) attribute_sentinel
Update realtime configuration.
All configuration options for http media cache.
void ast_category_append(struct ast_config *config, struct ast_category *category)
Appends a category to a config.
struct ast_comment * trailing
void ast_config_hook_unregister(const char *name)
Unregister a config hook.
struct ast_variable * ast_category_root(struct ast_config *config, char *cat)
returns the root ast_variable of a config
int ast_store_realtime(const char *family,...) attribute_sentinel
Create realtime configuration.
int ast_realtime_require_field(const char *family,...) attribute_sentinel
Inform realtime what fields that may be stored.
int ast_variable_list_replace(struct ast_variable **head, struct ast_variable *replacement)
Replace a variable in the given list with a new value.
int ast_config_hook_register(const char *name, const char *filename, const char *module, enum config_hook_flags flags, config_hook_cb hook)
Register a config hook for a particular file and module.
Inlinable API function macro.
int ast_store_realtime_fields(const char *family, const struct ast_variable *fields)
Create realtime configuration.
char * included_file
file name included
struct ast_variable * ast_category_first(struct ast_category *cat)
given a pointer to a category, return the root variable.
const char * ast_variable_find_in_list(const struct ast_variable *list, const char *variable)
Gets the value of a variable from a variable list by name.
char stuff[0]
Contents of file, name, and value in that order stuffed here.
struct ast_config * ast_config_new(void)
Create a new base configuration structure.
struct ast_variable * ast_variable_list_append_hint(struct ast_variable **head, struct ast_variable *search_hint, struct ast_variable *new_var)
Appends a variable list to the end of another list.
int ast_variable_list_replace_variable(struct ast_variable **head, struct ast_variable *oldvar, struct ast_variable *newvar)
Replace a variable in the given list with a new variable.
char * ast_realtime_encode_chunk(struct ast_str **dest, ssize_t maxlen, const char *chunk)
Encodes a chunk of data for realtime.
struct ast_config * ast_load_realtime_multientry(const char *family,...) attribute_sentinel
Retrieve realtime configuration.
Support for dynamic strings.
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_category_insert(struct ast_config *config, struct ast_category *cat, const char *match)
Inserts new category.
struct ast_config * ast_config_copy(const struct ast_config *orig)
Copies the contents of one ast_config into another.
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.
const char * ast_variable_find(const struct ast_category *category, const char *variable)
Gets a variable value from a specific category structure by name.
int ast_realtime_is_mapping_defined(const char *family)
Determine if a mapping exists for a given family.
Structure used to handle boolean flags.
config_hook_flags
Flags that affect the behaviour of config hooks.
struct ast_category * ast_category_new_template(const char *name, const char *in_file, int lineno)
Create a category making it a template.
int realtime_require(const char *database, const char *table, va_list ap)
Function pointer called to ensure database schema is properly configured for realtime use...
int ast_category_empty(struct ast_category *category)
Removes and destroys all variables in a category.
int ast_variable_lists_match(const struct ast_variable *left, const struct ast_variable *right, int exact_match)
Tests 2 variable lists to see if they match.
void ast_config_sort_categories(struct ast_config *config, int descending, int(*comparator)(struct ast_category *p, struct ast_category *q))
Sorts categories in a config in the order of a numerical value contained within them.
int ast_destroy_realtime(const char *family, const char *keyfield, const char *lookup,...) attribute_sentinel
Destroy realtime configuration.
struct ast_str * ast_variable_list_join(const struct ast_variable *head, const char *item_separator, const char *name_value_separator, const char *quote_char, struct ast_str **str)
Join an ast_variable list with specified separators and quoted values.
struct ast_variable * ast_variable_browse_filtered(const struct ast_config *config, const char *category_name, const char *filter)
Browse variables.
struct ast_variable * ast_load_realtime_fields(const char *family, const struct ast_variable *fields)
Retrieve realtime configuration.
const struct ast_variable * ast_variable_find_variable_in_list(const struct ast_variable *list, const char *variable_name)
Gets a variable from a variable list by name.
const char * ast_config_option(struct ast_config *cfg, const char *cat, const char *var)
Retrieve a configuration variable within the configuration set.
int ast_variables_match(const struct ast_variable *left, const struct ast_variable *right)
Tests 2 variable values to see if they match.
ast_parse_flags
Support code to parse config file arguments.
int ast_update_realtime_fields(const char *family, const char *keyfield, const char *lookup, const struct ast_variable *fields)
Update realtime configuration.
static int filter(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
struct ast_category * ast_category_get(const struct ast_config *config, const char *category_name, const char *filter)
Retrieve a category if it exists.
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
int ast_rq_is_int(require_type type)
Check if require type is an integer type.
int ast_destroy_realtime_fields(const char *family, const char *keyfield, const char *lookup, const struct ast_variable *fields)
Destroy realtime configuration.
struct ast_variable * ast_variables_dup(struct ast_variable *var)
Duplicate variable list.
const char * ast_category_get_name(const struct ast_category *category)
Return the name of the category.
struct ast_variable * ast_variable_list_from_string(const char *input, const char *item_separator, const char *name_value_separator)
Parse a string into an ast_variable list. The reverse of ast_variable_list_join.
int ast_update2_realtime_fields(const char *family, const struct ast_variable *lookup_fields, const struct ast_variable *update_fields)
Update realtime configuration.
struct ast_variable * ast_variable_list_from_quoted_string(const char *input, const char *item_separator, const char *name_value_separator, const char *quote_str)
Parse a string into an ast_variable list. The reverse of ast_variable_list_join.