.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "docs::api::Apache2::Module 3pm" .TH docs::api::Apache2::Module 3pm 2024-01-10 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Apache2::Module \- Perl API for creating and working with Apache modules .SH Synopsis .IX Header "Synopsis" .Vb 1 \& use Apache2::Module (); \& \& #Define a configuration directive \& my @directives = ( \& { \& name => \*(AqMyDirective\*(Aq, \& } \& ); \& \& Apache2::Module::add(_\|_PACKAGE_\|_, \e@directives); \& \& # iterate over the whole module list \& for (my $modp = Apache2::Module::top_module(); $modp; $modp = $modp\->next) { \& my $name = $modp\->name; \& my $index = $modp\->module_index; \& my $ap_api_major_version = $modp\->ap_api_major_version; \& my $ap_api_minor_version = $modp\->ap_api_minor_version; \& my $commands = $modp\->cmds; \& } \& \& # find a specific module \& my $module = Apache2::Module::find_linked_module(\*(Aqmod_ssl.c\*(Aq); \& \& # remove a specific module \& $module\->remove_loaded_module(); \& \& # access module configuration from a directive \& sub MyDirective { \& my ($self, $parms, $args) = @_; \& my $srv_cfg = Apache2::Module::get_config($self, $parms\->server); \& [...] \& } \& \& # test if an Apache module is loaded \& if (Apache2::Module::loaded(\*(Aqmod_ssl.c\*(Aq)) { \& [...] \& } \& \& # test if a Perl module is loaded \& if (Apache2::Module::loaded(\*(AqApache2::Status\*(Aq)) { \& [...] \& } .Ve .SH Description .IX Header "Description" \&\f(CW\*(C`Apache2::Module\*(C'\fR provides the Perl API for creating and working with Apache modules .PP See Apache Server Configuration Customization in Perl. .SH API .IX Header "API" \&\f(CW\*(C`Apache2::Module\*(C'\fR provides the following functions and/or methods: .ie n .SS """add""" .el .SS \f(CWadd\fP .IX Subsection "add" Add a module's custom configuration directive to Apache. .PP .Vb 1 \& Apache2::Module::add($package, $cmds); .Ve .ie n .IP "arg1: $package ( string )" 4 .el .IP "arg1: \f(CW$package\fR ( string )" 4 .IX Item "arg1: $package ( string )" the package of the module to add .ie n .IP "arg2: $cmds ( ARRAY of HASH refs )" 4 .el .IP "arg2: \f(CW$cmds\fR ( ARRAY of HASH refs )" 4 .IX Item "arg2: $cmds ( ARRAY of HASH refs )" the list of configuration directives to add .IP "ret: no return value" 4 .IX Item "ret: no return value" .PD 0 .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .PP See also Apache Server Configuration Customization in Perl. .ie n .SS """ap_api_major_version""" .el .SS \f(CWap_api_major_version\fP .IX Subsection "ap_api_major_version" Get the httpd API version this module was build against, \fBnot\fR the module's version. .PP .Vb 1 \& $major_version = $module\->ap_api_major_version(); .Ve .ie n .IP "obj: $module ( ""Apache2::Module object"" )" 4 .el .IP "obj: \f(CW$module\fR ( \f(CWApache2::Module object\fR )" 4 .IX Item "obj: $module ( Apache2::Module object )" .PD 0 .ie n .IP "ret: $major_version ( integer )" 4 .el .IP "ret: \f(CW$major_version\fR ( integer )" 4 .IX Item "ret: $major_version ( integer )" .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .PP This methid is used to check that module is compatible with this version of the server before loading it. .ie n .SS """ap_api_minor_version""" .el .SS \f(CWap_api_minor_version\fP .IX Subsection "ap_api_minor_version" Get the module API minor version. .PP .Vb 1 \& $minor_version = $module\->ap_api_minor_version(); .Ve .ie n .IP "obj: $module ( ""Apache2::Module object"" )" 4 .el .IP "obj: \f(CW$module\fR ( \f(CWApache2::Module object\fR )" 4 .IX Item "obj: $module ( Apache2::Module object )" .PD 0 .ie n .IP "ret: $minor_version ( integer )" 4 .el .IP "ret: \f(CW$minor_version\fR ( integer )" 4 .IX Item "ret: $minor_version ( integer )" .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .PP \&\f(CWap_api_minor_version()\fR provides API feature milestones. .PP It's not checked during module init. .ie n .SS """cmds""" .el .SS \f(CWcmds\fP .IX Subsection "cmds" Get the \f(CW\*(C`Apache2::Command\*(C'\fR object, describing all of the directives this module defines. .PP .Vb 1 \& $command = $module\->cmds(); .Ve .ie n .IP "obj: $module ( ""Apache2::Module object"" )" 4 .el .IP "obj: \f(CW$module\fR ( \f(CWApache2::Module object\fR )" 4 .IX Item "obj: $module ( Apache2::Module object )" .PD 0 .ie n .IP "ret: $command ( ""Apache2::Command object"" )" 4 .el .IP "ret: \f(CW$command\fR ( \f(CWApache2::Command object\fR )" 4 .IX Item "ret: $command ( Apache2::Command object )" .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .ie n .SS """get_config""" .el .SS \f(CWget_config\fP .IX Subsection "get_config" Retrieve a module's configuration. Used by configuration directives. .PP .Vb 4 \& $cfg = Apache2::Module::get_config($class, $server, $dir_config); \& $cfg = Apache2::Module::get_config($class, $server); \& $cfg = $self\->get_config($server, $dir_config); \& $cfg = $self\->get_config($server); .Ve .ie n .IP "obj: $module ( ""Apache2::Module object"" )" 4 .el .IP "obj: \f(CW$module\fR ( \f(CWApache2::Module object\fR )" 4 .IX Item "obj: $module ( Apache2::Module object )" .PD 0 .ie n .IP "arg1: $class ( string )" 4 .el .IP "arg1: \f(CW$class\fR ( string )" 4 .IX Item "arg1: $class ( string )" .PD The Perl package this configuration is for .ie n .IP "arg2: $server ( ""Apache2::ServerRec object"" )" 4 .el .IP "arg2: \f(CW$server\fR ( \f(CWApache2::ServerRec object\fR )" 4 .IX Item "arg2: $server ( Apache2::ServerRec object )" The current server, typically \&\f(CW\*(C`$r\->server\*(C'\fR or \&\f(CW\*(C`$parms\->server\*(C'\fR. .ie n .IP "opt arg3: $dir_config ( ""Apache2::ConfVector object"" )" 4 .el .IP "opt arg3: \f(CW$dir_config\fR ( \f(CWApache2::ConfVector object\fR )" 4 .IX Item "opt arg3: $dir_config ( Apache2::ConfVector object )" By default, the configuration returned is the server level one. To retrieve the per directory configuration, use \&\f(CW\*(C`$r\->per_dir_config\*(C'\fR as a last argument. .ie n .IP "ret: $cfg (HASH reference)" 4 .el .IP "ret: \f(CW$cfg\fR (HASH reference)" 4 .IX Item "ret: $cfg (HASH reference)" A reference to the hash holding the module configuration data. .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PP See also Apache Server Configuration Customization in Perl. .ie n .SS """find_linked_module""" .el .SS \f(CWfind_linked_module\fP .IX Subsection "find_linked_module" Find a module based on the name of the module .PP .Vb 1 \& $module = Apache2::Module::find_linked_module($name); .Ve .ie n .IP "arg1: $name ( string )" 4 .el .IP "arg1: \f(CW$name\fR ( string )" 4 .IX Item "arg1: $name ( string )" The name of the module ending in \f(CW\*(C`.c\*(C'\fR .ie n .IP "ret: $module ( ""Apache2::Module object"" )" 4 .el .IP "ret: \f(CW$module\fR ( \f(CWApache2::Module object\fR )" 4 .IX Item "ret: $module ( Apache2::Module object )" The module object if found, \f(CW\*(C`undef\*(C'\fR otherwise. .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PP For example: .PP .Vb 1 \& my $module = Apache2::Module::find_linked_module(\*(Aqmod_ssl.c\*(Aq); .Ve .ie n .SS """loaded""" .el .SS \f(CWloaded\fP .IX Subsection "loaded" Determine if a certain module is loaded .PP .Vb 1 \& $loaded = Apache2::Module::loaded($module); .Ve .ie n .IP "name: $module ( string )" 4 .el .IP "name: \f(CW$module\fR ( string )" 4 .IX Item "name: $module ( string )" The name of the module to search for. .Sp If \f(CW$module\fR ends with \f(CW\*(C`.c\*(C'\fR, search all the modules, statically compiled and dynamically loaded. .Sp If \f(CW$module\fR ends with \f(CW\*(C`.so\*(C'\fR, search only the dynamically loaded modules. .Sp If \f(CW$module\fR doesn't contain a \f(CW\*(C`.\*(C'\fR, search the loaded Perl modules (checks \f(CW%INC\fR). .ie n .IP "ret: $loaded ( boolean )" 4 .el .IP "ret: \f(CW$loaded\fR ( boolean )" 4 .IX Item "ret: $loaded ( boolean )" Returns true if the module is loaded, false otherwise. .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PP For example, to test if this server supports ssl: .PP .Vb 3 \& if (Apache2::Module::loaded(\*(Aqmod_ssl.c\*(Aq)) { \& [...] \& } .Ve .PP To test is this server dynamically loaded mod_perl: .PP .Vb 3 \& if (Apache2::Module::loaded(\*(Aqmod_perl.so\*(Aq)) { \& [...] \& } .Ve .PP To test if \f(CW\*(C`Apache2::Status\*(C'\fR is loaded: .PP .Vb 3 \& if (Apache2::Module::loaded(\*(AqApache2::Status\*(Aq)) { \& [...] \& } .Ve .ie n .SS """module_index""" .el .SS \f(CWmodule_index\fP .IX Subsection "module_index" Get the index to this modules structures in config vectors. .PP .Vb 1 \& $index = $module\->module_index(); .Ve .ie n .IP "obj: $module ( ""Apache2::Module object"" )" 4 .el .IP "obj: \f(CW$module\fR ( \f(CWApache2::Module object\fR )" 4 .IX Item "obj: $module ( Apache2::Module object )" .PD 0 .ie n .IP "ret: $index ( integer )" 4 .el .IP "ret: \f(CW$index\fR ( integer )" 4 .IX Item "ret: $index ( integer )" .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .ie n .SS """name""" .el .SS \f(CWname\fP .IX Subsection "name" Get the name of the module's \fI.c\fR file .PP .Vb 1 \& $name = $module\->name(); .Ve .ie n .IP "obj: $module ( ""Apache2::Module object"" )" 4 .el .IP "obj: \f(CW$module\fR ( \f(CWApache2::Module object\fR )" 4 .IX Item "obj: $module ( Apache2::Module object )" .PD 0 .ie n .IP "ret: $name ( string )" 4 .el .IP "ret: \f(CW$name\fR ( string )" 4 .IX Item "ret: $name ( string )" .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .PP For example a mod_perl module, will return: \fImod_perl.c\fR. .ie n .SS """next""" .el .SS \f(CWnext\fP .IX Subsection "next" Get the next module in the list, \f(CW\*(C`undef\*(C'\fR if this is the last module in the list. .PP .Vb 1 \& $next_module = $module\->next(); .Ve .ie n .IP "obj: $module ( ""Apache2::Module object"" )" 4 .el .IP "obj: \f(CW$module\fR ( \f(CWApache2::Module object\fR )" 4 .IX Item "obj: $module ( Apache2::Module object )" .PD 0 .ie n .IP "ret: $next_module ( ""Apache2::Module object"" )" 4 .el .IP "ret: \f(CW$next_module\fR ( \f(CWApache2::Module object\fR )" 4 .IX Item "ret: $next_module ( Apache2::Module object )" .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .ie n .SS """remove_loaded_module""" .el .SS \f(CWremove_loaded_module\fP .IX Subsection "remove_loaded_module" Remove a module from the list of loaded modules permanently. .PP .Vb 1 \& $module\->remove_loaded_module(); .Ve .ie n .IP "obj: $module ( ""Apache2::Module object"" )" 4 .el .IP "obj: \f(CW$module\fR ( \f(CWApache2::Module object\fR )" 4 .IX Item "obj: $module ( Apache2::Module object )" .PD 0 .IP "ret: no return value" 4 .IX Item "ret: no return value" .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .ie n .SS """top_module""" .el .SS \f(CWtop_module\fP .IX Subsection "top_module" Returns the first module in the module list. Useful to start a module iteration. .PP .Vb 1 \& $module = Apache2::Module::top_module(); .Ve .ie n .IP "ret: $module ( ""Apache2::Module object"" )" 4 .el .IP "ret: \f(CW$module\fR ( \f(CWApache2::Module object\fR )" 4 .IX Item "ret: $module ( Apache2::Module object )" .PD 0 .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .SH "See Also" .IX Header "See Also" mod_perl 2.0 documentation. .SH Copyright .IX Header "Copyright" mod_perl 2.0 and its core modules are copyrighted under The Apache Software License, Version 2.0. .SH Authors .IX Header "Authors" The mod_perl development team and numerous contributors.