mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
several changes via kpflemings review
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@59522 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
31
main/cdr.c
31
main/cdr.c
@@ -166,8 +166,11 @@ void ast_cdr_unregister(const char *name)
|
||||
*/
|
||||
struct ast_cdr *ast_cdr_dup(struct ast_cdr *cdr)
|
||||
{
|
||||
struct ast_cdr *newcdr = ast_cdr_alloc();
|
||||
|
||||
struct ast_cdr *newcdr;
|
||||
|
||||
if (!cdr) /* don't die if we get a null cdr pointer */
|
||||
return NULL;
|
||||
newcdr = ast_cdr_alloc();
|
||||
if (!newcdr)
|
||||
return NULL;
|
||||
|
||||
@@ -217,6 +220,9 @@ void ast_cdr_getvar(struct ast_cdr *cdr, const char *name, char **ret, char *wor
|
||||
const char *fmt = "%Y-%m-%d %T";
|
||||
const char *varbuf;
|
||||
|
||||
if (!cdr) /* don't die if the cdr is null */
|
||||
return;
|
||||
|
||||
*ret = NULL;
|
||||
/* special vars (the ones from the struct ast_cdr when requested by name)
|
||||
I'd almost say we should convert all the stringed vals to vars */
|
||||
@@ -288,6 +294,9 @@ int ast_cdr_setvar(struct ast_cdr *cdr, const char *name, const char *value, int
|
||||
struct varshead *headp;
|
||||
int x;
|
||||
|
||||
if (!cdr) /* don't die if the cdr is null */
|
||||
return -1;
|
||||
|
||||
for(x = 0; cdr_readonly_vars[x]; x++) {
|
||||
if (!strcasecmp(name, cdr_readonly_vars[x])) {
|
||||
ast_log(LOG_ERROR, "Attempt to set the '%s' read-only variable!.\n", name);
|
||||
@@ -328,6 +337,9 @@ int ast_cdr_copy_vars(struct ast_cdr *to_cdr, struct ast_cdr *from_cdr)
|
||||
const char *var, *val;
|
||||
int x = 0;
|
||||
|
||||
if (!to_cdr || !from_cdr) /* don't die if one of the pointers is null */
|
||||
return 0;
|
||||
|
||||
headpa = &from_cdr->varshead;
|
||||
headpb = &to_cdr->varshead;
|
||||
|
||||
@@ -403,6 +415,8 @@ void ast_cdr_free_vars(struct ast_cdr *cdr, int recur)
|
||||
/*! \brief print a warning if cdr already posted */
|
||||
static void check_post(struct ast_cdr *cdr)
|
||||
{
|
||||
if (!cdr)
|
||||
return;
|
||||
if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
|
||||
ast_log(LOG_NOTICE, "CDR on channel '%s' already posted\n", S_OR(cdr->channel, "<unknown>"));
|
||||
}
|
||||
@@ -410,6 +424,8 @@ static void check_post(struct ast_cdr *cdr)
|
||||
/*! \brief print a warning if cdr already started */
|
||||
static void check_start(struct ast_cdr *cdr)
|
||||
{
|
||||
if (!cdr)
|
||||
return;
|
||||
if (!ast_tvzero(cdr->start))
|
||||
ast_log(LOG_NOTICE, "CDR on channel '%s' already started\n", S_OR(cdr->channel, "<unknown>"));
|
||||
}
|
||||
@@ -447,7 +463,10 @@ void ast_cdr_discard(struct ast_cdr *cdr)
|
||||
|
||||
struct ast_cdr *ast_cdr_alloc(void)
|
||||
{
|
||||
return ast_calloc(1, sizeof(struct ast_cdr));
|
||||
struct ast_cdr *x = ast_calloc(1, sizeof(struct ast_cdr));
|
||||
if (!x)
|
||||
ast_log(LOG_ERROR,"Allocation Failure for a CDR!\n");
|
||||
return x;
|
||||
}
|
||||
|
||||
void ast_cdr_merge(struct ast_cdr *to, struct ast_cdr *from)
|
||||
@@ -646,7 +665,8 @@ static void set_one_cid(struct ast_cdr *cdr, struct ast_channel *c)
|
||||
{
|
||||
/* Grab source from ANI or normal Caller*ID */
|
||||
const char *num = S_OR(c->cid.cid_ani, c->cid.cid_num);
|
||||
|
||||
if (!cdr)
|
||||
return;
|
||||
if (!ast_strlen_zero(c->cid.cid_name)) {
|
||||
if (!ast_strlen_zero(num)) /* both name and number */
|
||||
snprintf(cdr->clid, sizeof(cdr->clid), "\"%s\" <%s>", c->cid.cid_name, num);
|
||||
@@ -997,6 +1017,9 @@ void ast_cdr_detach(struct ast_cdr *cdr)
|
||||
struct ast_cdr_batch_item *newtail;
|
||||
int curr;
|
||||
|
||||
if (!cdr)
|
||||
return;
|
||||
|
||||
/* maybe they disabled CDR stuff completely, so just drop it */
|
||||
if (!enabled) {
|
||||
if (option_debug)
|
||||
|
Reference in New Issue
Block a user