=head1 SYNOPSIS
- use IsisDB
+ use IsisDB;
+
my $isis = new IsisDB(
isisdb => './cds/cds',
);
+ for(my $mfn = 1; $mfn <= $isis->{'maxmfn'}; $mfn++) {
+ print $isis->to_ascii($mfn),"\n";
+ }
+
=head1 DESCRIPTION
This module will read CDS/ISIS databases and create hash values out of it.
It can be used as perl-only alternative to OpenIsis module.
+This will module will always be slower that OpenIsis module which use C
+library. However, since it's written in perl, it's platform independent (so
+you don't need C compiler), and can be easily modified.
+
+Unique feature of this module is ability to C<include_deleted> records.
+It will also skip zero sized fields (OpenIsis has a bug in XS bindings, so
+fields which are zero sized will be filled with random junk from memory).
+
=head1 METHODS
=cut
# some binary reads
#
-sub Read32 {
- my $self = shift;
-
- my $f = shift || die "Read32 needs file handle";
- read($$f,$b,4) || die "can't read 4 bytes from $$f from position ".tell($f);
- return unpack("l",$b);
-}
-
=head2 new
Open CDS/ISIS database
=item include_deleted
-Don't skip logically deleted records.
+Don't skip logically deleted records in ISIS.
=back
# NXTMFP offset to next available position in last block
# MFTYPE always 0 for user db file (1 for system)
seek(fileMST,4,0);
- $self->{'NXTMFN'}=$self->Read32(\*fileMST) || carp "NXTNFN is zero";
+
+ my $buff;
+
+ read(fileMST, $buff, 4);
+ $self->{'NXTMFN'}=unpack("l",$buff) || carp "NXTNFN is zero";
# save maximum MFN
$self->{'maxmfn'} = $self->{'NXTMFN'} - 1;
}
}
- my $buff;
read(fileCNT, $buff, 26);
$self->unpack_cnt($buff);
print "seeking to $mfnpos in file '$self->{isisdb}.XRF'\n" if ($self->{debug});
seek($self->{'fileXRF'},$mfnpos,0);
+ my $buff;
+
# read XRFMFB abd XRFMFP
- my $pointer=$self->Read32(\*{$self->{'fileXRF'}});
+ read($self->{'fileXRF'}, $buff, 4);
+ my $pointer=unpack("l",$buff) || carp "pointer is null";
my $XRFMFB = int($pointer/2048);
my $XRFMFP = $pointer - ($XRFMFB*2048);
seek($self->{'fileMST'},$offset4,0);
- my $value=$self->Read32(\*{$self->{'fileMST'}});
+ read($self->{'fileMST'}, $buff, 4);
+ my $value=unpack("l",$buff);
if ($value!=$mfn) {
print ("Error: The MFN:".$mfn." is not found in MST(".$value.")");
# $NVF=$self->Read16($fileMST);
# $STATUS=$self->Read16($fileMST);
- my $buff;
read($self->{'fileMST'}, $buff, 14);
my ($MFRL,$MFBWB,$MFBWP,$BASE,$NVF,$STATUS) = unpack("slssss", $buff);