📄 apache2::directive.3
字号:
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...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" '''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 turned on, we'll generate index entries on stderr for.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index.\" entries marked with X<> in POD. Of course, you'll have to process the.\" output yourself in some meaningful fashion..ie \nF \{\. de IX. tm Index:\\$1\t\\n%\t"\\$2"... nr % 0. rr F.\}.el \{\. de IX...\}.\".\" 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 "mod_perl-2.0.2::docs::api::Apache2::Directive 3".TH mod_perl-2.0.2::docs::api::Apache2::Directive 3 "2005-10-21" "perl v5.10.0" "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 Apacheconfiguration tree.SH "API".IX Header "API"\&\f(CW\*(C`Apache2::Directive\*(C'\fR provides the following functions and/or methods:.ie n .Sh """args""".el .Sh "\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\fR ( \f(CW""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 )".PDArguments are separated by a whitespace in the string..IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PPFor example, in \fIhttpd.conf\fR:.PP.Vb 1\& PerlSwitches \-M/opt/lib \-M/usr/local/lib \-wT.Ve.PPAnd 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 .Sh """as_hash""".el .Sh "\f(CWas_hash\fP".IX Subsection "as_hash"Get a hash representation of the configuration tree, in a formatsuitable for inclusion in <Perl> sections..PP.Vb 1\& $config_hash = $conftree\->as_hash();.Ve.ie n .IP "obj: $conftree\fR ( \f(CW""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.PPFor example: in \fIhttpd.conf\fR:.PP.Vb 4\& <Location /test>\& SetHandler perl\-script\& PerlHandler Test::Module\& </Location>.Ve.PPAnd 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 .Sh """as_string""".el .Sh "\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\fR ( \f(CW""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.PPFor example: in \fIhttpd.conf\fR:.PP.Vb 4\& <Location /test>\& SetHandler perl\-script\& PerlHandler Test::Module\& </Location>.Ve.PPAnd 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 .Sh """conftree""".el .Sh "\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\fR ( \f(CW""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 .Sh """directive""".el .Sh "\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\fR ( \f(CW""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 .Sh """filename""".el .Sh "\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\fR ( \f(CW""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.PPFor 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 thatVirtualHost was defined in..PPIf the directive was added with \&\f(CW\*(C`add_config()\*(C'\fR,the filename will be the path to the \fIhttpd.conf\fR that trigerredthat Perl code..ie n .Sh """first_child""".el .Sh "\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\fR ( \f(CW""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\fR ( \f(CW""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 )".PDReturns 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 .Sh """line_num""".el .Sh "\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\fR ( \f(CW""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 .Sh """lookup""".el .Sh "\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\fR ( \f(CW""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..SpIn \s-1SCALAR\s0 context, it returns only the first matching node..SpIf called with only \f(CW$directive\fR value, this method returns all nodesfrom that directive. For example:.Sp.Vb 1\& @Alias = $conftree\->lookup(\*(AqAlias\*(Aq);.Ve.Spreturns all nodes for \f(CW\*(C`Alias\*(C'\fR directives..SpIf called with an extra \f(CW$args\fR argument, it returns only nodes whereboth 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 .Sh """next""".el .Sh "\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\fR ( \f(CW""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\fR ( \f(CW""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 )".PDReturns 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 .Sh """parent""".el .Sh "\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\fR ( \f(CW""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""\fR ( \f(CW""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 )".PDReturns 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 underThe Apache Software License, Version 2.0..SH "Authors".IX Header "Authors"The mod_perl development team and numerouscontributors.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -