Fork CDR application. More...
#include "asterisk.h"#include "asterisk/file.h"#include "asterisk/channel.h"#include "asterisk/pbx.h"#include "asterisk/cdr.h"#include "asterisk/app.h"#include "asterisk/module.h"
Go to the source code of this file.
Enumerations | |
| enum | { OPT_SETANS = (1 << 0), OPT_SETDISP = (1 << 1), OPT_RESETDEST = (1 << 2), OPT_ENDCDR = (1 << 3), OPT_NORESET = (1 << 4), OPT_KEEPVARS = (1 << 5), OPT_VARSET = (1 << 6), OPT_ANSLOCK = (1 << 7), OPT_DONTOUCH = (1 << 8) } |
| enum | { OPT_ARG_VARSET = 0, OPT_ARG_ARRAY_SIZE } |
Functions | |
| static void | __reg_module (void) |
| static void | __unreg_module (void) |
| static void | ast_cdr_fork (struct ast_channel *chan, struct ast_flags optflags, char *set) |
| static int | forkcdr_exec (struct ast_channel *chan, void *data) |
| 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 = "Fork The CDR into 2 separate entities" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } |
| static char * | app = "ForkCDR" |
| static struct ast_module_info * | ast_module_info = &__mod_info |
| static struct ast_app_option | forkcdr_exec_options [128] = { [ 'a' ] = { .flag = OPT_SETANS }, [ 'A' ] = { .flag = OPT_ANSLOCK }, [ 'd' ] = { .flag = OPT_SETDISP }, [ 'D' ] = { .flag = OPT_RESETDEST }, [ 'e' ] = { .flag = OPT_ENDCDR }, [ 'R' ] = { .flag = OPT_NORESET }, [ 's' ] = { .flag = OPT_VARSET , .arg_index = OPT_ARG_VARSET + 1 }, [ 'T' ] = { .flag = OPT_DONTOUCH }, [ 'v' ] = { .flag = OPT_KEEPVARS },} |
Fork CDR application.
Definition in file app_forkcdr.c.
| anonymous enum |
| OPT_SETANS | |
| OPT_SETDISP | |
| OPT_RESETDEST | |
| OPT_ENDCDR | |
| OPT_NORESET | |
| OPT_KEEPVARS | |
| OPT_VARSET | |
| OPT_ANSLOCK | |
| OPT_DONTOUCH |
Definition at line 146 of file app_forkcdr.c.
{
OPT_SETANS = (1 << 0),
OPT_SETDISP = (1 << 1),
OPT_RESETDEST = (1 << 2),
OPT_ENDCDR = (1 << 3),
OPT_NORESET = (1 << 4),
OPT_KEEPVARS = (1 << 5),
OPT_VARSET = (1 << 6),
OPT_ANSLOCK = (1 << 7),
OPT_DONTOUCH = (1 << 8),
};
| anonymous enum |
Definition at line 158 of file app_forkcdr.c.
{
OPT_ARG_VARSET = 0,
/* note: this entry _MUST_ be the last one in the enum */
OPT_ARG_ARRAY_SIZE,
};
| static void __reg_module | ( | void | ) | [static] |
Definition at line 273 of file app_forkcdr.c.
| static void __unreg_module | ( | void | ) | [static] |
Definition at line 273 of file app_forkcdr.c.
| static void ast_cdr_fork | ( | struct ast_channel * | chan, |
| struct ast_flags | optflags, | ||
| char * | set | ||
| ) | [static] |
Definition at line 176 of file app_forkcdr.c.
References ast_cdr::answer, ast_cdr_append(), ast_cdr_dup(), ast_cdr_end(), AST_CDR_FLAG_ANSLOCKED, AST_CDR_FLAG_CHILD, AST_CDR_FLAG_DONT_TOUCH, AST_CDR_FLAG_KEEP_VARS, AST_CDR_FLAG_LOCKED, ast_cdr_free_vars(), ast_cdr_reset(), ast_cdr_setvar(), ast_set_flag, ast_strdupa, ast_strlen_zero(), ast_test_flag, ast_tvzero(), ast_channel::cdr, ast_cdr::disposition, ast_cdr::dstchannel, ast_cdr::next, OPT_ANSLOCK, OPT_DONTOUCH, OPT_ENDCDR, OPT_NORESET, OPT_RESETDEST, OPT_SETANS, OPT_SETDISP, and ast_cdr::start.
Referenced by forkcdr_exec().
{
struct ast_cdr *cdr;
struct ast_cdr *newcdr;
struct ast_flags flags = { AST_CDR_FLAG_KEEP_VARS };
cdr = chan->cdr;
while (cdr->next)
cdr = cdr->next;
if (!(newcdr = ast_cdr_dup(cdr)))
return;
ast_cdr_append(cdr, newcdr);
if (!ast_test_flag(&optflags, OPT_NORESET))
ast_cdr_reset(newcdr, &flags);
if (!ast_test_flag(cdr, AST_CDR_FLAG_KEEP_VARS))
ast_cdr_free_vars(cdr, 0);
if (!ast_strlen_zero(set)) {
char *varname = ast_strdupa(set), *varval;
varval = strchr(varname,'=');
if (varval) {
*varval = 0;
varval++;
ast_cdr_setvar(cdr, varname, varval, 0);
}
}
if (ast_test_flag(&optflags, OPT_SETANS) && !ast_tvzero(cdr->answer))
newcdr->answer = newcdr->start;
if (ast_test_flag(&optflags, OPT_SETDISP))
newcdr->disposition = cdr->disposition;
if (ast_test_flag(&optflags, OPT_RESETDEST))
newcdr->dstchannel[0] = 0;
if (ast_test_flag(&optflags, OPT_ENDCDR))
ast_cdr_end(cdr);
if (ast_test_flag(&optflags, OPT_ANSLOCK))
ast_set_flag(cdr, AST_CDR_FLAG_ANSLOCKED);
if (ast_test_flag(&optflags, OPT_DONTOUCH))
ast_set_flag(cdr, AST_CDR_FLAG_DONT_TOUCH);
ast_set_flag(cdr, AST_CDR_FLAG_CHILD | AST_CDR_FLAG_LOCKED);
}
| static int forkcdr_exec | ( | struct ast_channel * | chan, |
| void * | data | ||
| ) | [static] |
Definition at line 229 of file app_forkcdr.c.
References AST_APP_ARG, ast_app_parse_options(), AST_CDR_FLAG_KEEP_VARS, ast_cdr_fork(), AST_DECLARE_APP_ARGS, ast_log(), ast_set2_flag, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_test_flag, ast_channel::cdr, forkcdr_exec_options, LOG_WARNING, OPT_ARG_ARRAY_SIZE, OPT_ARG_VARSET, and OPT_KEEPVARS.
Referenced by load_module().
{
int res = 0;
char *argcopy = NULL;
struct ast_flags flags = {0};
char *opts[OPT_ARG_ARRAY_SIZE];
AST_DECLARE_APP_ARGS(arglist,
AST_APP_ARG(options);
);
if (!chan->cdr) {
ast_log(LOG_WARNING, "Channel does not have a CDR\n");
return 0;
}
argcopy = ast_strdupa(data);
AST_STANDARD_APP_ARGS(arglist, argcopy);
opts[OPT_ARG_VARSET] = 0;
if (!ast_strlen_zero(arglist.options))
ast_app_parse_options(forkcdr_exec_options, &flags, opts, arglist.options);
if (!ast_strlen_zero(data)) {
int keepvars = ast_test_flag(&flags, OPT_KEEPVARS) ? 1 : 0;
ast_set2_flag(chan->cdr, keepvars, AST_CDR_FLAG_KEEP_VARS);
}
ast_cdr_fork(chan, flags, opts[OPT_ARG_VARSET]);
return res;
}
| static int load_module | ( | void | ) | [static] |
Definition at line 268 of file app_forkcdr.c.
References ast_register_application_xml, and forkcdr_exec().
{
return ast_register_application_xml(app, forkcdr_exec);
}
| static int unload_module | ( | void | ) | [static] |
Definition at line 263 of file app_forkcdr.c.
References ast_unregister_application().
{
return ast_unregister_application(app);
}
struct ast_module_info __MODULE_INFO_SECTION __mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Fork The CDR into 2 separate entities" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } [static] |
Definition at line 273 of file app_forkcdr.c.
char* app = "ForkCDR" [static] |
Definition at line 144 of file app_forkcdr.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 273 of file app_forkcdr.c.
struct ast_app_option forkcdr_exec_options[128] = { [ 'a' ] = { .flag = OPT_SETANS }, [ 'A' ] = { .flag = OPT_ANSLOCK }, [ 'd' ] = { .flag = OPT_SETDISP }, [ 'D' ] = { .flag = OPT_RESETDEST }, [ 'e' ] = { .flag = OPT_ENDCDR }, [ 'R' ] = { .flag = OPT_NORESET }, [ 's' ] = { .flag = OPT_VARSET , .arg_index = OPT_ARG_VARSET + 1 }, [ 'T' ] = { .flag = OPT_DONTOUCH }, [ 'v' ] = { .flag = OPT_KEEPVARS },} [static] |
Definition at line 174 of file app_forkcdr.c.
Referenced by forkcdr_exec().