[asterisk-commits] file: branch file/astdb-sqlite3 r75399 - in /team/file/astdb-sqlite3: include...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jul 17 13:12:30 CDT 2007


Author: file
Date: Tue Jul 17 13:12:30 2007
New Revision: 75399

URL: http://svn.digium.com/view/asterisk?view=rev&rev=75399
Log:
Doxygenify the astdb API and add two API calls to request and release a database handle for those folks who want to use the sqlite3 API directly on the database and make their own tables.

Modified:
    team/file/astdb-sqlite3/include/asterisk/astdb.h
    team/file/astdb-sqlite3/main/db.c

Modified: team/file/astdb-sqlite3/include/asterisk/astdb.h
URL: http://svn.digium.com/view/asterisk/team/file/astdb-sqlite3/include/asterisk/astdb.h?view=diff&rev=75399&r1=75398&r2=75399
==============================================================================
--- team/file/astdb-sqlite3/include/asterisk/astdb.h (original)
+++ team/file/astdb-sqlite3/include/asterisk/astdb.h Tue Jul 17 13:12:30 2007
@@ -34,19 +34,75 @@
 	AST_LIST_ENTRY(ast_db_entry) list;
 };
 
+/*!
+ * \brief Retrieves the value of a database entry
+ * \param family Family entry belongs to
+ * \param key Entry key
+ * \param out Buffer to put value in
+ * \param outlen Maximum length of buffer
+ * \return Returns 0 on success, -1 on failure
+ */
 int ast_db_get(const char *family, const char *key, char *out, int outlen);
 
+/*!
+ * \brief Inserts entry into database
+ * \param family Family entry belongs to
+ * \param key Entry key
+ * \param value Value of entry
+ * \return Returns 0 on success, -1 on failure
+ */
 int ast_db_put(const char *family, const char *key, const char *value);
 
+/*!
+ * \brief Updates entry in database
+ * \param family Family entry belongs to
+ * \param key Entry key
+ * \param value New value
+ * \return Returns 0 on success, -1 on failure
+ */
 int ast_db_update(const char *family, const char *key, const char *value);
 
+/*!
+ * \brief Deletes entry in database
+ * \param family Family entry belongs to
+ * \param key Entry key
+ * \return Returns 0 on success, -1 on failure
+ */
 int ast_db_del(const char *family, const char *key);
 
+/*!
+ * \brief Deletes entries belong to a specific family and starting with a specific key name
+ * \param family Family entry belongs to
+ * \param keytree Beginning of key
+ * \return Returns 0 on success, -1 on failure
+ */
 int ast_db_deltree(const char *family, const char *keytree);
 
+/*!
+ * \brief Retrieves a list of database entries
+ * \param family Family entries belong to
+ * \param keytree Beginning of key
+ * \return Returns list on success, NULL on failure
+ */
 struct ast_db_entry *ast_db_gettree(const char *family, const char *keytree);
 
+/*!
+ * \brief Frees list of database tree entries
+ * \param entry First entry in list
+ */
 void ast_db_freetree(struct ast_db_entry *entry);
+
+/*!
+ * \brief Return open database handle for direct access
+ * \return Returns handle on success, NULL on failure
+ */
+void *ast_db_handle(void);
+
+/*!
+ * \brief Release database handle
+ * \param db Database handle
+ */
+void ast_db_release(void *db);
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }

Modified: team/file/astdb-sqlite3/main/db.c
URL: http://svn.digium.com/view/asterisk/team/file/astdb-sqlite3/main/db.c?view=diff&rev=75399&r1=75398&r2=75399
==============================================================================
--- team/file/astdb-sqlite3/main/db.c (original)
+++ team/file/astdb-sqlite3/main/db.c Tue Jul 17 13:12:30 2007
@@ -240,6 +240,24 @@
 	return 0;
 }
 
+void *ast_db_handle(void)
+{
+	ast_mutex_lock(&dblock);
+
+	if (!db && dbinit()) {
+		ast_mutex_unlock(&dblock);
+		return NULL;
+	}
+
+	return db;
+}
+
+void ast_db_release(void *db)
+{
+	ast_mutex_unlock(&dblock);
+	return;
+}
+
 static int database_put(int fd, int argc, char *argv[])
 {
 	int res;




More information about the asterisk-commits mailing list