summaryrefslogtreecommitdiff
path: root/cli.c
diff options
context:
space:
mode:
authorAnthony Minessale II <anthmct@yahoo.com>2004-10-22 20:59:38 +0000
committerAnthony Minessale II <anthmct@yahoo.com>2004-10-22 20:59:38 +0000
commit4f2438acab26d73f11acf59f4633aa192b933a47 (patch)
treed1889cfa957277c7fc802e1b4369b6ae7b79a913 /cli.c
parentc4da80e6e0482ac6a7d370df54bc922ee26080aa (diff)
This patch adds a new api call:
int pbx_builtin_serialize_variables(struct ast_channel *chan, char *buf, size_t size); takes a chan and a char * 'buf' assumed to be 'size' bytes. The function fills 'buf' with a <CR>('\n') delimited list of name,value pairs in turn delimeted by '=' eg: SIPCALLID=f30e4e72-f715193f@1.2.3.4 SIPUSERAGENT=Sipura/SPA2000-2.0.6(c) SIPDOMAIN=1.2.3.4 It returns the acutal number of variables encountered. If the attempt to fill 'buf' goes beyond 'size' bytes the operation is halted and the incomplete string is returned as is. To demonstrate a use for this, the "show channel <channame>" command has been retrofitted with the call so it also dumps all of the chan's vars *CLI> show channel Zap/5-1 -- General -- Name: Zap/5-1 Type: Zap UniqueID: 1098480666.17 Caller ID: 4999 Caller ID Name: Tony DNID Digits: (N/A) State: Up (6) Rings: 0 NativeFormat: 68 WriteFormat: 4 ReadFormat: 4 1st File Descriptor: 22 Frames in: 41969 Frames out: 83240 Time to Hangup: 0 Elapsed Time: 0h13m54s -- PBX -- Context: phone1 Extension: 4994 Priority: 2 Call Group: 2 Pickup Group: 2 Application: Dial Data: IAX2/ulaw@cube1/00010014994@croip Stack: 0 Blocking in: ast_waitfor_nandfds Variables: DIALEDPEERNUMBER=ulaw@cube1/00010014994@croip DIALEDPEERNAME=IAX2/cube1/3 CALLTYPE=SPEECH tempvar=tempval git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4051 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'cli.c')
-rwxr-xr-xcli.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/cli.c b/cli.c
index c6be4fefe..23c39b6e6 100755
--- a/cli.c
+++ b/cli.c
@@ -17,6 +17,7 @@
#include <asterisk/options.h>
#include <asterisk/cli.h>
#include <asterisk/module.h>
+#include <asterisk/pbx.h>
#include <asterisk/channel.h>
#include <asterisk/channel_pvt.h>
#include <asterisk/manager.h>
@@ -597,6 +598,7 @@ static int handle_showchan(int fd, int argc, char *argv[])
{
struct ast_channel *c=NULL;
struct timeval now;
+ char buf[1024];
long elapsed_seconds=0;
int hour=0, min=0, sec=0;
if (argc != 3)
@@ -649,6 +651,9 @@ static int handle_showchan(int fd, int argc, char *argv[])
c->context, c->exten, c->priority, c->callgroup, c->pickupgroup, ( c->appl ? c->appl : "(N/A)" ),
( c-> data ? (!ast_strlen_zero(c->data) ? c->data : "(Empty)") : "(None)"),
c->stack, (c->blocking ? c->blockproc : "(Not Blocking)"));
+ if(pbx_builtin_serialize_variables(c,buf,sizeof(buf)))
+ ast_cli(fd,"Variables:\n%s\n",buf);
+
ast_mutex_unlock(&c->lock);
break;
}