]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
use ast_localtime() in every place localtime_r() was being used
authorKevin P. Fleming <kpfleming@digium.com>
Thu, 14 Jun 2007 21:50:40 +0000 (21:50 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Thu, 14 Jun 2007 21:50:40 +0000 (21:50 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@69392 65c4cc65-6c06-0410-ace0-fbb531ad65f3

18 files changed:
apps/app_voicemail.c
cdr/cdr_csv.c
cdr/cdr_manager.c
cdr/cdr_odbc.c
cdr/cdr_pgsql.c
cdr/cdr_radius.c
cdr/cdr_sqlite.c
cdr/cdr_tds.c
channels/chan_iax2.c
channels/chan_mgcp.c
channels/chan_phone.c
include/asterisk/utils.h
main/asterisk.c
main/callerid.c
main/cdr.c
main/logger.c
main/pbx.c
main/say.c

index 01dbbfb993113d6ea58bdda1a915bf64a783e4d6..c585c2e5acafd219c660b4f90aedf183d3feabe7 100644 (file)
@@ -2111,7 +2111,7 @@ static int get_date(char *s, int len)
        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 @@ static int play_message_datetime(struct ast_channel *chan, struct ast_vm_user *v
 /* 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)
index 350620315517e31935f43588354d73ef48a92aed..5475398acb90521ae6e53cafe1e2e61568f771ab 100644 (file)
@@ -199,7 +199,7 @@ static int append_date(char *buf, struct timeval tv, size_t bufsize)
        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);
index bd6ef67098b8d2e3e91a8ba0aae280eabf333f34..352d7d400deaaffccc0643a4b28ce0b8a36fb61b 100644 (file)
@@ -95,17 +95,17 @@ static int manager_log(struct ast_cdr *cdr)
                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",
index db93eac55da1f91d95b7bdbde0f7bd6cb981aaef..4afda0e8edfd10a568cc1a1b0f9036f35671e647 100644 (file)
@@ -99,7 +99,7 @@ static int odbc_log(struct ast_cdr *cdr)
        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);
index dd43b45ba36531761f535f1a8ce0ef3b5dd613a5..7788cf037912c1981a8272d1eab1f770b691cdee 100644 (file)
@@ -77,7 +77,7 @@ static int pgsql_log(struct ast_cdr *cdr)
 
        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) {
index 9f9a4470a53fc035313c9ac7cd417a160fbad67f..6d890e7646b6d9c3af9954b45fed6f65055a56c0 100644 (file)
@@ -145,7 +145,7 @@ static int build_radius_record(VALUE_PAIR **send, struct ast_cdr *cdr)
        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 @@ static int build_radius_record(VALUE_PAIR **send, struct ast_cdr *cdr)
        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 @@ static int build_radius_record(VALUE_PAIR **send, struct ast_cdr *cdr)
        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;
index 146f7a20927b3bcc5688870de775c472821fa841..5aa8a515489b863f0854384c12fcdaf362f3cf4c 100644 (file)
@@ -101,15 +101,15 @@ static int sqlite_log(struct ast_cdr *cdr)
        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++) {
index 2ac8481a825483a0684f8fcda102eb94b57f66f2..444751d1a9d22f1b135612c7fa7ab8eea8e7ff81 100644 (file)
@@ -286,7 +286,7 @@ static void get_date(char *dateField, struct timeval tv)
        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);
        }
index 64a43df9815098a8534caede0ea2805681ebd7b7..d3e0a7e709f5c76e6067eb0ea70d80274899d1f8 100644 (file)
@@ -2761,9 +2761,10 @@ static unsigned int iax2_datetime(const char *tz)
        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 */
index 079c6b56eb5eb4e8ff1a4a2932a35c2040817f48..bda08d7a3fb1fe8fc27d16710e964743b92f82a6 100644 (file)
@@ -2214,7 +2214,7 @@ static int transmit_notify_request_with_callerid(struct mgcp_subchannel *sub, ch
        struct mgcp_endpoint *p = sub->parent;
        
        time(&t);
-       localtime_r(&t,&tm);
+       ast_localtime(&t, &tm, NULL);
        n = callername;
        l = callernum;
        if (!n)
index 961ec78b34a1dc5e3642f671851c4ba6457f26dd..d5b4500a9dd813842c46d112588d8f064d323c02 100644 (file)
@@ -295,7 +295,7 @@ static int phone_call(struct ast_channel *ast, char *dest, int timeout)
        int start;
 
        time(&UtcTime);
-       localtime_r(&UtcTime,&tm);
+       ast_localtime(&UtcTime, &tm, NULL);
 
        memset(&cid, 0, sizeof(PHONE_CID));
        if(&tm != NULL) {
index 1183876e94b21432d591fbe357be3c62a752569e..1e5203671eaeaff39e8be5f9311912d0d6dc1b6e 100644 (file)
 #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 @@ const char *ast_inet_ntoa(struct in_addr ia);
 #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);
 
index 7eccefdbfc510ceff80fcb6117600fbb94a5730e..0c36fda6a9bdd651dbd164f39dd4b2aba9285ba5 100644 (file)
@@ -1828,7 +1828,7 @@ static char *cli_prompt(EditLine *el)
                                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 @@ static char *cli_prompt(EditLine *el)
                                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;
index 901137348f643861b585beff3ba4013e987485e6..dfb43c77b6f40c81805bb7ba0589720177218b06 100644 (file)
@@ -720,7 +720,7 @@ static int callerid_genmsg(char *msg, int size, const char *number, const char *
        int i,x;
        /* Get the time */
        time(&t);
-       localtime_r(&t,&tm);
+       ast_localtime(&t, &tm, NULL);
        
        ptr = msg;
        
index ee0fb789e27ad4f6c1285da1759f8e3f6b5409e7..baa1165f825c14a3a0a2eeea61a36d99eb4830d8 100644 (file)
@@ -208,7 +208,8 @@ static void cdr_get_tv(struct timeval tv, const char *fmt, char *buf, int bufsiz
                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);
                }
        }
index cacedee44308acebcef9bfd9089eed5554a2637d..e2291d96615488491338298ad9be22e3f198b445 100644 (file)
@@ -726,7 +726,7 @@ void ast_log(int level, const char *file, int line, const char *function, const
                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 @@ void ast_verbose(const char *fmt, ...)
                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);
index 56e291175a9a7208ea65b3ff3a92ee029b6d8870..73c80ee05916bca3858f5842ba0de803711a1d53 100644 (file)
@@ -4232,7 +4232,7 @@ int ast_check_timing(const struct ast_timing *i)
        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)))
index 4d05848d0f9b68347ba6729e1a80a34d306c6a6f..2c3937c761950acb8d9a8083de1c12984fe1f986 100644 (file)
@@ -2924,8 +2924,8 @@ int ast_say_date_pt(struct ast_channel *chan, time_t t, const char *ints, const
        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 @@ int ast_say_time_en(struct ast_channel *chan, time_t t, const char *ints, const
        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 @@ int ast_say_time_de(struct ast_channel *chan, time_t t, const char *ints, const
 {
        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 @@ int ast_say_time_fr(struct ast_channel *chan, time_t t, const char *ints, const
 {
        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 @@ int ast_say_time_nl(struct ast_channel *chan, time_t t, const char *ints, const
 {
        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 @@ int ast_say_time_pt(struct ast_channel *chan, time_t t, const char *ints, const
        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 @@ int ast_say_time_pt_BR(struct ast_channel *chan, time_t t, const char *ints, con
 {
        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 @@ int ast_say_time_tw(struct ast_channel *chan, time_t t, const char *ints, const
        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 @@ int ast_say_datetime_en(struct ast_channel *chan, time_t t, const char *ints, co
        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 @@ int ast_say_datetime_de(struct ast_channel *chan, time_t t, const char *ints, co
 {
        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 @@ int ast_say_datetime_fr(struct ast_channel *chan, time_t t, const char *ints, co
        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 @@ int ast_say_datetime_nl(struct ast_channel *chan, time_t t, const char *ints, co
 {
        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 @@ int ast_say_datetime_pt(struct ast_channel *chan, time_t t, const char *ints, co
        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 @@ int ast_say_datetime_pt_BR(struct ast_channel *chan, time_t t, const char *ints,
 {
        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 @@ int ast_say_datetime_tw(struct ast_channel *chan, time_t t, const char *ints, co
        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 @@ int ast_say_datetime_from_now_en(struct ast_channel *chan, time_t t, const char
 
        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 @@ int ast_say_datetime_from_now_fr(struct ast_channel *chan, time_t t, const char
 
        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 @@ int ast_say_datetime_from_now_pt(struct ast_channel *chan, time_t t, const char
 
        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 @@ static int ast_say_time_gr(struct ast_channel *chan, time_t t, const char *ints,
        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 @@ static int ast_say_datetime_gr(struct ast_channel *chan, time_t t, const char *i
        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 @@ static int ast_say_time_ge(struct ast_channel *chan, time_t t, const char *ints,
 {
        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 @@ static int ast_say_datetime_ge(struct ast_channel *chan, time_t t, const char *i
 {
        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 @@ static int ast_say_datetime_from_now_ge(struct ast_channel *chan, time_t t, cons
 
        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 */