Add ${time_eval: expansion.
authorPhilip Hazel <ph10@hermes.cam.ac.uk>
Wed, 1 Mar 2006 11:40:51 +0000 (11:40 +0000)
committerPhilip Hazel <ph10@hermes.cam.ac.uk>
Wed, 1 Mar 2006 11:40:51 +0000 (11:40 +0000)
doc/doc-txt/ChangeLog
doc/doc-txt/NewStuff
src/src/expand.c
test/scripts/0000-Basic/0002
test/stdout/0002

index ffdc0a165857a59cafc034bfbc7f3238b266b94f..8b8ec9113e62b5c1abc85ef2e899bef7ba8c7fee 100644 (file)
@@ -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
 -------------------------------------------
 
 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.
 
       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
 -----------------
 
 Exim version 4.60
 -----------------
index d99a1347bea08cbbce0c0bc10f9dc8ce705f6e75..e8792c3fcfd9c363155a7fa9f5ff792d0768adec 100644 (file)
@@ -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
 --------------------
 
 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.
 
       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:<string>} converts an Exim time string such as
+      2d4h1m into a number of seconds.
+
 
 Version 4.60
 ------------
 
 Version 4.60
 ------------
index c4932d58d503f6b50782743bd40f01153b5d0409..5d63cb1913ab688ddfb93cdbcbd8e8a643cca4d4 100644 (file)
@@ -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    *
 
 /*************************************************
 *     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"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,
   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[] = {
   EOP_TIME_INTERVAL };
 
 static uschar *op_table_main[] = {
@@ -4788,6 +4790,20 @@ while (*s != 0)
 
       /* Handle time period formating */
 
 
       /* 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;
       case EOP_TIME_INTERVAL:
         {
         int n;
index e73b5a84b47108968e64ae1ebfd8656dbc35ba38..7ff379c4f3a8529cdfd5462cf348da0f6223b03d 100644 (file)
@@ -142,6 +142,12 @@ str2b64:${str2b64:The quick brown \n fox}
 strlen: ${strlen:}
 strlen: ${strlen:a}
 strlen: ${strlen:abcdefgh}
 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}
 time_interval: ${time_interval:0}
 time_interval: ${time_interval:44}
 time_interval: ${time_interval:999999}
index 5cdba5219bcdb3399cf156f4397b61e8bc862907..8e3c661b33a245ade48e4d9a9ec9cb1db17d5668 100644 (file)
 > strlen: 0
 > strlen: 1
 > strlen: 8
 > 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
 > time_interval: 0s
 > time_interval: 44s
 > time_interval: 1w4d13h46m39s