summaryrefslogtreecommitdiff
path: root/apps/app_forkcdr.c
diff options
context:
space:
mode:
authorMark Spencer <markster@digium.com>2005-02-23 22:48:47 +0000
committerMark Spencer <markster@digium.com>2005-02-23 22:48:47 +0000
commitb6c4282a03377890cbb866d8a066cce61a742ef8 (patch)
tree5cac482ff6e93ba883893efeabb3ed534e83e9d0 /apps/app_forkcdr.c
parent7954654d15209a5859d5feb02c13a1d96548e698 (diff)
Merge anthm's CDR updates (bug #3595)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5068 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_forkcdr.c')
-rwxr-xr-xapps/app_forkcdr.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/apps/app_forkcdr.c b/apps/app_forkcdr.c
index c2ef00b46..64679b551 100755
--- a/apps/app_forkcdr.c
+++ b/apps/app_forkcdr.c
@@ -25,8 +25,10 @@ static char *app = "ForkCDR";
static char *synopsis =
"Forks the Call Data Record";
static char *descrip =
-" ForkCDR(): Causes the Call Data Record to fork an additional\n"
- "cdr record starting from the time of the fork call\n";
+" ForkCDR([options]): Causes the Call Data Record to fork an additional\n"
+ "cdr record starting from the time of the fork call\n"
+"If the option 'v' is passed all cdr variables will be passed along also.\n"
+"";
STANDARD_LOCAL_USER;
@@ -34,17 +36,24 @@ STANDARD_LOCAL_USER;
LOCAL_USER_DECL;
-static void ast_cdr_clone(struct ast_cdr *cdr) {
+static void ast_cdr_clone(struct ast_cdr *cdr)
+{
struct ast_cdr *newcdr = ast_cdr_alloc();
memcpy(newcdr,cdr,sizeof(struct ast_cdr));
ast_cdr_append(cdr,newcdr);
gettimeofday(&newcdr->start, NULL);
memset(&newcdr->answer, 0, sizeof(newcdr->answer));
+ memset(&newcdr->varshead, 0, sizeof(newcdr->varshead));
+ ast_cdr_copy_vars(newcdr, cdr);
+ if (!ast_test_flag(cdr, AST_CDR_FLAG_KEEP_VARS)) {
+ ast_cdr_free_vars(cdr, 0);
+ }
newcdr->disposition = AST_CDR_NOANSWER;
ast_set_flag(cdr, AST_CDR_FLAG_CHILD|AST_CDR_FLAG_LOCKED);
}
-static void ast_cdr_fork(struct ast_channel *chan) {
+static void ast_cdr_fork(struct ast_channel *chan)
+{
if(chan && chan->cdr) {
ast_cdr_clone(chan->cdr);
}
@@ -55,7 +64,8 @@ static int forkcdr_exec(struct ast_channel *chan, void *data)
int res=0;
struct localuser *u;
LOCAL_USER_ADD(u);
-
+ ast_set2_flag(chan->cdr, strchr((char *)data, 'v'), AST_CDR_FLAG_KEEP_VARS);
+
ast_cdr_fork(chan);
LOCAL_USER_REMOVE(u);