func_hangupcause.c File Reference

Functions related to retreiving per-channel hangupcause information. More...

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

Include dependency graph for func_hangupcause.c:

Go to the source code of this file.

Functions

static void __reg_module (void)
static void __unreg_module (void)
static int hangupcause_clear_exec (struct ast_channel *chan, const char *data)
static int hangupcause_keys_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static int hangupcause_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static int load_module (void)
static int unload_module (void)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "HANGUPCAUSE related functions and applications" , .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, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
static const char app [] = "HangupCauseClear"
static struct ast_module_infoast_module_info = &__mod_info
static struct ast_custom_function hangupcause_function
static struct ast_custom_function hangupcause_keys_function


Detailed Description

Functions related to retreiving per-channel hangupcause information.

Author:
Kinsey Moore <kmoore@digium.com>
See Also:

Definition in file func_hangupcause.c.


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 258 of file func_hangupcause.c.

static void __unreg_module ( void   )  [static]

Definition at line 258 of file func_hangupcause.c.

static int hangupcause_clear_exec ( struct ast_channel chan,
const char *  data 
) [static]

Definition at line 204 of file func_hangupcause.c.

References ast_channel_dialed_causes_clear(), ast_channel_lock, and ast_channel_unlock.

Referenced by load_module().

00204                                                                               {
00205    ast_channel_lock(chan);
00206    ast_channel_dialed_causes_clear(chan);
00207    ast_channel_unlock(chan);
00208    return 0;
00209 }

static int hangupcause_keys_read ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
) [static]

Definition at line 171 of file func_hangupcause.c.

References ast_channel_dialed_causes_channels(), ast_channel_lock, ast_channel_unlock, ast_copy_string(), ast_free, ast_str_buffer(), and ast_str_strlen().

00172 {
00173    struct ast_str *chanlist;
00174 
00175    /* Ensure that the buffer is empty */
00176    *buf = 0;
00177 
00178    if (!chan) {
00179       return -1;
00180    }
00181 
00182    ast_channel_lock(chan);
00183    chanlist = ast_channel_dialed_causes_channels(chan);
00184    ast_channel_unlock(chan);
00185 
00186    if (chanlist && ast_str_strlen(chanlist)) {
00187       ast_copy_string(buf, ast_str_buffer(chanlist), len);
00188    }
00189 
00190    ast_free(chanlist);
00191    return 0;
00192 }

static int hangupcause_read ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
) [static]

< Channel name

< Type of information requested (ast or tech)

Definition at line 110 of file func_hangupcause.c.

References ao2_ref, args, AST_APP_ARG, ast_control_pvt_cause_code::ast_cause, ast_cause2str(), ast_channel_dialed_causes_find(), ast_channel_lock, ast_channel_unlock, ast_copy_string(), AST_DECLARE_APP_ARGS, ast_log, AST_STANDARD_APP_ARGS, ast_strdupa, ast_control_pvt_cause_code::code, LOG_WARNING, and type.

00111 {
00112    char *parms;
00113    struct ast_control_pvt_cause_code *cause_code;
00114    int res = 0;
00115    AST_DECLARE_APP_ARGS(args,
00116       AST_APP_ARG(channel);   /*!< Channel name */
00117       AST_APP_ARG(type);   /*!< Type of information requested (ast or tech) */
00118       );
00119 
00120    /* Ensure that the buffer is empty */
00121    *buf = 0;
00122 
00123    if (!chan) {
00124       return -1;
00125    }
00126 
00127    parms = ast_strdupa(data);
00128    AST_STANDARD_APP_ARGS(args, parms);
00129    if (args.argc != 2) {
00130       /* Must have two arguments. */
00131       ast_log(LOG_WARNING, "The HANGUPCAUSE function must have 2 parameters, not %u\n", args.argc);
00132       return -1;
00133    }
00134 
00135    ast_channel_lock(chan);
00136    cause_code = ast_channel_dialed_causes_find(chan, args.channel);
00137    ast_channel_unlock(chan);
00138 
00139    if (!cause_code) {
00140       ast_log(LOG_WARNING, "Unable to find information for channel %s\n", args.channel);
00141       return -1;
00142    }
00143 
00144    if (!strcmp(args.type, "ast")) {
00145       ast_copy_string(buf, ast_cause2str(cause_code->ast_cause), len);
00146    } else if (!strcmp(args.type, "tech")) {
00147       ast_copy_string(buf, cause_code->code, len);
00148    } else {
00149       ast_log(LOG_WARNING, "Information type not recognized (%s)\n", args.type);
00150       res = -1;
00151    }
00152 
00153    ao2_ref(cause_code, -1);
00154 
00155    return res;
00156 }

static int load_module ( void   )  [static]

static int unload_module ( void   )  [static]

Definition at line 230 of file func_hangupcause.c.

References ast_custom_function_unregister(), and ast_unregister_application().

00231 {
00232    int res;
00233 
00234    res = ast_custom_function_unregister(&hangupcause_function);
00235    res |= ast_custom_function_unregister(&hangupcause_keys_function);
00236    res |= ast_unregister_application(app);
00237    return res;
00238 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "HANGUPCAUSE related functions and applications" , .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, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, } [static]

Definition at line 258 of file func_hangupcause.c.

const char app[] = "HangupCauseClear" [static]

Definition at line 221 of file func_hangupcause.c.

Definition at line 258 of file func_hangupcause.c.

Initial value:

 {
   .name = "HANGUPCAUSE",
   .read = hangupcause_read,
}

Definition at line 211 of file func_hangupcause.c.

Initial value:

 {
   .name = "HANGUPCAUSE_KEYS",
   .read = hangupcause_keys_read,
}

Definition at line 216 of file func_hangupcause.c.


Generated on Thu Apr 16 06:31:18 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6