diff options
author | Sean Bright <sean.bright@gmail.com> | 2017-11-09 09:21:38 -0500 |
---|---|---|
committer | Sean Bright <sean.bright@gmail.com> | 2017-11-13 15:15:33 -0500 |
commit | ffccce76d9c85fb09a28883452cf9df318c3d050 (patch) | |
tree | 21cfa458a58160fc2eb994906d7bdeb4e899bf8b /include/asterisk | |
parent | 9eacd55c7191a460fe8704f81b9e5e3beaf014b9 (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.
Change-Id: I56f4e20ba1154bd52281f995c27a429a854f6a79
Diffstat (limited to 'include/asterisk')
-rw-r--r-- | include/asterisk/sorcery.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/include/asterisk/sorcery.h b/include/asterisk/sorcery.h index bfb2c39ad..bafca5fb6 100644 --- a/include/asterisk/sorcery.h +++ b/include/asterisk/sorcery.h @@ -298,6 +298,14 @@ struct ast_sorcery_wizard { /*! \brief Callback for retrieving multiple objects using a regex on their id */ void (*retrieve_regex)(const struct ast_sorcery *sorcery, void *data, const char *type, struct ao2_container *objects, const char *regex); + /*! \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 Optional callback for retrieving an object using fields */ void *(*retrieve_fields)(const struct ast_sorcery *sorcery, void *data, const char *type, const struct ast_variable *fields); @@ -1241,6 +1249,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 |