143 }
else if (params->
prefix) {
148 }
else if (params->
fields &&
206 if (!config_objects) {
221 .regex = &expression,
228 if (!config_objects || regcomp(&expression, regex, REG_EXTENDED | REG_NOSUB)) {
233 regfree(&expression);
247 if (!config_objects) {
323 const char *
id =
NULL;
371 ast_log(
LOG_ERROR,
"Config file '%s' could not be loaded; configuration contains more than one object of type '%s'\n",
378 ast_debug(2,
"Using bucket size of '%d' for objects of type '%s' from '%s'\n",
384 ast_log(
LOG_ERROR,
"Could not create bucket for new objects from '%s', keeping existing objects\n",
405 ast_log(
LOG_ERROR,
"Config file '%s' could not be loaded; configuration contains a duplicate object: '%s' of type '%s'\n",
416 ast_log(
LOG_ERROR,
"Config file '%s' could not be loaded due to error with object '%s' of type '%s'\n",
422 ast_log(
LOG_ERROR,
"Could not create an object of type '%s' with id '%s' from configuration file '%s'\n",
434 ast_log(
LOG_NOTICE,
"Retaining existing configuration for object of type '%s' with id '%s'\n", type,
id);
472 filename =
strsep(&tmp,
",");
483 while ((option =
strsep(&tmp,
","))) {
486 if (!strcasecmp(name,
"buckets")) {
488 ast_log(
LOG_ERROR,
"Unsupported bucket size of '%s' used for configuration file '%s', defaulting to automatic determination\n",
491 }
else if (!strcasecmp(name,
"integrity")) {
492 if (!strcasecmp(
value,
"file")) {
494 }
else if (!strcasecmp(
value,
"object")) {
497 ast_log(
LOG_ERROR,
"Unsupported integrity value of '%s' used for configuration file '%s', defaulting to 'object'\n",
500 }
else if (!strcasecmp(name,
"criteria")) {
509 ast_log(
LOG_ERROR,
"Could not create criteria entry of field '%s' with value '%s' for configuration file '%s'\n",
510 field,
value, filename);
514 }
else if (!strcasecmp(name,
"explicit_name")) {
519 ast_log(
LOG_ERROR,
"Could not create explicit name entry of '%s' for configuration file '%s'\n",
524 }
else if (!strcasecmp(name,
"single_object")) {
526 ast_log(
LOG_ERROR,
"Could not set single object value for configuration file '%s' as the value is empty\n",
533 ast_log(
LOG_ERROR,
"Unsupported option '%s' used for configuration file '%s'\n", name, filename);
struct ast_variable * next
static int sorcery_config_fields_cmp(void *obj, void *arg, int flags)
static void sorcery_config_retrieve_regex(const struct ast_sorcery *sorcery, void *data, const char *type, struct ao2_container *objects, const char *regex)
static int sorcery_is_criteria_met(struct ast_category *category, struct sorcery_config *config)
Internal function which determines if a category matches based on criteria.
static int sorcery_is_explicit_name_met(const struct ast_sorcery *sorcery, const char *type, struct ast_category *category, struct sorcery_config *config)
Internal function which determines if a category matches based on explicit name.
Asterisk main include file. File version handling, generic pbx functions.
unsigned int ast_sorcery_object_has_dynamic_contents(const void *object)
Get whether an object contains dynamic contents or not.
struct ast_variable * criteria
Any specific variable criteria for considering a defined category for this object.
unsigned int single_object
Enable enforcement of a single configuration object of this type.
static void sorcery_config_destructor(void *obj)
Destructor function for sorcery config.
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
The arg parameter is a search key, but is not an object.
#define ast_rwlock_destroy(rwlock)
#define ao2_callback(c, flags, cb_fn, arg)
#define CONFIG_STATUS_FILEINVALID
Generic (perhaps overly so) hashtable implementation Hash Table support in Asterisk.
static void * sorcery_config_open(const char *data)
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.
Universally unique identifier support.
int ast_sorcery_object_id_compare(void *obj, void *arg, int flags)
ao2 object comparator based on sorcery id.
Full structure for sorcery.
#define ao2_global_obj_ref(holder)
int ast_sorcery_objectset_apply(const struct ast_sorcery *sorcery, void *object, struct ast_variable *objectset)
Apply an object set (KVP list) to an object.
#define ao2_alloc_options(data_size, destructor_fn, options)
static struct ast_sorcery_wizard config_object_wizard
#define ast_strdup(str)
A wrapper for strdup()
const size_t prefix_len
Prefix length in bytes for matching object id.
const char * name
Name of the wizard.
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.
regex_t * regex
Regular expression for checking object id.
#define ast_strlen_zero(foo)
Configuration File Parser.
const char * prefix
Prefix for matching object id.
#define ast_debug(level,...)
Log a DEBUG message.
static void sorcery_config_load(void *data, const struct ast_sorcery *sorcery, const char *type)
static void sorcery_config_close(void *data)
Structure for registered object type.
const struct ast_sorcery * sorcery
Pointer to the sorcery structure.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
struct ao2_container * container
Optional container to put object into.
#define ao2_ref(o, delta)
static void * sorcery_config_retrieve_fields(const struct ast_sorcery *sorcery, void *data, const char *type, const struct ast_variable *fields)
struct ast_variable * ast_category_first(struct ast_category *cat)
given a pointer to a category, return the root variable.
void ast_config_destroy(struct ast_config *config)
Destroys a config.
#define ast_strdupa(s)
duplicate a string in memory from the stack
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
char uuid[AST_UUID_STR_LEN]
UUID for identifying us when opening a configuration file.
#define ast_variable_new(name, value, filename)
struct ao2_global_obj objects
Objects retrieved from the configuration file.
struct ast_sorcery_object_type * ast_sorcery_get_object_type(const struct ast_sorcery *sorcery, const char *type)
Get the sorcery object type given a type name.
#define CONFIG_STATUS_FILEUNCHANGED
Structure for storing configuration file sourced objects.
static void * sorcery_config_retrieve_id(const struct ast_sorcery *sorcery, void *data, const char *type, const char *id)
static int unload_module(void)
#define ast_sorcery_wizard_register(interface)
See __ast_sorcery_wizard_register()
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
int ast_sorcery_wizard_unregister(const struct ast_sorcery_wizard *interface)
Unregister a sorcery wizard.
#define ao2_global_obj_release(holder)
#define ast_rwlock_init(rwlock)
wrapper for rwlock with tracking enabled
const struct ast_variable * fields
Pointer to the fields to check.
void * ast_sorcery_alloc(const struct ast_sorcery *sorcery, const char *type, const char *id)
Allocate an object.
char * explicit_name
An explicit name for the configuration section, with it there can be only one.
#define ast_sorcery_objectset_create(sorcery, object)
Create an object set (KVP list) for an object.
int ast_sorcery_is_object_field_registered(const struct ast_sorcery_object_type *object_type, const char *field_name)
Determine if a particular object field has been registered with sorcery.
unsigned int configuration_invalid
Configuration is invalid in some way, force reload.
static int regex(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
unsigned int file_integrity
Enable file level integrity instead of object level.
char * ast_uuid_generate_str(char *buf, size_t size)
Generate a UUID string.
static int sorcery_is_configuration_met(const struct ast_sorcery *sorcery, const char *type, struct ast_category *category, struct sorcery_config *config)
Internal function which determines if criteria has been met for considering an object set applicable...
Module has failed to load, may be in an inconsistent state.
#define ao2_find(container, arg, flags)
Structure used for fields comparison.
char filename[]
Filename of the configuration file.
Structure used to handle boolean flags.
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
static int load_module(void)
Interface for a sorcery wizard.
#define ao2_global_obj_replace_unref(holder, obj)
char * strsep(char **str, const char *delims)
static void sorcery_config_reload(void *data, const struct ast_sorcery *sorcery, const char *type)
static struct ast_sorcery * sorcery
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.
int ast_sorcery_changeset_create(const struct ast_variable *original, const struct ast_variable *modified, struct ast_variable **changes)
Create a changeset given two object sets.
static void sorcery_config_retrieve_multiple(const struct ast_sorcery *sorcery, void *data, const char *type, struct ao2_container *objects, const struct ast_variable *fields)
static void sorcery_config_retrieve_prefix(const struct ast_sorcery *sorcery, void *data, const char *type, struct ao2_container *objects, const char *prefix, const size_t prefix_len)
int ast_sorcery_object_id_hash(const void *obj, int flags)
ao2 object hasher based on sorcery id.
static void sorcery_config_internal_load(void *data, const struct ast_sorcery *sorcery, const char *type, unsigned int reload)
#define ASTERISK_GPL_KEY
The text the key() function should return.
unsigned int has_dynamic_contents
Configuration contains at least one object with dynamic contents.
Asterisk module definitions.
unsigned int buckets
Number of buckets to use for objects.
int ast_is_prime(int num)
Determines if the specified number is prime.
const char * ast_category_get_name(const struct ast_category *category)
Return the name of the category.
Sorcery Data Access Layer API.
static char prefix[MAX_PREFIX]
#define ao2_link(container, obj)