114 ast_debug(1,
"Filtering out astdb field '%s' from retrieval\n", field->name);
119 objectset = field->
next;
137 const char *
prefix = data;
138 char family[strlen(
prefix) + strlen(
type) + 2];
142 snprintf(family,
sizeof(family),
"%s/%s",
prefix,
type);
193 const char *
prefix = data;
194 char family[strlen(
prefix) + strlen(
type) + 2];
201 snprintf(family,
sizeof(family),
"%s/%s",
prefix,
type);
209 ast_debug(3,
"Failed to retrieve object '%s' from astdb\n",
id);
240 for (dst = tree, src =
regex + 1; *src; ++src) {
248 }
else if (*src ==
'$') {
254 }
else if (strchr(
".?*+{[(|", *src)) {
280 const char *
prefix = data;
281 char family[strlen(
prefix) + strlen(
type) + 2];
282 char tree[strlen(
regex) + 1];
287 snprintf(family,
sizeof(family),
"%s/%s",
prefix,
type);
289 if (
regex[0] ==
'^') {
303 || regcomp(&expression,
regex, REG_EXTENDED | REG_NOSUB)) {
315 if (regexec(&expression, key, 0,
NULL, 0)) {
322 regfree(&expression);
329 regfree(&expression);
334 const char *family_prefix = data;
335 size_t family_len = strlen(family_prefix) + strlen(
type) + 1;
336 char family[family_len + 1];
337 char tree[prefix_len + 1];
341 snprintf(tree,
sizeof(tree),
"%.*s", (
int) prefix_len,
prefix);
342 snprintf(family,
sizeof(family),
"%s/%s", family_prefix,
type);
370 const char *
prefix = data;
386 const char *
prefix = data;
Persistent data storage (akin to *doze registry)
int ast_db_put(const char *family, const char *key, const char *value)
Store value addressed by family/key.
struct ast_db_entry * ast_db_gettree_by_prefix(const char *family, const char *key_prefix)
Get a list of values with the given key prefix.
int ast_db_get_allocated(const char *family, const char *key, char **out)
Get key value specified by family/key as a heap allocated string.
int ast_db_get(const char *family, const char *key, char *value, int valuelen)
Get key value specified by family/key.
int ast_db_del(const char *family, const char *key)
Delete entry in astdb.
struct ast_db_entry * ast_db_gettree(const char *family, const char *keytree)
Get a list of values within the astdb tree.
void ast_db_freetree(struct ast_db_entry *entry)
Free structure created by ast_db_gettree()
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdup(str)
A wrapper for strdup()
void ast_free_ptr(void *ptr)
free() wrapper
#define ao2_link(container, obj)
Add an object to a container.
static int regex(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
static char prefix[MAX_PREFIX]
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_variables_destroy(struct ast_variable *var)
Free variable list.
#define ast_debug(level,...)
Log a DEBUG message.
Asterisk JSON abstraction layer.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
void ast_json_free(void *p)
Asterisk's custom JSON allocator. Exposed for use by unit tests.
#define ast_json_dump_string(root)
Encode a JSON value to a compact string.
struct ast_json * ast_json_load_string(const char *input, struct ast_json_error *error)
Parse null terminated string into a JSON object or array.
@ AST_JSON_TO_AST_VARS_CODE_SUCCESS
Conversion successful.
enum ast_json_to_ast_vars_code ast_json_to_ast_variables(struct ast_json *json_variables, struct ast_variable **variables)
Convert a ast_json list of key/value pair tuples into a ast_variable list.
Asterisk module definitions.
@ AST_MODFLAG_GLOBAL_SYMBOLS
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODPRI_REALTIME_DRIVER
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
static struct ast_sorcery * sorcery
static struct ast_sorcery_wizard astdb_object_wizard
static void sorcery_astdb_retrieve_multiple(const struct ast_sorcery *sorcery, void *data, const char *type, struct ao2_container *objects, const struct ast_variable *fields)
static void * sorcery_astdb_retrieve_fields(const struct ast_sorcery *sorcery, void *data, const char *type, const struct ast_variable *fields)
static void * sorcery_astdb_retrieve_id(const struct ast_sorcery *sorcery, void *data, const char *type, const char *id)
static int sorcery_astdb_delete(const struct ast_sorcery *sorcery, void *data, void *object)
static int sorcery_astdb_update(const struct ast_sorcery *sorcery, void *data, void *object)
static void sorcery_astdb_retrieve_regex(const struct ast_sorcery *sorcery, void *data, const char *type, struct ao2_container *objects, const char *regex)
static void sorcery_astdb_retrieve_prefix(const struct ast_sorcery *sorcery, void *data, const char *type, struct ao2_container *objects, const char *prefix, const size_t prefix_len)
static struct ast_variable * sorcery_astdb_filter_objectset(struct ast_variable *objectset, const struct ast_sorcery *sorcery, const char *type)
Internal helper function which returns a filtered objectset.
static void sorcery_astdb_close(void *data)
static int load_module(void)
static int sorcery_astdb_create(const struct ast_sorcery *sorcery, void *data, void *object)
static int make_astdb_prefix_pattern(char *tree, const char *regex)
static int unload_module(void)
static void * sorcery_astdb_open(const char *data)
static void * sorcery_astdb_retrieve_fields_common(const struct ast_sorcery *sorcery, void *data, const char *type, const struct ast_variable *fields, struct ao2_container *objects)
Internal helper function which retrieves an object, or multiple objects, using fields for criteria.
Sorcery Data Access Layer API.
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
int ast_sorcery_wizard_unregister(const struct ast_sorcery_wizard *interface)
Unregister a sorcery wizard.
const char * ast_sorcery_object_get_type(const void *object)
Get the type of a sorcery object.
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 ast_sorcery_wizard_register(interface)
See __ast_sorcery_wizard_register()
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.
void * ast_sorcery_alloc(const struct ast_sorcery *sorcery, const char *type, const char *id)
Allocate an object.
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.
struct ast_json * ast_sorcery_objectset_json_create(const struct ast_sorcery *sorcery, const void *object)
Create an object set in JSON format for an object.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
JSON parsing error information.
Abstract JSON element (object, array, string, int, ...).
Structure for registered object type.
char name[MAX_OBJECT_TYPE]
Unique name of the object type.
Interface for a sorcery wizard.
const char * name
Name of the wizard.
Full structure for sorcery.
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
int error(const char *format,...)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.