--- trunk/IsisDB.pm 2004/12/28 00:43:04 1 +++ trunk/IsisDB.pm 2004/12/28 01:41:45 2 @@ -68,6 +68,10 @@ debug => 1, ); +Options are described below: + +=over 5 + =item isisdb Prefix path to CDS/ISIS. It should contain full or relative path to database @@ -82,6 +86,10 @@ Dump a C of debugging output. +=back + +It will also set C<$isis-E{'maxmfn'}> which is maximum MFN stored in database. + =cut sub new { @@ -91,7 +99,7 @@ $self->{isisdb} = {@_}->{isisdb} || croak "new needs database name as argument!"; - $self->{debug} = {@_}->{debug} || 1; # XXX remove debug always! + $self->{debug} = {@_}->{debug}; # if you want to read .FDT file use read_fdt argument when creating class! if ({@_}->{read_fdt} && -e $self->{isisdb}.".FDT") { @@ -134,6 +142,9 @@ seek(fileMST,4,0); $self->{'NXTMFN'}=$self->Read32(\*fileMST) || carp "NXTNFN is zero"; + # save maximum MFN + $self->{'maxmfn'} = $self->{'NXTMFN'} - 1; + close(fileMST); # Get the index information from $db.CNT @@ -183,11 +194,16 @@ $self ? return $self : return undef; } +=head2 GetMFN + +Read record with selected MFN + + my $rec = $isis->GetMFN(55); -# Get a record from the MFN -# Return the number of fields in the record. -# Return -1 if the record is marked for deletion -# The record is then extracted with call to GETs +Returns hash with keys which are field names and values are unpacked values +for that field. + +=cut sub GetMFN { my $self = shift; @@ -289,10 +305,12 @@ # Get Variable Fields + delete $self->{record}; + for (my $i = 0 ; $i < $NVF ; $i++) { my $rec; read(fileMST,$rec,$FieldLEN[$i]); - $self->{record}->{$FieldTAG[$i]} = $rec; + push @{$self->{record}->{$FieldTAG[$i]}}, $rec; } close(fileMST); @@ -303,9 +321,39 @@ print Dumper($self) if ($self->{debug}); - return $NVF; + return $self->{'record'}; } +=head2 to_ascii + +Dump ascii output of selected MFN + + print $isis->to_ascii(55); + +=cut + +sub to_ascii { + my $self = shift; + + my $mfn = shift || croak "need MFN"; + + my $rec = $self->GetMFN($mfn); + +print STDERR Dumper($rec); + + my $out = "0\t$mfn"; + + foreach my $f (sort keys %{$rec}) { + $out .= "\n$f\t".join("\n$f\t",@{$self->{record}->{$f}}); + } + + $out .= "\n"; + + return $out; +} + +################# old cruft which is not ported from php to perl + =begin php # Load the dictionary from the $db.L0x files.