From 45b7d61ea2adcc366813f5c72565da054158b5f2 Mon Sep 17 00:00:00 2001 Message-Id: <45b7d61ea2adcc366813f5c72565da054158b5f2.1715005056.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sun, 14 Jun 2015 00:47:59 +0100 Subject: [PATCH] defs.m4, local.m4: Abstract out machinery for header-renaming lists. Organization: Straylight/Edgeware From: Mark Wooding We're going to be renaming some more headers soon... --- defs.m4 | 17 +++++++++++++++++ local.m4 | 8 +++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/defs.m4 b/defs.m4 index f2767fd..289dd52 100644 --- a/defs.m4 +++ b/defs.m4 @@ -112,6 +112,23 @@ m4_ifdef(<:_done:$1/$2:>, <::>, <:m4_dnl m4_ifdef(<:_head:$1/$2:>, <:<:##:> m4_indir(<:_head:$1/$2:>) :>)m4_define(<:_done:$1/$2:>):>):>):>) +## RENAME_HEADERS_ADD(list) +## +## Return a newline-separated list of message header additions of the form +## X-Distorted-Renamed-HEADER: VALUE +## for each HEADER in the LIST which appears in the current message, where +## VALUE is the HEADER's current value. +m4_define(<:RENAME_HEADERS_ADD:>, <:m4_dnl +CLRSEP<::>FOREACH(<:\ + ${if def:h_$:><:1:{X-Distorted-Renamed-$:><:1: $h_$:><:1:\n}}:>, + <:$1:>):>) + +## RENAME_HEADERS_REMOVE(list) +## +## Return the LIST, with items separated by colons. +m4_define(<:RENAME_HEADERS_REMOVE:>, <:m4_dnl +CLRSEP<::>FOREACH(<:SEP(:)$:><:1:>, <:$1:>):>) + ## LOOKUP_DOMAIN(dom, [if-found], [if-not-found]) ## ## Look up DOM in the master domains file. If it's found, put the diff --git a/local.m4 b/local.m4 index 65939a2..fd212a7 100644 --- a/local.m4 +++ b/local.m4 @@ -69,7 +69,7 @@ FILTER_ROUTER(dot_forward, SECTION(routers, deliver)m4_dnl ## Deliver mail to a user, in the absence of any other instructions. -m4_define(<:STRIP_HEADERS:>, <:m4_dnl +m4_define(<:DOVECOT_HEADERS:>, <:m4_dnl Content-Length, Status, X-IMAP, X-IMAPbase, m4_dnl X-Keywords, X-Status, X-UID:>)m4_dnl deliver: @@ -79,10 +79,8 @@ deliver: cannot_route_message = Unknown local part ## Strip headers used by Dovecot for its own purposes. - headers_remove = CLRSEP<::>FOREACH(<:SEP(:)$1:>, <:STRIP_HEADERS:>) - headers_add = CLRSEP<::>FOREACH(<:\ - ${if def:h_$1:{X-Distorted-Renamed-$1: $h_$1:\n}}:>, - <:STRIP_HEADERS:>) + headers_remove = RENAME_HEADERS_REMOVE(<:DOVECOT_HEADERS:>) + headers_add = RENAME_HEADERS_ADD(<:DOVECOT_HEADERS:>) DIVERT(null) ###----- That's all, folks -------------------------------------------------- -- [mdw]