summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJenkins2 <jenkins2@gerrit.asterisk.org>2017-11-16 10:50:17 -0600
committerGerrit Code Review <gerrit2@gerrit.digium.api>2017-11-16 10:50:17 -0600
commit595735200c167a1ce9373b1147979fabffd642d2 (patch)
tree75009dc63809f46e700a0c46c4adb825150abf1b /include
parent4960fc1e6975b29b9b7a598170f1f8f89ad21ae4 (diff)
parent2e01b779cc18c1f0f66c28db775e1e6b1d5065e4 (diff)
Merge "sorcery: Add ast_sorcery_retrieve_by_prefix()" into 15
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/sorcery.h37
1 files changed, 36 insertions, 1 deletions
diff --git a/include/asterisk/sorcery.h b/include/asterisk/sorcery.h
index 896633816..fcc8a542e 100644
--- a/include/asterisk/sorcery.h
+++ b/include/asterisk/sorcery.h
@@ -315,6 +315,14 @@ struct ast_sorcery_wizard {
/* \brief Callback for whether or not the wizard believes the object is stale */
int (*is_stale)(const struct ast_sorcery *sorcery, void *data, void *object);
+
+ /*! \brief Optional callback for retrieving multiple objects by matching their id with a prefix */
+ void (*retrieve_prefix)(const struct ast_sorcery *sorcery,
+ void *data,
+ const char *type,
+ struct ao2_container *objects,
+ const char *prefix,
+ const size_t prefix_len);
};
/*! \brief Interface for a sorcery object type observer */
@@ -367,9 +375,20 @@ int ast_sorcery_init(void);
int __ast_sorcery_wizard_register(const struct ast_sorcery_wizard *interface, struct ast_module *module);
/*!
+ * \brief Register a sorcery wizard
+ *
+ * \param interface Pointer to a wizard interface
+ * \param module Pointer to the module implementing the interface
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ */
+int __ast_sorcery_wizard_register_with_prefix(const struct ast_sorcery_wizard *interface, struct ast_module *module);
+
+/*!
* \brief See \ref __ast_sorcery_wizard_register()
*/
-#define ast_sorcery_wizard_register(interface) __ast_sorcery_wizard_register(interface, AST_MODULE_SELF)
+#define ast_sorcery_wizard_register(interface) __ast_sorcery_wizard_register_with_prefix(interface, ast_module_info ? ast_module_info->self : NULL)
/*!
* \brief Unregister a sorcery wizard
@@ -1241,6 +1260,22 @@ void *ast_sorcery_retrieve_by_fields(const struct ast_sorcery *sorcery, const ch
struct ao2_container *ast_sorcery_retrieve_by_regex(const struct ast_sorcery *sorcery, const char *type, const char *regex);
/*!
+ * \brief Retrieve multiple objects whose id begins with the specified prefix
+ * \since 13.19.0
+ *
+ * \param sorcery Pointer to a sorcery structure
+ * \param type Type of object to retrieve
+ * \param prefix Object id prefix
+ * \param prefix_len The length of prefix in bytes
+ *
+ * \retval non-NULL if error occurs
+ * \retval NULL success
+ *
+ * \note The prefix is matched in a case sensitive manner.
+ */
+struct ao2_container *ast_sorcery_retrieve_by_prefix(const struct ast_sorcery *sorcery, const char *type, const char *prefix, const size_t prefix_len);
+
+/*!
* \brief Update an object
*
* \param sorcery Pointer to a sorcery structure