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
This commit is contained in:
Jason Parker 2007-09-10 17:39:08 +00:00
parent c4133cc03f
commit 10f28b2d79
1 changed files with 6 additions and 4 deletions

View File

@ -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");