mod_macro.xml revision b4ddd0004bc04c857001f9f5e4600f3957054a32
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<?xml version="1.0"?>
530eba85dbd41b8a0fa5255d3648d1440199a661slive<!DOCTYPE modulesynopsis SYSTEM "/style/modulesynopsis.dtd">
e942c741056732f50da2074b36fe59805d370650slive<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
5f5d1b4cc970b7f06ff8ef6526128e9a27303d88nd<!-- $LastChangedRevision$ -->
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd<!--
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding Licensed to the Apache Software Foundation (ASF) under one or more
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding contributor license agreements. See the NOTICE file distributed with
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding this work for additional information regarding copyright ownership.
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding The ASF licenses this file to You under the Apache License, Version 2.0
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding (the "License"); you may not use this file except in compliance with
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding the License. You may obtain a copy of the License at
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd http://www.apache.org/licenses/LICENSE-2.0
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd Unless required by applicable law or agreed to in writing, software
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd distributed under the License is distributed on an "AS IS" BASIS,
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd See the License for the specific language governing permissions and
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd limitations under the License.
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd-->
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd
7db9f691a00ead175b03335457ca296a33ddf31bnd<modulesynopsis metafile="mod_macro.xml.meta">
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<name>mod_macro</name>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<description>This module provides usage of macros within apache runtime configuration files</description>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<status>Base</status>
530eba85dbd41b8a0fa5255d3648d1440199a661slive<sourcefile>mod_macro.c</sourcefile>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<identifier>macro_module</identifier>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna<summary>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <p>This modules provides macros within apache runtime configuration files.
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna These macros have parameters. They are expanded when used (parameters are
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna substituted by their values given as an argument), and the result is
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna processed normally.</p>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna</summary>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna<section id="features"><title>Features</title>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna<p>Definition of a macro:</p>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <ul>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <li> macro definition within a &lt;Macro&gt; section, following
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna the apache style.</li>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <li> user defined names for the macro and its parameters.</li>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <li> macro names are case-insensitive, like apache directives.</li>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <li> macro parameter names are case sensitive.</li>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <li> macro parameters must have distinct names.</li>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <li> error on empty parameter names.</li>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <li> redefining a macro generates a warning.</li>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <li> macro definitions can be nested... (but what for?)</li>
90efa9f1730742d874edb5a7803adce11c9f08eanoodl <li> warn about unused macro parameters.</li>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <li> warn about macro parameter names which prefix one another.</li>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <li> warn if a parameter is not prefixed by any of '<code>$%@</code>'
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna (good practice).</li>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <li> the available prefixes help deal with interactions with other
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna directives such as <directive module="core">Define</directive>.</li>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <li> tip: it may be useful to define a macro parameter with surrounding
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna braces, say <code>${foo}</code> so that the name can appear with
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna surrounding characters such as <code>bla${foo}bla</code>.</li>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <li> warn about empty macro contents.</li>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <li> warns if sections are not properly nested within a macro.
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna (if it is detected so).</li>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <li> the lexical scope of macro parameters is restricted to the macro text,
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna it is not forwarded to includes for instance.</li>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <li> arbitrary contents in macros.
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <p>It means you can put perl sections or whatever you like in a macro.
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna No assumption is made about the lexical structure (quotes, spaces or
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna whatever) within the macro contents but to expect a set of
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna backslash-continued independent lines.</p></li>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna </ul>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna<p>Use of a macro:</p>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna
3139522a1418fa699dfd78dcf8dde54253f2c55cnoirin <ul>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <li> number of arguments must match the definition.</li>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <li> all occurences of macro parameters are substituted by their values.</li>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <li> in case of conflicts, the longest parameter name is chosen.</li>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <li> macro expansion recursion is detected and stopped (error).</li>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <li> warn about empty arguments when used.</li>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <li> on errors, try to describe precisely where the error occured.</li>
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess <li> <code>$</code> and <code>%</code>-prefixed parameters are not
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive escaped.</li>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <li> <code>@</code>-prefixed parameters are escaped in quotes.</li>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive </ul>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<p>Removal of a macro definition:</p>
18b4b0fd6056093002ddef488636bf5ebe415ef0erikabele
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <ul>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <li> the macro must be already defined.</li>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive </ul>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<highlight language="config">
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive&lt;Macro DirGroup $dir $group&gt;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive &lt;Directory $dir&gt;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive require group $group
fb77c505254b6e9c925e23e734463e87574f8f40kess &lt;/Directory&gt;
fb77c505254b6e9c925e23e734463e87574f8f40kess&lt;/Macro&gt;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveUse DirGroup /www/apache/private private
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveUse DirGroup /www/apache/server admin
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveUndefMacro DirGroup
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</highlight>
fb77c505254b6e9c925e23e734463e87574f8f40kess
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</section>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<!-- Macro -->
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<directivesynopsis type="section">
fb77c505254b6e9c925e23e734463e87574f8f40kess<name>Macro</name>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<description>Define a configuration file macro</description>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<syntax>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive&lt;Macro <var>name</var> [<var>par1</var> .. <var>parN</var>]&gt;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive... &lt;/Macro&gt;</syntax>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<contextlist>
fb77c505254b6e9c925e23e734463e87574f8f40kess<context>server config</context>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<context>virtual host</context>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<context>directory</context>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</contextlist>
fb77c505254b6e9c925e23e734463e87574f8f40kess
fb77c505254b6e9c925e23e734463e87574f8f40kess<usage>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>The <directive>Macro</directive> directive controls the definition of
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive a macro within the server runtime configuration files.
fb77c505254b6e9c925e23e734463e87574f8f40kess The first argument is the name of the macro.
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess Other arguments are parameters to the macro. It is good practice to prefix
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive parameter names with any of '<code>$%@</code>', and not macro names
bc4b55ec8f31569d606d5680d50189a355bcd7a6rbowen with such characters.
fb77c505254b6e9c925e23e734463e87574f8f40kess </p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <highlight language="config">
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive&lt;Macro LocalAccessPolicy&gt;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive order deny,allow
fb77c505254b6e9c925e23e734463e87574f8f40kess deny from all
fb77c505254b6e9c925e23e734463e87574f8f40kess allow from 10.2.16.0/24
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive&lt;/Macro&gt;
fb77c505254b6e9c925e23e734463e87574f8f40kess
fb77c505254b6e9c925e23e734463e87574f8f40kess&lt;Macro RestrictedAccessPolicy $ipnumbers&gt;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive order deny,allow
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd deny from all
130d299c4b2b15be45532a176604c71fdc7bea5bnd allow from $ipnumbers
130d299c4b2b15be45532a176604c71fdc7bea5bnd&lt;/Macro&gt;
130d299c4b2b15be45532a176604c71fdc7bea5bnd </highlight>
130d299c4b2b15be45532a176604c71fdc7bea5bnd</usage>
130d299c4b2b15be45532a176604c71fdc7bea5bnd</directivesynopsis>
ef8e89e090461194ecadd31e8796a2c51e0531a2kess
130d299c4b2b15be45532a176604c71fdc7bea5bnd<!-- Use -->
130d299c4b2b15be45532a176604c71fdc7bea5bnd<directivesynopsis>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd<name>Use</name>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd<description>Use a macro</description>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<syntax>Use <var>name</var> [<var>value1</var> ... <var>valueN</var>]
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</syntax>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<contextlist>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<context>server config</context>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<context>virtual host</context>
003f0c9fda6664daf5092a0e42f65ede20098153slive<context>directory</context>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd</contextlist>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<usage>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>The <directive>Use</directive> directive controls the use of a macro.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive The specified macro is expanded. It must be given the same number of
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive arguments than in the macro definition. The provided values are
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess associated to their corresponding initial parameters and are substituted
003f0c9fda6664daf5092a0e42f65ede20098153slive before processing.</p>
003f0c9fda6664daf5092a0e42f65ede20098153slive
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess <highlight language="config">
6b64034fa2a644ba291c484c0c01c7df5b8d982ckessUse LocalAccessPolicy
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive...
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndUse RestrictedAccessPolicy "192.54.172.0/24 192.54.148.0/24"
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd </highlight>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>is equivalent, with the macros defined above, to:</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <highlight language="config">
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveorder deny,allow
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivedeny from all
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveallow from 10.2.16.0/24
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive...
130d299c4b2b15be45532a176604c71fdc7bea5bndorder deny,allow
130d299c4b2b15be45532a176604c71fdc7bea5bnddeny from all
130d299c4b2b15be45532a176604c71fdc7bea5bndallow from 192.54.172.0/24 192.54.148.0/24
130d299c4b2b15be45532a176604c71fdc7bea5bnd </highlight>
130d299c4b2b15be45532a176604c71fdc7bea5bnd</usage>
130d299c4b2b15be45532a176604c71fdc7bea5bnd
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd</directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<!-- UndefMacro -->
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<directivesynopsis>
1a3f62ca37273a15a06bb94a61d3c6fcf4bf38c9rbowen<name>undefMacro</name>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<description>Undefine a macro</description>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<syntax>UndefMacro <var>name</var></syntax>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<contextlist>
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding<context>server config</context>
684f2a9a422185adda0692a1203c5ad6687fc5c5nd<context>virtual host</context>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd<context>directory</context>
530eba85dbd41b8a0fa5255d3648d1440199a661slive</contextlist>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<usage>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>The <directive>UndefMacro</directive> directive undefines a macro
003f0c9fda6664daf5092a0e42f65ede20098153slive which has been defined before hand.</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <highlight language="config">
843a03fe0b138a4c1f64cb90a014e9417ac30691fieldingUndefMacro LocalAccessPolicy
843a03fe0b138a4c1f64cb90a014e9417ac30691fieldingUndefMacro RestrictedAccessPolicy
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding </highlight>
684f2a9a422185adda0692a1203c5ad6687fc5c5nd</usage>
a8ce9095d102e43fecb81093a132b90b9a227f78kess</directivesynopsis>
684f2a9a422185adda0692a1203c5ad6687fc5c5nd</modulesynopsis>
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding