astdb.h

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 1999 - 2005, Digium, Inc.
00005  *
00006  * Mark Spencer <markster@digium.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*!
00020  * \file
00021  * \brief Persistant data storage (akin to *doze registry)
00022  */
00023 
00024 #ifndef _ASTERISK_ASTDB_H
00025 #define _ASTERISK_ASTDB_H
00026 
00027 #if defined(__cplusplus) || defined(c_plusplus)
00028 extern "C" {
00029 #endif
00030 
00031 struct ast_db_entry {
00032    struct ast_db_entry *next;
00033    char *key;
00034    char data[0];
00035 };
00036 
00037 /*! \brief Get key value specified by family/key */
00038 int ast_db_get(const char *family, const char *key, char *value, int valuelen);
00039 
00040 /*!
00041  * \brief Get key value specified by family/key as a heap allocated string.
00042  *
00043  * \details
00044  * Given a \a family and \a key, sets \a out to a pointer to a heap
00045  * allocated string.  In the event of an error, \a out will be set to
00046  * NULL.  The string must be freed by calling ast_free().
00047  *
00048  * \retval -1 An error occurred
00049  * \retval 0 Success
00050  */
00051 int ast_db_get_allocated(const char *family, const char *key, char **out);
00052 
00053 /*! \brief Store value addressed by family/key */
00054 int ast_db_put(const char *family, const char *key, const char *value);
00055 
00056 /*! \brief Delete entry in astdb */
00057 int ast_db_del(const char *family, const char *key);
00058 
00059 /*!
00060  * \brief Delete one or more entries in astdb
00061  *
00062  * \details
00063  * If both parameters are NULL, the entire database will be purged.  If
00064  * only keytree is NULL, all entries within the family will be purged.
00065  * It is an error for keytree to have a value when family is NULL.
00066  *
00067  * \retval -1 An error occurred
00068  * \retval >= 0 Number of records deleted
00069  */
00070 int ast_db_deltree(const char *family, const char *keytree);
00071 
00072 /*!
00073  * \brief Get a list of values within the astdb tree
00074  *
00075  * \details
00076  * If family is specified, only those keys will be returned.  If keytree
00077  * is specified, subkeys are expected to exist (separated from the key with
00078  * a slash).  If subkeys do not exist and keytree is specified, the tree will
00079  * consist of either a single entry or NULL will be returned.
00080  *
00081  * Resulting tree should be freed by passing the return value to ast_db_freetree()
00082  * when usage is concluded.
00083  */
00084 struct ast_db_entry *ast_db_gettree(const char *family, const char *keytree);
00085 
00086 /*! \brief Free structure created by ast_db_gettree() */
00087 void ast_db_freetree(struct ast_db_entry *entry);
00088 
00089 #if defined(__cplusplus) || defined(c_plusplus)
00090 }
00091 #endif
00092 
00093 #endif /* _ASTERISK_ASTDB_H */

Generated on Thu Apr 16 06:27:14 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6