aboutsummaryrefslogtreecommitdiffstats
path: root/cdr
diff options
context:
space:
mode:
authorseanbright <seanbright@f38db490-d61c-443f-a65b-d21fe96a405b>2008-09-03 13:48:12 +0000
committerseanbright <seanbright@f38db490-d61c-443f-a65b-d21fe96a405b>2008-09-03 13:48:12 +0000
commit706602fc520d237c45cf0b17c5b55a681c879263 (patch)
tree6bd33073c10b4c9d3ed04e796027034ebdd84e0a /cdr
parent49e43b7f6e91b6f685a5a95337c6ea4f22a91fe8 (diff)
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. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@140821 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'cdr')
-rw-r--r--cdr/cdr_sqlite.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/cdr/cdr_sqlite.c b/cdr/cdr_sqlite.c
index 601e5b245..4a3c9406d 100644
--- a/cdr/cdr_sqlite.c
+++ b/cdr/cdr_sqlite.c
@@ -87,24 +87,26 @@ static char sql_create_table[] = "CREATE TABLE cdr ("
#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,