It's working now. I am still wondering how a ^ in REGEXP
does not prevent the famous comma_count to work.
Beware: there is no limit on the level of recursion,
if someone can add it: thanks.
The coding of a dot like '[.]' is to prevent the loss
of meaning when '\.' would be used: when you store a
reg.exp. in a variable, the '\' of the '\.' gets lost.
(you could also code '\\.' of course)
See http://www.xs4all.nl/~rvtol/procmailrc.txt for
a way to use it.
#-------------
# .procmailrc
#-------------
#DEFAULT=|
LINEBUF=4096
SHELL=/bin/sh
LOGABSTRACT=yes
VERBOSE=on
LOGFILE=$_.log
# WSP contains [<space><tab>]
WSP="[ ]+"
QUAD1="0*([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])"
QUADn="0*([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])"
IP=$QUAD1[.]$QUADn[.]$QUADn[.]$QUADn
#-----------------------------------------------
XIP=""
REGEXP="Received:"
MATEXP=$REGEXP".*[^0-9.]\/$IP"
:0
* $ ^\/$REGEXP(.*)$(.*$)*
{
HEADERLINES = $MATCH
INCLUDERC = ${HOME}/XIP.rc
}
:0 fh w
* XIP ??
| formail -A"X-IP-CHAIN: $XIP"
#--------
# XIP.rc
#--------
:0
* HEADERLINES ?? $ ^$MATEXP
{
:0
* ! MATCH ?? ^194\.109\.(6|127)\.
{
:0
* ! MATCH ?? ^127\.0\.0\.1
* ! MATCH ?? ^(192\.168|172\.(1[6-9]|2[0-9]|3[01])|10)\.
* ! XIP ?? $ ^.*\[$MATCH]
{
XIP=$XIP[$MATCH]
}
}
:0
* HEADERLINES ?? $ ^$REGEXP(.*$)*\/$REGEXP(.*$)*
{
HEADERLINES = $MATCH
INCLUDERC = $_
}
}
# 194.109.6.0/8 = my ISP's mailservers
# 194.109.127.0/8 = more ISP's servers
# 127.0.0.1 = localhost
# 192.168.0.0/16 = IP private-address range
# 172.16.0.0/20 = IP private-address range
# 169.254.0.0/16 = Microsoft AutoAddress range (DHCP)
# 10.0.0.0/24 = IP private-address range
Good luck, Ruud
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail