diff options
author | Luis Ontanon <luis.ontanon@gmail.com> | 2006-09-07 16:16:51 +0000 |
---|---|---|
committer | Luis Ontanon <luis.ontanon@gmail.com> | 2006-09-07 16:16:51 +0000 |
commit | c704e3414f5fd5e1cc8c1a403f94c2417728b246 (patch) | |
tree | c9674f6b0276095cb8ee0a0fa28d5202313ba6bd /epan/make-sminmpec.pl | |
parent | 45fb0d9d6cf819f322d0731a380e3af00e52d5b3 (diff) |
From Andrew Feren:
This adds some features to update enterprise-numbers from the web.
As used in the Makefile currently
make-sminmpec.pl <infile> <outfile.c>
works exactly the same. Additionally <infile> can be a URL to an infile in
the expected format.
Using the new "-gen" switch will create a new <infile>
example:
make-sminmpec.pl -gen \
http://www.iana.org/assignments/enterprise-numbers \
enterprise-numbers
other than that I modified so that calling it like
make-sminmpec.pl -gen
be like
make-sminmpec.pl -gen \
http://www.iana.org/assignments/enterprise-numbers \
sminmpec.c
svn path=/trunk/; revision=19172
Diffstat (limited to 'epan/make-sminmpec.pl')
-rwxr-xr-x | epan/make-sminmpec.pl | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/epan/make-sminmpec.pl b/epan/make-sminmpec.pl index dc473b1e8e..38dc2e0464 100755 --- a/epan/make-sminmpec.pl +++ b/epan/make-sminmpec.pl @@ -22,13 +22,54 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. use strict; +use Getopt::Long; + +my $opt_gen; +GetOptions("gen" => \$opt_gen ); my $in = shift; my $out = shift; -open IN, "< $in"; +if (! defined $in && ! defined $out and $opt_gen) { + $in = "http://www.iana.org/assignments/enterprise-numbers"; + $out = "sminmpec.c"; +} + +my @in_lines; + open OUT, "> $out"; +if($in =~ m/^http:/i) { + eval "require LWP::UserAgent;"; + if ( $@ ) { + die "LWP isn't installed. It is part of the standard Perl\n" . + " module libwww. Bailing.\n"; + } + my $agent = LWP::UserAgent->new; + + warn "starting to fetch $in ...\n"; + + my $request = HTTP::Request->new(GET => $in); + my $result = $agent->request($request); + + warn "done fetching $in ...\n"; + + @in_lines = split /\n/, $result->content; +} else { + open IN, "< $in"; + @in_lines = <IN>; + close IN; +} + +if ($opt_gen) { + for (@in_lines) { + chomp; + print OUT "$_\n"; + } + exit; +} + + my $body = ''; my $code; @@ -37,7 +78,7 @@ sub escape_non_ascii { return sprintf '\0%.3o',$val; } -while(<IN>) { +for(@in_lines) { s/[\000-\037]//g; s/\\/\\\\/g; s/"/\\"/g; @@ -51,8 +92,6 @@ while(<IN>) { } } -close IN; - print OUT <<"_SMINMPEC"; /* * THIS FILE IS AUTOGENERATED, DO NOT EDIT |