mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 20:04:50 +00:00
use CDR API calls instead of re-implementing them (bug #4726)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6213 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -40,28 +40,21 @@ STANDARD_LOCAL_USER;
|
||||
|
||||
LOCAL_USER_DECL;
|
||||
|
||||
|
||||
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);
|
||||
newcdr->start = ast_tvnow();
|
||||
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)
|
||||
{
|
||||
if(chan && chan->cdr) {
|
||||
ast_cdr_clone(chan->cdr);
|
||||
}
|
||||
struct ast_cdr *cdr;
|
||||
struct ast_cdr *newcdr;
|
||||
if (!chan || !(cdr = chan->cdr))
|
||||
return;
|
||||
while (cdr->next)
|
||||
cdr = cdr->next;
|
||||
if (!(newcdr = ast_cdr_dup(cdr)))
|
||||
return;
|
||||
ast_cdr_append(cdr, newcdr);
|
||||
ast_cdr_reset(newcdr, AST_CDR_FLAG_KEEP_VARS);
|
||||
if (!ast_test_flag(cdr, AST_CDR_FLAG_KEEP_VARS))
|
||||
ast_cdr_free_vars(cdr, 0);
|
||||
ast_set_flag(cdr, AST_CDR_FLAG_CHILD | AST_CDR_FLAG_LOCKED);
|
||||
}
|
||||
|
||||
static int forkcdr_exec(struct ast_channel *chan, void *data)
|
||||
|
4
cdr.c
4
cdr.c
@@ -147,7 +147,7 @@ void ast_cdr_unregister(char *name)
|
||||
AST_LIST_UNLOCK(&be_list);
|
||||
}
|
||||
|
||||
static struct ast_cdr *cdr_dup(struct ast_cdr *cdr)
|
||||
struct ast_cdr *ast_cdr_dup(struct ast_cdr *cdr)
|
||||
{
|
||||
struct ast_cdr *newcdr;
|
||||
|
||||
@@ -809,7 +809,7 @@ void ast_cdr_reset(struct ast_cdr *cdr, int flags)
|
||||
if (ast_test_flag(&tmp, AST_CDR_FLAG_LOCKED) || !ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
|
||||
if (ast_test_flag(&tmp, AST_CDR_FLAG_POSTED)) {
|
||||
ast_cdr_end(cdr);
|
||||
if ((dup = cdr_dup(cdr))) {
|
||||
if ((dup = ast_cdr_dup(cdr))) {
|
||||
ast_cdr_detach(dup);
|
||||
}
|
||||
ast_set_flag(cdr, AST_CDR_FLAG_POSTED);
|
||||
|
@@ -104,6 +104,12 @@ typedef int (*ast_cdrbe)(struct ast_cdr *cdr);
|
||||
*/
|
||||
extern struct ast_cdr *ast_cdr_alloc(void);
|
||||
|
||||
/*! Duplicate a record */
|
||||
/*!
|
||||
* Returns a malloc'd ast_cdr structure, returns NULL on error (malloc failure)
|
||||
*/
|
||||
extern struct ast_cdr *ast_cdr_dup(struct ast_cdr *cdr);
|
||||
|
||||
/*! Free a record */
|
||||
/* \param cdr ast_cdr structure to free
|
||||
* Returns nothing important
|
||||
|
Reference in New Issue
Block a user