Directory/Apache.pm untested

filter: Statementstmt 0.0% 0 / 50 Branchbran 0.0% 0 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 75 CC 9 SCAR 36.9
CC
9
Cov
0%
handler
72.0
BEGIN
6.0
BEGIN
2.0
CRAP 39.9
1 package XML::Directory::Apache;
2  
3 require 5.005_03;
4 BEGIN { require warnings if $] >= 5.006; }
5  
6 use strict;
7 use XML::Directory::String;
8 use Apache::Constants qw(:common );
9  
10  
11 sub handler {
12 my $r = shift;
13 my %query = $r->args;
14 my $path = $r->path_info;
15 my $dets = 2;
16 my $depth = 1000;
17 my $ret;
18  
19 $dets = $query{dets} if $query{dets};
20 $depth = $query{depth} if $query{depth};
21  
22 if ($path) {
23  
24 my $dir = new XML::Directory::String($path,$dets,$depth);
25 $dir->enable_ns if $query{ns} == 1;
26 $dir->error_treatment('warn');
27 my $rc = $dir->parse;
28 $ret = $dir->get_string;
29  
30 } else {
31  
32 my $dir = new XML::Directory;
33 $dir->enable_ns if $query{ns} == 1;
34 my $ns = $dir->get_ns_data;
35  
36 my $pref = '';
37 my $decl = '';
38 if ($ns->{enabled}) {
39 if ($ns->{prefix}) {
40 $pref = "$ns->{prefix}:";
41 $decl = " xmlns:$ns->{prefix}=\"$ns->{uri}\"";
42 } else {
43 $decl = " xmlns=\"$ns->{uri}\"";
44 }
45 }
46  
47 $ret .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
48 $ret .= "<$pref" . 'dirtree' . "$decl>\n";
49 $ret .= "<$pref"
50 . "error number=\"100\">Path not defined!</$pref" . "error>\n";
51 $ret .= "</$pref" . "dirtree>\n";
52 }
53  
54 $r->status(OK);
55 $r->content_type("text/xml");
56 $r->no_cache(1);
57 $r->send_http_header();
58 $r->print($ret);
59  
60  
61 return OK;
62 }
63  
64 1;
65  
66 __END__