[exim] Expansion strings for processing maildirsize files

Αρχική Σελίδα
Delete this message
Reply to this message
Συντάκτης: Steven A. Reisman
Ημερομηνία:  
Προς: exim-users
Αντικείμενο: [exim] Expansion strings for processing maildirsize files
I've collected a set of expansion strings for processing Maildir++
maildirsize files directly within Exim without need for outside helper
scripts.

To test, put the expansion strings (including comments) into a file
named "strings", create a local "maildirsize" file (sample data below),
and enter the command:

exim4 -be <strings


Hopefully, the mailing list will find these useful.

Steve



Sample maildirsize file:

8388608S,1000C
6923289 971
12368 2
76575 3
96002 7
-184945 -12
-184945 -12
24087 1
24087 1
4021 1
3653 1
8739 1
24087 1
-40500 -4
-27740 -2


maildirsize expansion strings:

# maildirsize file (using : as eol string)
${readfile{maildirsize}{:}}

# first line of file
${sg{${readfile{maildirsize}{:}}}{:.*}{}}

# maildir size quota
${sg{${sg{${readfile{maildirsize}{:}}}{:.*}{}}}{S.*}{}}

# message count quota
${sg{${sg{${readfile{maildirsize}{:}}}{C.*}{}}}{[^,]*,}{}}

# extract lines 2 though the end-of-file
${sg{${readfile{maildirsize}{:}}}{^[^:]*:}{}}

# extract first number from lines 2+
${sg{${sg{${readfile{maildirsize}{:}}}{^[^:]*:}{}}}{ [-0-9]*:}{:}}

   # sum of the numbers in the above list (cumulative size)
   #  using "reduce"
   ${reduce{${sg{${sg{${readfile{maildirsize}{:}}}{^[^:]*:}{}}}\
             { [-0-9]*:}{:}}}{0}{${eval:$value+$item}}}
   #  using "eval"
   ${eval:${sg{${sg{${sg{${readfile{maildirsize}{:}}}{^[^:]*:}{}}}\
             { [-0-9]*:}{:}}0}{:}{+}}}


# extract second number from lines 2+
${sg{${sg{${readfile{maildirsize}{:}}}{^[^:]*:}{}}}{[-0-9]+ }{}}

   # sum of the numbers in the above list (message count)
   #  using "reduce"
   ${reduce{${sg{${sg{${readfile{maildirsize}{:}}}{^[^:]*:}{}}}\
             {[-0-9]+ }{}}}{0}{${eval:$value+$item}}}
   #  using "eval"
   ${eval:${sg{${sg{${sg{${readfile{maildirsize}{:}}}{^[^:]*:}{}}}\
             {[-0-9]+ }{:}}0}{:}{+}}}