aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2008-08-05 16:56:11 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2008-08-05 16:56:11 +0000
commit0891b8a53c15aa09b50404299c22413cbf586943 (patch)
treed6b2d0850bac2afae7026e0560ca97c249f82d66 /include
parent6c7e27ae2521df1506a0774c9b275433580f6c40 (diff)
make datastore creation and destruction a generic API since it is not really channel related, and add the ability to add/find/remove datastores to manager sessions
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@135680 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/channel.h55
-rw-r--r--include/asterisk/datastore.h78
-rw-r--r--include/asterisk/manager.h26
3 files changed, 121 insertions, 38 deletions
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index 5923f7cc1..6166359fa 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -150,8 +150,7 @@ extern "C" {
#include "asterisk/utils.h"
#include "asterisk/linkedlists.h"
#include "asterisk/stringfields.h"
-
-#define DATASTORE_INHERIT_FOREVER INT_MAX
+#include "asterisk/datastore.h"
#define AST_MAX_FDS 10
/*
@@ -186,37 +185,6 @@ struct ast_generator {
void (*digit)(struct ast_channel *chan, char digit);
};
-/*! \brief Structure for a data store type */
-struct ast_datastore_info {
- const char *type; /*!< Type of data store */
- void *(*duplicate)(void *data); /*!< Duplicate item data (used for inheritance) */
- void (*destroy)(void *data); /*!< Destroy function */
- /*!
- * \brief Fix up channel references
- *
- * \arg data The datastore data
- * \arg old_chan The old channel owning the datastore
- * \arg new_chan The new channel owning the datastore
- *
- * This is exactly like the fixup callback of the channel technology interface.
- * It allows a datastore to fix any pointers it saved to the owning channel
- * in case that the owning channel has changed. Generally, this would happen
- * when the datastore is set to be inherited, and a masquerade occurs.
- *
- * \return nothing.
- */
- void (*chan_fixup)(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan);
-};
-
-/*! \brief Structure for a channel data store */
-struct ast_datastore {
- const char *uid; /*!< Unique data store identifier */
- void *data; /*!< Contained data */
- const struct ast_datastore_info *info; /*!< Data store type information */
- unsigned int inheritance; /*!< Number of levels this item will continue to be inherited */
- AST_LIST_ENTRY(ast_datastore) entry; /*!< Used for easy linking */
-};
-
/*! \brief Structure for all kinds of caller ID identifications.
* \note All string fields here are malloc'ed, so they need to be
* freed when the structure is deleted.
@@ -653,16 +621,24 @@ enum channelreloadreason {
};
/*!
- * \brief Create a channel datastore structure
- *
* \note None of the datastore API calls lock the ast_channel they are using.
* So, the channel should be locked before calling the functions that
* take a channel argument.
*/
-struct ast_datastore *ast_channel_datastore_alloc(const struct ast_datastore_info *info, const char *uid);
-/*! \brief Free a channel datastore structure */
-int ast_channel_datastore_free(struct ast_datastore *datastore);
+/*!
+ * \brief Create a channel data store object
+ * \deprecated You should use the ast_datastore_alloc() generic function instead.
+ */
+struct ast_datastore *ast_channel_datastore_alloc(const struct ast_datastore_info *info, const char *uid)
+ __attribute__ ((deprecated));
+
+/*!
+ * \brief Free a channel data store object
+ * \deprecated You should use the ast_datastore_free() generic function instead.
+ */
+int ast_channel_datastore_free(struct ast_datastore *datastore)
+ __attribute__ ((deprecated));
/*! \brief Inherit datastores from a parent to a child. */
int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to);
@@ -695,6 +671,9 @@ int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore
*
* \note The datastore returned from this function must not be used if the
* reference to the channel is released.
+ *
+ * \retval pointer to the datastore if found
+ * \retval NULL if not found
*/
struct ast_datastore *ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid);
diff --git a/include/asterisk/datastore.h b/include/asterisk/datastore.h
new file mode 100644
index 000000000..fe1ff8462
--- /dev/null
+++ b/include/asterisk/datastore.h
@@ -0,0 +1,78 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2007 - 2008, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ * \brief Asterisk datastore objects
+ */
+
+#ifndef _ASTERISK_DATASTORE_H
+#define _ASTERISK_DATASTORE_H
+
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
+#include "asterisk/linkedlists.h"
+
+#define DATASTORE_INHERIT_FOREVER INT_MAX
+
+/*! \brief Structure for a data store type */
+struct ast_datastore_info {
+ const char *type; /*!< Type of data store */
+ void *(*duplicate)(void *data); /*!< Duplicate item data (used for inheritance) */
+ void (*destroy)(void *data); /*!< Destroy function */
+
+ /*!
+ * \brief Fix up channel references
+ *
+ * \arg data The datastore data
+ * \arg old_chan The old channel owning the datastore
+ * \arg new_chan The new channel owning the datastore
+ *
+ * This is exactly like the fixup callback of the channel technology interface.
+ * It allows a datastore to fix any pointers it saved to the owning channel
+ * in case that the owning channel has changed. Generally, this would happen
+ * when the datastore is set to be inherited, and a masquerade occurs.
+ *
+ * \return nothing.
+ */
+ void (*chan_fixup)(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan);
+};
+
+/*! \brief Structure for a data store object */
+struct ast_datastore {
+ const char *uid; /*!< Unique data store identifier */
+ void *data; /*!< Contained data */
+ const struct ast_datastore_info *info; /*!< Data store type information */
+ unsigned int inheritance; /*!< Number of levels this item will continue to be inherited */
+ AST_LIST_ENTRY(ast_datastore) entry; /*!< Used for easy linking */
+};
+
+/*!
+ * \brief Create a data store object
+ */
+struct ast_datastore *ast_datastore_alloc(const struct ast_datastore_info *info, const char *uid);
+
+/*!
+ * \brief Free a data store object
+ */
+int ast_datastore_free(struct ast_datastore *datastore);
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
+
+#endif /* _ASTERISK_DATASTORE_H */
diff --git a/include/asterisk/manager.h b/include/asterisk/manager.h
index ecc047829..fa1d27292 100644
--- a/include/asterisk/manager.h
+++ b/include/asterisk/manager.h
@@ -21,6 +21,7 @@
#include "asterisk/network.h"
#include "asterisk/lock.h"
+#include "asterisk/datastore.h"
/*!
\file
@@ -212,4 +213,29 @@ int init_manager(void);
/*! \brief Called by Asterisk module functions and the CLI command */
int reload_manager(void);
+/*!
+ * \brief Add a datastore to a session
+ *
+ * \retval 0 success
+ * \retval non-zero failure
+ */
+
+int astman_datastore_add(struct mansession *s, struct ast_datastore *datastore);
+
+/*!
+ * \brief Remove a datastore from a session
+ *
+ * \retval 0 success
+ * \retval non-zero failure
+ */
+int astman_datastore_remove(struct mansession *s, struct ast_datastore *datastore);
+
+/*!
+ * \brief Find a datastore on a session
+ *
+ * \retval pointer to the datastore if found
+ * \retval NULL if not found
+ */
+struct ast_datastore *astman_datastore_find(struct mansession *s, const struct ast_datastore_info *info, const char *uid);
+
#endif /* _ASTERISK_MANAGER_H */