aboutsummaryrefslogtreecommitdiffstats
path: root/cli.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-11-06 21:33:01 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-11-06 21:33:01 +0000
commitbf6699ffaa0bd600fc9ec757bb71f95bbdb85ec8 (patch)
treea5f42628f0ff2ce1270ac8d345ee3b0d2dd37d6f /cli.c
parent77e6c046554ed00cf54f9cc6b9f9eaabc756dabe (diff)
Add features (incomplete, highly experimental), fix DundiLookup app, debug improvements (bug #2800)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@4167 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'cli.c')
-rwxr-xr-xcli.c62
1 files changed, 45 insertions, 17 deletions
diff --git a/cli.c b/cli.c
index 23c39b6e6..16a05b082 100755
--- a/cli.c
+++ b/cli.c
@@ -37,6 +37,8 @@
#define VERSION_INFO "Asterisk " ASTERISK_VERSION " built by " BUILD_USER "@" BUILD_HOSTNAME \
" on a " BUILD_MACHINE " running " BUILD_OS
+extern unsigned long global_fin, global_fout;
+
void ast_cli(int fd, char *fmt, ...)
{
char *stuff;
@@ -548,47 +550,73 @@ static int handle_commandcomplete(int fd, int argc, char *argv[])
static int handle_debugchan(int fd, int argc, char *argv[])
{
struct ast_channel *c=NULL;
+ int is_all;
if (argc != 3)
return RESULT_SHOWUSAGE;
+
+ is_all = !strcasecmp("all", argv[2]);
+ if (is_all) {
+ global_fin |= 0x80000000;
+ global_fout |= 0x80000000;
+ }
c = ast_channel_walk_locked(NULL);
while(c) {
- if (!strcasecmp(c->name, argv[2])) {
- c->fin |= 0x80000000;
- c->fout |= 0x80000000;
- break;
+ if (is_all || !strcasecmp(c->name, argv[2])) {
+ if (!(c->fin & 0x80000000) || !(c->fout & 0x80000000)) {
+ c->fin |= 0x80000000;
+ c->fout |= 0x80000000;
+ ast_cli(fd, "Debugging enabled on channel %s\n", c->name);
+ }
+ if (!is_all)
+ break;
}
ast_mutex_unlock(&c->lock);
c = ast_channel_walk_locked(c);
}
- if (c) {
- ast_cli(fd, "Debugging enabled on channel %s\n", c->name);
- ast_mutex_unlock(&c->lock);
+ if (!is_all) {
+ if (c)
+ ast_mutex_unlock(&c->lock);
+ else
+ ast_cli(fd, "No such channel %s\n", argv[2]);
}
else
- ast_cli(fd, "No such channel %s\n", argv[2]);
+ ast_cli(fd, "Debugging on new channels is enabled\n");
return RESULT_SUCCESS;
}
static int handle_nodebugchan(int fd, int argc, char *argv[])
{
struct ast_channel *c=NULL;
+ int is_all;
if (argc != 4)
return RESULT_SHOWUSAGE;
+ is_all = !strcasecmp("all", argv[3]);
+ if (is_all) {
+ global_fin &= ~0x80000000;
+ global_fout &= ~0x80000000;
+ }
c = ast_channel_walk_locked(NULL);
while(c) {
- if (!strcasecmp(c->name, argv[3])) {
- c->fin &= 0x7fffffff;
- c->fout &= 0x7fffffff;
- break;
+ if (is_all || !strcasecmp(c->name, argv[3])) {
+ if ((c->fin & 0x80000000) || (c->fout & 0x80000000)) {
+ c->fin &= 0x7fffffff;
+ c->fout &= 0x7fffffff;
+ ast_cli(fd, "Debugging disabled on channel %s\n", c->name);
+ }
+ if (!is_all)
+ break;
}
ast_mutex_unlock(&c->lock);
c = ast_channel_walk_locked(c);
}
- if (c) {
- ast_cli(fd, "Debugging disabled on channel %s\n", c->name);
- ast_mutex_unlock(&c->lock);
- } else
- ast_cli(fd, "No such channel %s\n", argv[2]);
+ if (!is_all) {
+ if (c)
+ ast_mutex_unlock(&c->lock);
+ else
+ ast_cli(fd, "No such channel %s\n", argv[3]);
+ }
+ else
+ ast_cli(fd, "Debugging on new channels is disabled\n");
return RESULT_SUCCESS;
}