00001 /* 00002 * Asterisk -- An open source telephony toolkit. 00003 * 00004 * Copyright (C) 2007 - 2008, Digium, Inc. 00005 * 00006 * See http://www.asterisk.org for more information about 00007 * the Asterisk project. Please do not directly contact 00008 * any of the maintainers of this project for assistance; 00009 * the project provides a web site, mailing lists and IRC 00010 * channels for your use. 00011 * 00012 * This program is free software, distributed under the terms of 00013 * the GNU General Public License Version 2. See the LICENSE file 00014 * at the top of the source tree. 00015 */ 00016 00017 /*! \file 00018 * \brief Asterisk datastore objects 00019 */ 00020 00021 #ifndef _ASTERISK_DATASTORE_H 00022 #define _ASTERISK_DATASTORE_H 00023 00024 #if defined(__cplusplus) || defined(c_plusplus) 00025 extern "C" { 00026 #endif 00027 00028 #include "asterisk/linkedlists.h" 00029 00030 /*! \brief Structure for a data store type */ 00031 struct ast_datastore_info { 00032 const char *type; /*!< Type of data store */ 00033 void *(*duplicate)(void *data); /*!< Duplicate item data (used for inheritance) */ 00034 void (*destroy)(void *data); /*!< Destroy function */ 00035 00036 /*! 00037 * \brief Fix up channel references 00038 * 00039 * \arg data The datastore data 00040 * \arg old_chan The old channel owning the datastore 00041 * \arg new_chan The new channel owning the datastore 00042 * 00043 * This is exactly like the fixup callback of the channel technology interface. 00044 * It allows a datastore to fix any pointers it saved to the owning channel 00045 * in case that the owning channel has changed. Generally, this would happen 00046 * when the datastore is set to be inherited, and a masquerade occurs. 00047 * 00048 * \return nothing. 00049 */ 00050 void (*chan_fixup)(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan); 00051 }; 00052 00053 /*! \brief Structure for a data store object */ 00054 struct ast_datastore { 00055 const char *uid; /*!< Unique data store identifier */ 00056 void *data; /*!< Contained data */ 00057 const struct ast_datastore_info *info; /*!< Data store type information */ 00058 unsigned int inheritance; /*!< Number of levels this item will continue to be inherited */ 00059 AST_LIST_ENTRY(ast_datastore) entry; /*!< Used for easy linking */ 00060 }; 00061 00062 /*! 00063 * \brief Create a data store object 00064 * \param[in] info information describing the data store object 00065 * \param[in] uid unique identifer 00066 * \version 1.6.1 moved here and renamed from ast_channel_datastore_alloc 00067 */ 00068 struct ast_datastore *ast_datastore_alloc(const struct ast_datastore_info *info, const char *uid); 00069 00070 /*! 00071 * \brief Free a data store object 00072 * \param[in] datastore datastore to free 00073 * \version 1.6.1 moved here and renamed from ast_channel_datastore_free 00074 */ 00075 int ast_datastore_free(struct ast_datastore *datastore); 00076 00077 #if defined(__cplusplus) || defined(c_plusplus) 00078 } 00079 #endif 00080 00081 #endif /* _ASTERISK_DATASTORE_H */