3 # Something to create my subset of the US call book data,
4 # in my flat file form, either from the main data base or
5 # else the daily updates.
7 # You can get the main database from:
9 # http://wireless.fcc.gov/uls/data/complete/l_amat.zip
11 # The daily data bases are available as a set of seven from here:-
13 # http://wireless.fcc.gov/uls/data/daily/l_am_sat.zip
14 # http://wireless.fcc.gov/uls/data/daily/l_am_sun.zip
15 # http://wireless.fcc.gov/uls/data/daily/l_am_mon.zip
16 # http://wireless.fcc.gov/uls/data/daily/l_am_tue.zip
17 # http://wireless.fcc.gov/uls/data/daily/l_am_wed.zip
18 # http://wireless.fcc.gov/uls/data/daily/l_am_thu.zip
19 # http://wireless.fcc.gov/uls/data/daily/l_am_fri.zip
21 # this program expects one or more zip files containing the call book
24 # Copyright (c) 2002 Dirk Koopman G1TLH
31 # make sure that modules are searched in the order local then perl
33 # root of directory tree for this system
37 $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'};
39 unshift @INC, "$root/local";
42 use vars qw($VERSION $BRANCH);
43 $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
44 $BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ || (0,0));
45 $main::build += $VERSION;
46 $main::branch += $BRANCH;
49 use Archive::Zip qw(:ERROR_CODES);
50 use Archive::Zip::MemberRead;
54 my $blksize = 1024 * 1024;
58 my $dbrawfn = "$main::data/usdbraw";
60 rename "$dbrawfn.oo", "$dbrawfn.ooo";
61 rename "$dbrawfn.o", "$dbrawfn.oo";
62 rename "$dbrawfn", "$dbrawfn.o";
63 my $gzfh = gzopen($dbrawfn, "wb") or die "Cannot open $dbrawfn $!";
67 foreach my $argv (@ARGV) {
68 my $zip = new Archive::Zip($argv) or die "Cannot open $argv $!\n";
69 print "Doing $argv\n";
70 handleEN($zip, $argv);
71 handleAM($zip, $argv);
72 handleHS($zip, $argv);
76 print "$ctycount Cities found\n";
82 my ($zip, $argv) = @_;
84 my $ofn = "$main::data/$mname";
85 print " Handling EN records, unzipping";
86 if ($zip->extractMember($mname, $ofn) == AZ_OK) {
87 my $fh = new IO::File "$ofn" or die "Cannot open $ofn $!";
95 while (my $l = $fh->getline) {
97 my ($rt,$usi,$ulsfn,$ebfno,$call,$type,$lid,$name,$first,$middle,$last,$suffix,
98 $phone,$fax,$email,$street,$city,$state,$zip,$pobox,$attl,$sgin,$frn) = split /\|/, $l;
100 my $rec = uc join '|', $call,$city,$state if $city && $state;
102 if (length $buf > $blksize) {
103 $gzfh->gzwrite($buf);
106 my $c = uc "$city|$state";
109 if (length $buf > $blksize) {
110 $gzfh->gzwrite($buf);
112 print ", $count records\n";
117 print "EN missing in $argv\n";