[asterisk-commits] seanbright: branch seanbright/cdr-tds-conversion r126059 - /team/seanbright/c...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jun 27 17:17:34 CDT 2008


Author: seanbright
Date: Fri Jun 27 17:17:33 2008
New Revision: 126059

URL: http://svn.digium.com/view/asterisk?view=rev&rev=126059
Log:
Remove some unused variables and cleanup a bit.

Modified:
    team/seanbright/cdr-tds-conversion/cdr/cdr_tds.c

Modified: team/seanbright/cdr-tds-conversion/cdr/cdr_tds.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/cdr-tds-conversion/cdr/cdr_tds.c?view=diff&rev=126059&r1=126058&r2=126059
==============================================================================
--- team/seanbright/cdr-tds-conversion/cdr/cdr_tds.c (original)
+++ team/seanbright/cdr-tds-conversion/cdr/cdr_tds.c Fri Jun 27 17:17:33 2008
@@ -98,7 +98,7 @@
 static struct cdr_tds_config *settings;
 
 static char *anti_injection(const char *, int);
-static void get_date(char *, struct timeval);
+static void get_date(char *, size_t len, struct timeval);
 
 static int mssql_connect(void);
 static int mssql_disconnect(void);
@@ -107,13 +107,11 @@
 
 static int tds_log(struct ast_cdr *cdr)
 {
-	char sqlcmd[2048], start[80], answer[80], end[80];
+	char start[80], answer[80], end[80];
 	char *accountcode, *src, *dst, *dcontext, *clid, *channel, *dstchannel, *lastapp, *lastdata, *uniqueid;
 	RETCODE erc;
 
 	ast_mutex_lock(&tds_lock);
-
-	memset(sqlcmd, 0, 2048);
 
 	accountcode = anti_injection(cdr->accountcode, 20);
 	src = anti_injection(cdr->src, 80);
@@ -126,9 +124,9 @@
 	lastdata = anti_injection(cdr->lastdata, 80);
 	uniqueid = anti_injection(cdr->uniqueid, 32);
 
-	get_date(start, cdr->start);
-	get_date(answer, cdr->answer);
-	get_date(end, cdr->end);
+	get_date(start, 80, cdr->start);
+	get_date(answer, 80, cdr->answer);
+	get_date(end, 80, cdr->end);
 
 	/* Ensure that we are connected */
 	if (!settings->connected) {
@@ -270,25 +268,23 @@
 	return buf;
 }
 
-static void get_date(char *dateField, struct timeval tv)
-{
-	struct ast_tm tm;
-	char buf[80];
-
+static void get_date(char *dateField, size_t len, struct timeval tv)
+{
 	/* To make sure we have date variable if not insert null to SQL */
 	if (!ast_tvzero(tv)) {
+		struct ast_tm tm;
 		ast_localtime(&tv, &tm, NULL);
-		ast_strftime(buf, 80, DATE_FORMAT, &tm);
-		sprintf(dateField, "'%s'", buf);
-	} else {
-		strcpy(dateField, "null");
+		ast_strftime(dateField, len, DATE_FORMAT, &tm);
+	} else {
+		ast_copy_string(dateField, "null", len);
 	}
 }
 
 static int mssql_disconnect(void)
 {
-	if (!settings)
+	if (!settings) {
 		return 0;
+	}
 
 	if (settings->dbproc) {
 		dbclose(settings->dbproc);
@@ -371,7 +367,8 @@
 
 static int tds_message_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *procname, int line)
 {
-	ast_log(LOG_NOTICE, "Msg %d, Level %d, State %d, Line %d\n%s\n", msgno, severity, msgstate, line, msgtext);
+	ast_log(LOG_NOTICE, "Msg %d, Level %d, State %d, Line %d\n", msgno, severity, msgstate, line);
+	ast_log(LOG_NOTICE, "%s\n", msgtext);
 
 	return 0;
 }




More information about the asterisk-commits mailing list