aboutsummaryrefslogtreecommitdiffstats
path: root/cdr
diff options
context:
space:
mode:
authorjeremy <jeremy@f38db490-d61c-443f-a65b-d21fe96a405b>2004-01-11 18:23:33 +0000
committerjeremy <jeremy@f38db490-d61c-443f-a65b-d21fe96a405b>2004-01-11 18:23:33 +0000
commit58cc160e47cb9ac9c2d79e51f9fa447df1778736 (patch)
tree2a7a648fe105eb684570d522b9c76b25b392af08 /cdr
parent52f5e66e3f02da31d4e565ee7fd0b4a79e3026eb (diff)
Add userfield logging
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1948 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'cdr')
-rwxr-xr-xcdr/cdr_pgsql.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/cdr/cdr_pgsql.c b/cdr/cdr_pgsql.c
index d17d3f946..ce8710af2 100755
--- a/cdr/cdr_pgsql.c
+++ b/cdr/cdr_pgsql.c
@@ -76,7 +76,7 @@ static int pgsql_log(struct ast_cdr *cdr)
if (connected) {
char *clid=NULL, *dcontext=NULL, *channel=NULL, *dstchannel=NULL, *lastapp=NULL, *lastdata=NULL;
- char *uniqueid=NULL;
+ char *uniqueid=NULL, *userfield=NULL;
/* Maximum space needed would be if all characters needed to be escaped, plus a trailing NULL */
if ((clid = alloca(strlen(cdr->clid) * 2 + 1)) != NULL)
@@ -93,9 +93,11 @@ static int pgsql_log(struct ast_cdr *cdr)
PQescapeString(lastdata, cdr->lastdata, strlen(cdr->lastdata));
if ((uniqueid = alloca(strlen(cdr->uniqueid) * 2 + 1)) != NULL)
PQescapeString(uniqueid, cdr->uniqueid, strlen(cdr->uniqueid));
+ if ((userfield = alloca(strlen(cdr->userfield) * 2 + 1)) !+ NULL)
+ PQescapeString(userfield, cdr->userfield, strlen(cdr->userfield));
/* Check for all alloca failures above at once */
- if ((!clid) || (!dcontext) || (!channel) || (!dstchannel) || (!lastapp) || (!lastdata) || (!uniqueid)) {
+ if ((!clid) || (!dcontext) || (!channel) || (!dstchannel) || (!lastapp) || (!lastdata) || (!uniqueid) || (!userfield)) {
ast_log(LOG_ERROR, "cdr_pgsql: Out of memory error (insert fails)\n");
ast_mutex_unlock(&pgsql_lock);
return -1;
@@ -103,7 +105,7 @@ static int pgsql_log(struct ast_cdr *cdr)
ast_log(LOG_DEBUG,"cdr_pgsql: inserting a CDR record.\n");
- sprintf(sqlcmd,"INSERT INTO cdr (calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,duration,billsec,disposition,amaflags,accountcode,uniqueid) VALUES ('%s','%s','%s','%s','%s', '%s','%s','%s','%s',%i,%i,'%s',%i,'%s','%s')",timestr,clid,cdr->src, cdr->dst, dcontext,channel, dstchannel, lastapp, lastdata,cdr->duration,cdr->billsec,ast_cdr_disp2str(cdr->disposition),cdr->amaflags, cdr->accountcode, uniqueid);
+ sprintf(sqlcmd,"INSERT INTO cdr (calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,duration,billsec,disposition,amaflags,accountcode,uniqueid,userfield) VALUES ('%s','%s','%s','%s','%s', '%s','%s','%s','%s',%i,%i,'%s',%i,'%s','%s','%s')",timestr,clid,cdr->src, cdr->dst, dcontext,channel, dstchannel, lastapp, lastdata,cdr->duration,cdr->billsec,ast_cdr_disp2str(cdr->disposition),cdr->amaflags, cdr->accountcode, uniqueid, userfield);
ast_log(LOG_DEBUG,"cdr_pgsql: SQL command executed: %s\n",sqlcmd);
/* Test to be sure we're still connected... */