chiark / gitweb /
user-spam.m4: Fix indentation in the output.
[exim-config] / defs.m4
CommitLineData
185b5456
MW
1m4_divert(-1)m4_dnl ### -*-m4-*-
2###
3### Basic definitions for distorted.org.uk Exim configuration
4###
5### (c) 2012 Mark Wooding
6###
7
8###----- Licensing notice ---------------------------------------------------
9###
10### This program is free software; you can redistribute it and/or modify
11### it under the terms of the GNU General Public License as published by
12### the Free Software Foundation; either version 2 of the License, or
13### (at your option) any later version.
14###
15### This program is distributed in the hope that it will be useful,
16### but WITHOUT ANY WARRANTY; without even the implied warranty of
17### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18### GNU General Public License for more details.
19###
20### You should have received a copy of the GNU General Public License
21### along with this program; if not, write to the Free Software Foundation,
22### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
24m4_changequote(<:, :>)
25m4_changecom(<:#:#:>)
26
27###--------------------------------------------------------------------------
28### Output file preamble and postamble.
29
30m4_divert(0)m4_dnl
556dabe1 31### -*-conf-*- GENERATED FROM exim-config/*.m4 (MODE) DO NOT EDIT!
185b5456
MW
32###
33### Exim configuration for distorted.org.uk.
34
35m4_divert(1000)m4_dnl
556dabe1 36### GENERATED FROM exim-config/*.m4 (MODE): DO NOT EDIT!
185b5456
MW
37m4_divert(-1)
38
39###--------------------------------------------------------------------------
40### Useful macros.
41
42## ONEOF(arg, ...)
43##
44## Output the first of its arguments that is non-empty.
45m4_define(<:ONEOF:>, <:m4_ifelse(<:$#:>, <:1:>, <:$1:>,
46 <:$1:>, <::>, <:ONEOF(m4_shift($@)):>, <:$1:>):>)
47
28cfda76 48## DEFCONF(conf, default)
185b5456
MW
49##
50## Define config variable CONF, assigning it the DEFAULT value if not
51## overridden by `SETCONF'.
52m4_define(<:DEFCONF:>,
53<:m4_ifdef(<:CONF_$1:>, <::>,
54<:m4_define(<:CONF_$1:>, <:$2:>):>):>)
55
28cfda76 56## SETCONF(conf, value)
185b5456
MW
57##
58## Set config variable VALUE.
59m4_define(<:SETCONF:>, <:m4_define(<:CONF_$1:>, <:$2:>):>)
60
61## FOREACH(what, list)
62##
63## The LIST is a comma-separated list of things, like an m4 argument list.
64## For each item in the list, expand WHAT as if it's the body of a macro with
65## the list item as its arguments. In other words, the list item itself can
66## be a list of comma-separated items, which are available as $1, $2, ...,
67## within WHAT.
68m4_define(<:_FOREACH:>, <:m4_dnl
69m4_ifelse(<:$#:>, <:1:>, <:_foreach_func($1):>,
70 <:_foreach_func($1)<::>_FOREACH(m4_shift($@)):>):>)
71m4_define(<:FOREACH:>, <:m4_dnl
72m4_pushdef(<:_foreach_func:>, <:$1:>)m4_dnl
73_FOREACH($2)<::>m4_dnl
74m4_popdef(<:_foreach_func:>):>)
75
31c92220
MW
76## CLRSEP
77##
78## Clear the separator. Use in conjunction with `SEP' below.
79m4_define(<:CLRSEP:>, <:m4_define(<:__sep:>, <::>):>)m4_dnl
80
81## SEP(newsep)
82##
83## Insert the current separator, and then set the separator to NEWSEP. This
84## is handy in `FOREACH' loops, in order to separate the items with the
85## correct number of fenceposts: call `CLRSEP' before the list, and begin
86## each item with SEP(...).
87m4_define(<:SEP:>, <:__sep<::>m4_define(<:__sep:>, <:$1:>):>)m4_dnl
88
28cfda76
MW
89## DIVERT(name)
90##
91## Make _div:NAME be the current diversion.
185b5456
MW
92m4_define(<:DIVERT:>, <:m4_dnl
93m4_divert(m4_indir(<:_div:$1:>))m4_dnl
94:>)
95
28cfda76
MW
96## SECTION(name, [sub])
97##
98## Contribute the following text to section NAME, inserting appropriate
99## header text to the top of the section if necessary. If a SUB-section name
100## is given, then the contribution is made to the subsection, and the
101## subsection's header (if any) is also inserted.
185b5456
MW
102m4_define(<:SECTION:>, <:m4_dnl
103DIVERT(<:$1:>)m4_dnl
104m4_ifdef(<:_done:$1:>, <::>, <:m4_dnl
105###--------------------------------------------------------------------------
106m4_ifdef(<:_head:$1:>, <:m4_indir(<:_head:$1:>):>, <:begin $1:>)
107
108m4_define(<:_done:$1:>, <:1:>):>)m4_dnl
109m4_ifelse(<:$2:>, <::>, <::>, <:m4_dnl
110DIVERT(<:$1/$2:>)m4_dnl
111m4_ifdef(<:_done:$1/$2:>, <::>, <:m4_dnl
112m4_ifdef(<:_head:$1/$2:>, <:<:##:> m4_indir(<:_head:$1/$2:>)
113:>)m4_define(<:_done:$1/$2:>):>):>):>)
114
1e5ccd7c
MW
115## ADD_HEADER(hdrs)
116##
117## An ACL action to add the given HDRS, which are a `\n'-terminated list of
118## new header lines.
119m4_define(<:ADD_HEADER:>, <:m4_dnl
17553a31 120set acl_m_hdradd = ${if def:acl_m_hdradd{$acl_m_hdradd}{}}$1\n:>)
1e5ccd7c 121
45b7d61e
MW
122## RENAME_HEADERS_ADD(list)
123##
124## Return a newline-separated list of message header additions of the form
125## X-Distorted-Renamed-HEADER: VALUE
126## for each HEADER in the LIST which appears in the current message, where
127## VALUE is the HEADER's current value.
128m4_define(<:RENAME_HEADERS_ADD:>, <:m4_dnl
285fc90e 129FOREACH(<:\
945da4ac 130 ${if def:h_$:><:1:{X-CONF_header_token-Renamed-$:><:1: $h_$:><:1:\n}}:>,
45b7d61e
MW
131 <:$1:>):>)
132
133## RENAME_HEADERS_REMOVE(list)
134##
135## Return the LIST, with items separated by colons.
136m4_define(<:RENAME_HEADERS_REMOVE:>, <:m4_dnl
137CLRSEP<::>FOREACH(<:SEP(:)$:><:1:>, <:$1:>):>)
138
61295d9c
MW
139## WARNING_HEADER(tag, msg)
140##
141## Add a warning header to the current mesage.
142m4_define(<:WARNING_HEADER:>,
143<:add_header = X-CONF_header_token-Warning: $1 $2:>)
144
28cfda76
MW
145## LOOKUP_DOMAIN(dom, [if-found], [if-not-found])
146##
147## Look up DOM in the master domains file. If it's found, put the
148## information found in `$value' and expand to IF-FOUND, which may use `KV'
149## to extract keyword values, and defaults to `$value'; otherwise, obey
150## IF-NOT-FOUND, which may be the token `fail', or replacement text in
151## braces.
185b5456
MW
152m4_define(<:LOOKUP_DOMAIN:>,
153 <:if exists{CONF_sysconf_dir/domains.conf} \
154 {${lookup {$1}partial0-lsearch{CONF_sysconf_dir/domains.conf} \
155 m4_ifelse(<:$2$3:>, <::>, <::>,
156 <:$2:>, <::>, <:{$value}$3:>,
157 <:$2$3:>)}} \
158 $3:>)
159
28cfda76
MW
160## KV(key, result)
161##
162## Extract the value of the named KEY in the ${extract ...}-style string in
163## the current $value (where it may have been left by `LOOKUP-DOMAIN'). The
164## RESULT is a pair {IF-FOUND}{IF-NOT-FOUND}; the former may use $value to
165## refer to the value; the latter may be `fail' (not in braces) to force
166## expansion failure.
185b5456 167m4_define(<:KV:>, <:${extract {$1}{$value}$2}:>)
28cfda76
MW
168
169## DOMKV(key, result)
170##
171## Extract the value of the named KEY in the ${extract ...}-style string in
172## $domain_data; see `KV'.
185b5456
MW
173m4_define(<:DOMKV:>, <:${extract {$1}{$domain_data}$2}:>)
174
175m4_divert(999)m4_dnl
176###----- That's all, folks --------------------------------------------------
177m4_divert(-1)