Mon Mar 31 07:40:50 2008

Asterisk developer's documentation


func_cdr.c File Reference

Call Detail Record related dialplan functions. More...

#include "asterisk.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/logger.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) }

Functions

 AST_APP_OPTIONS (cdr_func_options,{AST_APP_OPTION('l', OPT_LAST), AST_APP_OPTION('r', OPT_RECURSIVE), AST_APP_OPTION('u', OPT_UNPARSED),})
 AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"CDR dialplan function")
static int cdr_read (struct ast_channel *chan, char *cmd, char *parse, char *buf, size_t len)
static int cdr_write (struct ast_channel *chan, char *cmd, char *parse, const char *value)
static int load_module (void)
static int unload_module (void)

Variables

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 

Definition at line 45 of file func_cdr.c.

00045      {
00046    OPT_RECURSIVE = (1 << 0),
00047    OPT_UNPARSED = (1 << 1),
00048    OPT_LAST = (1 << 2),
00049 } cdr_option_flags;


Function Documentation

AST_APP_OPTIONS ( cdr_func_options   ) 

AST_MODULE_INFO_STANDARD ( ASTERISK_GPL_KEY  ,
"CDR dialplan function"   
)

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

Definition at line 57 of file func_cdr.c.

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

00059 {
00060    char *ret;
00061    struct ast_flags flags = { 0 };
00062    struct ast_cdr *cdr = chan ? chan->cdr : NULL;
00063    AST_DECLARE_APP_ARGS(args,
00064               AST_APP_ARG(variable);
00065               AST_APP_ARG(options);
00066    );
00067 
00068    if (ast_strlen_zero(parse))
00069       return -1;
00070 
00071    if (!cdr)
00072       return -1;
00073 
00074    AST_STANDARD_APP_ARGS(args, parse);
00075 
00076    if (!ast_strlen_zero(args.options))
00077       ast_app_parse_options(cdr_func_options, &flags, NULL, args.options);
00078 
00079    if (ast_test_flag(&flags, OPT_LAST))
00080       while (cdr->next)
00081          cdr = cdr->next;
00082 
00083    ast_cdr_getvar(cdr, args.variable, &ret, buf, len,
00084              ast_test_flag(&flags, OPT_RECURSIVE),
00085             ast_test_flag(&flags, OPT_UNPARSED));
00086 
00087    return 0;
00088 }

static int cdr_write ( struct ast_channel chan,
char *  cmd,
char *  parse,
const char *  value 
) [static]

Definition at line 90 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, ast_flags::flags, and OPT_RECURSIVE.

00092 {
00093    struct ast_flags flags = { 0 };
00094    AST_DECLARE_APP_ARGS(args,
00095               AST_APP_ARG(variable);
00096               AST_APP_ARG(options);
00097    );
00098 
00099    if (ast_strlen_zero(parse) || !value || !chan)
00100       return -1;
00101 
00102    AST_STANDARD_APP_ARGS(args, parse);
00103 
00104    if (!ast_strlen_zero(args.options))
00105       ast_app_parse_options(cdr_func_options, &flags, NULL, args.options);
00106 
00107    if (!strcasecmp(args.variable, "accountcode"))
00108       ast_cdr_setaccount(chan, value);
00109    else if (!strcasecmp(args.variable, "userfield"))
00110       ast_cdr_setuserfield(chan, value);
00111    else if (!strcasecmp(args.variable, "amaflags"))
00112       ast_cdr_setamaflags(chan, value);
00113    else if (chan->cdr)
00114       ast_cdr_setvar(chan->cdr, args.variable, value, ast_test_flag(&flags, OPT_RECURSIVE));
00115       /* No need to worry about the u flag, as all fields for which setting
00116        * 'u' would do anything are marked as readonly. */
00117 
00118    return 0;
00119 }

static int load_module ( void   )  [static]

Definition at line 164 of file func_cdr.c.

References ast_custom_function_register(), and cdr_function.

00165 {
00166    return ast_custom_function_register(&cdr_function);
00167 }

static int unload_module ( void   )  [static]

Definition at line 159 of file func_cdr.c.

References ast_custom_function_unregister(), and cdr_function.

00160 {
00161    return ast_custom_function_unregister(&cdr_function);
00162 }


Variable Documentation

struct ast_custom_function cdr_function [static]

Definition at line 121 of file func_cdr.c.

Referenced by load_module(), and unload_module().

enum { ... } cdr_option_flags


Generated on Mon Mar 31 07:40:50 2008 for Asterisk - the Open Source PBX by  doxygen 1.5.1