From 002cefc721e5fe01ba6ecb9ec7261f549f4f1459 Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Sun, 27 Apr 2014 13:26:17 -0700 Subject: make-sminmpec.pl fixups. Enforce a minimum number of entries and do our work in the epan directory. Change-Id: I69cc6ae3255b23706a2e67db890a9718e10568b2 Reviewed-on: https://code.wireshark.org/review/1398 Reviewed-by: Gerald Combs --- tools/make-sminmpec.pl | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'tools/make-sminmpec.pl') diff --git a/tools/make-sminmpec.pl b/tools/make-sminmpec.pl index 3c2f6177da..e1a9afaf5b 100755 --- a/tools/make-sminmpec.pl +++ b/tools/make-sminmpec.pl @@ -20,12 +20,21 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. use strict; +use File::Spec; + +my ($vol, $script_dir, $file) = File::Spec->splitpath( __FILE__ ); +my $epan_dir = File::Spec->catpath($vol, $script_dir, '../epan'); +chdir($epan_dir) || die("Can't find $epan_dir"); my $in = shift; -$in = "http://www.iana.org/assignments/enterprise-numbers/enterprise-numbers" unless(defined $in); +$in = "http://www.iana.org/assignments/enterprise-numbers" unless(defined $in); my @in_lines; +my $revision = '2014-04-27'; + +my $min_entries = 100; +my $smi_total = 0; if($in =~ m/^http:/i) { eval "require LWP::UserAgent;"; @@ -33,13 +42,12 @@ if($in =~ m/^http:/i) { my $agent = LWP::UserAgent->new; $agent->env_proxy; - $agent->agent("Wireshark make-sminmpec.pl"); + $agent->agent("Wireshark make-sminmpec.pl/$revision"); warn "starting to fetch $in ...\n"; my $request = HTTP::Request->new(GET => $in); - if (-f "enterprise-numbers") { my $mtime; (undef,undef,undef,undef,undef,undef,undef,undef,undef,$mtime,undef,undef,undef) = stat("enterprise-numbers"); @@ -75,8 +83,6 @@ if($in =~ m/^http:/i) { } -open OUT, "> sminmpec.c"; - my $body = ''; my $code; my $prev_code = -1; ## Assumption: First code in enterprise file is 0; @@ -107,9 +113,16 @@ for(@in_lines) { } $prev_code = $code; $body .= " { $code, \"$name\" },\n"; + $smi_total++; } } +# If this happens check what IANA is serving. +# XXX We already overwrote enterprise-numbers above. +if ($smi_total < $smi_total) { die "Too few SMI entries ($smi_total)\n"; } + +open OUT, "> sminmpec.c"; + print OUT <<"_SMINMPEC"; /* * THIS FILE IS AUTOGENERATED, DO NOT EDIT -- cgit v1.2.1