|
NAMEApache::Config::Preproc - Preprocess Apache configuration filesSYNOPSISuse Apache::Config::Preproc; $x = new Apache::Config::Preproc '/path/to/httpd.conf', -expand => [ qw(include compact macro ifmodule ifdefine) ] or die $Apache::Admin::Config::ERROR; DESCRIPTIONApache::Config::Preproc reads and parses Apache configuration file, expanding the syntactic constructs selected by the -expand option. In the simplest case, the argument to that option is a reference to the list of names. Each name in the list identifies a module responsible for processing specific Apache configuration keywords. For convenience, most modules are named after the keyword they process, so that, e.g. include is responsible for inclusion of the files listed with Include and IncludeOptional statements. The list of built-in module names follows:
See the section MODULES for a detailed description of these modules. More expansions can be easily implemented by supplying a corresponding expansion module (see the section MODULE INTERNALS below). If the -expand argument is not supplied, the following default is used: [ 'include' ] The rest of methods is inherited from Apache::Admin::Config. IMPORTThe package provides two implementations of the main preprocessing method. The default implementation uses only the documented methods of the base Apache::Admin::Config class and due to its deficiences shows the O(N**2) time complexity. The optimized implementations does some introspection into the internals of the base class, which allow it to reduce the time complexity to O(N). Whenever possible, the optimized implementation is selected. You can, however, force using the particular implementation by supplying keywords to the "use" statement. To select the default implementation:use Apache::Config::Preproc qw(:default); To select the optimized implementation: use Apache::Config::Preproc qw(:optimized); See the source code for details. CONSTRUCTORnew$obj = new Apache::Config::Preproc $file, [-expand => $modlist], [-indent => $integer], ['-create'], ['-no-comment-grouping'], ['-no-blank-grouping'] Reads the Apache configuration file from $file and preprocesses it. The $file argument can be either the file name or file handle. The keyword arguments are:
Rest of arguments is the same as for the Apache::Admin::Config constructor:
METHODSAll methods are inherited from Apache::Admin::Config.Additional methods: filenameReturns the name of the configuration file.optionsReturns the list of options passed to the constructor when creating the object.MODULESThe preprocessing phases to be performed on the parsed configuration text are defined by the -expand argument. Internally, each name in its argument list causes loading of a Perl module responsible for this particular phase. Arguments to the constructor can be supplied using any of the following constructs:{ NAME => [ ARG, ...] } or [ NAME, ARG, ... ] This section describes the built-in modules and their arguments. compactThe compact module eliminates empty and comment lines. The constructor takes no arguments.includeProcesses Include and IncludeOptional statements and replaces them with the contents of the files supplied in their argument. If the latter is not an absolute file name, it is searched in the server root directory.The following keyword arguments can be used to set the default server root directory:
When the ServerRoot statement is seen, its value overwrites any previously set server root directory. ifmoduleProcesses IfModule statements. If the statement's argument evaluates to true, it is replaced by the statements inside it. Otherwise, it is removed. Nested statements are allowed. The LoadModule statements are examined in order to evaluate the argument.The constructor understands the following arguments:
ifdefineEliminates the Define and UnDefine statements and expands the <IfDefine> statements in the Apache configuration parse tree. Optional arguments to the constructor are treated as the names of symbols to define (similar to the httpd -D options). Example:-expand => [ { ifdefine => [ qw(SSL FOREGROUND) ] } ] locusAttaches to each node in the parse tree a Text::Locus object which describes the location of the corresponding statement in the source file. The location for each node can be accessed via the locus method. E.g. the following prints location and type of each statement:$x = new Apache::Config::Preproc '/etc/httpd.conf', -expand => [ qw(locus) ]; foreach ($x->select) { print $_->locus } See Text::Locus for a detailed discussion of the locus object and its methods. macroProcesses Macro and Use statements (see mod_macro). Macro statements are removed. Each Use statement is replaced by the expansion of the macro named in its argument.The constructor accepts the following arguments:
MODULE INTERNALSEach keyword phase listed in the -expand array causes loading of the package Apache::Config::Preproc::phase. This package must inherit from Apache::Config::Preproc::Expand and overload at least the expand method. See the description of Apache::Config::Preproc::Expand for a detailed description.EXAMPLEmy $obj = new Apache::Config::Preproc('/etc/httpd/httpd.conf', -expand => [qw(compact include ifmodule macro)], -indent => 4) or die $Apache::Admin::Config::ERROR; print $obj->dump_raw This snippet loads the Apache configuration from file /etc/httpd/httpd.conf, performs all the built-in expansions, and prints the result on standard output, using 4 character indent for each additional level of nesting. SEE ALSOApache::Admin::ConfigApache::Config::Preproc::compact Apache::Config::Preproc::ifdefine Apache::Config::Preproc::ifmodule Apache::Config::Preproc::include Apache::Config::Preproc::locus Apache::Config::Preproc::macro
Visit the GSP FreeBSD Man Page Interface. |