]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_macro.html.en
update transformation
[apache] / docs / manual / mod / mod_macro.html.en
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
4         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5               This file is generated from xml source: DO NOT EDIT
6         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7       -->
8 <title>mod_macro - Apache HTTP Server</title>
9 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
10 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
11 <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" />
12 <script src="../style/scripts/prettify.js" type="text/javascript">
13 </script>
14
15 <link href="../images/favicon.ico" rel="shortcut icon" /></head>
16 <body>
17 <div id="page-header">
18 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
19 <p class="apache">Apache HTTP Server Version 2.5</p>
20 <img alt="" src="../images/feather.gif" /></div>
21 <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="../images/left.gif" /></a></div>
22 <div id="path">
23 <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="../">Version 2.5</a> &gt; <a href="./">Modules</a></div>
24 <div id="page-content">
25 <div id="preamble"><h1>Apache Module mod_macro</h1>
26 <div class="toplang">
27 <p><span>Available Languages: </span><a href="../en/mod/mod_macro.html" title="English">&nbsp;en&nbsp;</a> |
28 <a href="../fr/mod/mod_macro.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a></p>
29 </div>
30 <table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>This module provides usage of macros within apache runtime configuration files</td></tr>
31 <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Base</td></tr>
32 <tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>macro_module</td></tr>
33 <tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>mod_macro.c</td></tr></table>
34 <h3>Summary</h3>
35
36
37     <p>This modules provides macros within apache runtime configuration files.
38     These macros have parameters.  They are expanded when used (parameters are
39     substituted by their values given as an argument), and the result is
40     processed normally.</p>
41 </div>
42 <div id="quickview"><h3 class="directives">Directives</h3>
43 <ul id="toc">
44 <li><img alt="" src="../images/down.gif" /> <a href="#macro">&lt;Macro&gt;</a></li>
45 <li><img alt="" src="../images/down.gif" /> <a href="#undefmacro">undefMacro</a></li>
46 <li><img alt="" src="../images/down.gif" /> <a href="#use">Use</a></li>
47 </ul>
48 <h3>Topics</h3>
49 <ul id="topics">
50 <li><img alt="" src="../images/down.gif" /> <a href="#features">Features</a></li>
51 </ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
52 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
53 <div class="section">
54 <h2><a name="features" id="features">Features</a></h2>
55
56 <p>
57     Definition of a macro:
58 </p>
59     <ul>
60     <li> macro definition within a &lt;Macro&gt; section, following
61          the apache style.</li>
62     <li> user defined names for the macro and its parameters.</li>
63     <li> macro names are case-insensitive, like apache directives.</li>
64     <li> macro parameter names are case sensitive.</li>
65     <li> macro parameters must have distinct names.</li>
66     <li> error on empty parameter names.</li>
67     <li> redefining a macro generates a warning.</li>
68     <li> macro definitions can be nested... (but what for?)</li>
69     <li> warn about unused macro parameters.</li>
70     <li> warn about macro parameter names which prefix one another.</li>
71     <li> warn if a parameter is not prefixed by any of '<code>$%@</code>'
72          (good practice).</li>
73     <li> the available prefixes help deal with interactions with other
74          directives such as <code class="directive"><a href="../mod/core.html#define">Define</a></code>.</li>
75     <li> tip: it may be useful to define a macro parameter with surrounding
76          braces, say <code>${foo}</code> so that the name can appear with
77          surrounding characters such as <code>bla${foo}bla</code>.</li>
78     <li> warn about empty macro contents.</li>
79     <li> warns if sections are not properly nested within a macro.
80          (if it is detected so).</li>
81     <li> the lexical scope of macro parameters is restricted to the macro text,
82          it is not forwarded to includes for instance.</li>
83     <li> arbitrary contents in macros.
84          <p>It means you can put perl sections or whatever you like in a macro.
85          No assumption is made about the lexical structure (quotes, spaces or
86          whatever) within the macro contents but to expect a set of
87          backslash-continued independent lines.</p></li>
88     </ul>
89
90 <p>
91     Use of a macro:
92 </p>
93     <ul>
94     <li> number of arguments must match the definition.</li>
95     <li> all occurences of macro parameters are substituted by their values.</li>
96     <li> in case of conflicts, the longest parameter name is chosen.</li>
97     <li> macro expansion recursion is detected and stopped (error).</li>
98     <li> warn about empty arguments when used.</li>
99     <li> on errors, try to describe precisely where the error occured.</li>
100     <li> <code>$</code> and <code>%</code>-prefixed parameters are not
101           escaped.</li>
102     <li> <code>@</code>-prefixed parameters are escaped in quotes.</li>
103     </ul>
104
105 <p>
106    Removal of a macro definition:
107 </p>
108    <ul>
109    <li> the macro must be already defined.</li>
110    </ul>
111
112     <pre class="prettyprint lang-config">
113 &lt;Macro DirGroup $dir $group&gt;
114   &lt;Directory $dir&gt;
115     require group $group
116   &lt;/Directory&gt;
117 &lt;/Macro&gt;
118
119 Use DirGroup /www/apache/private private
120 Use DirGroup /www/apache/server  admin
121
122 UndefMacro DirGroup
123     </pre>
124
125
126 </div>
127 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
128 <div class="directive-section"><h2><a name="Macro" id="Macro">&lt;Macro&gt;</a> <a name="macro" id="macro">Directive</a></h2>
129 <table class="directive">
130 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Define a configuration file macro</td></tr>
131 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>
132 &lt;Macro <var>name</var> [<var>par1</var> .. <var>parN</var>]&gt;
133 ... &lt;/Macro&gt;</code></td></tr>
134 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory</td></tr>
135 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
136 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_macro</td></tr>
137 </table>
138     <p>The <code class="directive">Macro</code> directive controls the definition of
139     a macro within the server runtime configuration files.
140     The first argument is the name of the macro.
141     Other arguments are parameters to the macro. It is good practice to prefix
142     parameter names with any of '<code>$%@</code>', and not macro names
143     with such characters.
144     </p>
145
146     <pre class="prettyprint lang-config">
147 &lt;Macro LocalAccessPolicy&gt;
148   order deny,allow
149   deny from all
150   allow from 10.2.16.0/24
151 &lt;/Macro&gt;
152
153 &lt;Macro RestrictedAccessPolicy $ipnumbers&gt;
154    order deny,allow
155    deny from all
156    allow from $ipnumbers
157 &lt;/Macro&gt;
158     </pre>
159
160
161 </div>
162 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
163 <div class="directive-section"><h2><a name="undefMacro" id="undefMacro">undefMacro</a> <a name="undefmacro" id="undefmacro">Directive</a></h2>
164 <table class="directive">
165 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Undefine a macro</td></tr>
166 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>UndefMacro <var>name</var></code></td></tr>
167 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory</td></tr>
168 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
169 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_macro</td></tr>
170 </table>
171     <p>The <code class="directive">UndefMacro</code> directive undefines a macro
172     which has been defined before hand.</p>
173
174     <pre class="prettyprint lang-config">
175 UndefMacro LocalAccessPolicy
176 UndefMacro RestrictedAccessPolicy
177     </pre>
178
179
180 </div>
181 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
182 <div class="directive-section"><h2><a name="Use" id="Use">Use</a> <a name="use" id="use">Directive</a></h2>
183 <table class="directive">
184 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Use a macro</td></tr>
185 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>Use <var>name</var> [<var>value1</var> ... <var>valueN</var>]
186 </code></td></tr>
187 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory</td></tr>
188 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
189 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_macro</td></tr>
190 </table>
191     <p> The <code class="directive">Use</code> directive controls the use of a macro.
192     The specified macro is expanded. It must be given the same number of
193     arguments than in the  macro definition. The provided values are
194     associated to their corresponding initial parameters and are substituted
195     before processing.</p>
196
197     <pre class="prettyprint lang-config">
198 Use LocalAccessPolicy
199 ...
200 Use RestrictedAccessPolicy "192.54.172.0/24 192.54.148.0/24"
201     </pre>
202
203
204     <p>is equivalent, with the macros defined above, to:</p>
205
206     <pre class="prettyprint lang-config">
207 order deny,allow
208 deny from all
209 allow from 10.2.16.0/24
210 ...
211 order deny,allow
212 deny from all
213 allow from 192.54.172.0/24 192.54.148.0/24
214     </pre>
215
216
217 </div>
218 </div>
219 <div class="bottomlang">
220 <p><span>Available Languages: </span><a href="../en/mod/mod_macro.html" title="English">&nbsp;en&nbsp;</a> |
221 <a href="../fr/mod/mod_macro.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a></p>
222 </div><div class="top"><a href="#page-header"><img src="../images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
223 <script type="text/javascript"><!--//--><![CDATA[//><!--
224 var comments_shortname = 'httpd';
225 var comments_identifier = 'http://httpd.apache.org/docs/trunk/mod/mod_macro.html';
226 (function(w, d) {
227     if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
228         d.write('<div id="comments_thread"><\/div>');
229         var s = d.createElement('script');
230         s.type = 'text/javascript';
231         s.async = true;
232         s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
233         (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
234     }
235     else {
236         d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
237     }
238 })(window, document);
239 //--><!]]></script></div><div id="footer">
240 <p class="apache">Copyright 2013 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
241 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
242 if (typeof(prettyPrint) !== 'undefined') {
243     prettyPrint();
244 }
245 //--><!]]></script>
246 </body></html>