Fri Nov 12 12:01:53 2010

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 __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Call Detail Record (CDR) dialplan function" , .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 = "0901e4e500243c855563a2d78b0c03e4" , .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.

00169      {
00170    OPT_RECURSIVE = (1 << 0),
00171    OPT_UNPARSED = (1 << 1),
00172    OPT_LAST = (1 << 2),
00173    OPT_SKIPLOCKED = (1 << 3),
00174 } 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.

00185 {
00186    char *ret;
00187    struct ast_flags flags = { 0 };
00188    struct ast_cdr *cdr = chan ? chan->cdr : NULL;
00189    AST_DECLARE_APP_ARGS(args,
00190               AST_APP_ARG(variable);
00191               AST_APP_ARG(options);
00192    );
00193 
00194    if (ast_strlen_zero(parse))
00195       return -1;
00196 
00197    if (!cdr)
00198       return -1;
00199 
00200    AST_STANDARD_APP_ARGS(args, parse);
00201 
00202    if (!ast_strlen_zero(args.options))
00203       ast_app_parse_options(cdr_func_options, &flags, NULL, args.options);
00204 
00205    if (ast_test_flag(&flags, OPT_LAST))
00206       while (cdr->next)
00207          cdr = cdr->next;
00208 
00209    if (ast_test_flag(&flags, OPT_SKIPLOCKED))
00210       while (ast_test_flag(cdr, AST_CDR_FLAG_LOCKED) && cdr->next)
00211          cdr = cdr->next;
00212 
00213    ast_cdr_getvar(cdr, args.variable, &ret, buf, len,
00214              ast_test_flag(&flags, OPT_RECURSIVE),
00215             ast_test_flag(&flags, OPT_UNPARSED));
00216 
00217    return ret ? 0 : -1;
00218 }

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, ast_cdr::next, OPT_LAST, and OPT_RECURSIVE.

00222 {
00223    struct ast_cdr *cdr = chan ? chan->cdr : NULL;
00224    struct ast_flags flags = { 0 };
00225    AST_DECLARE_APP_ARGS(args,
00226               AST_APP_ARG(variable);
00227               AST_APP_ARG(options);
00228    );
00229 
00230    if (ast_strlen_zero(parse) || !value || !chan)
00231       return -1;
00232 
00233    if (!cdr)
00234       return -1;
00235 
00236    AST_STANDARD_APP_ARGS(args, parse);
00237 
00238    if (!ast_strlen_zero(args.options))
00239       ast_app_parse_options(cdr_func_options, &flags, NULL, args.options);
00240 
00241    if (ast_test_flag(&flags, OPT_LAST))
00242       while (cdr->next)
00243          cdr = cdr->next;
00244 
00245    if (!strcasecmp(args.variable, "accountcode"))  /* the 'l' flag doesn't apply to setting the accountcode, userfield, or amaflags */
00246       ast_cdr_setaccount(chan, value);
00247    else if (!strcasecmp(args.variable, "userfield"))
00248       ast_cdr_setuserfield(chan, value);
00249    else if (!strcasecmp(args.variable, "amaflags"))
00250       ast_cdr_setamaflags(chan, value);
00251    else
00252       ast_cdr_setvar(cdr, args.variable, value, ast_test_flag(&flags, OPT_RECURSIVE));
00253       /* No need to worry about the u flag, as all fields for which setting
00254        * 'u' would do anything are marked as readonly. */
00255 
00256    return 0;
00257 }

static int load_module ( void   )  [static]

Definition at line 270 of file func_cdr.c.

References ast_custom_function_register.

00271 {
00272    return ast_custom_function_register(&cdr_function);
00273 }

static int unload_module ( void   )  [static]

Definition at line 265 of file func_cdr.c.

References ast_custom_function_unregister().

00266 {
00267    return ast_custom_function_unregister(&cdr_function);
00268 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Call Detail Record (CDR) dialplan function" , .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 = "0901e4e500243c855563a2d78b0c03e4" , .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

Generated by  doxygen 1.6.2