diff options
32 files changed, 183 insertions, 151 deletions
diff --git a/epan/dissectors/Makefile.nmake b/epan/dissectors/Makefile.nmake index 815cd33208..78c5174925 100644 --- a/epan/dissectors/Makefile.nmake +++ b/epan/dissectors/Makefile.nmake @@ -111,6 +111,6 @@ maintainer-clean: distclean rm -f $(GENERATED_FILES) checkapi: - $(PERL) ../../tools/checkAPIs.pl \ + $(PERL) ../../tools/checkAPIs.pl -g abort \ $(ALL_DISSECTORS_SRC) \ packet-dcerpc-nt.c diff --git a/plugins/agentx/Makefile.nmake b/plugins/agentx/Makefile.nmake index f4387832d2..dcf18805e8 100644 --- a/plugins/agentx/Makefile.nmake +++ b/plugins/agentx/Makefile.nmake @@ -100,4 +100,4 @@ distclean: clean maintainer-clean: distclean checkapi: - $(PERL) ../../tools/checkAPIs.pl $(DISSECTOR_SRC) + $(PERL) ../../tools/checkAPIs.pl -g abort $(DISSECTOR_SRC) diff --git a/plugins/artnet/Makefile.nmake b/plugins/artnet/Makefile.nmake index f4387832d2..dcf18805e8 100644 --- a/plugins/artnet/Makefile.nmake +++ b/plugins/artnet/Makefile.nmake @@ -100,4 +100,4 @@ distclean: clean maintainer-clean: distclean checkapi: - $(PERL) ../../tools/checkAPIs.pl $(DISSECTOR_SRC) + $(PERL) ../../tools/checkAPIs.pl -g abort $(DISSECTOR_SRC) diff --git a/plugins/asn1/Makefile.nmake b/plugins/asn1/Makefile.nmake index 2902af11b1..dfd5812d29 100644 --- a/plugins/asn1/Makefile.nmake +++ b/plugins/asn1/Makefile.nmake @@ -101,4 +101,4 @@ maintainer-clean: distclean checkapi: # TODO: Fix api's :) -# $(PERL) ../../tools/checkAPIs.pl $(DISSECTOR_SRC) +# $(PERL) ../../tools/checkAPIs.pl -g abort $(DISSECTOR_SRC) diff --git a/plugins/ciscosm/Makefile.nmake b/plugins/ciscosm/Makefile.nmake index f4387832d2..dcf18805e8 100644 --- a/plugins/ciscosm/Makefile.nmake +++ b/plugins/ciscosm/Makefile.nmake @@ -100,4 +100,4 @@ distclean: clean maintainer-clean: distclean checkapi: - $(PERL) ../../tools/checkAPIs.pl $(DISSECTOR_SRC) + $(PERL) ../../tools/checkAPIs.pl -g abort $(DISSECTOR_SRC) diff --git a/plugins/docsis/Makefile.nmake b/plugins/docsis/Makefile.nmake index f4387832d2..dcf18805e8 100644 --- a/plugins/docsis/Makefile.nmake +++ b/plugins/docsis/Makefile.nmake @@ -100,4 +100,4 @@ distclean: clean maintainer-clean: distclean checkapi: - $(PERL) ../../tools/checkAPIs.pl $(DISSECTOR_SRC) + $(PERL) ../../tools/checkAPIs.pl -g abort $(DISSECTOR_SRC) diff --git a/plugins/easy_codec/Makefile.nmake b/plugins/easy_codec/Makefile.nmake index 2c1adb4774..b6b9978e9b 100644 --- a/plugins/easy_codec/Makefile.nmake +++ b/plugins/easy_codec/Makefile.nmake @@ -64,4 +64,4 @@ distclean: clean maintainer-clean: distclean checkapi: - $(PERL) ../../tools/checkAPIs.pl $(DISSECTOR_SRC) + $(PERL) ../../tools/checkAPIs.pl -g abort $(DISSECTOR_SRC) diff --git a/plugins/enttec/Makefile.nmake b/plugins/enttec/Makefile.nmake index f4387832d2..dcf18805e8 100644 --- a/plugins/enttec/Makefile.nmake +++ b/plugins/enttec/Makefile.nmake @@ -100,4 +100,4 @@ distclean: clean maintainer-clean: distclean checkapi: - $(PERL) ../../tools/checkAPIs.pl $(DISSECTOR_SRC) + $(PERL) ../../tools/checkAPIs.pl -g abort $(DISSECTOR_SRC) diff --git a/plugins/ethercat/Makefile.nmake b/plugins/ethercat/Makefile.nmake index 582b54ca57..0b09e71e51 100644 --- a/plugins/ethercat/Makefile.nmake +++ b/plugins/ethercat/Makefile.nmake @@ -100,4 +100,4 @@ distclean: clean maintainer-clean: distclean checkapi: - $(PERL) ../../tools/checkAPIs.pl $(DISSECTOR_SRC) + $(PERL) ../../tools/checkAPIs.pl -g abort $(DISSECTOR_SRC) diff --git a/plugins/giop/Makefile.nmake b/plugins/giop/Makefile.nmake index 16ef412e52..0c7cd6b514 100644 --- a/plugins/giop/Makefile.nmake +++ b/plugins/giop/Makefile.nmake @@ -51,7 +51,7 @@ distclean: clean maintainer-clean: distclean checkapi: - $(PERL) ../../tools/checkAPIs.pl \ + $(PERL) ../../tools/checkAPIs.pl -g abort \ packet-cosnaming.c \ packet-coseventcomm.c \ packet-tango.c \ diff --git a/plugins/gryphon/Makefile.nmake b/plugins/gryphon/Makefile.nmake index f4387832d2..dcf18805e8 100644 --- a/plugins/gryphon/Makefile.nmake +++ b/plugins/gryphon/Makefile.nmake @@ -100,4 +100,4 @@ distclean: clean maintainer-clean: distclean checkapi: - $(PERL) ../../tools/checkAPIs.pl $(DISSECTOR_SRC) + $(PERL) ../../tools/checkAPIs.pl -g abort $(DISSECTOR_SRC) diff --git a/plugins/infiniband/Makefile.nmake b/plugins/infiniband/Makefile.nmake index f0f5d2dfa2..590652a023 100644 --- a/plugins/infiniband/Makefile.nmake +++ b/plugins/infiniband/Makefile.nmake @@ -96,4 +96,4 @@ distclean: clean maintainer-clean: distclean checkapi: - $(PERL) ../../tools/checkAPIs.pl $(DISSECTOR_SRC) + $(PERL) ../../tools/checkAPIs.pl -g abort $(DISSECTOR_SRC) diff --git a/plugins/irda/Makefile.nmake b/plugins/irda/Makefile.nmake index f4387832d2..dcf18805e8 100644 --- a/plugins/irda/Makefile.nmake +++ b/plugins/irda/Makefile.nmake @@ -100,4 +100,4 @@ distclean: clean maintainer-clean: distclean checkapi: - $(PERL) ../../tools/checkAPIs.pl $(DISSECTOR_SRC) + $(PERL) ../../tools/checkAPIs.pl -g abort $(DISSECTOR_SRC) diff --git a/plugins/lwres/Makefile.nmake b/plugins/lwres/Makefile.nmake index f4387832d2..dcf18805e8 100644 --- a/plugins/lwres/Makefile.nmake +++ b/plugins/lwres/Makefile.nmake @@ -100,4 +100,4 @@ distclean: clean maintainer-clean: distclean checkapi: - $(PERL) ../../tools/checkAPIs.pl $(DISSECTOR_SRC) + $(PERL) ../../tools/checkAPIs.pl -g abort $(DISSECTOR_SRC) diff --git a/plugins/m2m/Makefile.nmake b/plugins/m2m/Makefile.nmake index ad2bb88f5b..3c6db870c5 100644 --- a/plugins/m2m/Makefile.nmake +++ b/plugins/m2m/Makefile.nmake @@ -100,4 +100,4 @@ distclean: clean maintainer-clean: distclean checkapi: - $(PERL) ../../tools/checkAPIs.pl $(DISSECTOR_SRC) + $(PERL) ../../tools/checkAPIs.pl -g abort $(DISSECTOR_SRC) diff --git a/plugins/mate/Makefile.nmake b/plugins/mate/Makefile.nmake index ef8aee90d4..906b718202 100644 --- a/plugins/mate/Makefile.nmake +++ b/plugins/mate/Makefile.nmake @@ -128,4 +128,4 @@ $(LEMON)\lemon.exe: cd ../../plugins/mate checkapi: - $(PERL) ../../tools/checkAPIs.pl $(DISSECTOR_SRC) + $(PERL) ../../tools/checkAPIs.pl -g abort $(DISSECTOR_SRC) diff --git a/plugins/opcua/Makefile.nmake b/plugins/opcua/Makefile.nmake index f4387832d2..dcf18805e8 100644 --- a/plugins/opcua/Makefile.nmake +++ b/plugins/opcua/Makefile.nmake @@ -100,4 +100,4 @@ distclean: clean maintainer-clean: distclean checkapi: - $(PERL) ../../tools/checkAPIs.pl $(DISSECTOR_SRC) + $(PERL) ../../tools/checkAPIs.pl -g abort $(DISSECTOR_SRC) diff --git a/plugins/opsi/Makefile.nmake b/plugins/opsi/Makefile.nmake index f4387832d2..dcf18805e8 100644 --- a/plugins/opsi/Makefile.nmake +++ b/plugins/opsi/Makefile.nmake @@ -100,4 +100,4 @@ distclean: clean maintainer-clean: distclean checkapi: - $(PERL) ../../tools/checkAPIs.pl $(DISSECTOR_SRC) + $(PERL) ../../tools/checkAPIs.pl -g abort $(DISSECTOR_SRC) diff --git a/plugins/pcli/Makefile.nmake b/plugins/pcli/Makefile.nmake index f4387832d2..dcf18805e8 100644 --- a/plugins/pcli/Makefile.nmake +++ b/plugins/pcli/Makefile.nmake @@ -100,4 +100,4 @@ distclean: clean maintainer-clean: distclean checkapi: - $(PERL) ../../tools/checkAPIs.pl $(DISSECTOR_SRC) + $(PERL) ../../tools/checkAPIs.pl -g abort $(DISSECTOR_SRC) diff --git a/plugins/profinet/Makefile.nmake b/plugins/profinet/Makefile.nmake index f4387832d2..dcf18805e8 100644 --- a/plugins/profinet/Makefile.nmake +++ b/plugins/profinet/Makefile.nmake @@ -100,4 +100,4 @@ distclean: clean maintainer-clean: distclean checkapi: - $(PERL) ../../tools/checkAPIs.pl $(DISSECTOR_SRC) + $(PERL) ../../tools/checkAPIs.pl -g abort $(DISSECTOR_SRC) diff --git a/plugins/rlm/Makefile.nmake b/plugins/rlm/Makefile.nmake index f4387832d2..dcf18805e8 100644 --- a/plugins/rlm/Makefile.nmake +++ b/plugins/rlm/Makefile.nmake @@ -100,4 +100,4 @@ distclean: clean maintainer-clean: distclean checkapi: - $(PERL) ../../tools/checkAPIs.pl $(DISSECTOR_SRC) + $(PERL) ../../tools/checkAPIs.pl -g abort $(DISSECTOR_SRC) diff --git a/plugins/rtnet/Makefile.nmake b/plugins/rtnet/Makefile.nmake index f4387832d2..dcf18805e8 100644 --- a/plugins/rtnet/Makefile.nmake +++ b/plugins/rtnet/Makefile.nmake @@ -100,4 +100,4 @@ distclean: clean maintainer-clean: distclean checkapi: - $(PERL) ../../tools/checkAPIs.pl $(DISSECTOR_SRC) + $(PERL) ../../tools/checkAPIs.pl -g abort $(DISSECTOR_SRC) diff --git a/plugins/rudp/Makefile.nmake b/plugins/rudp/Makefile.nmake index f4387832d2..dcf18805e8 100644 --- a/plugins/rudp/Makefile.nmake +++ b/plugins/rudp/Makefile.nmake @@ -100,4 +100,4 @@ distclean: clean maintainer-clean: distclean checkapi: - $(PERL) ../../tools/checkAPIs.pl $(DISSECTOR_SRC) + $(PERL) ../../tools/checkAPIs.pl -g abort $(DISSECTOR_SRC) diff --git a/plugins/sbus/Makefile.nmake b/plugins/sbus/Makefile.nmake index f4387832d2..dcf18805e8 100644 --- a/plugins/sbus/Makefile.nmake +++ b/plugins/sbus/Makefile.nmake @@ -100,4 +100,4 @@ distclean: clean maintainer-clean: distclean checkapi: - $(PERL) ../../tools/checkAPIs.pl $(DISSECTOR_SRC) + $(PERL) ../../tools/checkAPIs.pl -g abort $(DISSECTOR_SRC) diff --git a/plugins/sercosiii/Makefile.nmake b/plugins/sercosiii/Makefile.nmake index f4387832d2..dcf18805e8 100644 --- a/plugins/sercosiii/Makefile.nmake +++ b/plugins/sercosiii/Makefile.nmake @@ -100,4 +100,4 @@ distclean: clean maintainer-clean: distclean checkapi: - $(PERL) ../../tools/checkAPIs.pl $(DISSECTOR_SRC) + $(PERL) ../../tools/checkAPIs.pl -g abort $(DISSECTOR_SRC) diff --git a/plugins/stats_tree/Makefile.nmake b/plugins/stats_tree/Makefile.nmake index 8c8501c5c7..e3cc88ecf9 100644 --- a/plugins/stats_tree/Makefile.nmake +++ b/plugins/stats_tree/Makefile.nmake @@ -54,4 +54,4 @@ distclean: clean maintainer-clean: distclean checkapi: - $(PERL) ../../tools/checkAPIs.pl $(TAP_SRC) + $(PERL) ../../tools/checkAPIs.pl -g abort $(TAP_SRC) diff --git a/plugins/tpg/Makefile.nmake b/plugins/tpg/Makefile.nmake index a8dbd785ff..1369afce13 100644 --- a/plugins/tpg/Makefile.nmake +++ b/plugins/tpg/Makefile.nmake @@ -65,4 +65,4 @@ $(LEMON)\lemon.exe: cd ../../plugins/mate checkapi: - $(PERL) ../../tools/checkAPIs.pl $(DISSECTOR_SRC) + $(PERL) ../../tools/checkAPIs.pl -g abort $(DISSECTOR_SRC) diff --git a/plugins/unistim/Makefile.nmake b/plugins/unistim/Makefile.nmake index f4387832d2..dcf18805e8 100644 --- a/plugins/unistim/Makefile.nmake +++ b/plugins/unistim/Makefile.nmake @@ -100,4 +100,4 @@ distclean: clean maintainer-clean: distclean checkapi: - $(PERL) ../../tools/checkAPIs.pl $(DISSECTOR_SRC) + $(PERL) ../../tools/checkAPIs.pl -g abort $(DISSECTOR_SRC) diff --git a/plugins/v5ua/Makefile.nmake b/plugins/v5ua/Makefile.nmake index f4387832d2..dcf18805e8 100644 --- a/plugins/v5ua/Makefile.nmake +++ b/plugins/v5ua/Makefile.nmake @@ -100,4 +100,4 @@ distclean: clean maintainer-clean: distclean checkapi: - $(PERL) ../../tools/checkAPIs.pl $(DISSECTOR_SRC) + $(PERL) ../../tools/checkAPIs.pl -g abort $(DISSECTOR_SRC) diff --git a/plugins/wimax/Makefile.nmake b/plugins/wimax/Makefile.nmake index 5d0a5e124b..29649a676f 100644 --- a/plugins/wimax/Makefile.nmake +++ b/plugins/wimax/Makefile.nmake @@ -100,6 +100,6 @@ distclean: clean maintainer-clean: distclean checkapi: - $(PERL) ../../tools/checkAPIs.pl \ + $(PERL) ../../tools/checkAPIs.pl -g abort \ $(DISSECTOR_SRC) \ $(DISSECTOR_SUPPORT_SRC) diff --git a/plugins/wimaxasncp/Makefile.nmake b/plugins/wimaxasncp/Makefile.nmake index 2ed14f00c1..83ce3cf539 100644 --- a/plugins/wimaxasncp/Makefile.nmake +++ b/plugins/wimaxasncp/Makefile.nmake @@ -108,4 +108,4 @@ distclean: clean maintainer-clean: distclean checkapi: - $(PERL) ../../tools/checkAPIs.pl $(DISSECTOR_SRC) + $(PERL) ../../tools/checkAPIs.pl -g abort $(DISSECTOR_SRC) diff --git a/tools/checkAPIs.pl b/tools/checkAPIs.pl index 3da00c2163..4a54d018e0 100755 --- a/tools/checkAPIs.pl +++ b/tools/checkAPIs.pl @@ -6,6 +6,9 @@ # A simple tool to check source code for function calls that should not # be called by Wireshark code. # +# Usage: +# checkAPIs.pl [-g group1] [-g group2] file1 file2 ... +# # $Id$ # # Wireshark - Network traffic analyzer @@ -28,120 +31,139 @@ # use strict; +use Getopt::Long; -# APIs that MUST NOT be used in Wireshark -my @prohibitedAPIs= -( - # Memory-unsafe APIs - # Use something that won't overwrite the end of your buffer instead - # of these: - 'gets', - 'sprintf', - 'vsprintf', - 'strcpy', - 'strncpy', - 'strcat', - 'strncat', - 'cftime', - 'ascftime', - ### non-portable APIs - # use glib (g_*) versions instead of these: - 'ntohl', - 'ntohs', - 'htonl', - 'htons', - 'strdup', - 'strndup', - ### non-ANSI C - # use memset, memcpy, memcmp instead of these: - 'bzero', - 'bcopy', - 'bcmp', - # use ep_*, se_*, or g_* functions instead of these: - # (One thing to be aware of is that space allocated with malloc() - # may not be freeable--at least on Windows--with g_free() and - # vice-versa.) - 'malloc', - 'free', - # Locale-unsafe APIs - # These may have unexpected behaviors in some locales (e.g., - # "I" isn't always the upper-case form of "i", and "i" isn't - # always the lower-case form of "I"). Use the g_ascii_* version - # instead. - 'strcasecmp', - 'strncasecmp', - 'g_strcasecmp', - 'g_strncasecmp', - 'g_strup', - 'g_strdown', - 'g_string_up', - 'g_string_down', - # Use the ws_* version of these: - # (Necessary because on Windows we use UTF8 for throughout the code - # so we must tweak that to UTF16 before operating on the file. Code - # using these functions will work unless the file/path name contains - # non-ASCII chars.) - 'open', - 'rename', - 'mkdir', - 'stat', - 'unlink', - 'remove', - 'fopen', - 'freopen', - # Misc - 'tmpnam' # use mkstemp -); +my %APIs = ( + # API groups. + # # Group name, e.g. 'prohibited' + # '<name>' => { + # # 1 if these are errors, 0 if warnings + # 'count_errors' => 1, + # # Function list + # 'functions' => [ 'f1', f2', ... ] }, + + # APIs that MUST NOT be used in Wireshark + 'prohibited' => { 'count_errors' => 1, 'functions' => [ + # Memory-unsafe APIs + # Use something that won't overwrite the end of your buffer instead + # of these: + 'gets', + 'sprintf', + 'vsprintf', + 'strcpy', + 'strncpy', + 'strcat', + 'strncat', + 'cftime', + 'ascftime', + ### non-portable APIs + # use glib (g_*) versions instead of these: + 'ntohl', + 'ntohs', + 'htonl', + 'htons', + 'strdup', + 'strndup', + ### non-ANSI C + # use memset, memcpy, memcmp instead of these: + 'bzero', + 'bcopy', + 'bcmp', + # use ep_*, se_*, or g_* functions instead of these: + # (One thing to be aware of is that space allocated with malloc() + # may not be freeable--at least on Windows--with g_free() and + # vice-versa.) + 'malloc', + 'free', + # Locale-unsafe APIs + # These may have unexpected behaviors in some locales (e.g., + # "I" isn't always the upper-case form of "i", and "i" isn't + # always the lower-case form of "I"). Use the g_ascii_* version + # instead. + 'strcasecmp', + 'strncasecmp', + 'g_strcasecmp', + 'g_strncasecmp', + 'g_strup', + 'g_strdown', + 'g_string_up', + 'g_string_down', + # Use the ws_* version of these: + # (Necessary because on Windows we use UTF8 for throughout the code + # so we must tweak that to UTF16 before operating on the file. Code + # using these functions will work unless the file/path name contains + # non-ASCII chars.) + 'open', + 'rename', + 'mkdir', + 'stat', + 'unlink', + 'remove', + 'fopen', + 'freopen', + # Misc + 'tmpnam' # use mkstemp + ]}, + + # APIs that SHOULD NOT be used in Wireshark (any more) + 'deprecated' => { 'count_errors' => 0, 'functions' => [ + ### Depreciated glib functions + # use g_string_printf() instead of: + 'g_string_sprintf', + # use g_string_append_printf instead of: + 'g_string_sprintfa', + 'g_tree_traverse', + 'g_basename', + 'g_dirname', + 'g_hash_table_freeze', + 'g_hash_table_thaw', + 'G_HAVE_GINT64', + 'g_io_channel_close', + 'g_io_channel_read', + 'g_io_channel_seek', + 'g_io_channel_write', + 'g_main_new', + 'g_main_destroy', + 'g_main_run', + 'g_main_set_poll_func', + 'g_scanner_add_symbol', + 'g_scanner_remove_symbol', + 'g_scanner_foreach_symbol', + 'g_scanner_freeze_symbol_table', + 'g_scanner_thaw_symbol_table', + # Wireshark should not write to stdout (?) + # (Of course tshark should!) + 'printf', + 'perror', + # Use PROTO_ITEM_SET_HIDDEN instead of these: + 'proto_tree_add_item_hidden', + 'proto_tree_add_bytes_hidden', + 'proto_tree_add_time_hidden', + 'proto_tree_add_ipxnet_hidden', + 'proto_tree_add_ipv4_hidden', + 'proto_tree_add_ipv6_hidden', + 'proto_tree_add_ether_hidden', + 'proto_tree_add_guid_hidden', + 'proto_tree_add_oid_hidden', + 'proto_tree_add_string_hidden', + 'proto_tree_add_boolean_hidden', + 'proto_tree_add_float_hidden', + 'proto_tree_add_double_hidden', + 'proto_tree_add_uint_hidden', + 'proto_tree_add_int_hidden', + ]}, + + # APIs that make the program exit. Dissectors shouldn't call these + 'abort' => { 'count_errors' => 1, 'functions' => [ + 'abort', + 'exit', + 'g_assert', + 'g_error', + ]}, -# APIs that SHOULD NOT be used in Wireshark (any more) -my @deprecatedAPIs= -( - ### Depreciated glib functions - # use g_string_printf() instead of: - 'g_string_sprintf', - # use g_string_append_printf instead of: - 'g_string_sprintfa', - 'g_tree_traverse', - 'g_basename', - 'g_dirname', - 'g_hash_table_freeze', - 'g_hash_table_thaw', - 'G_HAVE_GINT64', - 'g_io_channel_close', - 'g_io_channel_read', - 'g_io_channel_seek', - 'g_io_channel_write', - 'g_main_new', - 'g_main_destroy', - 'g_main_run', - 'g_main_set_poll_func', - 'g_scanner_add_symbol', - 'g_scanner_remove_symbol', - 'g_scanner_foreach_symbol', - 'g_scanner_freeze_symbol_table', - 'g_scanner_thaw_symbol_table', - # Wireshark should not write to stdout (?) - # (Of course tshark should!) - 'printf', - 'perror', - # Use PROTO_ITEM_SET_HIDDEN instead of these: - 'proto_tree_add_item_hidden', - 'proto_tree_add_bytes_hidden', - 'proto_tree_add_time_hidden', - 'proto_tree_add_ipxnet_hidden', - 'proto_tree_add_ipv4_hidden', - 'proto_tree_add_ipv6_hidden', - 'proto_tree_add_ether_hidden', - 'proto_tree_add_guid_hidden', - 'proto_tree_add_oid_hidden', - 'proto_tree_add_string_hidden', - 'proto_tree_add_boolean_hidden', - 'proto_tree_add_float_hidden', - 'proto_tree_add_double_hidden', - 'proto_tree_add_uint_hidden', - 'proto_tree_add_int_hidden', ); + # Given a list of APIs and the contents of a file, see if the API appears # in the file. If so, push the API onto the provided list. sub findAPIinList($$$) @@ -188,12 +210,16 @@ my $commentAndStringRegex = qr{(?:$DoubleQuotedStr|$SingleQuotedStr)|($CComment) # MAIN # my $errorCount = 0; +# The default list, which can be expanded. +my @apiGroups = qw(prohibited deprecated); + +GetOptions('g=s' => \@apiGroups); while ($_ = $ARGV[0]) { shift; my $filename = $_; - my @foundProhibitedAPIs = (); - my @foundDeprecatedAPIs = (); + my $fileContents = ''; + my @foundAPIs = (); die "No such file: \"$filename\"" if (! -e $filename); @@ -201,7 +227,9 @@ while ($_ = $ARGV[0]) $filename =~ s@^\./@@; # Read in the file (ouch, but it's easier that way) - my $fileContents = `cat $filename`; + open(FC, $filename) || die("Couldn't open $filename"); + while (<FC>) { $fileContents .= $_; } + close(FC); if ($fileContents =~ m{[\x80-\xFF]}) { @@ -231,16 +259,20 @@ while ($_ = $ARGV[0]) $errorCount++; } - findAPIinList(\@prohibitedAPIs, \$fileContents, \@foundProhibitedAPIs); + for my $apiName (@apiGroups) { + my $pfx = "Warning"; + @foundAPIs = (); - # the use of "prohibited" APIs is an error, increment the error count - $errorCount += @foundProhibitedAPIs; + findAPIinList($APIs{$apiName}->{functions}, \$fileContents, \@foundAPIs); - findAPIinList(\@deprecatedAPIs, \$fileContents, \@foundDeprecatedAPIs); - # (the use of deprecated APIs is bad but not an error) + if ($APIs{$apiName}->{count_errors}) { + # the use of "prohibited" APIs is an error, increment the error count + $errorCount += @foundAPIs; + $pfx = "Error"; + } - print "Error: Found prohibited APIs in ".$filename.": ".join(',', @foundProhibitedAPIs)."\n" if @foundProhibitedAPIs; - print "Warning: Found deprecated APIs in ".$filename.": ".join(',', @foundDeprecatedAPIs)."\n" if @foundDeprecatedAPIs; + print $pfx . ": Found " . $apiName . " APIs in ".$filename.": ".join(',', @foundAPIs)."\n" if @foundAPIs; + } } |