summaryrefslogtreecommitdiff
path: root/main/db.c
diff options
context:
space:
mode:
authorJason Parker <jparker@digium.com>2007-09-10 17:39:08 +0000
committerJason Parker <jparker@digium.com>2007-09-10 17:39:08 +0000
commit10f28b2d798c0e9c1dc6c4502f51504c2a973a5b (patch)
tree7bea51d8cd185e0037ec75cc305c830ef07b8366 /main/db.c
parentc4133cc03fe3fd5a47b196ef0e6d27ac0a14589c (diff)
Add a counter to the 'database deltree' CLI command.
Note: this is slightly different than the initial patch, because I felt that using res <= 0 would be a change in behavior. Closes issue #10687, patch by junky git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@82154 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/db.c')
-rw-r--r--main/db.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/main/db.c b/main/db.c
index 292e7af86..f0ad5eaa7 100644
--- a/main/db.c
+++ b/main/db.c
@@ -104,6 +104,7 @@ int ast_db_deltree(const char *family, const char *keytree)
char *keys;
int res;
int pass;
+ int counter = 0;
if (family) {
if (keytree) {
@@ -135,11 +136,12 @@ int ast_db_deltree(const char *family, const char *keytree)
}
if (keymatch(keys, prefix)) {
astdb->del(astdb, &key, 0);
+ counter++;
}
}
astdb->sync(astdb, 0);
ast_mutex_unlock(&dblock);
- return 0;
+ return counter;
}
int ast_db_put(const char *family, const char *keys, const char *value)
@@ -291,10 +293,10 @@ static int database_deltree(int fd, int argc, char *argv[])
} else {
res = ast_db_deltree(argv[2], NULL);
}
- if (res) {
+ if (res < 0) {
ast_cli(fd, "Database entries do not exist.\n");
} else {
- ast_cli(fd, "Database entries removed.\n");
+ ast_cli(fd, "%d database entries removed.\n",res);
}
return RESULT_SUCCESS;
}
@@ -629,7 +631,7 @@ static int manager_dbdeltree(struct mansession *s, const struct message *m)
else
res = ast_db_deltree(family, NULL);
- if (res)
+ if (res < 0)
astman_send_error(s, m, "Database entry not found");
else
astman_send_ack(s, m, "Key tree deleted successfully");