chiark / gitweb /
defs.m4: Fix commentary, and add missing descriptions.
[exim-config] / defs.m4
1 m4_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
24 m4_changequote(<:, :>)
25 m4_changecom(<:#:#:>)
26
27 ###--------------------------------------------------------------------------
28 ### Output file preamble and postamble.
29
30 m4_divert(0)m4_dnl
31 ### -*-conf-*- GENERATED FROM /etc/mail/m4/*.m4: DO NOT EDIT!
32 ###
33 ### Exim configuration for distorted.org.uk.
34
35 m4_divert(1000)m4_dnl
36 ### GENERATED FROM exim4.conf.m4: DO NOT EDIT!
37 m4_divert(-1)
38
39 ###--------------------------------------------------------------------------
40 ### Useful macros.
41
42 ## ONEOF(arg, ...)
43 ##
44 ## Output the first of its arguments that is non-empty.
45 m4_define(<:ONEOF:>, <:m4_ifelse(<:$#:>, <:1:>, <:$1:>,
46         <:$1:>, <::>, <:ONEOF(m4_shift($@)):>, <:$1:>):>)
47
48 ## DEFCONF(conf, default)
49 ##
50 ## Define config variable CONF, assigning it the DEFAULT value if not
51 ## overridden by `SETCONF'.
52 m4_define(<:DEFCONF:>,
53 <:m4_ifdef(<:CONF_$1:>, <::>,
54 <:m4_define(<:CONF_$1:>, <:$2:>):>):>)
55
56 ## SETCONF(conf, value)
57 ##
58 ## Set config variable VALUE.
59 m4_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.
68 m4_define(<:_FOREACH:>, <:m4_dnl
69 m4_ifelse(<:$#:>, <:1:>, <:_foreach_func($1):>,
70         <:_foreach_func($1)<::>_FOREACH(m4_shift($@)):>):>)
71 m4_define(<:FOREACH:>, <:m4_dnl
72 m4_pushdef(<:_foreach_func:>, <:$1:>)m4_dnl
73 _FOREACH($2)<::>m4_dnl
74 m4_popdef(<:_foreach_func:>):>)
75
76 ## DIVERT(name)
77 ##
78 ## Make _div:NAME be the current diversion.
79 m4_define(<:DIVERT:>, <:m4_dnl
80 m4_divert(m4_indir(<:_div:$1:>))m4_dnl
81 :>)
82
83 ## SECTION(name, [sub])
84 ##
85 ## Contribute the following text to section NAME, inserting appropriate
86 ## header text to the top of the section if necessary.  If a SUB-section name
87 ## is given, then the contribution is made to the subsection, and the
88 ## subsection's header (if any) is also inserted.
89 m4_define(<:SECTION:>, <:m4_dnl
90 DIVERT(<:$1:>)m4_dnl
91 m4_ifdef(<:_done:$1:>, <::>, <:m4_dnl
92 ###--------------------------------------------------------------------------
93 m4_ifdef(<:_head:$1:>, <:m4_indir(<:_head:$1:>):>, <:begin $1:>)
94
95 m4_define(<:_done:$1:>, <:1:>):>)m4_dnl
96 m4_ifelse(<:$2:>, <::>, <::>, <:m4_dnl
97 DIVERT(<:$1/$2:>)m4_dnl
98 m4_ifdef(<:_done:$1/$2:>, <::>, <:m4_dnl
99 m4_ifdef(<:_head:$1/$2:>, <:<:##:> m4_indir(<:_head:$1/$2:>)
100 :>)m4_define(<:_done:$1/$2:>):>):>):>)
101
102 ## LOOKUP_DOMAIN(dom, [if-found], [if-not-found])
103 ##
104 ## Look up DOM in the master domains file.  If it's found, put the
105 ## information found in `$value' and expand to IF-FOUND, which may use `KV'
106 ## to extract keyword values, and defaults to `$value'; otherwise, obey
107 ## IF-NOT-FOUND, which may be the token `fail', or replacement text in
108 ## braces.
109 m4_define(<:LOOKUP_DOMAIN:>,
110         <:if exists{CONF_sysconf_dir/domains.conf} \
111              {${lookup {$1}partial0-lsearch{CONF_sysconf_dir/domains.conf} \
112                        m4_ifelse(<:$2$3:>, <::>, <::>,
113                                  <:$2:>, <::>, <:{$value}$3:>,
114                                  <:$2$3:>)}} \
115              $3:>)
116
117 ## KV(key, result)
118 ##
119 ## Extract the value of the named KEY in the ${extract ...}-style string in
120 ## the current $value (where it may have been left by `LOOKUP-DOMAIN').  The
121 ## RESULT is a pair {IF-FOUND}{IF-NOT-FOUND}; the former may use $value to
122 ## refer to the value; the latter may be `fail' (not in braces) to force
123 ## expansion failure.
124 m4_define(<:KV:>, <:${extract {$1}{$value}$2}:>)
125
126 ## DOMKV(key, result)
127 ##
128 ## Extract the value of the named KEY in the ${extract ...}-style string in
129 ## $domain_data; see `KV'.
130 m4_define(<:DOMKV:>, <:${extract {$1}{$domain_data}$2}:>)
131
132 m4_divert(999)m4_dnl
133 ###----- That's all, folks --------------------------------------------------
134 m4_divert(-1)