[asterisk-commits] russell: branch group/newcdr r201327 - /team/group/newcdr/main/cdr.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jun 17 09:29:28 CDT 2009


Author: russell
Date: Wed Jun 17 09:29:18 2009
New Revision: 201327

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=201327
Log:
BUFSIZ is an irrelevant constant and should not be used like this.

Change to using ast_strdupa() and tweak some formatting.

Modified:
    team/group/newcdr/main/cdr.c

Modified: team/group/newcdr/main/cdr.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/main/cdr.c?view=diff&rev=201327&r1=201326&r2=201327
==============================================================================
--- team/group/newcdr/main/cdr.c (original)
+++ team/group/newcdr/main/cdr.c Wed Jun 17 09:29:18 2009
@@ -942,9 +942,11 @@
 int ast_cdr_setaccount(struct ast_channel *chan, const char *account)
 {
 	struct ast_cdr *cdr = chan->cdr;
-	char buf[BUFSIZ/2] = "";
-	if (!ast_strlen_zero(chan->accountcode))
-		ast_copy_string(buf, chan->accountcode, sizeof(buf));
+	const char *old_acct = "";
+
+	if (!ast_strlen_zero(chan->accountcode)) {
+		old_acct = ast_strdupa(chan->accountcode);
+	}
 
 	ast_string_field_set(chan, accountcode, account);
 	for ( ; cdr ; cdr = cdr->next) {
@@ -953,17 +955,24 @@
 		}
 	}
 
-	/* Signal change of account code to manager */
-	manager_event(EVENT_FLAG_CALL, "NewAccountCode", "Channel: %s\r\nUniqueid: %s\r\nAccountCode: %s\r\nOldAccountCode: %s\r\n", chan->name, chan->uniqueid, chan->accountcode, buf);
+	manager_event(EVENT_FLAG_CALL, "NewAccountCode",
+			"Channel: %s\r\n"
+			"Uniqueid: %s\r\n"
+			"AccountCode: %s\r\n"
+			"OldAccountCode: %s\r\n",
+			chan->name, chan->uniqueid, chan->accountcode, old_acct);
+
 	return 0;
 }
 
 int ast_cdr_setpeeraccount(struct ast_channel *chan, const char *account)
 {
 	struct ast_cdr *cdr = chan->cdr;
-	char buf[BUFSIZ/2] = "";
-	if (!ast_strlen_zero(chan->peeraccount))
-		ast_copy_string(buf, chan->peeraccount, sizeof(buf));
+	const char *old_acct = "";
+
+	if (!ast_strlen_zero(chan->peeraccount)) {
+		old_acct = ast_strdupa(chan->peeraccount);
+	}
 
 	ast_string_field_set(chan, peeraccount, account);
 	for ( ; cdr ; cdr = cdr->next) {
@@ -972,8 +981,13 @@
 		}
 	}
 
-	/* Signal change of account code to manager */
-	manager_event(EVENT_FLAG_CALL, "NewPeerAccount", "Channel: %s\r\nUniqueid: %s\r\nPeerAccount: %s\r\nOldPeerAccount: %s\r\n", chan->name, chan->uniqueid, chan->peeraccount, buf);
+	manager_event(EVENT_FLAG_CALL, "NewPeerAccount",
+			"Channel: %s\r\n"
+			"Uniqueid: %s\r\n"
+			"PeerAccount: %s\r\n"
+			"OldPeerAccount: %s\r\n",
+			chan->name, chan->uniqueid, chan->peeraccount, old_acct);
+
 	return 0;
 }
 




More information about the asterisk-commits mailing list