home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-perl-addon-1.4.9-installer.exe / Directive.pm < prev    next >
Encoding:
Perl POD Document  |  2004-09-23  |  7.1 KB  |  409 lines

  1. # /*
  2. #  * *********** WARNING **************
  3. #  * This file generated by ModPerl::WrapXS/0.01
  4. #  * Any changes made here will be lost
  5. #  * ***********************************
  6. #  * 01: lib/ModPerl/Code.pm:701
  7. #  * 02: O:\147xampp\sources\mod_perl-1.99_16\blib\lib/ModPerl/WrapXS.pm:584
  8. #  * 03: O:\147xampp\sources\mod_perl-1.99_16\blib\lib/ModPerl/WrapXS.pm:1100
  9. #  * 04: Makefile.PL:335
  10. #  * 05: Makefile.PL:283
  11. #  * 06: Makefile.PL:51
  12. #  */
  13.  
  14.  
  15. package Apache::Directive;
  16.  
  17. use strict;
  18. use warnings FATAL => 'all';
  19.  
  20.  
  21.  
  22. use Apache::XSLoader ();
  23. our $VERSION = '0.01';
  24. Apache::XSLoader::load __PACKAGE__;
  25.  
  26.  
  27.  
  28. 1;
  29. __END__
  30.  
  31. =head1 NAME
  32.  
  33. Apache::Directive - Perl API for manipulating Apache configuration tree
  34.  
  35.  
  36.  
  37.  
  38. =head1 Synopsis
  39.  
  40.   use Apache::Directive ();
  41.   
  42.   my $tree = Apache::Directive->conftree;
  43.   
  44.   my $documentroot = $tree->lookup('DocumentRoot');
  45.   
  46.   my $vhost = $tree->lookup('VirtualHost', 'localhost:8000');
  47.   my $servername = $vhost->{'ServerName'};
  48.   
  49.   use Data::Dumper;
  50.   print Dumper($tree->as_hash);
  51.   
  52.   my $node = $tree;
  53.   while ($node) {
  54.       print $node->as_string;
  55.  
  56.       #do something with $node
  57.   
  58.       if (my $kid = $node->first_child) {
  59.           $node = $kid;
  60.       } 
  61.       elsif (my $next = $node->next) {
  62.           $node = $next;
  63.       }
  64.       else {
  65.           if (my $parent = $node->parent) {
  66.               $node = $parent->next;
  67.           }
  68.           else {
  69.               $node = undef;
  70.           }
  71.       }
  72.   }
  73.  
  74.  
  75.  
  76.  
  77.  
  78. =head1 Description
  79.  
  80. C<Apache::Directive> allows its users to search and navigate the
  81. internal Apache configuration.
  82.  
  83. Internally, this information is stored in a tree structure. Each node
  84. in the tree has a reference to its parent (if it's not the root), its
  85. first child (if any), and to its next sibling.
  86.  
  87. B<All these methods are read-only>
  88.  
  89.  
  90.  
  91.  
  92.  
  93. =head1 API
  94.  
  95. C<Apache::Directive> provides the following functions and/or methods:
  96.  
  97.  
  98.  
  99.  
  100.  
  101. =head2 C<args> 
  102.  
  103. The arguments for the current directive, stored as a space separated
  104. list
  105.  
  106.   $args      = $node->args();
  107.  
  108. =over 4
  109.  
  110. =item obj: C<$node>
  111. ( C<L<Apache::Directive object|docs::2.0::api::Apache::Directive>> )
  112.  
  113. =item ret: C<$args> ( string )
  114.  
  115. =item since: 1.99_12
  116.  
  117. =back
  118.  
  119.  
  120.  
  121. =head2 C<as_hash>
  122.  
  123. Returns a hash representation of the configuration tree, in a format
  124. suitable for inclusion in E<lt>PerlE<gt> sections.
  125.  
  126.    $config_hash = $conftree->as_hash();
  127.  
  128. =over 4
  129.  
  130. =item obj: C<$conftree>
  131. ( C<L<Apache::Directive object|docs::2.0::api::Apache::Directive>> )
  132.  
  133. The config tree to stringify
  134.  
  135. =item ret: C<$config_hash> (HASH)
  136.  
  137. =item since: 1.99_12
  138.  
  139. =back
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146. =head2 C<as_string>
  147.  
  148. Returns a string representation of the configuration node, in
  149. F<httpd.conf> format. This does not traverse down to sub-trees.
  150.  
  151.    $string = $node->as_string();
  152.  
  153. =over 4
  154.  
  155. =item obj: C<$node>
  156. ( C<L<Apache::Directive object|docs::2.0::api::Apache::Directive>> )
  157.  
  158. The config tree to stringify
  159.  
  160. =item ret: C<$string> ( string )
  161.  
  162. =item since: 1.99_12
  163.  
  164. =back
  165.  
  166.  
  167.  
  168. =head2 C<conftree>
  169.  
  170. Returns the root of the configuration tree.
  171.  
  172.   $tree = Apache::Directive->conftree();
  173.  
  174. =over 4
  175.  
  176. =item obj: C<Apache::Directive> (class name)
  177.  
  178. =item ret: C<$tree> ( C<L<Apache::Directive object|docs::2.0::api::Apache::Directive>> )
  179.  
  180. =item since: 1.99_12
  181.  
  182. =back
  183.  
  184.  
  185.  
  186.  
  187.  
  188. =head2 C<directive>
  189.  
  190. Returns the name of the directive in C<$node>.
  191.  
  192.   $name = $node->directive();
  193.  
  194. =over 4
  195.  
  196. =item obj: C<$node>
  197. ( C<L<Apache::Directive object|docs::2.0::api::Apache::Directive>> )
  198.  
  199. =item ret: C<$directive> ( string )
  200.  
  201. =item since: 1.99_12
  202.  
  203. =back
  204.  
  205.  
  206.  
  207.  
  208.  
  209. =head2 C<filename>
  210.  
  211. Returns the filename the configuration node was created from
  212.  
  213.   $filename = $node->filename();
  214.  
  215. =over 4
  216.  
  217. =item obj: C<$node>
  218. ( C<L<Apache::Directive object|docs::2.0::api::Apache::Directive>> )
  219.  
  220. =item ret: C<$filename> ( string )
  221.  
  222. =item since: 1.99_12
  223.  
  224. =back
  225.  
  226.  
  227.  
  228.  
  229.  
  230. =head2 C<first_child>
  231.  
  232. The first child node of this directive
  233.  
  234.   $subtree = $node->first_child;
  235.  
  236. =over 4
  237.  
  238. =item obj: C<$node>
  239. ( C<L<Apache::Directive object|docs::2.0::api::Apache::Directive>> )
  240.  
  241. =item ret: C<$child_node>
  242. ( C<L<Apache::Directive object|docs::2.0::api::Apache::Directive>> )
  243.  
  244. Returns the first child node of C<$node>, C<undef> if there is none
  245.  
  246. =item since: 1.99_12
  247.  
  248. =back
  249.  
  250.  
  251.  
  252.  
  253. =head2 C<line_num>
  254.  
  255. Returns the line number in C<filename> this node was created from
  256.  
  257.   $lineno = $node->line_num();
  258.  
  259. =over 4
  260.  
  261. =item obj: C<$node>
  262. ( C<L<Apache::Directive object|docs::2.0::api::Apache::Directive>> )
  263.  
  264. =item arg1: C<$lineno> (integer)
  265.  
  266. =item since: 1.99_12
  267.  
  268. =back
  269.  
  270.  
  271.  
  272.  
  273. =head2 C<lookup>
  274.  
  275. Returns node(s) matching a certain value.
  276.  
  277.   $node  = $conftree->lookup($directive, $args);
  278.   @nodes = $conftree->lookup($directive, $args);
  279.  
  280. =over 4
  281.  
  282. =item obj: C<$conftree>
  283. ( C<L<Apache::Directive object|docs::2.0::api::Apache::Directive>> )
  284.  
  285. The config tree to stringify
  286.  
  287. =item arg1: C<$directive> ( string )
  288.  
  289. =item opt arg2: C<args> ( string )
  290.  
  291. =item ret: C<$string> ( string / ARRAY of HASHES )
  292.  
  293. In list context, it will return all matching nodes.
  294.  
  295. In scalar context, it will return only the first matching node.
  296.  
  297. If called with only C<$directive> value, this will return all nodes
  298. from that directive. For example:
  299.  
  300.   @Alias = $conftree->lookup('Alias');
  301.  
  302. would return all nodes for Alias directives.
  303.  
  304. If called with an extra C<$args> argument, this will return only nodes
  305. where both the directive and the args matched. For example:
  306.  
  307.   $VHost = $tree->lookup('VirtualHost', '_default_:8000');
  308.  
  309. =item since: 1.99_12
  310.  
  311. =back
  312.  
  313. If called with only one C<$directive> value, this will return all
  314. nodes from that directive:
  315.  
  316.   @Alias = $tree->lookup('Alias');
  317.  
  318. Would return all nodes for Alias directives.
  319.  
  320. If called with an extra C<$args> argument, this will return only nodes
  321. where both the directive and the args matched:
  322.  
  323.   $VHost = $tree->lookup('VirtualHosts', '_default_:8000');
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336. =head2 C<next>
  337.  
  338. The next directive node in the tree
  339.  
  340.   $next_node = $node->next();
  341.  
  342. =over 4
  343.  
  344. =item obj: C<$node>
  345. ( C<L<Apache::Directive object|docs::2.0::api::Apache::Directive>> )
  346.  
  347. =item ret: C<$next_node>
  348. ( C<L<Apache::Directive object|docs::2.0::api::Apache::Directive>> )
  349.  
  350. Returns the next sibling of C<$node>, C<undef> if there is none
  351.  
  352. =item since: 1.99_12
  353.  
  354. =back
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361. =head2 C<parent>
  362.  
  363. The parent node of this directive
  364.  
  365.   $parent_node = $node->parent();
  366.  
  367. =over 4
  368.  
  369. =item obj: C<$node> ( C<L<Apache::Directive object|docs::2.0::api::Apache::Directive>> )
  370.  
  371. =item ret: C<parent_node>
  372. ( C<L<Apache::Directive object|docs::2.0::api::Apache::Directive>> )
  373.  
  374. Returns the parent of C<$node>, C<undef> if this node is the root node
  375.  
  376. =item since: 1.99_12
  377.  
  378. =back
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385. =head1 See Also
  386.  
  387. L<mod_perl 2.0 documentation|docs::2.0::index>.
  388.  
  389.  
  390.  
  391.  
  392. =head1 Copyright
  393.  
  394. mod_perl 2.0 and its core modules are copyrighted under
  395. The Apache Software License, Version 2.0.
  396.  
  397.  
  398.  
  399.  
  400. =head1 Authors
  401.  
  402. L<The mod_perl development team and numerous
  403. contributors|about::contributors::people>.
  404.  
  405. =cut
  406.  
  407.