[asterisk-commits] eliel: branch group/data_api_gsoc2009 r200143 - in /team/group/data_api_gsoc2...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jun 11 12:45:34 CDT 2009
Author: eliel
Date: Thu Jun 11 12:45:31 2009
New Revision: 200143
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=200143
Log:
Address Tilghman's comments on review board.
Modified:
team/group/data_api_gsoc2009/include/asterisk/data.h
team/group/data_api_gsoc2009/main/data.c
Modified: team/group/data_api_gsoc2009/include/asterisk/data.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/data_api_gsoc2009/include/asterisk/data.h?view=diff&rev=200143&r1=200142&r2=200143
==============================================================================
--- team/group/data_api_gsoc2009/include/asterisk/data.h (original)
+++ team/group/data_api_gsoc2009/include/asterisk/data.h Thu Jun 11 12:45:31 2009
@@ -35,7 +35,7 @@
* To register a callback use:
*
* \code
- * ast_data_register("/node/path", callback_fn);
+ * ast_data_register("/node/path", &callback_fn);
* \endcode
*
* If you instead want to register multiple nodes at once use:
@@ -53,12 +53,12 @@
* };
*
* ...
- *
+ *
* ast_data_register_multiple(list_providers, ARRAY_LEN(list_providers));
* \endcode
*
* To unregister a callback function already registered you can just call:
- *
+ *
* \code
* ast_data_unregister(NULL);
* \endcode
@@ -75,16 +75,22 @@
extern "C" {
#endif
-/*! \brief opaque definition of an ast_data handler. */
+/*! \brief opaque definition of an ast_data handler, a tree node. */
struct ast_data;
typedef struct ast_data *(*ast_data_get_cb)(void);
-typedef struct ast_data *(*ast_data_put_cb)(void);
+typedef int *(*ast_data_put_cb)(void);
+typedef char **(*ast_data_tokenizer)(void);
/*! \brief The structure of the node handler. */
struct ast_data_handler {
+ /*! \brief Data get callback implementation. */
ast_data_get_cb get;
+ /*! \brief Data put callback implementation. */
ast_data_put_cb put;
+ /*! \brief The tokenizer is used to retrieve from the node generator
+ * the list of possible attributes in the search string. */
+ ast_data_tokenizer tokenizer;
};
/*! \brief This entries are for multiple registers. */
@@ -96,6 +102,25 @@
};
#define AST_DATA_ENTRY(__path, __handler) { .path = __path, .handler = __handler }
+
+/*! \brief Specifies the user information to be passed to the
+ * data API.
+ */
+struct ast_data_security_user {
+ AST_DECLARE_STRING_FIELDS(
+ AST_STRING_FIELD(username);
+ AST_STRING_FIELD(groupname);
+ );
+};
+
+/*! \brief Specifies the district information to be passed to the
+ * data API.
+ */
+struct ast_data_security_district {
+ AST_DECLARE_STRING_FIELDS(
+ AST_STRING_FIELD(district);
+ );
+};
/*! \brief A query to the data API is specified in this structure. */
struct ast_data_query {
@@ -109,16 +134,20 @@
* Setting it to NULL will return every internal node. */
AST_STRING_FIELD(filter);
);
- /* XXX: Complete with security related stuff. */
+
+ /*! \brief user information trying to access the tree. */
+ struct ast_data_security_user *secuser;
+ /*! \brief district trying to access the tree. */
+ struct ast_data_security_district *secdistrict;
};
/*!
* \brief Register a data provider.
* \param[in] path The path of the node to register.
- * \param[in] handler The structure defining this node handler.
+ * \param[in] handler The structure defining this node handler.
* \param[in] registrar Who is registering this node.
* \see ast_data_unregister
- * \retval < 0 on error.
+ * \retval <0 on error.
* \retval 0 on success.
* \see __ast_data_unregister, __ast_data_register_multiple
*/
@@ -130,7 +159,7 @@
* \param[in] data_entries An array of data_entries structures.
* \param[in] entries The number of entries in the data_entries array.
* \param[in] registrar Who is registering this nodes.
- * \retval < 0 on error (none of the nodes are being registered on error).
+ * \retval <0 on error (none of the nodes are being registered on error).
* \retval 0 on success.
* \see __ast_data_register, __ast_data_unregister
*/
@@ -144,7 +173,7 @@
* \param[in] registrar Who is trying to unregister this node, only the owner (the one who registered
* the node) will be able to unregister it.
* \see ast_data_register
- * \retval < 0 on error.
+ * \retval <0 on error.
* \retval 0 on success.
* \see __ast_data_register, __ast_data_register_multiple
*/
@@ -175,14 +204,14 @@
* \retval NULL on error.
* \retval A dinamically allocated iterator structure.
*/
-struct ast_data_iterator *ast_data_iterator_start(struct ast_data *tree, const char *elements);
+struct ast_data_iterator *ast_data_iterator_init(struct ast_data *tree, const char *elements);
/*!
* \brief Release (stop using) an iterator.
* \param[in] iterator The iterator created by ast_data_iterator_start.
* \see ast_data_iterator_start
*/
-struct ast_data *ast_data_iterator_stop(struct ast_data_iterator *iterator);
+struct ast_data *ast_data_iterator_end(struct ast_data_iterator *iterator);
/*!
* \brief Get the next node of the tree.
@@ -199,7 +228,7 @@
* \param[in] path The path to the node.
* \param[out] value The node content.
* \retval 0 on success.
- * \retval < 0 on error.
+ * \retval <0 on error.
*/
int ast_data_retrieve_int(struct ast_data *tree, const char *path, const int *value);
@@ -209,7 +238,7 @@
* \param[in] path The path to the string node.
* \param[out] value The node content.
* \retval 0 on success.
- * \retval < 0 on error.
+ * \retval <0 on error.
*/
int ast_data_retrieve_str(struct ast_data *tree, const char *path, const struct ast_str **value);
@@ -219,7 +248,7 @@
* \param[in] path The path to the string node.
* \param[out] value The node content.
* \retval 0 on success.
- * \retval < 0 on error.
+ * \retval <0 on error.
*/
int ast_data_retrieve_char(struct ast_data *tree, const char *path, const char **value);
@@ -229,7 +258,7 @@
* \param[in] path The path to the boolean node.
* \param[out] value The node content.
* \retval 0 on success.
- * \retval < 0 on error.
+ * \retval <0 on error.
*/
int ast_data_retrieve_bool(struct ast_data *tree, const char *path, const char *value);
Modified: team/group/data_api_gsoc2009/main/data.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/data_api_gsoc2009/main/data.c?view=diff&rev=200143&r1=200142&r2=200143
==============================================================================
--- team/group/data_api_gsoc2009/main/data.c (original)
+++ team/group/data_api_gsoc2009/main/data.c Thu Jun 11 12:45:31 2009
@@ -84,7 +84,7 @@
* \brief Lock the data registered handlers structure for writing.
* \see data_unlock
*/
-static void data_write_lock(void)
+static inline void data_write_lock(void)
{
ast_rwlock_wrlock(&root_data_lock);
}
@@ -95,7 +95,7 @@
* \see data_unlock
*/
/* XXX: avoid defining functions that at the moment are not being used.
-static void data_read_lock(void)
+static inline void data_read_lock(void)
{
ast_rwlock_rdlock(&root_data_lock);
}
@@ -105,7 +105,7 @@
* \internal
* \brief Unlock the data registered handlers structure.
*/
-static void data_unlock(void)
+static inline void data_unlock(void)
{
ast_rwlock_unlock(&root_data_lock);
}
@@ -132,7 +132,7 @@
/*!
* \internal
* \brief Create a new data node.
- * \param[in] name The name of the node we are going to create.
+ * \param[in] name The name of the node we are going to create.
* \param[in] handler The handler registered for this node.
* \param[in] registrar The name of the registrar.
* \retval NULL on error.
@@ -233,7 +233,7 @@
* \param[in] parent The parent node.
* \param[in] path The path of nodes to release.
* \param[in] registrar Who registered this node.
- * \retval < 0 on error.
+ * \retval <0 on error.
* \retval 0 on success.
* \see data_node_provider_create
*/
More information about the asterisk-commits
mailing list