summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSean Bright <sean.bright@gmail.com>2017-11-09 09:21:38 -0500
committerSean Bright <sean.bright@gmail.com>2017-11-13 15:08:50 -0500
commitcf062303e35e4baa0dc2aa3dfb68b2c25b1ed2c2 (patch)
treeef53d0517a09247cd97c4d9ee70c294a5a607ae8 /include
parentb1743cb3c75a943a8a9cb55a3e4355f0133156fe (diff)
sorcery: Add ast_sorcery_retrieve_by_prefix()
Some consumers of the sorcery API use ast_sorcery_retrieve_by_regex only so that they can anchor the potential match as a prefix and not because they truly need regular expressions. Rather than using regular expressions for simple prefix lookups, add a new operation - ast_sorcery_retrieve_by_prefix - that does them. Patches against 13 and 15 have a compatibility layer needed to maintain ABI that is not needed in master. Change-Id: I56f4e20ba1154bd52281f995c27a429a854f6a79
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 0cb434766..73ed06078 100644
--- a/include/asterisk/sorcery.h
+++ b/include/asterisk/sorcery.h
@@ -312,6 +312,14 @@ struct ast_sorcery_wizard {
/*! \brief Callback for closing a wizard */
void (*close)(void *data);
+
+ /*! \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 */
@@ -364,9 +372,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_info ? ast_module_info->self : NULL)
+#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
@@ -1218,6 +1237,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