Re: [Exim] need help with a condition

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Peter N Lewis
Datum:  
To: exim-users
Betreff: Re: [Exim] need help with a condition
At 18:14 +0800 12/7/02, Peter N Lewis wrote:
>At 10:38 +0200 12/7/02, Nico Erfurth wrote:
>
>>Sometimes the exim-expansion can be VERY confusing ;)
>
>Definitely!
>
>Has anyone considered writing an exim condition compiler?


Ok, putting my money where my mouth is, I've made a start on this.

I wrote a Perl script will compile simple expressions into exim
expressions Here are some examples:

if $message_age < 300 then 1 else 0

Result: ${if <{$message_age}{300}{1}{0}}


if    !def('sender_host_address')  then 0 else 1


Result: ${if !def:sender_host_address{0}{1}}


if    $header('X-Stairways-Local') eq 'yes'  then 0 else 1


Result: ${if eq{$header_X-Stairways-Local:}{yes}{0}{1}}

if (($message_age < 300) & (exists('/var/lock/MASTER'))) |
(!defheader('X-delayed') & !(exists('/var/lock/MASTER'))) then 1 else 0

Result: ${if or {{and
{{<{$message_age}{300}}{exists{/var/lock/MASTER}}}}{and
{{!def:header_X-delayed:}{!exists{/var/lock/MASTER}}}}}{1}{0}}


if    !def('sender_host_address')
      | ($sender_host_address eq "127.0.0.1")
      | ($lc($header('X-Stairways-Local')) eq 'yes') then 0 else 1


Result: ${if or
{{!def:sender_host_address}{eq{$sender_host_address}{127.0.0.1}}{eq{${lc:$header_X-Stairways-Local:}}{yes}}}{0}{1}}

Notes:

Strings must be quoted with single or double quotes. No expansion is done, and
quotes cannot contain the quotation mark used.
Functions that return a string are stated as $func(params)
Functions that return a condition are stated as func(params)

Caveats:

Not much testing (all the above run through exim -be, but whether
they are correct I could not say!).

No documentation.

The script is available from <http://www.peter.com.au/macosx/#exim-comp>

Hopefully it'll be useful to someone,
    Peter.


--
<http://www.interarchy.com/> <http://download.interarchy.com/>