Asterisk.org: Developer Documentation (28 Oct 2009)

Wed Oct 28 15:48:56 2009

## Asterisk developer's documentation

# func_cdr.c File Reference

Call Detail Record related dialplan functions. More...

`#include <stdlib.h>`
`#include <string.h>`
`#include <sys/types.h>`
`#include "asterisk.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.

## Functions

static char * | builtin_function_cdr_read (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
static void | builtin_function_cdr_write (struct ast_channel *chan, char *cmd, char *data, const char *value)

## Variables

static struct ast_custom_function | cdr_function

## Detailed Description

Call Detail Record related dialplan functions.

Definition in file func_cdr.c.

## Function Documentation

static char* builtin_function_cdr_read | ( | struct ast_channel * | chan,
|  | char * | cmd,
|  | char * | data,
|  | char * | buf,
|  | size_t | len |
| ) |  |  | `[static]`

Definition at line 40 of file func_cdr.c.

References ast_app_separate_args(), ast_cdr_getvar(), ast_strdupa, ast_strlen_zero(), ast_channel::cdr, and ast_cdr::next.

    00041 {
    00042    char *ret;
    00043    char *mydata;
    00044    int argc;
    00045    char *argv[2];
    00046    int recursive = 0;
    00047    struct ast_cdr *cdr = chan ? chan->cdr : NULL;
    00048
    00049    if (ast_strlen_zero(data))
    00050       return NULL;
    00051
    00052    if (!cdr)
    00053       return NULL;
    00054
    00055    mydata = ast_strdupa(data);
    00056    argc = ast_app_separate_args(mydata, '|', argv, sizeof(argv) / sizeof(argv[0]));
    00057
    00058    /* check for a trailing flags argument */
    00059    if (argc > 1) {
    00060       argc--;
    00061       if (strchr(argv[argc], 'r'))
    00062          recursive = 1;
    00063    }
    00064
    00065    /* Find last entry */
    00066    while (cdr->next)
    00067       cdr = cdr->next;
    00068
    00069    ast_cdr_getvar(cdr, argv[0], &ret, buf, len, recursive);
    00070
    00071    return ret;
    00072 }

static void builtin_function_cdr_write | ( | struct ast_channel * | chan,
|  | char * | cmd,
|  | char * | data,
|  | const char * | value |
| ) |  |  | `[static]`

Definition at line 74 of file func_cdr.c.

References ast_app_separate_args(), ast_cdr_setaccount(), ast_cdr_setuserfield(), ast_cdr_setvar(), ast_strdupa, ast_strlen_zero(), and ast_channel::cdr.

    00075 {
    00076    char *mydata;
    00077    int argc;
    00078    char *argv[2];
    00079    int recursive = 0;
    00080
    00081    if (ast_strlen_zero(data) || !value || !chan)
    00082       return;
    00083
    00084    mydata = ast_strdupa(data);
    00085    argc = ast_app_separate_args(mydata, '|', argv, sizeof(argv) / sizeof(argv[0]));
    00086
    00087    /* check for a trailing flags argument */
    00088    if (argc > 1) {
    00089       argc--;
    00090       if (strchr(argv[argc], 'r'))
    00091          recursive = 1;
    00092    }
    00093
    00094    if (!strcasecmp(argv[0], "accountcode"))
    00095       ast_cdr_setaccount(chan, value);
    00096    else if (!strcasecmp(argv[0], "userfield"))
    00097       ast_cdr_setuserfield(chan, value);
    00098    else if (chan->cdr)
    00099       ast_cdr_setvar(chan->cdr, argv[0], value, recursive);
    00100 }

## Variable Documentation

struct ast_custom_function cdr_function`[static]`

Definition at line 105 of file func_cdr.c.