1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#!/usr/bin/perl -w
use strict;
use Carp;
my $path=shift || '.';
findInDir($path);
foreach my $hook (sort keys %::Hooks) {
my $h=$::Hooks{$hook};
for my $x (qw(declared implemented type args)) {
print "$hook datum '$x' missing\n" if !exists $h->{$x};
}
print "$hook\n";
print " declared in $h->{declared}\n" if defined $h->{declared};
print " implemented in $h->{implemented}\n" if defined $h->{implemented};
print " type is $h->{type}\n" if defined $h->{type};
print " $h->{ret} $hook($h->{args})\n" if defined $h->{args};
print "\n";
}
sub findInDir {
my $path=shift;
local(*D);
opendir(D,$path) || croak "Can't open $path: $!";
while(my $f=readdir D) {
next if $f=~/^\./;
my $file="$path/$f";
if(-d $file) {
findInDir($file);
next;
}
next if $file !~ /\.[ch]$/;
scanFile($file);
}
closedir D;
}
sub scanFile {
my $file=shift;
# print "scanning $file\n";
open(F,$file) || croak "Can't open $file: $!";
while(<F>) {
next if /\#define/;
next if /\@deffunc/;
if(/AP_DECLARE_HOOK\((.*)\)/) {
my $def=$1;
my($ret,$name,$args)=$def=~/([^,\s]+)\s*,\s*([^,\s]+)\s*,\s*\((.*)\)/;
croak "Don't understand $def in $file" if !defined $args;
# print "found $ret $name($args) in $file\n";
croak "$name declared twice! ($_)"
if exists $::Hooks{$name}->{declared};
$::Hooks{$name}->{declared}=$file;
$::Hooks{$name}->{ret}=$ret;
$::Hooks{$name}->{args}=$args;
} elsif(/AP_DECLARE_HOOK\((\s*[^,\s]+)\s*,\s*([^,\s]+)/) {
# really we should swallow subsequent lines to get the arguments...
my $name=$2;
my $ret=$1;
croak "$name declared twice! ($_)"
if exists $::Hooks{$name}->{declared};
$::Hooks{$name}->{declared}=$file;
$::Hooks{$name}->{ret}=$ret;
$::Hooks{$name}->{args}='???';
}
if(/AP_IMPLEMENT_HOOK_()(VOID)\(([^,\s]+)/
|| /AP_IMPLEMENT(_OPTIONAL|)_HOOK_(.*?)\([^,]+?\s*,\s*([^,\s]+)/) {
my($type,$name)=($1 ? "OPTIONAL $2" : $2,$3);
# print "found $name $type in $file\n";
croak "$name implemented twice ($::Hooks{$name}->{implemented} and $file) ($_)"
if exists $::Hooks{$name}->{implemented};
$::Hooks{$name}->{implemented}=$file;
$::Hooks{$name}->{type}=$type;
}
}
}
|