[asterisk-commits] file: trunk r52308 - in /trunk: CHANGES main/db.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Jan 25 15:49:24 MST 2007


Author: file
Date: Thu Jan 25 16:49:24 2007
New Revision: 52308

URL: http://svn.digium.com/view/asterisk?view=rev&rev=52308
Log:
Add DBDel and DBDelTree manager commands. (issue #8516 reported by dprado)

Modified:
    trunk/CHANGES
    trunk/main/db.c

Modified: trunk/CHANGES
URL: http://svn.digium.com/view/asterisk/trunk/CHANGES?view=diff&rev=52308&r1=52307&r2=52308
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Thu Jan 25 16:49:24 2007
@@ -66,6 +66,7 @@
   * Added 's' option to Page application.
   * Added the srvlookup option to iax.conf
   * Added 'E' and 'V' commands to ExternalIVR.
+  * Added 'DBDel' and 'DBDelTree' manager commands.
 
 SIP changes
 -----------

Modified: trunk/main/db.c
URL: http://svn.digium.com/view/asterisk/trunk/main/db.c?view=diff&rev=52308&r1=52307&r2=52308
==============================================================================
--- trunk/main/db.c (original)
+++ trunk/main/db.c Thu Jan 25 16:49:24 2007
@@ -588,11 +588,62 @@
 	return 0;
 }
 
+static int manager_dbdel(struct mansession *s, const struct message *m)
+{
+	const char *family = astman_get_header(m, "Family");
+	const char *key = astman_get_header(m, "Key");
+	int res;
+
+	if (ast_strlen_zero(family)) {
+		astman_send_error(s, m, "No family specified.");
+		return 0;
+	}
+
+	if (ast_strlen_zero(key)) {
+		astman_send_error(s, m, "No key specified.");
+		return 0;
+	}
+
+	res = ast_db_del(family, key);
+	if (res)
+		astman_send_error(s, m, "Database entry not found");
+	else
+		astman_send_ack(s, m, "Key deleted successfully");
+
+	return 0;
+}
+
+static int manager_dbdeltree(struct mansession *s, const struct message *m)
+{
+	const char *family = astman_get_header(m, "Family");
+	const char *key = astman_get_header(m, "Key");
+	int res;
+
+	if (ast_strlen_zero(family)) {
+		astman_send_error(s, m, "No family specified.");
+		return 0;
+	}
+
+	if (!ast_strlen_zero(key))
+		res = ast_db_deltree(family, key);
+	else
+		res = ast_db_deltree(family, NULL);
+
+	if (res)
+		astman_send_error(s, m, "Database entry not found");
+	else
+		astman_send_ack(s, m, "Key tree deleted successfully");
+	
+	return 0;
+}
+
 int astdb_init(void)
 {
 	dbinit();
 	ast_cli_register_multiple(cli_database, sizeof(cli_database) / sizeof(struct ast_cli_entry));
 	ast_manager_register("DBGet", EVENT_FLAG_SYSTEM, manager_dbget, "Get DB Entry");
 	ast_manager_register("DBPut", EVENT_FLAG_SYSTEM, manager_dbput, "Put DB Entry");
-	return 0;
-}
+	ast_manager_register("DBDel", EVENT_FLAG_SYSTEM, manager_dbdel, "Delete DB Entry");
+	ast_manager_register("DBDelTree", EVENT_FLAG_SYSTEM, manager_dbdeltree, "Delete DB Tree");
+	return 0;
+}



More information about the asterisk-commits mailing list