68 |
debug => 1, |
debug => 1, |
69 |
); |
); |
70 |
|
|
71 |
|
Options are described below: |
72 |
|
|
73 |
|
=over 5 |
74 |
|
|
75 |
=item isisdb |
=item isisdb |
76 |
|
|
77 |
Prefix path to CDS/ISIS. It should contain full or relative path to database |
Prefix path to CDS/ISIS. It should contain full or relative path to database |
86 |
|
|
87 |
Dump a C<lot> of debugging output. |
Dump a C<lot> of debugging output. |
88 |
|
|
89 |
|
=back |
90 |
|
|
91 |
|
It will also set C<$isis-E<gt>{'maxmfn'}> which is maximum MFN stored in database. |
92 |
|
|
93 |
=cut |
=cut |
94 |
|
|
95 |
sub new { |
sub new { |
99 |
|
|
100 |
$self->{isisdb} = {@_}->{isisdb} || croak "new needs database name as argument!"; |
$self->{isisdb} = {@_}->{isisdb} || croak "new needs database name as argument!"; |
101 |
|
|
102 |
$self->{debug} = {@_}->{debug} || 1; # XXX remove debug always! |
$self->{debug} = {@_}->{debug}; |
103 |
|
|
104 |
# if you want to read .FDT file use read_fdt argument when creating class! |
# if you want to read .FDT file use read_fdt argument when creating class! |
105 |
if ({@_}->{read_fdt} && -e $self->{isisdb}.".FDT") { |
if ({@_}->{read_fdt} && -e $self->{isisdb}.".FDT") { |
142 |
seek(fileMST,4,0); |
seek(fileMST,4,0); |
143 |
$self->{'NXTMFN'}=$self->Read32(\*fileMST) || carp "NXTNFN is zero"; |
$self->{'NXTMFN'}=$self->Read32(\*fileMST) || carp "NXTNFN is zero"; |
144 |
|
|
145 |
|
# save maximum MFN |
146 |
|
$self->{'maxmfn'} = $self->{'NXTMFN'} - 1; |
147 |
|
|
148 |
close(fileMST); |
close(fileMST); |
149 |
|
|
150 |
# Get the index information from $db.CNT |
# Get the index information from $db.CNT |
194 |
$self ? return $self : return undef; |
$self ? return $self : return undef; |
195 |
} |
} |
196 |
|
|
197 |
|
=head2 GetMFN |
198 |
|
|
199 |
|
Read record with selected MFN |
200 |
|
|
201 |
|
my $rec = $isis->GetMFN(55); |
202 |
|
|
203 |
# Get a record from the MFN |
Returns hash with keys which are field names and values are unpacked values |
204 |
# Return the number of fields in the record. |
for that field. |
205 |
# Return -1 if the record is marked for deletion |
|
206 |
# The record is then extracted with call to GETs |
=cut |
207 |
|
|
208 |
sub GetMFN { |
sub GetMFN { |
209 |
my $self = shift; |
my $self = shift; |
305 |
|
|
306 |
# Get Variable Fields |
# Get Variable Fields |
307 |
|
|
308 |
|
delete $self->{record}; |
309 |
|
|
310 |
for (my $i = 0 ; $i < $NVF ; $i++) { |
for (my $i = 0 ; $i < $NVF ; $i++) { |
311 |
my $rec; |
my $rec; |
312 |
read(fileMST,$rec,$FieldLEN[$i]); |
read(fileMST,$rec,$FieldLEN[$i]); |
313 |
$self->{record}->{$FieldTAG[$i]} = $rec; |
push @{$self->{record}->{$FieldTAG[$i]}}, $rec; |
314 |
} |
} |
315 |
close(fileMST); |
close(fileMST); |
316 |
|
|
321 |
|
|
322 |
print Dumper($self) if ($self->{debug}); |
print Dumper($self) if ($self->{debug}); |
323 |
|
|
324 |
return $NVF; |
return $self->{'record'}; |
325 |
} |
} |
326 |
|
|
327 |
|
=head2 to_ascii |
328 |
|
|
329 |
|
Dump ascii output of selected MFN |
330 |
|
|
331 |
|
print $isis->to_ascii(55); |
332 |
|
|
333 |
|
=cut |
334 |
|
|
335 |
|
sub to_ascii { |
336 |
|
my $self = shift; |
337 |
|
|
338 |
|
my $mfn = shift || croak "need MFN"; |
339 |
|
|
340 |
|
my $rec = $self->GetMFN($mfn); |
341 |
|
|
342 |
|
print STDERR Dumper($rec); |
343 |
|
|
344 |
|
my $out = "0\t$mfn"; |
345 |
|
|
346 |
|
foreach my $f (sort keys %{$rec}) { |
347 |
|
$out .= "\n$f\t".join("\n$f\t",@{$self->{record}->{$f}}); |
348 |
|
} |
349 |
|
|
350 |
|
$out .= "\n"; |
351 |
|
|
352 |
|
return $out; |
353 |
|
} |
354 |
|
|
355 |
|
################# old cruft which is not ported from php to perl |
356 |
|
|
357 |
=begin php |
=begin php |
358 |
|
|
359 |
# Load the dictionary from the $db.L0x files. |
# Load the dictionary from the $db.L0x files. |