diff options
author | murf <murf@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-04-09 18:32:07 +0000 |
---|---|---|
committer | murf <murf@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-04-09 18:32:07 +0000 |
commit | 06afe72ddde29a01ab01380a6136c35913c8b619 (patch) | |
tree | e5d6613b436e3aa37ac46a65ae4b15e4393f1464 /main/channel.c | |
parent | e712a2adf2cccce5cd6d454617e3f7d125004451 (diff) |
This is a big improvement over the current CDR fixes. It may still need refinement, but this won't have as many folks bothered.
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@60989 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/channel.c')
-rw-r--r-- | main/channel.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/main/channel.c b/main/channel.c index bb7f556c5..4f0b58536 100644 --- a/main/channel.c +++ b/main/channel.c @@ -711,7 +711,7 @@ static const struct ast_channel_tech null_tech = { }; /*! \brief Create a new channel structure */ -struct ast_channel *ast_channel_alloc(int needqueue, int state, const char *cid_num, const char *cid_name, const char *name_fmt, ...) +struct ast_channel *ast_channel_alloc(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const int amaflag, const char *name_fmt, ...) { struct ast_channel *tmp; int x; @@ -824,6 +824,30 @@ struct ast_channel *ast_channel_alloc(int needqueue, int state, const char *cid_ } /* Reminder for the future: under what conditions do we NOT want to track cdrs on channels? */ + + /* These 4 variables need to be set up for the cdr_init() to work right */ + if (amaflag) + tmp->amaflags = amaflag; + else + tmp->amaflags = ast_default_amaflags; + + if (!ast_strlen_zero(acctcode)) + ast_string_field_set(tmp, accountcode, acctcode); + else + ast_string_field_set(tmp, accountcode, ast_default_accountcode); + + if (!ast_strlen_zero(context)) + ast_copy_string(tmp->context, context, sizeof(tmp->context)); + else + strcpy(tmp->context, "default"); + + if (!ast_strlen_zero(exten)) + ast_copy_string(tmp->exten, exten, sizeof(tmp->exten)); + else + strcpy(tmp->exten, "s"); + + tmp->priority = 1; + tmp->cdr = ast_cdr_alloc(); ast_cdr_init(tmp->cdr, tmp); ast_cdr_start(tmp->cdr); @@ -835,13 +859,7 @@ struct ast_channel *ast_channel_alloc(int needqueue, int state, const char *cid_ AST_LIST_HEAD_INIT_NOLOCK(&tmp->datastores); - strcpy(tmp->context, "default"); - strcpy(tmp->exten, "s"); - tmp->priority = 1; - ast_string_field_set(tmp, language, defaultlanguage); - tmp->amaflags = ast_default_amaflags; - ast_string_field_set(tmp, accountcode, ast_default_accountcode); tmp->tech = &null_tech; |