]> granicus.if.org Git - apache/blob - support/list_hooks.pl
hide some unused code on Win32 and NetWare
[apache] / support / list_hooks.pl
1 #!/usr/bin/perl -w
2 #
3 # Licensed to the Apache Software Foundation (ASF) under one or more
4 # contributor license agreements.  See the NOTICE file distributed with
5 # this work for additional information regarding copyright ownership.
6 # The ASF licenses this file to You under the Apache License, Version 2.0
7 # (the "License"); you may not use this file except in compliance with
8 # the License.  You may obtain a copy of the License at
9 #
10 #     http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17
18 use strict;
19
20 use Carp;
21
22 my $path=shift || '.';
23
24 findInDir($path);
25
26 foreach my $hook (sort keys %::Hooks) {
27     my $h=$::Hooks{$hook};
28     for my $x (qw(declared implemented type args)) {
29         print "$hook datum '$x' missing\n" if !exists $h->{$x};
30     }
31     print "$hook\n";
32     print "  declared in $h->{declared}\n" if defined $h->{declared};
33     print "  implemented in $h->{implemented}\n" if defined $h->{implemented};
34     print "  type is $h->{type}\n" if defined $h->{type};
35     print "  $h->{ret} $hook($h->{args})\n" if defined $h->{args};
36     print "\n";
37 }
38
39 sub findInDir {
40     my $path=shift;
41
42     local(*D);
43     opendir(D,$path) || croak "Can't open $path: $!";
44     while(my $f=readdir D) {
45         next if $f=~/^\./;
46         my $file="$path/$f";
47
48         if(-d $file) {
49             findInDir($file);
50             next;
51         }
52         next if $file !~ /\.[ch]$/;
53
54         scanFile($file);
55     }
56     closedir D;
57 }
58
59 sub scanFile {
60     my $file=shift;
61
62 #   print "scanning $file\n";
63
64     open(F,$file) || croak "Can't open $file: $!";
65     while(<F>) {
66         next if /\#define/;
67         next if /\@deffunc/;
68         if(/AP_DECLARE_HOOK\s*\(/) {
69             my($ret,$name,$args);
70             while(!(($ret,$name,$args)=
71                    /AP_DECLARE_HOOK\s*\(\s*([^,]+)\s*,\s*([^,\s]+)\s*,\s*\((.*?)\)\)/s)) {
72                 chomp;
73                 # swallow subsequent lines if needed to get all the required info
74                 my $l=<F>;
75                 return unless defined $l;
76                 $l=~s/^\s*/ /;
77                 $_.=$l;
78             }
79             $ret=~s/\s*$//;
80             $args=~s/^\s*//; $args=~s/\s*$//;
81 #           print "found $ret $name($args) in $file\n";
82
83             croak "$name declared twice! ($_)"
84                 if exists $::Hooks{$name}->{declared};
85             $::Hooks{$name}->{declared}=$file;
86             $::Hooks{$name}->{ret}=$ret;
87             $::Hooks{$name}->{args}=$args;
88         }
89         if(/AP_IMPLEMENT_HOOK_()(VOID)\(([^,\s]+)/
90            || /AP_IMPLEMENT(_OPTIONAL|)_HOOK_(.*?)\([^,]+?\s*,\s*([^,\s]+)/) {
91             my($type,$name)=($1 ? "OPTIONAL $2" : $2,$3);
92
93 #           print "found $name $type in $file\n";
94
95             croak "$name implemented twice ($::Hooks{$name}->{implemented} and $file) ($_)"
96                 if exists $::Hooks{$name}->{implemented};
97             $::Hooks{$name}->{implemented}=$file;
98             $::Hooks{$name}->{type}=$type;
99         }
100     }
101 }