[asterisk-commits] kpfleming: branch 1.4 r69392 - in /branches/1.4:
apps/ cdr/ channels/ include...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Thu Jun 14 14:50:41 MST 2007
Author: kpfleming
Date: Thu Jun 14 16:50:40 2007
New Revision: 69392
URL: http://svn.digium.com/view/asterisk?view=rev&rev=69392
Log:
use ast_localtime() in every place localtime_r() was being used
Modified:
branches/1.4/apps/app_voicemail.c
branches/1.4/cdr/cdr_csv.c
branches/1.4/cdr/cdr_manager.c
branches/1.4/cdr/cdr_odbc.c
branches/1.4/cdr/cdr_pgsql.c
branches/1.4/cdr/cdr_radius.c
branches/1.4/cdr/cdr_sqlite.c
branches/1.4/cdr/cdr_tds.c
branches/1.4/channels/chan_iax2.c
branches/1.4/channels/chan_mgcp.c
branches/1.4/channels/chan_phone.c
branches/1.4/include/asterisk/utils.h
branches/1.4/main/asterisk.c
branches/1.4/main/callerid.c
branches/1.4/main/cdr.c
branches/1.4/main/logger.c
branches/1.4/main/pbx.c
branches/1.4/main/say.c
Modified: branches/1.4/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/apps/app_voicemail.c?view=diff&rev=69392&r1=69391&r2=69392
==============================================================================
--- branches/1.4/apps/app_voicemail.c (original)
+++ branches/1.4/apps/app_voicemail.c Thu Jun 14 16:50:40 2007
@@ -2111,7 +2111,7 @@
struct tm tm;
time_t t;
t = time(0);
- localtime_r(&t,&tm);
+ ast_localtime(&t, &tm, NULL);
return strftime(s, len, "%a %b %e %r %Z %Y", &tm);
}
@@ -4223,10 +4223,10 @@
/* No internal variable parsing for now, so we'll comment it out for the time being */
#if 0
/* Set the DIFF_* variables */
- localtime_r(&t, &time_now);
+ ast_localtime(&t, &time_now, NULL);
tv_now = ast_tvnow();
tnow = tv_now.tv_sec;
- localtime_r(&tnow,&time_then);
+ ast_localtime(&tnow, &time_then, NULL);
/* Day difference */
if (time_now.tm_year == time_then.tm_year)
Modified: branches/1.4/cdr/cdr_csv.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/cdr/cdr_csv.c?view=diff&rev=69392&r1=69391&r2=69392
==============================================================================
--- branches/1.4/cdr/cdr_csv.c (original)
+++ branches/1.4/cdr/cdr_csv.c Thu Jun 14 16:50:40 2007
@@ -199,7 +199,7 @@
if (usegmtime) {
gmtime_r(&t,&tm);
} else {
- localtime_r(&t,&tm);
+ ast_localtime(&t, &tm, NULL);
}
strftime(tmp, sizeof(tmp), DATE_FORMAT, &tm);
return append_string(buf, tmp, bufsize);
Modified: branches/1.4/cdr/cdr_manager.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/cdr/cdr_manager.c?view=diff&rev=69392&r1=69391&r2=69392
==============================================================================
--- branches/1.4/cdr/cdr_manager.c (original)
+++ branches/1.4/cdr/cdr_manager.c Thu Jun 14 16:50:40 2007
@@ -95,17 +95,17 @@
return 0;
t = cdr->start.tv_sec;
- localtime_r(&t, &timeresult);
+ ast_localtime(&t, &timeresult, NULL);
strftime(strStartTime, sizeof(strStartTime), DATE_FORMAT, &timeresult);
if (cdr->answer.tv_sec) {
t = cdr->answer.tv_sec;
- localtime_r(&t, &timeresult);
+ ast_localtime(&t, &timeresult, NULL);
strftime(strAnswerTime, sizeof(strAnswerTime), DATE_FORMAT, &timeresult);
}
t = cdr->end.tv_sec;
- localtime_r(&t, &timeresult);
+ ast_localtime(&t, &timeresult, NULL);
strftime(strEndTime, sizeof(strEndTime), DATE_FORMAT, &timeresult);
manager_event(EVENT_FLAG_CALL, "Cdr",
Modified: branches/1.4/cdr/cdr_odbc.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/cdr/cdr_odbc.c?view=diff&rev=69392&r1=69391&r2=69392
==============================================================================
--- branches/1.4/cdr/cdr_odbc.c (original)
+++ branches/1.4/cdr/cdr_odbc.c Thu Jun 14 16:50:40 2007
@@ -99,7 +99,7 @@
if (usegmtime)
gmtime_r(&cdr->start.tv_sec,&tm);
else
- localtime_r(&cdr->start.tv_sec,&tm);
+ ast_localtime(&cdr->start.tv_sec, &tm, NULL);
ast_mutex_lock(&odbc_lock);
strftime(timestr, sizeof(timestr), DATE_FORMAT, &tm);
Modified: branches/1.4/cdr/cdr_pgsql.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/cdr/cdr_pgsql.c?view=diff&rev=69392&r1=69391&r2=69392
==============================================================================
--- branches/1.4/cdr/cdr_pgsql.c (original)
+++ branches/1.4/cdr/cdr_pgsql.c Thu Jun 14 16:50:40 2007
@@ -77,7 +77,7 @@
ast_mutex_lock(&pgsql_lock);
- localtime_r(&cdr->start.tv_sec,&tm);
+ ast_localtime(&cdr->start.tv_sec, &tm, NULL);
strftime(timestr, sizeof(timestr), DATE_FORMAT, &tm);
if ((!connected) && pghostname && pgdbuser && pgpassword && pgdbname) {
Modified: branches/1.4/cdr/cdr_radius.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/cdr/cdr_radius.c?view=diff&rev=69392&r1=69391&r2=69392
==============================================================================
--- branches/1.4/cdr/cdr_radius.c (original)
+++ branches/1.4/cdr/cdr_radius.c Thu Jun 14 16:50:40 2007
@@ -145,7 +145,7 @@
if (ast_test_flag(&global_flags, RADIUS_FLAG_USEGMTIME))
gmtime_r(&(cdr->start.tv_sec), &tm);
else
- localtime_r(&(cdr->start.tv_sec), &tm);
+ ast_localtime(&(cdr->start.tv_sec), &tm, NULL);
strftime(timestr, sizeof(timestr), DATE_FORMAT, &tm);
if (!rc_avpair_add(rh, send, PW_AST_START_TIME, timestr, strlen(timestr), VENDOR_CODE))
return -1;
@@ -154,7 +154,7 @@
if (ast_test_flag(&global_flags, RADIUS_FLAG_USEGMTIME))
gmtime_r(&(cdr->answer.tv_sec), &tm);
else
- localtime_r(&(cdr->answer.tv_sec), &tm);
+ ast_localtime(&(cdr->answer.tv_sec), &tm, NULL);
strftime(timestr, sizeof(timestr), DATE_FORMAT, &tm);
if (!rc_avpair_add(rh, send, PW_AST_ANSWER_TIME, timestr, strlen(timestr), VENDOR_CODE))
return -1;
@@ -163,7 +163,7 @@
if (ast_test_flag(&global_flags, RADIUS_FLAG_USEGMTIME))
gmtime_r(&(cdr->end.tv_sec), &tm);
else
- localtime_r(&(cdr->end.tv_sec), &tm);
+ ast_localtime(&(cdr->end.tv_sec), &tm, NULL);
strftime(timestr, sizeof(timestr), DATE_FORMAT, &tm);
if (!rc_avpair_add(rh, send, PW_AST_END_TIME, timestr, strlen(timestr), VENDOR_CODE))
return -1;
Modified: branches/1.4/cdr/cdr_sqlite.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/cdr/cdr_sqlite.c?view=diff&rev=69392&r1=69391&r2=69392
==============================================================================
--- branches/1.4/cdr/cdr_sqlite.c (original)
+++ branches/1.4/cdr/cdr_sqlite.c Thu Jun 14 16:50:40 2007
@@ -101,15 +101,15 @@
ast_mutex_lock(&sqlite_lock);
t = cdr->start.tv_sec;
- localtime_r(&t, &tm);
+ ast_localtime(&t, &tm, NULL);
strftime(startstr, sizeof(startstr), DATE_FORMAT, &tm);
t = cdr->answer.tv_sec;
- localtime_r(&t, &tm);
+ ast_localtime(&t, &tm, NULL);
strftime(answerstr, sizeof(answerstr), DATE_FORMAT, &tm);
t = cdr->end.tv_sec;
- localtime_r(&t, &tm);
+ ast_localtime(&t, &tm, NULL);
strftime(endstr, sizeof(endstr), DATE_FORMAT, &tm);
for(count=0; count<5; count++) {
Modified: branches/1.4/cdr/cdr_tds.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/cdr/cdr_tds.c?view=diff&rev=69392&r1=69391&r2=69392
==============================================================================
--- branches/1.4/cdr/cdr_tds.c (original)
+++ branches/1.4/cdr/cdr_tds.c Thu Jun 14 16:50:40 2007
@@ -286,7 +286,7 @@
if (!ast_tvzero(tv))
{
t = tv.tv_sec;
- localtime_r(&t, &tm);
+ ast_localtime(&t, &tm, NULL);
strftime(buf, 80, DATE_FORMAT, &tm);
sprintf(dateField, "'%s'", buf);
}
Modified: branches/1.4/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_iax2.c?view=diff&rev=69392&r1=69391&r2=69392
==============================================================================
--- branches/1.4/channels/chan_iax2.c (original)
+++ branches/1.4/channels/chan_iax2.c Thu Jun 14 16:50:40 2007
@@ -2761,9 +2761,10 @@
struct tm tm;
unsigned int tmp;
time(&t);
- localtime_r(&t, &tm);
if (!ast_strlen_zero(tz))
ast_localtime(&t, &tm, tz);
+ else
+ ast_localtime(&t, &tm, NULL);
tmp = (tm.tm_sec >> 1) & 0x1f; /* 5 bits of seconds */
tmp |= (tm.tm_min & 0x3f) << 5; /* 6 bits of minutes */
tmp |= (tm.tm_hour & 0x1f) << 11; /* 5 bits of hours */
Modified: branches/1.4/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_mgcp.c?view=diff&rev=69392&r1=69391&r2=69392
==============================================================================
--- branches/1.4/channels/chan_mgcp.c (original)
+++ branches/1.4/channels/chan_mgcp.c Thu Jun 14 16:50:40 2007
@@ -2214,7 +2214,7 @@
struct mgcp_endpoint *p = sub->parent;
time(&t);
- localtime_r(&t,&tm);
+ ast_localtime(&t, &tm, NULL);
n = callername;
l = callernum;
if (!n)
Modified: branches/1.4/channels/chan_phone.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_phone.c?view=diff&rev=69392&r1=69391&r2=69392
==============================================================================
--- branches/1.4/channels/chan_phone.c (original)
+++ branches/1.4/channels/chan_phone.c Thu Jun 14 16:50:40 2007
@@ -295,7 +295,7 @@
int start;
time(&UtcTime);
- localtime_r(&UtcTime,&tm);
+ ast_localtime(&UtcTime, &tm, NULL);
memset(&cid, 0, sizeof(PHONE_CID));
if(&tm != NULL) {
Modified: branches/1.4/include/asterisk/utils.h
URL: http://svn.digium.com/view/asterisk/branches/1.4/include/asterisk/utils.h?view=diff&rev=69392&r1=69391&r2=69392
==============================================================================
--- branches/1.4/include/asterisk/utils.h (original)
+++ branches/1.4/include/asterisk/utils.h Thu Jun 14 16:50:40 2007
@@ -32,12 +32,14 @@
#include <arpa/inet.h> /* we want to override inet_ntoa */
#include <netdb.h>
#include <limits.h>
+#include <time.h> /* we want to override localtime_r */
#include "asterisk/lock.h"
#include "asterisk/time.h"
#include "asterisk/strings.h"
#include "asterisk/logger.h"
#include "asterisk/compiler.h"
+#include "asterisk/localtime.h"
/*! \note
\verbatim
@@ -235,6 +237,11 @@
#endif
#define inet_ntoa __dont__use__inet_ntoa__use__ast_inet_ntoa__instead__
+#ifdef localtime_r
+#undef localtime_r
+#endif
+#define localtime_r __dont_use_localtime_r_use_ast_localtime_instead__
+
int ast_utils_init(void);
int ast_wait_for_input(int fd, int ms);
Modified: branches/1.4/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/asterisk.c?view=diff&rev=69392&r1=69391&r2=69392
==============================================================================
--- branches/1.4/main/asterisk.c (original)
+++ branches/1.4/main/asterisk.c Thu Jun 14 16:50:40 2007
@@ -1828,7 +1828,7 @@
case 'd': /* date */
memset(&tm, 0, sizeof(tm));
time(&ts);
- if (localtime_r(&ts, &tm)) {
+ if (ast_localtime(&ts, &tm, NULL)) {
strftime(p, sizeof(prompt) - strlen(prompt), "%Y-%m-%d", &tm);
}
break;
@@ -1888,7 +1888,7 @@
case 't': /* time */
memset(&tm, 0, sizeof(tm));
time(&ts);
- if (localtime_r(&ts, &tm)) {
+ if (ast_localtime(&ts, &tm, NULL)) {
strftime(p, sizeof(prompt) - strlen(prompt), "%H:%M:%S", &tm);
}
break;
Modified: branches/1.4/main/callerid.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/callerid.c?view=diff&rev=69392&r1=69391&r2=69392
==============================================================================
--- branches/1.4/main/callerid.c (original)
+++ branches/1.4/main/callerid.c Thu Jun 14 16:50:40 2007
@@ -720,7 +720,7 @@
int i,x;
/* Get the time */
time(&t);
- localtime_r(&t,&tm);
+ ast_localtime(&t, &tm, NULL);
ptr = msg;
Modified: branches/1.4/main/cdr.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/cdr.c?view=diff&rev=69392&r1=69391&r2=69392
==============================================================================
--- branches/1.4/main/cdr.c (original)
+++ branches/1.4/main/cdr.c Thu Jun 14 16:50:40 2007
@@ -208,7 +208,8 @@
time_t t = tv.tv_sec;
if (t) {
struct tm tm;
- localtime_r(&t, &tm);
+
+ ast_localtime(&t, &tm, NULL);
strftime(buf, bufsize, fmt, &tm);
}
}
Modified: branches/1.4/main/logger.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/logger.c?view=diff&rev=69392&r1=69391&r2=69392
==============================================================================
--- branches/1.4/main/logger.c (original)
+++ branches/1.4/main/logger.c Thu Jun 14 16:50:40 2007
@@ -726,7 +726,7 @@
return;
time(&t);
- localtime_r(&t, &tm);
+ ast_localtime(&t, &tm, NULL);
strftime(date, sizeof(date), dateformat, &tm);
AST_LIST_LOCK(&logchannels);
@@ -860,7 +860,7 @@
char *datefmt;
time(&t);
- localtime_r(&t, &tm);
+ ast_localtime(&t, &tm, NULL);
strftime(date, sizeof(date), dateformat, &tm);
datefmt = alloca(strlen(date) + 3 + strlen(fmt) + 1);
sprintf(datefmt, "[%s] %s", date, fmt);
Modified: branches/1.4/main/pbx.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/pbx.c?view=diff&rev=69392&r1=69391&r2=69392
==============================================================================
--- branches/1.4/main/pbx.c (original)
+++ branches/1.4/main/pbx.c Thu Jun 14 16:50:40 2007
@@ -4232,7 +4232,7 @@
struct tm tm;
time_t t = time(NULL);
- localtime_r(&t,&tm);
+ ast_localtime(&t, &tm, NULL);
/* If it's not the right month, return */
if (!(i->monthmask & (1 << tm.tm_mon)))
Modified: branches/1.4/main/say.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/say.c?view=diff&rev=69392&r1=69391&r2=69392
==============================================================================
--- branches/1.4/main/say.c (original)
+++ branches/1.4/main/say.c Thu Jun 14 16:50:40 2007
@@ -2924,8 +2924,8 @@
struct tm tm;
char fn[256];
int res = 0;
- ast_localtime(&t,&tm,NULL);
- localtime_r(&t,&tm);
+
+ ast_localtime(&t, &tm, NULL);
snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
if (!res)
res = wait_file(chan, ints, fn, lang);
@@ -5480,7 +5480,8 @@
struct tm tm;
int res = 0;
int hour, pm=0;
- localtime_r(&t,&tm);
+
+ ast_localtime(&t, &tm, NULL);
hour = tm.tm_hour;
if (!hour)
hour = 12;
@@ -5526,7 +5527,8 @@
{
struct tm tm;
int res = 0;
- localtime_r(&t,&tm);
+
+ ast_localtime(&t, &tm, NULL);
if (!res)
res = ast_say_number(chan, tm.tm_hour, ints, lang, "n");
if (!res)
@@ -5544,7 +5546,8 @@
{
struct tm tm;
int res = 0;
- localtime_r(&t,&tm);
+
+ ast_localtime(&t, &tm, NULL);
res = ast_say_number(chan, tm.tm_hour, ints, lang, "f");
if (!res)
@@ -5561,7 +5564,8 @@
{
struct tm tm;
int res = 0;
- localtime_r(&t,&tm);
+
+ ast_localtime(&t, &tm, NULL);
if (!res)
res = ast_say_number(chan, tm.tm_hour, ints, lang, (char *) NULL);
if (!res)
@@ -5580,7 +5584,8 @@
struct tm tm;
int res = 0;
int hour;
- localtime_r(&t,&tm);
+
+ ast_localtime(&t, &tm, NULL);
hour = tm.tm_hour;
if (!res)
res = ast_say_number(chan, hour, ints, lang, "f");
@@ -5606,7 +5611,8 @@
{
struct tm tm;
int res = 0;
- localtime_r(&t,&tm);
+
+ ast_localtime(&t, &tm, NULL);
res = ast_say_number(chan, tm.tm_hour, ints, lang, "f");
if (!res) {
@@ -5635,7 +5641,8 @@
struct tm tm;
int res = 0;
int hour, pm=0;
- localtime_r(&t,&tm);
+
+ ast_localtime(&t, &tm, NULL);
hour = tm.tm_hour;
if (!hour)
hour = 12;
@@ -5702,7 +5709,8 @@
char fn[256];
int res = 0;
int hour, pm=0;
- localtime_r(&t,&tm);
+
+ ast_localtime(&t, &tm, NULL);
if (!res) {
snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
res = ast_streamfile(chan, fn, lang);
@@ -5765,7 +5773,8 @@
{
struct tm tm;
int res = 0;
- localtime_r(&t,&tm);
+
+ ast_localtime(&t, &tm, NULL);
res = ast_say_date(chan, t, ints, lang);
if (!res)
ast_say_time(chan, t, ints, lang);
@@ -5779,7 +5788,8 @@
struct tm tm;
char fn[256];
int res = 0;
- localtime_r(&t,&tm);
+
+ ast_localtime(&t, &tm, NULL);
if (!res)
res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
@@ -5817,7 +5827,8 @@
{
struct tm tm;
int res = 0;
- localtime_r(&t,&tm);
+
+ ast_localtime(&t, &tm, NULL);
res = ast_say_date(chan, t, ints, lang);
if (!res) {
res = ast_streamfile(chan, "digits/nl-om", lang);
@@ -5836,7 +5847,8 @@
char fn[256];
int res = 0;
int hour, pm=0;
- localtime_r(&t,&tm);
+
+ ast_localtime(&t, &tm, NULL);
if (!res) {
snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
res = ast_streamfile(chan, fn, lang);
@@ -5899,7 +5911,8 @@
{
struct tm tm;
int res = 0;
- localtime_r(&t,&tm);
+
+ ast_localtime(&t, &tm, NULL);
res = ast_say_date(chan, t, ints, lang);
if (!res)
res = ast_say_time(chan, t, ints, lang);
@@ -5913,7 +5926,8 @@
char fn[256];
int res = 0;
int hour, pm=0;
- localtime_r(&t,&tm);
+
+ ast_localtime(&t, &tm, NULL);
if (!res)
res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
if (!res) {
@@ -5992,8 +6006,8 @@
time(&nowt);
- localtime_r(&t,&tm);
- localtime_r(&nowt,&now);
+ ast_localtime(&t, &tm, NULL);
+ ast_localtime(&nowt,&now, NULL);
daydiff = now.tm_yday - tm.tm_yday;
if ((daydiff < 0) || (daydiff > 6)) {
/* Day of month and month */
@@ -6032,8 +6046,8 @@
time(&nowt);
- localtime_r(&t,&tm);
- localtime_r(&nowt,&now);
+ ast_localtime(&t, &tm, NULL);
+ ast_localtime(&nowt, &now, NULL);
daydiff = now.tm_yday - tm.tm_yday;
if ((daydiff < 0) || (daydiff > 6)) {
/* Day of month and month */
@@ -6072,8 +6086,8 @@
time(&nowt);
- localtime_r(&t,&tm);
- localtime_r(&nowt,&now);
+ ast_localtime(&t, &tm, NULL);
+ ast_localtime(&nowt, &now, NULL);
daydiff = now.tm_yday - tm.tm_yday;
if ((daydiff < 0) || (daydiff > 6)) {
/* Day of month and month */
@@ -6296,7 +6310,7 @@
int res = 0;
int hour, pm=0;
- localtime_r(&t,&tm);
+ ast_localtime(&t, &tm, NULL);
hour = tm.tm_hour;
if (!hour)
@@ -6341,7 +6355,8 @@
struct tm tm;
char fn[256];
int res = 0;
- localtime_r(&t,&tm);
+
+ ast_localtime(&t, &tm, NULL);
/* W E E K - D A Y */
@@ -6829,7 +6844,8 @@
{
struct tm tm;
int res = 0;
- localtime_r(&t,&tm);
+
+ ast_localtime(&t, &tm, NULL);
res = ast_say_number(chan, tm.tm_hour, ints, lang, (char*)NULL);
if (!res) {
@@ -6859,7 +6875,8 @@
{
struct tm tm;
int res = 0;
- localtime_r(&t,&tm);
+
+ ast_localtime(&t, &tm, NULL);
res = ast_say_date(chan, t, ints, lang);
if (!res)
ast_say_time(chan, t, ints, lang);
@@ -6882,8 +6899,8 @@
time(&nowt);
- localtime_r(&t,&tm);
- localtime_r(&nowt,&now);
+ ast_localtime(&t, &tm, NULL);
+ ast_localtime(&nowt, &now, NULL);
daydiff = now.tm_yday - tm.tm_yday;
if ((daydiff < 0) || (daydiff > 6)) {
/* Day of month and month */
More information about the asterisk-commits
mailing list