Sat Apr 26 2014 22:02:51

Asterisk developer's documentation


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, }
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]
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().

{
   struct ast_str *chanlist;

   /* Ensure that the buffer is empty */
   *buf = 0;

   if (!chan) {
      return -1;
   }

   ast_channel_lock(chan);
   chanlist = ast_channel_dialed_causes_channels(chan);
   ast_channel_unlock(chan);

   if (chanlist && ast_str_strlen(chanlist)) {
      ast_copy_string(buf, ast_str_buffer(chanlist), len);
   }

   ast_free(chanlist);
   return 0;
}
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_control_pvt_cause_code::code, LOG_WARNING, and type.

{
   char *parms;
   struct ast_control_pvt_cause_code *cause_code;
   int res = 0;
   AST_DECLARE_APP_ARGS(args,
      AST_APP_ARG(channel);   /*!< Channel name */
      AST_APP_ARG(type);   /*!< Type of information requested (ast or tech) */
      );

   /* Ensure that the buffer is empty */
   *buf = 0;

   if (!chan) {
      return -1;
   }

   parms = ast_strdupa(data);
   AST_STANDARD_APP_ARGS(args, parms);
   if (args.argc != 2) {
      /* Must have two arguments. */
      ast_log(LOG_WARNING, "The HANGUPCAUSE function must have 2 parameters, not %d\n", args.argc);
      return -1;
   }

   ast_channel_lock(chan);
   cause_code = ast_channel_dialed_causes_find(chan, args.channel);
   ast_channel_unlock(chan);

   if (!cause_code) {
      ast_log(LOG_WARNING, "Unable to find information for channel %s\n", args.channel);
      return -1;
   }

   if (!strcmp(args.type, "ast")) {
      ast_copy_string(buf, ast_cause2str(cause_code->ast_cause), len);
   } else if (!strcmp(args.type, "tech")) {
      ast_copy_string(buf, cause_code->code, len);
   } else {
      ast_log(LOG_WARNING, "Information type not recognized (%s)\n", args.type);
      res = -1;
   }

   ao2_ref(cause_code, -1);

   return res;
}

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, } [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.