Wed Oct 28 11:45:44 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"

Include dependency graph for app_dumpchan.c:

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 = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, }
static char * app = "DumpChan"
static const struct
ast_module_info
ast_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 160 of file app_dumpchan.c.

static void __unreg_module ( void   )  [static]

Definition at line 160 of file app_dumpchan.c.

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

Definition at line 132 of file app_dumpchan.c.

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

Referenced by load_module().

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

static int load_module ( void   )  [static]

Definition at line 155 of file app_dumpchan.c.

References ast_register_application, and dumpchan_exec().

00156 {
00157    return ast_register_application(app, dumpchan_exec, synopsis, desc);
00158 }

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::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          "Language=           %s\n"
00079          "State=              %s (%d)\n"
00080          "Rings=              %d\n"
00081          "NativeFormat=       %s\n"
00082          "WriteFormat=        %s\n"
00083          "ReadFormat=         %s\n"
00084          "RawWriteFormat=     %s\n"
00085          "RawReadFormat=      %s\n"
00086          "1stFileDescriptor=  %d\n"
00087          "Framesin=           %d %s\n"
00088          "Framesout=          %d %s\n"
00089          "TimetoHangup=       %ld\n"
00090          "ElapsedTime=        %dh%dm%ds\n"
00091          "Context=            %s\n"
00092          "Extension=          %s\n"
00093          "Priority=           %d\n"
00094          "CallGroup=          %s\n"
00095          "PickupGroup=        %s\n"
00096          "Application=        %s\n"
00097          "Data=               %s\n"
00098          "Blocking_in=        %s\n",
00099          c->name,
00100          c->tech->type,
00101          c->uniqueid,
00102          S_OR(c->cid.cid_num, "(N/A)"),
00103          S_OR(c->cid.cid_name, "(N/A)"),
00104          S_OR(c->cid.cid_dnid, "(N/A)"),
00105          S_OR(c->cid.cid_rdnis, "(N/A)"),
00106          c->language,
00107          ast_state2str(c->_state),
00108          c->_state,
00109          c->rings,
00110          ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->nativeformats),
00111          ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->writeformat),
00112          ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->readformat),
00113          ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->rawwriteformat),
00114          ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->rawreadformat),
00115          c->fds[0], c->fin & ~DEBUGCHAN_FLAG, (c->fin & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
00116          c->fout & ~DEBUGCHAN_FLAG, (c->fout & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "", (long)c->whentohangup,
00117          hour,
00118          min,
00119          sec,
00120          c->context,
00121          c->exten,
00122          c->priority,
00123          ast_print_group(cgrp, sizeof(cgrp), c->callgroup),
00124          ast_print_group(pgrp, sizeof(pgrp), c->pickupgroup),
00125          ( c->appl ? c->appl : "(N/A)" ),
00126          ( c-> data ? S_OR(c->data, "(Empty)") : "(None)"),
00127          (ast_test_flag(c, AST_FLAG_BLOCKING) ? c->blockproc : "(Not Blocking)"));
00128 
00129    return 0;
00130 }

static int unload_module ( void   )  [static]

Definition at line 150 of file app_dumpchan.c.

References ast_unregister_application().

00151 {
00152    return ast_unregister_application(app);
00153 }


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 = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } [static]

Definition at line 160 of file app_dumpchan.c.

char* app = "DumpChan" [static]

Definition at line 39 of file app_dumpchan.c.

const struct ast_module_info* ast_module_info = &__mod_info [static]

Definition at line 160 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 Wed Oct 28 11:45:44 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.6