[exim-dev] [Bug 458] Various expansion items and conditions …

Page principale
Supprimer ce message
Répondre à ce message
Auteur: bug458
Date:  
À: exim-dev
Anciens-sujets: [exim-dev] [Bug 458] New: Expansion condition: forall and/or forany
Sujet: [exim-dev] [Bug 458] Various expansion items and conditions iterating over lists
------- You are receiving this mail because: -------
You are the QA contact for the bug, or are watching the QA contact.

http://www.exim.org/bugzilla/show_bug.cgi?id=458


holmgren@??? changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #68 is|0                           |1
           obsolete|                            |





------- Comment #18 from holmgren@??? 2007-02-10 23:27 -------
Created an attachment (id=69)
--> (http://www.exim.org/bugzilla/attachment.cgi?id=69&action=view)
Now with "reduce" too.

${reduce {<list>}{<start>}{<expr>}} reduces a list to a scalar value by
combining two values at a time. I borrow $value for the running value; it is
initially set to <start>, then for each list element, $item is set to it like
before, and then $value is updated to the value of <expr>. If expansion of
<expr> is forced to fail, the item is simply skipped. Summation can be
implemented as ${reduce {<list>}{0}{${eval:$value+$item}}} and "max" as
${reduce {<list>}{0}{${if >{$item}{$value}{$item}{$value}}}} (if all items are
positive).

Now to solve Simon's problem...

${reduce
    {${map {${addresses:$recipients}}
           {${lookup {${domain:$item}}lsearch{/etc/exim/conf/domains}
                     {${lookup {${local_part:$item}}partial0-lsearch
                                       {/etc/exim/conf/${domain:$item}/acls}
                               {${lookup {$value}lsearch*
                                                 {/etc/exim/conf/acls/spam}
                                         {${extract
{reject}{$value}{$value}{0}}}
                                         {0}}}
                               {0}}}
                     {0}}}
           }}
    {0}
    {${if >{$item}{$value}{$item}{$value}}}
}


(Line-continuation backslashes omitted.)

Slightly better, I'd say, if it works.

--
Configure bugmail: http://www.exim.org/bugzilla/userprefs.cgi?tab=email