1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!-- Copyright (c) 1998-2002 Fabien Coelho. All rights reserved. -->
<!-- $Id: mod_macro.src.html,v 1.37 2002/06/01 21:46:44 coelho Exp $ -->
<HTML>
<HEAD>
<TITLE>Apache module mod_macro</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000"
LINK="#0000FF" VLINK="#000080" ALINK="#FF0000">
<DIV ALIGN="CENTER">
<IMG SRC="../images/sub.gif" ALT="[APACHE DOCUMENTATION]">
<H3>Apache HTTP Server Version 2.0</H3>
</DIV>
<H1 ALIGN="CENTER">Module mod_macro 1.1.4</H1>
<P>
This module is contained in the <CODE>mod_macro.c</CODE> file, and
is not compiled in by default. It provides for using macros within apache
runtime configuration files. These macros can be given arguments.
They are expanded when used (arguments are substituted by their values),
and the result is processed normally.
</P>
<P>
This documentation describes version 1.1.4 of mod_macro.
For the latest version see:
</p>
<p>
<center>
<a href="http://www.coelho.net/mod_macro/">
<code>http://www.coelho.net/mod_macro/</code></a>
</center>
</p>
<HR>
<H2>Features</H2>
Definition of a macro:
<UL>
<LI> macro definition within a <Macro> section, in the apache style.
<LI> user defined names for the macro and its arguments.
<LI> macro names are case-insensitive.
<LI> macro argument names are case sensitive.
<LI> arguments of a macro must have distinct names.
<LI> error on empty argument names.
<LI> redefining a macro generates a warning.
<LI> macro definitions can be nested... (but what for?)
<LI> warn about unused macro arguments.
<LI> warn about macro arguments which prefix one another.
<LI> warn if arguments are not prefixed by any of '<code>$%&@#</code>'
(good practice).
<LI> warn about empty macro contents.
<LI> warns if sections are not properly nested within a macro.
(if it is detected so).
<LI> arbitrary contents in macros.
<p>It means you can put perl sections or
whatever you like in a macro. No assumption is made about
the lexical structure (quotes, spaces or whatever)
within the macro contents but to expect a set of
backslash-continued independent lines.</p>
</UL>
Use of a macro:
<UL>
<LI> number of arguments must match the definition.
<LI> all occurences of macro arguments are substituted by their values.
<LI> in case of conflicts, the longest argument name is chosen.
<LI> macro expansion recursion is detected and stopped (error).
<LI> warn about empty arguments when used.
<LI> on errors, try to describe precisely where the error occured.
</UL>
Misc:
<UL>
<LI> Error directive to stop processing a configuration file.
<LI> Warning directive to issue warnings from a configuration file.
</UL>
<HR>
<H2>Directives</H2>
<UL>
<LI><A HREF="#error">Error</A>
<LI><A HREF="#macro"><Macro></A>
<LI><A HREF="#use">Use</A>
<LI><A HREF="#warning">Warning</A>
</UL>
<HR>
<H2><A NAME="error">Error directive</A></H2>
<A HREF="directive-dict.html#Syntax" REL="Help">
<STRONG>Syntax:</STRONG></A> Error <EM>message</EM><BR>
<A HREF="directive-dict.html#Context" REL="Help">
<STRONG>Context:</STRONG></A> server config, virtual host, directory<BR>
<A HREF="directive-dict.html#Override" REL="Help">
<STRONG>Override:</STRONG></A> <BR>
<A HREF="directive-dict.html#Status" REL="Help">
<STRONG>Status:</STRONG></A> Extra<BR>
<A HREF="directive-dict.html#Module" REL="Help">
<STRONG>Module:</STRONG></A> mod_macro<BR>
<A HREF="directive-dict.html#Compatibility" REL="Help">
<STRONG>Compatibility:</STRONG></A> Apache 1.3 <BR>
<P>
This directive issues an error from the configuration file and stop
processing it.
</P>
<PRE>
<IfModule !mod_perl.c>
Error Hey, you forgot to install mod_perl! I need it!
</IfModule>
</PRE>
<HR>
<H2><A NAME="macro"><Macro> directive</A></H2>
<A HREF="directive-dict.html#Syntax" REL="Help">
<STRONG>Syntax:</STRONG></A><Macro <EM>name</EM> <EM>args...</EM>><BR>
<A HREF="directive-dict.html#Context" REL="Help">
<STRONG>Context:</STRONG></A> server config, virtual host, directory <BR>
<A HREF="directive-dict.html#Override" REL="Help">
<STRONG>Override:</STRONG></A> <BR>
<A HREF="directive-dict.html#Status" REL="Help">
<STRONG>Status:</STRONG></A> Extra<BR>
<A HREF="directive-dict.html#Module" REL="Help">
<STRONG>Module:</STRONG></A> mod_macro<BR>
<A HREF="directive-dict.html#Compatibility" REL="Help">
<STRONG>Compatibility:</STRONG></A> Apache 1.3 <BR>
<P>
This directive controls the definition of a macro within the server
runtime configuration files. The first argument is the name of the macro.
Others are arguments to the macro. It is good practice to prefix
argument names with any of '$%&@#', and not macro names with such characters.
</P>
<P>
Notes: If you're using <code>mod_macro</code> along with
<code>mod_define</code>, do not use the '$' character as a prefix to macro
arguments (because this character is reserved for defined variables). Also
<code>mod_define</code> variable substitution is performed <b>after</b>
macro expansion.
</P>
<PRE>
<Macro LocalAccessPolicy>
order deny,allow
deny from all
allow from 10.2.16.0/24
</Macro>
<Macro RestrictedAccessPolicy $ipnumbers>
order deny,allow
deny from all
allow from $ipnumbers
</Macro>
</PRE>
<HR>
<H2><A NAME="use">Use directive</A></H2>
<A HREF="directive-dict.html#Syntax" REL="Help">
<STRONG>Syntax:</STRONG></A> Use <EM>name</EM> <EM>values...</EM><BR>
<A HREF="directive-dict.html#Context" REL="Help">
<STRONG>Context:</STRONG></A> server config, virtual host, directory<BR>
<A HREF="directive-dict.html#Override" REL="Help">
<STRONG>Override:</STRONG></A> <BR>
<A HREF="directive-dict.html#Status" REL="Help">
<STRONG>Status:</STRONG></A> Extra<BR>
<A HREF="directive-dict.html#Module" REL="Help">
<STRONG>Module:</STRONG></A> mod_macro<BR>
<A HREF="directive-dict.html#Compatibility" REL="Help">
<STRONG>Compatibility:</STRONG></A> Apache 1.3 <BR>
<P>
This directive controls the use of a macro. The specified macro is
expanded. It must be given the same number of arguments than in the
macro definition. The provided values are associated to their corresponding
initial argument and are substituted before processing.
</P>
<PRE>
Use LocalAccessPolicy
...
Use RestrictedAccessPolicy "192.54.172.0/24 192.54.148.0/24"
</PRE>
is equivalent, with the macros defined above, to:<br>
<PRE>
order deny,allow
deny from all
allow from 10.2.16.0/24
...
order deny,allow
deny from all
allow from 192.54.172.0/24 192.54.148.0/24
</PRE>
<HR>
<H2><A NAME="warning">Warning directive</A></H2>
<A HREF="directive-dict.html#Syntax" REL="Help">
<STRONG>Syntax:</STRONG></A> Warning <EM>message</EM><BR>
<A HREF="directive-dict.html#Context" REL="Help">
<STRONG>Context:</STRONG></A> server config, virtual host, directory<BR>
<A HREF="directive-dict.html#Override" REL="Help">
<STRONG>Override:</STRONG></A> <BR>
<A HREF="directive-dict.html#Status" REL="Help">
<STRONG>Status:</STRONG></A> Extra<BR>
<A HREF="directive-dict.html#Module" REL="Help">
<STRONG>Module:</STRONG></A> mod_macro<BR>
<A HREF="directive-dict.html#Compatibility" REL="Help">
<STRONG>Compatibility:</STRONG></A> Apache 1.3 <BR>
<P>
This directive issues a warning from the configuration file.
Processing goes on.
</P>
<PRE>
<IfDefine !RunProxy>
Warning The PROXY will not run!
</IfDefine>
<IfDefine RunProxy>
# proxy configuration
...
</IfDefine>
</PRE>
<HR>
<H3 ALIGN="CENTER">Apache HTTP Server Version 1.3</H3>
<A HREF="./"><IMG SRC="../images/index.gif" ALT="Index"></A>
<A HREF="../"><IMG SRC="../images/home.gif" ALT="Home"></A>
</BODY>
</HTML>
|