[Asterisk-code-review] main/bucket: Add a callback function for ast bucket file obj... (asterisk[master])
Matt Jordan
asteriskteam at digium.com
Tue Jul 14 09:31:12 CDT 2015
Matt Jordan has submitted this change and it was merged.
Change subject: main/bucket: Add a callback function for ast_bucket_file objects
......................................................................
main/bucket: Add a callback function for ast_bucket_file objects
This patch adds a new function to the bucket API for ast_bucket_file
objects, ast_bucket_file_metadata_callback. It will call ao2_callback on
the ast_bucket_file's ao2_container of metadata, calling the provided
ao2_callback_fn callback on each piece of metadata associated with the
file.
This is particularly useful when a bucket backend has added metadata,
and a higher level API wants to be aware of/access said metadata,
without knowing for sure what the key is.
Change-Id: I96f6757717f47b650df91a437f7df16406227466
---
M include/asterisk/bucket.h
M main/bucket.c
2 files changed, 17 insertions(+), 0 deletions(-)
Approvals:
Anonymous Coward #1000019: Verified
Matt Jordan: Looks good to me, approved
Joshua Colp: Looks good to me, but someone else must approve
diff --git a/include/asterisk/bucket.h b/include/asterisk/bucket.h
index c335fd3..4a27c3c 100644
--- a/include/asterisk/bucket.h
+++ b/include/asterisk/bucket.h
@@ -195,6 +195,17 @@
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
*
* \param uri Complete URI for the bucket
diff --git a/main/bucket.c b/main/bucket.c
index afb0175..f7845c8 100644
--- a/main/bucket.c
+++ b/main/bucket.c
@@ -362,6 +362,12 @@
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 */
static void bucket_destroy(void *obj)
{
--
To view, visit https://gerrit.asterisk.org/879
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I96f6757717f47b650df91a437f7df16406227466
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>
More information about the asterisk-code-review
mailing list