Thu Apr 28 2011 17:16:06

Asterisk developer's documentation


func_cdr.c File Reference

Call Detail Record related dialplan functions. 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 "asterisk/cdr.h"
Include dependency graph for func_cdr.c:

Go to the source code of this file.

Enumerations

enum  { OPT_RECURSIVE = (1 << 0), OPT_UNPARSED = (1 << 1), OPT_LAST = (1 << 2), OPT_SKIPLOCKED = (1 << 3) }

Functions

static void __reg_module (void)
static void __unreg_module (void)
static int cdr_read (struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
static int cdr_write (struct ast_channel *chan, const char *cmd, char *parse, const char *value)
static int load_module (void)
static int unload_module (void)

Variables

static struct ast_module_info
__MODULE_INFO_SECTION 
__mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Call Detail Record (CDR) dialplan function" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, }
static struct ast_module_infoast_module_info = &__mod_info
static struct ast_app_option cdr_func_options [128] = { [ 'l' ] = { .flag = OPT_LAST }, [ 'r' ] = { .flag = OPT_RECURSIVE }, [ 's' ] = { .flag = OPT_SKIPLOCKED }, [ 'u' ] = { .flag = OPT_UNPARSED },}
static struct ast_custom_function cdr_function
enum { ... }  cdr_option_flags

Detailed Description

Call Detail Record related dialplan functions.

Author:
Anthony Minessale II

Definition in file func_cdr.c.


Enumeration Type Documentation

anonymous enum
Enumerator:
OPT_RECURSIVE 
OPT_UNPARSED 
OPT_LAST 
OPT_SKIPLOCKED 

Definition at line 169 of file func_cdr.c.

     {
   OPT_RECURSIVE = (1 << 0),
   OPT_UNPARSED = (1 << 1),
   OPT_LAST = (1 << 2),
   OPT_SKIPLOCKED = (1 << 3),
} cdr_option_flags;

Function Documentation

static void __reg_module ( void  ) [static]

Definition at line 275 of file func_cdr.c.

static void __unreg_module ( void  ) [static]

Definition at line 275 of file func_cdr.c.

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

Definition at line 183 of file func_cdr.c.

References AST_APP_ARG, ast_app_parse_options(), AST_CDR_FLAG_LOCKED, ast_cdr_getvar(), AST_DECLARE_APP_ARGS, AST_STANDARD_APP_ARGS, ast_strlen_zero(), ast_test_flag, ast_channel::cdr, cdr_func_options, ast_cdr::next, OPT_LAST, OPT_RECURSIVE, OPT_SKIPLOCKED, and OPT_UNPARSED.

{
   char *ret;
   struct ast_flags flags = { 0 };
   struct ast_cdr *cdr = chan ? chan->cdr : NULL;
   AST_DECLARE_APP_ARGS(args,
              AST_APP_ARG(variable);
              AST_APP_ARG(options);
   );

   if (ast_strlen_zero(parse))
      return -1;

   if (!cdr)
      return -1;

   AST_STANDARD_APP_ARGS(args, parse);

   if (!ast_strlen_zero(args.options))
      ast_app_parse_options(cdr_func_options, &flags, NULL, args.options);

   if (ast_test_flag(&flags, OPT_LAST))
      while (cdr->next)
         cdr = cdr->next;

   if (ast_test_flag(&flags, OPT_SKIPLOCKED))
      while (ast_test_flag(cdr, AST_CDR_FLAG_LOCKED) && cdr->next)
         cdr = cdr->next;

   ast_cdr_getvar(cdr, args.variable, &ret, buf, len,
             ast_test_flag(&flags, OPT_RECURSIVE),
            ast_test_flag(&flags, OPT_UNPARSED));

   return ret ? 0 : -1;
}
static int cdr_write ( struct ast_channel chan,
const char *  cmd,
char *  parse,
const char *  value 
) [static]

Definition at line 220 of file func_cdr.c.

References AST_APP_ARG, ast_app_parse_options(), ast_cdr_setaccount(), ast_cdr_setamaflags(), ast_cdr_setuserfield(), ast_cdr_setvar(), AST_DECLARE_APP_ARGS, AST_STANDARD_APP_ARGS, ast_strlen_zero(), ast_test_flag, ast_channel::cdr, cdr_func_options, chan, ast_cdr::next, OPT_LAST, and OPT_RECURSIVE.

{
   struct ast_cdr *cdr = chan ? chan->cdr : NULL;
   struct ast_flags flags = { 0 };
   AST_DECLARE_APP_ARGS(args,
              AST_APP_ARG(variable);
              AST_APP_ARG(options);
   );

   if (ast_strlen_zero(parse) || !value || !chan)
      return -1;

   if (!cdr)
      return -1;

   AST_STANDARD_APP_ARGS(args, parse);

   if (!ast_strlen_zero(args.options))
      ast_app_parse_options(cdr_func_options, &flags, NULL, args.options);

   if (ast_test_flag(&flags, OPT_LAST))
      while (cdr->next)
         cdr = cdr->next;

   if (!strcasecmp(args.variable, "accountcode"))  /* the 'l' flag doesn't apply to setting the accountcode, userfield, or amaflags */
      ast_cdr_setaccount(chan, value);
   else if (!strcasecmp(args.variable, "userfield"))
      ast_cdr_setuserfield(chan, value);
   else if (!strcasecmp(args.variable, "amaflags"))
      ast_cdr_setamaflags(chan, value);
   else
      ast_cdr_setvar(cdr, args.variable, value, ast_test_flag(&flags, OPT_RECURSIVE));
      /* No need to worry about the u flag, as all fields for which setting
       * 'u' would do anything are marked as readonly. */

   return 0;
}
static int load_module ( void  ) [static]

Definition at line 270 of file func_cdr.c.

References ast_custom_function_register.

static int unload_module ( void  ) [static]

Definition at line 265 of file func_cdr.c.

References ast_custom_function_unregister().


Variable Documentation

struct ast_module_info __MODULE_INFO_SECTION __mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Call Detail Record (CDR) dialplan function" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } [static]

Definition at line 275 of file func_cdr.c.

Definition at line 275 of file func_cdr.c.

struct ast_app_option cdr_func_options[128] = { [ 'l' ] = { .flag = OPT_LAST }, [ 'r' ] = { .flag = OPT_RECURSIVE }, [ 's' ] = { .flag = OPT_SKIPLOCKED }, [ 'u' ] = { .flag = OPT_UNPARSED },} [static]

Definition at line 181 of file func_cdr.c.

Referenced by cdr_read(), and cdr_write().

Initial value:
 {
   .name = "CDR",
   .read = cdr_read,
   .write = cdr_write,
}

Definition at line 259 of file func_cdr.c.

enum { ... } cdr_option_flags