diff options
author | Jeremy Harris <jgh146exb@wizmail.org> | 2012-04-23 21:03:46 +0100 |
---|---|---|
committer | Jeremy Harris <jgh146exb@wizmail.org> | 2012-05-17 22:27:04 +0100 |
commit | f57879265211e8eee3f8e231287c71b66167afee (patch) | |
tree | 7905f15ed5a6fb4b6a9b2b3e663870fe2434d388 /src | |
parent | 75fe387d4b7dd458b79fc22d593095cd84ca8ea4 (diff) |
Support expansion variable for hi-res timestamp (bug 1172).
Diffstat (limited to 'src')
-rw-r--r-- | src/src/expand.c | 5 | ||||
-rw-r--r-- | src/src/macros.h | 2 | ||||
-rw-r--r-- | 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 a571fa526..70fb32c5e 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 9889d6813..f7a22b668 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 c6afb713e..9aa845c82 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; |