From f90d018c03bbf7d8ac2cd50d33b47bdd7a4bcdf1 Mon Sep 17 00:00:00 2001 From: Philip Hazel Date: Wed, 1 Mar 2006 11:40:51 +0000 Subject: [PATCH] Add ${time_eval: expansion. --- doc/doc-txt/ChangeLog | 4 +++- doc/doc-txt/NewStuff | 5 ++++- src/src/expand.c | 18 +++++++++++++++++- test/scripts/0000-Basic/0002 | 6 ++++++ test/stdout/0002 | 6 ++++++ 5 files changed, 36 insertions(+), 3 deletions(-) diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index ffdc0a165..8b8ec9113 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.318 2006/03/01 11:24:04 ph10 Exp $ +$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.319 2006/03/01 11:40:51 ph10 Exp $ Change log file for Exim from version 4.21 ------------------------------------------- @@ -252,6 +252,8 @@ PH/50 When an Exim quota was set without a file count quota, and mailbox_size information. It now does the scan only if it needs to find either the size of the count of files. +PH/51 Added ${time_eval: to convert Exim time strings into seconds. + Exim version 4.60 ----------------- diff --git a/doc/doc-txt/NewStuff b/doc/doc-txt/NewStuff index d99a1347b..e8792c3fc 100644 --- a/doc/doc-txt/NewStuff +++ b/doc/doc-txt/NewStuff @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/NewStuff,v 1.92 2006/02/28 12:42:47 ph10 Exp $ +$Cambridge: exim/doc/doc-txt/NewStuff,v 1.93 2006/03/01 11:40:51 ph10 Exp $ New Features in Exim -------------------- @@ -102,6 +102,9 @@ PH/15 The smtp transport has a new option called authenticated_sender_force. When set true, it allows the authenticated_sender option's value to be used, even if Exim has not authenticated as a client. +PH/16 The expansion ${time_eval:} converts an Exim time string such as + 2d4h1m into a number of seconds. + Version 4.60 ------------ diff --git a/src/src/expand.c b/src/src/expand.c index c4932d58d..5d63cb191 100644 --- a/src/src/expand.c +++ b/src/src/expand.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/expand.c,v 1.55 2006/02/28 14:54:54 ph10 Exp $ */ +/* $Cambridge: exim/src/src/expand.c,v 1.56 2006/03/01 11:40:51 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -94,12 +94,14 @@ static uschar *op_table_underscore[] = { US"from_utf8", US"local_part", US"quote_local_part", + US"time_eval", US"time_interval"}; enum { EOP_FROM_UTF8, EOP_LOCAL_PART, EOP_QUOTE_LOCAL_PART, + EOP_TIME_EVAL, EOP_TIME_INTERVAL }; static uschar *op_table_main[] = { @@ -4788,6 +4790,20 @@ while (*s != 0) /* Handle time period formating */ + case EOP_TIME_EVAL: + { + int n = readconf_readtime(sub, 0, FALSE); + if (n < 0) + { + expand_string_message = string_sprintf("string \"%s\" is not an " + "Exim time interval in \"%s\" operator", sub, name); + goto EXPAND_FAILED; + } + sprintf(CS var_buffer, "%d", n); + yield = string_cat(yield, &size, &ptr, var_buffer, Ustrlen(var_buffer)); + continue; + } + case EOP_TIME_INTERVAL: { int n; diff --git a/test/scripts/0000-Basic/0002 b/test/scripts/0000-Basic/0002 index e73b5a84b..7ff379c4f 100644 --- a/test/scripts/0000-Basic/0002 +++ b/test/scripts/0000-Basic/0002 @@ -142,6 +142,12 @@ str2b64:${str2b64:The quick brown \n fox} strlen: ${strlen:} strlen: ${strlen:a} strlen: ${strlen:abcdefgh} +time_eval: ${time_eval:10s} +time_eval: ${time_eval:2h} +time_eval: ${time_eval:1d5m} +time_eval: ${time_eval:1w2d3h4m5s} +time_eval: ${time_eval:14} +time_eval: ${time_eval:rhubarb} time_interval: ${time_interval:0} time_interval: ${time_interval:44} time_interval: ${time_interval:999999} diff --git a/test/stdout/0002 b/test/stdout/0002 index 5cdba5219..8e3c661b3 100644 --- a/test/stdout/0002 +++ b/test/stdout/0002 @@ -123,6 +123,12 @@ > strlen: 0 > strlen: 1 > strlen: 8 +> time_eval: 10 +> time_eval: 7200 +> time_eval: 86700 +> time_eval: 788645 +> Failed: string "14" is not an Exim time interval in "time_eval" operator +> Failed: string "rhubarb" is not an Exim time interval in "time_eval" operator > time_interval: 0s > time_interval: 44s > time_interval: 1w4d13h46m39s -- 2.25.1