[asterisk-commits] seanbright: trunk r140821 - /trunk/cdr/cdr_sqlite.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Sep 3 08:48:12 CDT 2008


Author: seanbright
Date: Wed Sep  3 08:48:12 2008
New Revision: 140821

URL: http://svn.digium.com/view/asterisk?view=rev&rev=140821
Log:
Move some duplicated code into a separate function.

Also try to do some wacky stuff in the commit message, like:
a newline \n
a bell \a
a tab \t
a format specification %p

That is all.

Modified:
    trunk/cdr/cdr_sqlite.c

Modified: trunk/cdr/cdr_sqlite.c
URL: http://svn.digium.com/view/asterisk/trunk/cdr/cdr_sqlite.c?view=diff&rev=140821&r1=140820&r2=140821
==============================================================================
--- trunk/cdr/cdr_sqlite.c (original)
+++ trunk/cdr/cdr_sqlite.c Wed Sep  3 08:48:12 2008
@@ -87,24 +87,26 @@
 #endif
 ");";
 
+static void format_date(char *buffer, size_t length, struct timeval *when)
+{
+	struct ast_tm tm;
+
+	ast_localtime(when, &tm, NULL);
+	ast_strftime(buffer, length, DATE_FORMAT, &tm);
+}
+
 static int sqlite_log(struct ast_cdr *cdr)
 {
 	int res = 0;
 	char *zErr = 0;
-	struct ast_tm tm;
 	char startstr[80], answerstr[80], endstr[80];
 	int count;
 
 	ast_mutex_lock(&sqlite_lock);
 
-	ast_localtime(&cdr->start, &tm, NULL);
-	ast_strftime(startstr, sizeof(startstr), DATE_FORMAT, &tm);
-
-	ast_localtime(&cdr->answer, &tm, NULL);
-	ast_strftime(answerstr, sizeof(answerstr), DATE_FORMAT, &tm);
-
-	ast_localtime(&cdr->end, &tm, NULL);
-	ast_strftime(endstr, sizeof(endstr), DATE_FORMAT, &tm);
+	format_date(startstr, sizeof(startstr), &cdr->start);
+	format_date(answerstr, sizeof(answerstr), &cdr->answer);
+	format_date(endstr, sizeof(endstr), &cdr->end);
 
 	for(count=0; count<5; count++) {
 		res = sqlite_exec_printf(db,




More information about the asterisk-commits mailing list