.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" 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 .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . 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 .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "libapache2-mod-perl2-2.0.11::docs::api::Apache2::Directive 3pm" .TH libapache2-mod-perl2-2.0.11::docs::api::Apache2::Directive 3pm "2021-02-22" "perl v5.32.1" "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::Directive \- Perl API for manipulating the Apache configuration tree .SH "Synopsis" .IX Header "Synopsis" .Vb 1 \& use Apache2::Directive (); \& \& my $tree = Apache2::Directive::conftree(); \& \& my $documentroot = $tree\->lookup(\*(AqDocumentRoot\*(Aq); \& \& my $vhost = $tree\->lookup(\*(AqVirtualHost\*(Aq, \*(Aqlocalhost:8000\*(Aq); \& my $servername = $vhost\->{\*(AqServerName\*(Aq}; \& \& use Data::Dumper; \& print Dumper $tree\->as_hash; \& \& my $node = $tree; \& while ($node) { \& print $node\->as_string; \& \& #do something with $node \& \& my $directive = $node\->directive; \& my $args = $node\->args; \& my $filename = $node\->filename; \& my $line_num = $node\->line_num; \& \& if (my $kid = $node\->first_child) { \& $node = $kid; \& } \& elsif (my $next = $node\->next) { \& $node = $next; \& } \& else { \& if (my $parent = $node\->parent) { \& $node = $parent\->next; \& } \& else { \& $node = undef; \& } \& } \& } .Ve .SH "Description" .IX Header "Description" \&\f(CW\*(C`Apache2::Directive\*(C'\fR provides the Perl \s-1API\s0 for manipulating the Apache configuration tree .SH "API" .IX Header "API" \&\f(CW\*(C`Apache2::Directive\*(C'\fR provides the following functions and/or methods: .ie n .SS """args""" .el .SS "\f(CWargs\fP" .IX Subsection "args" Get the arguments for the current directive: .PP .Vb 1 \& $args = $node\->args(); .Ve .ie n .IP "obj: $node ( ""Apache2::Directive object"" )" 4 .el .IP "obj: \f(CW$node\fR ( \f(CWApache2::Directive object\fR )" 4 .IX Item "obj: $node ( Apache2::Directive object )" .PD 0 .ie n .IP "ret: $args ( string )" 4 .el .IP "ret: \f(CW$args\fR ( string )" 4 .IX Item "ret: $args ( string )" .PD Arguments are separated by a whitespace in the string. .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PP For example, in \fIhttpd.conf\fR: .PP .Vb 1 \& PerlSwitches \-M/opt/lib \-M/usr/local/lib \-wT .Ve .PP And later: .PP .Vb 3 \& my $tree = Apache2::Directive::conftree(); \& my $node = $tree\->lookup(\*(AqPerlSwitches\*(Aq); \& my $args = $node\->args; .Ve .PP \&\f(CW$args\fR now contains the string \*(L"\-M/opt/lib \-M/usr/local/lib \-wT\*(R" .ie n .SS """as_hash""" .el .SS "\f(CWas_hash\fP" .IX Subsection "as_hash" Get a hash representation of the configuration tree, in a format suitable for inclusion in sections. .PP .Vb 1 \& $config_hash = $conftree\->as_hash(); .Ve .ie n .IP "obj: $conftree ( ""Apache2::Directive object"" )" 4 .el .IP "obj: \f(CW$conftree\fR ( \f(CWApache2::Directive object\fR )" 4 .IX Item "obj: $conftree ( Apache2::Directive object )" The config tree to stringify .ie n .IP "ret: $config_hash ( \s-1HASH\s0 reference )" 4 .el .IP "ret: \f(CW$config_hash\fR ( \s-1HASH\s0 reference )" 4 .IX Item "ret: $config_hash ( HASH reference )" .PD 0 .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .PP For example: in \fIhttpd.conf\fR: .PP .Vb 4 \& \& SetHandler perl\-script \& PerlHandler Test::Module \& .Ve .PP And later: .PP .Vb 3 \& my $tree = Apache2::Directive::conftree(); \& my $node = $tree\->lookup(\*(AqLocation\*(Aq, \*(Aq/test/\*(Aq); \& my $hash = $node\->as_hash; .Ve .PP \&\f(CW$hash\fR now is: .PP .Vb 4 \& { \& \*(AqSetHandler\*(Aq => \*(Aqperl\-script\*(Aq, \& \*(AqPerlHandler\*(Aq => \*(AqTest::Module\*(Aq, \& } .Ve .ie n .SS """as_string""" .el .SS "\f(CWas_string\fP" .IX Subsection "as_string" Get a string representation of the configuration node, in \&\fIhttpd.conf\fR format. .PP .Vb 1 \& $string = $node\->as_string(); .Ve .ie n .IP "obj: $node ( ""Apache2::Directive object"" )" 4 .el .IP "obj: \f(CW$node\fR ( \f(CWApache2::Directive object\fR )" 4 .IX Item "obj: $node ( Apache2::Directive object )" The config tree to stringify .ie n .IP "ret: $string ( string )" 4 .el .IP "ret: \f(CW$string\fR ( string )" 4 .IX Item "ret: $string ( string )" .PD 0 .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .PP For example: in \fIhttpd.conf\fR: .PP .Vb 4 \& \& SetHandler perl\-script \& PerlHandler Test::Module \& .Ve .PP And later: .PP .Vb 3 \& my $tree = Apache2::Directive::conftree(); \& my $node = $tree\->lookup(\*(AqLocation\*(Aq, \*(Aq/test/\*(Aq); \& my $string = $node\->as_string; .Ve .PP \&\f(CW$string\fR is now: .PP .Vb 2 \& SetHandler perl\-script \& PerlHandler Test::Module .Ve .ie n .SS """conftree""" .el .SS "\f(CWconftree\fP" .IX Subsection "conftree" Get the root of the configuration tree: .PP .Vb 1 \& $conftree = Apache2::Directive::conftree(); .Ve .ie n .IP "obj: ""Apache2::Directive"" ( class name )" 4 .el .IP "obj: \f(CWApache2::Directive\fR ( class name )" 4 .IX Item "obj: Apache2::Directive ( class name )" .PD 0 .ie n .IP "ret: $conftree ( ""Apache2::Directive object"" )" 4 .el .IP "ret: \f(CW$conftree\fR ( \f(CWApache2::Directive object\fR )" 4 .IX Item "ret: $conftree ( Apache2::Directive object )" .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .ie n .SS """directive""" .el .SS "\f(CWdirective\fP" .IX Subsection "directive" Get the name of the directive in \f(CW$node\fR: .PP .Vb 1 \& $name = $node\->directive(); .Ve .ie n .IP "obj: $node ( ""Apache2::Directive object"" )" 4 .el .IP "obj: \f(CW$node\fR ( \f(CWApache2::Directive object\fR )" 4 .IX Item "obj: $node ( Apache2::Directive 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 .ie n .SS """filename""" .el .SS "\f(CWfilename\fP" .IX Subsection "filename" Get the \fIfilename\fR the configuration node was created from: .PP .Vb 1 \& $filename = $node\->filename(); .Ve .ie n .IP "obj: $node ( ""Apache2::Directive object"" )" 4 .el .IP "obj: \f(CW$node\fR ( \f(CWApache2::Directive object\fR )" 4 .IX Item "obj: $node ( Apache2::Directive object )" .PD 0 .ie n .IP "ret: $filename ( string )" 4 .el .IP "ret: \f(CW$filename\fR ( string )" 4 .IX Item "ret: $filename ( string )" .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .PP For example: .PP .Vb 3 \& my $tree = Apache2::Directive::conftree(); \& my $node = $tree\->lookup(\*(AqVirtualHost\*(Aq, \*(Aqexample.com\*(Aq); \& my $filename = $node\->filename; .Ve .PP \&\f(CW$filename\fR is now the full path to the \fIhttpd.conf\fR that VirtualHost was defined in. .PP If the directive was added with \&\f(CW\*(C`add_config()\*(C'\fR, the filename will be the path to the \fIhttpd.conf\fR that trigerred that Perl code. .ie n .SS """first_child""" .el .SS "\f(CWfirst_child\fP" .IX Subsection "first_child" Get the first child node of this directive: .PP .Vb 1 \& $child_node = $node\->first_child; .Ve .ie n .IP "obj: $node ( ""Apache2::Directive object"" )" 4 .el .IP "obj: \f(CW$node\fR ( \f(CWApache2::Directive object\fR )" 4 .IX Item "obj: $node ( Apache2::Directive object )" .PD 0 .ie n .IP "ret: $child_node ( ""Apache2::Directive object"" )" 4 .el .IP "ret: \f(CW$child_node\fR ( \f(CWApache2::Directive object\fR )" 4 .IX Item "ret: $child_node ( Apache2::Directive object )" .PD Returns the first child node of \f(CW$node\fR, \f(CW\*(C`undef\*(C'\fR if there is none .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .ie n .SS """line_num""" .el .SS "\f(CWline_num\fP" .IX Subsection "line_num" Get the line number in a \fIfilename\fR this node was created at: .PP .Vb 1 \& $lineno = $node\->line_num(); .Ve .ie n .IP "obj: $node ( ""Apache2::Directive object"" )" 4 .el .IP "obj: \f(CW$node\fR ( \f(CWApache2::Directive object\fR )" 4 .IX Item "obj: $node ( Apache2::Directive object )" .PD 0 .ie n .IP "arg1: $lineno (integer)" 4 .el .IP "arg1: \f(CW$lineno\fR (integer)" 4 .IX Item "arg1: $lineno (integer)" .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .ie n .SS """lookup""" .el .SS "\f(CWlookup\fP" .IX Subsection "lookup" Get the node(s) matching a certain value. .PP .Vb 2 \& $node = $conftree\->lookup($directive, $args); \& @nodes = $conftree\->lookup($directive, $args); .Ve .ie n .IP "obj: $conftree ( ""Apache2::Directive object"" )" 4 .el .IP "obj: \f(CW$conftree\fR ( \f(CWApache2::Directive object\fR )" 4 .IX Item "obj: $conftree ( Apache2::Directive object )" The config tree to stringify .ie n .IP "arg1: $directive ( string )" 4 .el .IP "arg1: \f(CW$directive\fR ( string )" 4 .IX Item "arg1: $directive ( string )" The name of the directive to search for .ie n .IP "opt arg2: ""args"" ( string )" 4 .el .IP "opt arg2: \f(CWargs\fR ( string )" 4 .IX Item "opt arg2: args ( string )" Optional args to the directive to filter for .ie n .IP "ret: $string ( string / \s-1ARRAY\s0 of \s-1HASH\s0 refs )" 4 .el .IP "ret: \f(CW$string\fR ( string / \s-1ARRAY\s0 of \s-1HASH\s0 refs )" 4 .IX Item "ret: $string ( string / ARRAY of HASH refs )" In \s-1LIST\s0 context, it returns all matching nodes. .Sp In \s-1SCALAR\s0 context, it returns only the first matching node. .Sp If called with only \f(CW$directive\fR value, this method returns all nodes from that directive. For example: .Sp .Vb 1 \& @Alias = $conftree\->lookup(\*(AqAlias\*(Aq); .Ve .Sp returns all nodes for \f(CW\*(C`Alias\*(C'\fR directives. .Sp If called with an extra \f(CW$args\fR argument, it returns only nodes where both the directive and the args matched. For example: .Sp .Vb 1 \& $VHost = $tree\->lookup(\*(AqVirtualHost\*(Aq, \*(Aq_default_:8000\*(Aq); .Ve .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .ie n .SS """next""" .el .SS "\f(CWnext\fP" .IX Subsection "next" Get the next directive node in the tree: .PP .Vb 1 \& $next_node = $node\->next(); .Ve .ie n .IP "obj: $node ( ""Apache2::Directive object"" )" 4 .el .IP "obj: \f(CW$node\fR ( \f(CWApache2::Directive object\fR )" 4 .IX Item "obj: $node ( Apache2::Directive object )" .PD 0 .ie n .IP "ret: $next_node ( ""Apache2::Directive object"" )" 4 .el .IP "ret: \f(CW$next_node\fR ( \f(CWApache2::Directive object\fR )" 4 .IX Item "ret: $next_node ( Apache2::Directive object )" .PD Returns the next sibling of \f(CW$node\fR, \f(CW\*(C`undef\*(C'\fR if there is none .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .ie n .SS """parent""" .el .SS "\f(CWparent\fP" .IX Subsection "parent" Get the parent node of this directive: .PP .Vb 1 \& $parent_node = $node\->parent(); .Ve .ie n .IP "obj: $node ( ""Apache2::Directive object"" )" 4 .el .IP "obj: \f(CW$node\fR ( \f(CWApache2::Directive object\fR )" 4 .IX Item "obj: $node ( Apache2::Directive object )" .PD 0 .ie n .IP "ret: ""parent_node"" ( ""Apache2::Directive object"" )" 4 .el .IP "ret: \f(CWparent_node\fR ( \f(CWApache2::Directive object\fR )" 4 .IX Item "ret: parent_node ( Apache2::Directive object )" .PD Returns the parent of \f(CW$node\fR, \f(CW\*(C`undef\*(C'\fR if this node is the root node .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .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.