summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Laurie <ben@apache.org>2001-05-27 17:31:08 +0200
committerBen Laurie <ben@apache.org>2001-05-27 17:31:08 +0200
commit6148b9896401e93fd5a030b1aec030073f687d4f (patch)
tree5ce22215d00c95b132ab00be45e5c05425927f1c
parentmod_ssl status (diff)
downloadapache2-6148b9896401e93fd5a030b1aec030073f687d4f.tar.xz
apache2-6148b9896401e93fd5a030b1aec030073f687d4f.zip
Utility to list available hooks.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@89232 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--os/unix/unixd.h3
-rwxr-xr-xsupport/list_hooks.pl77
2 files changed, 78 insertions, 2 deletions
diff --git a/os/unix/unixd.h b/os/unix/unixd.h
index e943b38912..344f5a7183 100644
--- a/os/unix/unixd.h
+++ b/os/unix/unixd.h
@@ -79,8 +79,7 @@ typedef struct {
gid_t gid;
} ap_unix_identity_t;
-AP_DECLARE_HOOK(ap_unix_identity_t *, get_suexec_identity,(const request_rec *r)
-)
+AP_DECLARE_HOOK(ap_unix_identity_t *, get_suexec_identity,(const request_rec *r))
/* common stuff that unix MPMs will want */
diff --git a/support/list_hooks.pl b/support/list_hooks.pl
new file mode 100755
index 0000000000..c52c567142
--- /dev/null
+++ b/support/list_hooks.pl
@@ -0,0 +1,77 @@
+#!/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)) {
+ croak "$hook datum '$x' missing" if !exists $h->{$x};
+ }
+ print "$hook\n";
+ print " declared in $h->{declared}\n";
+ print " implemented in $h->{implemented}\n";
+ print " type is $h->{type}\n";
+ print " $h->{ret} $hook($h->{args})\n";
+ 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;
+ }
+ 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;
+ }
+ }
+}