[exim-cvs] Support expansion variable for hi-res timestamp (…

Αρχική Σελίδα
Delete this message
Reply to this message
Συντάκτης: Exim Git Commits Mailing List
Ημερομηνία:  
Προς: exim-cvs
Αντικείμενο: [exim-cvs] Support expansion variable for hi-res timestamp (bug 1172).
Gitweb: http://git.exim.org/exim.git/commitdiff/f57879265211e8eee3f8e231287c71b66167afee
Commit:     f57879265211e8eee3f8e231287c71b66167afee
Parent:     75fe387d4b7dd458b79fc22d593095cd84ca8ea4
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Mon Apr 23 21:03:46 2012 +0100
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Thu May 17 22:27:04 2012 +0100


    Support expansion variable for hi-res timestamp (bug 1172).
---
 src/src/expand.c |    5 +++++
 src/src/macros.h |    2 +-
 src/src/tod.c    |   13 ++++++++++++-
 3 files changed, 18 insertions(+), 2 deletions(-)


diff --git a/src/src/expand.c b/src/src/expand.c
index a571fa5..70fb32c 100644
--- a/src/src/expand.c
+++ b/src/src/expand.c
@@ -363,6 +363,7 @@ enum {
                         /* local_scan()) */
   vtype_todbsdin,       /* value not used; generate BSD inbox tod */
   vtype_tode,           /* value not used; generate tod in epoch format */
+  vtype_todel,          /* value not used; generate tod in epoch/usec format */
   vtype_todf,           /* value not used; generate full tod */
   vtype_todl,           /* value not used; generate log tod */
   vtype_todlf,          /* value not used; generate log file datestamp tod */
@@ -620,6 +621,7 @@ static var_entry var_table[] = {
 #endif
   { "tod_bsdinbox",        vtype_todbsdin,    NULL },
   { "tod_epoch",           vtype_tode,        NULL },
+  { "tod_epoch_l",         vtype_todel,       NULL },
   { "tod_full",            vtype_todf,        NULL },
   { "tod_log",             vtype_todl,        NULL },
   { "tod_logfile",         vtype_todlf,       NULL },
@@ -1589,6 +1591,9 @@ while (last > first)
     case vtype_tode:                           /* Unix epoch time of day */
     return tod_stamp(tod_epoch);


+    case vtype_todel:                          /* Unix epoch/usec time of day */
+    return tod_stamp(tod_epoch_l);
+
     case vtype_todf:                           /* Full time of day */
     return tod_stamp(tod_full);


diff --git a/src/src/macros.h b/src/src/macros.h
index 9889d68..f7a22b6 100644
--- a/src/src/macros.h
+++ b/src/src/macros.h
@@ -196,7 +196,7 @@ enum { RESET_NEXT, RESET_ANSWERS, RESET_AUTHORITY, RESET_ADDITIONAL };

 enum { tod_log, tod_log_bare, tod_log_zone, tod_log_datestamp_daily,
        tod_log_datestamp_monthly, tod_zone, tod_full, tod_bsdin,
-       tod_mbx, tod_epoch, tod_zulu };
+       tod_mbx, tod_epoch, tod_epoch_l, tod_zulu };


/* For identifying types of driver */

diff --git a/src/src/tod.c b/src/src/tod.c
index c6afb71..9aa845c 100644
--- a/src/src/tod.c
+++ b/src/src/tod.c
@@ -34,6 +34,7 @@ option.
 Argument:  type of timestamp required:
              tod_bsdin                  BSD inbox format
              tod_epoch                  Unix epoch format
+             tod_epochl                 Unix epoch/usec format
              tod_full                   full date and time
              tod_log                    log file data line format,
                                           with zone if log_timezone is TRUE
@@ -51,9 +52,19 @@ Returns:   pointer to fixed buffer containing the timestamp
 uschar *
 tod_stamp(int type)
 {
-time_t now = time(NULL);
+time_t now;
 struct tm *t;


+if (type == tod_epoch_l)
+ {
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ (void) sprintf(CS timebuf, "%ld%06ld", tv.tv_sec, tv.tv_usec ); /* Unix epoch/usec format */
+ return timebuf;
+ }
+
+now = time(NULL);
+
/* Vary log type according to timezone requirement */

if (type == tod_log) type = log_timezone? tod_log_zone : tod_log_bare;