Fri Jul 24 00:41:08 2009

Asterisk developer's documentation


app_dumpchan.c File Reference

Application to dump channel variables. More...

#include "asterisk.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/channel.h"

Go to the source code of this file.

Functions

static void __reg_module (void)
static void __unreg_module (void)
static int dumpchan_exec (struct ast_channel *chan, void *data)
static int load_module (void)
static int serialize_showchan (struct ast_channel *c, char *buf, size_t size)
static int unload_module (void)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Dump Info About The Calling Channel" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "a9c98e5d177805051735cb5b0b16b0a0" , .load = load_module, .unload = unload_module, }
static char * app = "DumpChan"
static struct ast_module_infoast_module_info = &__mod_info
static char * desc
static char * synopsis = "Dump Info About The Calling Channel"


Detailed Description

Application to dump channel variables.

Author:
Anthony Minessale <anthmct@yahoo.com>

Definition in file app_dumpchan.c.


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 162 of file app_dumpchan.c.

static void __unreg_module ( void   )  [static]

Definition at line 162 of file app_dumpchan.c.

static int dumpchan_exec ( struct ast_channel chan,
void *  data 
) [static]

Definition at line 134 of file app_dumpchan.c.

References ast_str_alloca, ast_strlen_zero(), ast_verbose, chan, ast_channel::name, option_verbose, pbx_builtin_serialize_variables(), serialize_showchan(), and ast_str::str.

Referenced by load_module().

00135 {
00136    struct ast_str *vars = ast_str_alloca(BUFSIZ * 4); /* XXX very large! */
00137    char info[1024];
00138    int level = 0;
00139    static char *line = "================================================================================";
00140 
00141    if (!ast_strlen_zero(data))
00142       level = atoi(data);
00143 
00144    pbx_builtin_serialize_variables(chan, &vars);
00145    serialize_showchan(chan, info, sizeof(info));
00146    if (option_verbose >= level)
00147       ast_verbose("\nDumping Info For Channel: %s:\n%s\nInfo:\n%s\nVariables:\n%s%s\n", chan->name, line, info, vars->str, line);
00148 
00149    return 0;
00150 }

static int load_module ( void   )  [static]

Definition at line 157 of file app_dumpchan.c.

References ast_register_application, and dumpchan_exec().

00158 {
00159    return ast_register_application(app, dumpchan_exec, synopsis, desc);
00160 }

static int serialize_showchan ( struct ast_channel c,
char *  buf,
size_t  size 
) [static]

Definition at line 49 of file app_dumpchan.c.

References ast_channel::_state, ast_channel::appl, AST_FLAG_BLOCKING, ast_getformatname_multiple(), ast_print_group(), ast_state2str(), ast_test_flag, ast_tvnow(), ast_channel::blockproc, ast_channel::callgroup, ast_channel::cdr, ast_channel::cid, ast_callerid::cid_dnid, ast_callerid::cid_name, ast_callerid::cid_num, ast_callerid::cid_rdnis, ast_channel::context, ast_channel::data, DEBUGCHAN_FLAG, ast_channel::exten, ast_channel::fds, ast_channel::fin, ast_channel::fout, ast_channel::language, ast_channel::name, ast_channel::nativeformats, ast_channel::parkinglot, ast_channel::pickupgroup, ast_channel::priority, ast_channel::rawreadformat, ast_channel::rawwriteformat, ast_channel::readformat, ast_channel::rings, S_OR, sec, ast_cdr::start, ast_channel::tech, ast_channel_tech::type, ast_channel::uniqueid, ast_channel::whentohangup, and ast_channel::writeformat.

Referenced by dumpchan_exec().

00050 {
00051    struct timeval now;
00052    long elapsed_seconds = 0;
00053    int hour = 0, min = 0, sec = 0;
00054    char cgrp[BUFSIZ/2];
00055    char pgrp[BUFSIZ/2];
00056    char formatbuf[BUFSIZ/2];
00057 
00058    now = ast_tvnow();
00059    memset(buf, 0, size);
00060    if (!c)
00061       return 0;
00062 
00063    if (c->cdr) {
00064       elapsed_seconds = now.tv_sec - c->cdr->start.tv_sec;
00065       hour = elapsed_seconds / 3600;
00066       min = (elapsed_seconds % 3600) / 60;
00067       sec = elapsed_seconds % 60;
00068    }
00069 
00070    snprintf(buf,size,
00071          "Name=               %s\n"
00072          "Type=               %s\n"
00073          "UniqueID=           %s\n"
00074          "CallerIDNum=        %s\n"
00075          "CallerIDName=       %s\n"
00076          "DNIDDigits=         %s\n"
00077          "RDNIS=              %s\n"
00078          "Parkinglot=         %s\n"
00079          "Language=           %s\n"
00080          "State=              %s (%d)\n"
00081          "Rings=              %d\n"
00082          "NativeFormat=       %s\n"
00083          "WriteFormat=        %s\n"
00084          "ReadFormat=         %s\n"
00085          "RawWriteFormat=     %s\n"
00086          "RawReadFormat=      %s\n"
00087          "1stFileDescriptor=  %d\n"
00088          "Framesin=           %d %s\n"
00089          "Framesout=          %d %s\n"
00090          "TimetoHangup=       %ld\n"
00091          "ElapsedTime=        %dh%dm%ds\n"
00092          "Context=            %s\n"
00093          "Extension=          %s\n"
00094          "Priority=           %d\n"
00095          "CallGroup=          %s\n"
00096          "PickupGroup=        %s\n"
00097          "Application=        %s\n"
00098          "Data=               %s\n"
00099          "Blocking_in=        %s\n",
00100          c->name,
00101          c->tech->type,
00102          c->uniqueid,
00103          S_OR(c->cid.cid_num, "(N/A)"),
00104          S_OR(c->cid.cid_name, "(N/A)"),
00105          S_OR(c->cid.cid_dnid, "(N/A)"),
00106          S_OR(c->cid.cid_rdnis, "(N/A)"),
00107          c->parkinglot,
00108          c->language,
00109          ast_state2str(c->_state),
00110          c->_state,
00111          c->rings,
00112          ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->nativeformats),
00113          ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->writeformat),
00114          ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->readformat),
00115          ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->rawwriteformat),
00116          ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->rawreadformat),
00117          c->fds[0], c->fin & ~DEBUGCHAN_FLAG, (c->fin & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
00118          c->fout & ~DEBUGCHAN_FLAG, (c->fout & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "", (long)c->whentohangup.tv_sec,
00119          hour,
00120          min,
00121          sec,
00122          c->context,
00123          c->exten,
00124          c->priority,
00125          ast_print_group(cgrp, sizeof(cgrp), c->callgroup),
00126          ast_print_group(pgrp, sizeof(pgrp), c->pickupgroup),
00127          ( c->appl ? c->appl : "(N/A)" ),
00128          ( c-> data ? S_OR(c->data, "(Empty)") : "(None)"),
00129          (ast_test_flag(c, AST_FLAG_BLOCKING) ? c->blockproc : "(Not Blocking)"));
00130 
00131    return 0;
00132 }

static int unload_module ( void   )  [static]

Definition at line 152 of file app_dumpchan.c.

References ast_unregister_application().

00153 {
00154    return ast_unregister_application(app);
00155 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Dump Info About The Calling Channel" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "a9c98e5d177805051735cb5b0b16b0a0" , .load = load_module, .unload = unload_module, } [static]

Definition at line 162 of file app_dumpchan.c.

char* app = "DumpChan" [static]

Definition at line 39 of file app_dumpchan.c.

struct ast_module_info* ast_module_info = &__mod_info [static]

Definition at line 162 of file app_dumpchan.c.

char* desc [static]

Definition at line 41 of file app_dumpchan.c.

char* synopsis = "Dump Info About The Calling Channel" [static]

Definition at line 40 of file app_dumpchan.c.


Generated on Fri Jul 24 00:41:08 2009 for Asterisk - the Open Source PBX by  doxygen 1.4.7