|
Packit |
90a5c9 |
#!/usr/bin/perl -w
|
|
Packit |
90a5c9 |
#
|
|
Packit |
90a5c9 |
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
Packit |
90a5c9 |
# contributor license agreements. See the NOTICE file distributed with
|
|
Packit |
90a5c9 |
# this work for additional information regarding copyright ownership.
|
|
Packit |
90a5c9 |
# The ASF licenses this file to You under the Apache License, Version 2.0
|
|
Packit |
90a5c9 |
# (the "License"); you may not use this file except in compliance with
|
|
Packit |
90a5c9 |
# the License. You may obtain a copy of the License at
|
|
Packit |
90a5c9 |
#
|
|
Packit |
90a5c9 |
# http://www.apache.org/licenses/LICENSE-2.0
|
|
Packit |
90a5c9 |
#
|
|
Packit |
90a5c9 |
# Unless required by applicable law or agreed to in writing, software
|
|
Packit |
90a5c9 |
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
Packit |
90a5c9 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
Packit |
90a5c9 |
# See the License for the specific language governing permissions and
|
|
Packit |
90a5c9 |
# limitations under the License.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
use strict;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
use Carp;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
my $path=shift || '.';
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
findInDir($path);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
foreach my $hook (sort keys %::Hooks) {
|
|
Packit |
90a5c9 |
my $h=$::Hooks{$hook};
|
|
Packit |
90a5c9 |
for my $x (qw(declared implemented type args)) {
|
|
Packit |
90a5c9 |
print "$hook datum '$x' missing\n" if !exists $h->{$x};
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
print "$hook\n";
|
|
Packit |
90a5c9 |
print " declared in $h->{declared}\n" if defined $h->{declared};
|
|
Packit |
90a5c9 |
print " implemented in $h->{implemented}\n" if defined $h->{implemented};
|
|
Packit |
90a5c9 |
print " type is $h->{type}\n" if defined $h->{type};
|
|
Packit |
90a5c9 |
print " $h->{ret} $hook($h->{args})\n" if defined $h->{args};
|
|
Packit |
90a5c9 |
print "\n";
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
sub findInDir {
|
|
Packit |
90a5c9 |
my $path=shift;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
local(*D);
|
|
Packit |
90a5c9 |
opendir(D,$path) || croak "Can't open $path: $!";
|
|
Packit |
90a5c9 |
while(my $f=readdir D) {
|
|
Packit |
90a5c9 |
next if $f=~/^\./;
|
|
Packit |
90a5c9 |
my $file="$path/$f";
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if(-d $file) {
|
|
Packit |
90a5c9 |
findInDir($file);
|
|
Packit |
90a5c9 |
next;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
next if $file !~ /\.[ch]$/;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
scanFile($file);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
closedir D;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
sub scanFile {
|
|
Packit |
90a5c9 |
my $file=shift;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
# print "scanning $file\n";
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
open(F,$file) || croak "Can't open $file: $!";
|
|
Packit |
90a5c9 |
while(<F>) {
|
|
Packit |
90a5c9 |
next if /\#define/;
|
|
Packit |
90a5c9 |
next if /\@deffunc/;
|
|
Packit |
90a5c9 |
if(/AP_DECLARE_HOOK\s*\(/) {
|
|
Packit |
90a5c9 |
my($ret,$name,$args);
|
|
Packit |
90a5c9 |
while(!(($ret,$name,$args)=
|
|
Packit |
90a5c9 |
/AP_DECLARE_HOOK\s*\(\s*([^,]+)\s*,\s*([^,\s]+)\s*,\s*\((.*?)\)\)/s)) {
|
|
Packit |
90a5c9 |
chomp;
|
|
Packit |
90a5c9 |
# swallow subsequent lines if needed to get all the required info
|
|
Packit |
90a5c9 |
my $l=<F>;
|
|
Packit |
90a5c9 |
return unless defined $l;
|
|
Packit |
90a5c9 |
$l=~s/^\s*/ /;
|
|
Packit |
90a5c9 |
$_.=$l;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
$ret=~s/\s*$//;
|
|
Packit |
90a5c9 |
$args=~s/^\s*//; $args=~s/\s*$//;
|
|
Packit |
90a5c9 |
# print "found $ret $name($args) in $file\n";
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
croak "$name declared twice! ($_)"
|
|
Packit |
90a5c9 |
if exists $::Hooks{$name}->{declared};
|
|
Packit |
90a5c9 |
$::Hooks{$name}->{declared}=$file;
|
|
Packit |
90a5c9 |
$::Hooks{$name}->{ret}=$ret;
|
|
Packit |
90a5c9 |
$::Hooks{$name}->{args}=$args;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
if(/AP_IMPLEMENT_HOOK_()(VOID)\(([^,\s]+)/
|
|
Packit |
90a5c9 |
|| /AP_IMPLEMENT(_OPTIONAL|)_HOOK_(.*?)\([^,]+?\s*,\s*([^,\s]+)/) {
|
|
Packit |
90a5c9 |
my($type,$name)=($1 ? "OPTIONAL $2" : $2,$3);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
# print "found $name $type in $file\n";
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
croak "$name implemented twice ($::Hooks{$name}->{implemented} and $file) ($_)"
|
|
Packit |
90a5c9 |
if exists $::Hooks{$name}->{implemented};
|
|
Packit |
90a5c9 |
$::Hooks{$name}->{implemented}=$file;
|
|
Packit |
90a5c9 |
$::Hooks{$name}->{type}=$type;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|