check-includes.pl revision 499b34cea04a46823d003d4c0520c8b03e8513cb
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence# Copyright (C) 2000, 2001 Internet Software Consortium.
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# Permission to use, copy, modify, and distribute this software for any
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# purpose with or without fee is hereby granted, provided that the above
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister# copyright notice and this permission notice appear in all copies.
70e5a7403f0e0a3bd292b8287c5fed5772c15270Automatic Updater# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister# INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister# $Id: check-includes.pl,v 1.7 2001/01/09 22:00:46 bwelling Exp $
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister# Rudimentary, primarily for use by the developers.
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister# This just evolved with no serious attempt at making it
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister# bulletproof or foolproof. Or pretty even. Probably would
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister# have done it differently if it were actually designed as opposed
1b6d529cb5ee0ad44f8518e1b8c2cbca54bbdf18David Lawrence# to just growing as a multi-tentacled thing as various messages
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister# were either added or selectively silenced.
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister# XXX many warnings should not be made unless the header will be a public file
ae32d75897b39cf93af7348d101dcda8b4b12a54James Bristeruse vars qw($debug $isc_includes $dns_includes $lwres_includes
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister$isc_includes = "-Ilib/isc/include -Ilib/isc/unix/include " .
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister$dns_includes = "-Ilib/dns/include -Ilib/dns/sec/dst/include";
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister$0 =~ s%.*/%%;
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrencedie "Usage: $0 [-debug] headerfile ...\n" unless @ARGV > 0;
ae32d75897b39cf93af7348d101dcda8b4b12a54James Bristerunless (-f 'configure.in') {
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister die "$0: run from top of bind9 source tree\n";
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister# Outer loop runs once for each file.
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister unless ($file =~ /\.h$/) {
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister print "$0: skipping non-header file $file\n";
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister die "$0: $file: no such file\n" unless -f $file;
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister # header file fragments; ignore
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister # XXX rdatastruct itself is moderately tricky.
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister next if $file =~ m%/rdatastruct(pre|suf)\.h$%;
efe2f579ba6fbec4229129015780f2d925085b04Michael Graff # From external sources; ignore.
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister next if $file =~ m%lib/dns/sec/(dnssafe|openssl)%m;
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister # Totally wrong platform; ignore.
e44487bfc23599b6b240e09d83d1c862fecfcc82Michael Graff $tmpfile =~ s/\.h$/.c/;
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister $file =~ m%(.*/)?(.*)/(.*)\.h%;
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister $symbol =~ s/\\-/_/g;
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister if (! m%^\#ifndef\ $symbol\n
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister \#define\ $symbol\ 1\n
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister \#endif\ /\*\ $symbol\ \*/\n
ae32d75897b39cf93af7348d101dcda8b4b12a54James Brister print "$file has non-conforming wrapper for symbol $symbol\n"
print "$file has ISC_EVENTCLASS_ without <isc/eventclass.h>\n"
! m%^#include <isc/resultclass\.h>%m) {
print "$file has ISC_RESULTCLASS_ without <isc/resultclass.h>\n"
! m%^#include <isc/platform.h>%m) {
print "$file has ISC_PLATFORM_ without <isc/platform.h>\n"
print "$file has <isc/eventclass.h> without ISC_EVENTCLASS_\n";
print "$file has <isc/resultclass.h> without ISC_RESULTCLASS_\n";
print "$file has <isc/platform.h> but no ISC_PLATFORM_\n";
close(TMP);
compile() {
my $includes;