From: Jeremy Harris Date: Mon, 23 Apr 2012 20:03:46 +0000 (+0100) Subject: Support expansion variable for hi-res timestamp (bug 1172). X-Git-Tag: exim-4_80_RC1~5 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f57879265211e8eee3f8e231287c71b66167afee;p=exim.git Support expansion variable for hi-res timestamp (bug 1172). --- 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;