Whole document tree
    

Whole document tree

Apache module mod_macro
[APACHE DOCUMENTATION]

Apache HTTP Server Version 1.3

Module mod_macro 1.1.1

This module is contained in the mod_macro.c 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.

This documentation describes version 1.1.1 of mod_macro. For the latest version see:

http://www.cri.ensmp.fr/~coelho/mod_macro/


Features

Definition of a macro:
  • macro definition within a <Macro> section, in the apache style.
  • user defined names for the macro and its arguments.
  • macro names are case-insensitive.
  • macro argument names are case sensitive.
  • arguments of a macro must have distinct names.
  • error on empty argument names.
  • redefining a macro generates a warning.
  • macro definitions can be nested... (but what for?)
  • warn about unused macro arguments.
  • warn about macro arguments which prefix one another.
  • warn if arguments are not prefixed by any of '$%&@#' (good practice).
  • warn about empty macro contents.
  • warns if sections are not properly nested within a macro. (if it is detected so).
  • arbitrary contents in macros.

    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.

Use of a macro:
  • number of arguments must match the definition.
  • all occurences of macro arguments are substituted by their values.
  • in case of conflicts, the longest argument name is chosen.
  • macro expansion recursion is detected and stopped (error).
  • warn about empty arguments when used.
  • on errors, try to describe precisely where the error occured.
Misc:
  • Error directive to stop processing a configuration file.
  • Warning directive to issue warnings from a configuration file.

Directives


Error directive

Syntax: Error message
Context: server config, virtual host, directory
Override:
Status: Extra
Module: mod_macro
Compatibility: Apache 1.3

This directive issues an error from the configuration file and stop processing it.

<IfModule !mod_perl.c>
Error Hey, you forgot to install mod_perl! I need it!
</IfModule>

<Macro> directive

Syntax:<Macro name args...>
Context: server config, virtual host, directory
Override:
Status: Extra
Module: mod_macro
Compatibility: Apache 1.3

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.

   <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>

Use directive

Syntax: Use name values...
Context: server config, virtual host, directory
Override:
Status: Extra
Module: mod_macro
Compatibility: Apache 1.3

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.

   Use LocalAccessPolicy

   ...

   Use RestrictedAccessPolicy "192.54.172.0/24 192.54.148.0/24"
is equivalent, with the macros defined above, to:
   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

Warning directive

Syntax: Warning message
Context: server config, virtual host, directory
Override:
Status: Extra
Module: mod_macro
Compatibility: Apache 1.3

This directive issues a warning from the configuration file. Processing goes on.

<IfDefine !RunProxy>
Warning The PROXY will not run!
</IfDefine>

<IfDefine RunProxy>
# proxy configuration
...
</IfDefine>

Apache HTTP Server Version 1.3

Index Home