Merge "main/bucket: Add a callback function for ast_bucket_file objects"

This commit is contained in:
Matt Jordan
2015-07-14 09:31:11 -05:00
committed by Gerrit Code Review
2 changed files with 17 additions and 0 deletions

View File

@@ -194,6 +194,17 @@ int ast_bucket_file_metadata_unset(struct ast_bucket_file *file, const char *nam
*/ */
struct ast_bucket_metadata *ast_bucket_file_metadata_get(struct ast_bucket_file *file, const char *name); struct ast_bucket_metadata *ast_bucket_file_metadata_get(struct ast_bucket_file *file, const char *name);
/*!
* \brief Execute a callback function on the metadata associated with a file
* \since 14.0.0
*
* \param file The bucket file
* \param cb An ao2 callback function that will be called with each \c ast_bucket_metadata
* associated with \c file
* \param arg An optional argument to pass to \c cb
*/
void ast_bucket_file_metadata_callback(struct ast_bucket_file *file, ao2_callback_fn cb, void *arg);
/*! /*!
* \brief Allocate a new bucket * \brief Allocate a new bucket
* *

View File

@@ -362,6 +362,12 @@ struct ast_bucket_metadata *ast_bucket_file_metadata_get(struct ast_bucket_file
return ao2_find(file->metadata, name, OBJ_KEY); return ao2_find(file->metadata, name, OBJ_KEY);
} }
void ast_bucket_file_metadata_callback(struct ast_bucket_file *file, ao2_callback_fn cb, void *arg)
{
ao2_callback(file->metadata, 0, cb, arg);
}
/*! \brief Destructor for buckets */ /*! \brief Destructor for buckets */
static void bucket_destroy(void *obj) static void bucket_destroy(void *obj)
{ {