/[Biblio-Isis]/trunk/lib/Biblio/Isis.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Biblio/Isis.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 7 by dpavlin, Wed Dec 29 15:10:34 2004 UTC revision 10 by dpavlin, Wed Dec 29 16:04:07 2004 UTC
# Line 7  use Data::Dumper; Line 7  use Data::Dumper;
7  BEGIN {  BEGIN {
8          use Exporter ();          use Exporter ();
9          use vars qw ($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);          use vars qw ($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
10          $VERSION     = 0.02;          $VERSION     = 0.03;
11          @ISA         = qw (Exporter);          @ISA         = qw (Exporter);
12          #Give a hoot don't pollute, do not export more than needed by default          #Give a hoot don't pollute, do not export more than needed by default
13          @EXPORT      = qw ();          @EXPORT      = qw ();
# Line 66  Open CDS/ISIS database Line 66  Open CDS/ISIS database
66          isisdb => './cds/cds',          isisdb => './cds/cds',
67          read_fdt => 1,          read_fdt => 1,
68          debug => 1,          debug => 1,
69            include_deleted => 1,
70   );   );
71    
72  Options are described below:  Options are described below:
# Line 86  by default. Line 87  by default.
87    
88  Dump a C<lot> of debugging output.  Dump a C<lot> of debugging output.
89    
90    =item include_deleted
91    
92    Don't skip logically deleted records.
93    
94  =back  =back
95    
96  It will also set C<$isis-E<gt>{'maxmfn'}> which is maximum MFN stored in database.  It will also set C<$isis-E<gt>{'maxmfn'}> which is maximum MFN stored in database.
# Line 97  sub new { Line 102  sub new {
102          my $self = {};          my $self = {};
103          bless($self, $class);          bless($self, $class);
104    
105          $self->{isisdb} = {@_}->{isisdb} || croak "new needs database name as argument!";          croak "new needs database name (isisdb) as argument!" unless ({@_}->{isisdb});
106    
107          $self->{debug} = {@_}->{debug};          foreach my $v (qw{isisdb debug include_deleted}) {
108                    $self->{$v} = {@_}->{$v};
109            }
110    
111          # 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!
112          if ({@_}->{read_fdt} && -e $self->{isisdb}.".FDT") {          if ({@_}->{read_fdt} && -e $self->{isisdb}.".FDT") {
# Line 173  sub new { Line 180  sub new {
180                  my $buff = shift || return;                  my $buff = shift || return;
181                  my @arr = unpack("ssssssllls", $buff);                  my @arr = unpack("ssssssllls", $buff);
182    
183                    print "unpack_cnt: ",join(" ",@arr),"\n" if ($self->{'debug'});
184    
185                  my $IDTYPE = shift @arr;                  my $IDTYPE = shift @arr;
186                  foreach (@flds) {                  foreach (@flds) {
187                          $self->{$IDTYPE}->{$_} = abs(shift @arr);                          $self->{$IDTYPE}->{$_} = abs(shift @arr);
# Line 270  print ("Error: The MFN:".$mfn." is not f Line 279  print ("Error: The MFN:".$mfn." is not f
279    
280          print "MFRL: $MFRL MFBWB: $MFBWB MFBWP: $MFBWP BASE: $BASE NVF: $NVF STATUS: $STATUS\n" if ($self->{debug});          print "MFRL: $MFRL MFBWB: $MFBWB MFBWP: $MFBWP BASE: $BASE NVF: $NVF STATUS: $STATUS\n" if ($self->{debug});
281    
282            # delete old record
283            delete $self->{record};
284    
285            if (! $self->{'include_deleted'} && $MFRL < 0) {
286                    print "## logically deleted record $mfn, skipping...\n" if ($self->{debug});
287                    return;
288            }
289    
290          # Get Directory Format          # Get Directory Format
291    
292          my @FieldPOS;          my @FieldPOS;
293          my @FieldLEN;          my @FieldLEN;
294          my @FieldTAG;          my @FieldTAG;
295    
296            read($self->{'fileMST'}, $buff, 6 * $NVF);
297    
298            my $fld_len = 0;
299    
300          for (my $i = 0 ; $i < $NVF ; $i++) {          for (my $i = 0 ; $i < $NVF ; $i++) {
301    
302  #               $TAG=$self->Read16($fileMST);  #               $TAG=$self->Read16($fileMST);
303  #               $POS=$self->Read16($fileMST);  #               $POS=$self->Read16($fileMST);
304  #               $LEN=$self->Read16($fileMST);  #               $LEN=$self->Read16($fileMST);
305    
306                  read($self->{'fileMST'}, $buff, 6);                  my ($TAG,$POS,$LEN) = unpack("sss", substr($buff,$i * 6, 6));
                 my ($TAG,$POS,$LEN) = unpack("sss", $buff);  
307    
308                  print "TAG: $TAG POS: $POS LEN: $LEN\n" if ($self->{debug});                  print "TAG: $TAG POS: $POS LEN: $LEN\n" if ($self->{debug});
309    
# Line 300  print ("Error: The MFN:".$mfn." is not f Line 320  print ("Error: The MFN:".$mfn." is not f
320                  push @FieldTAG,$TAG;                  push @FieldTAG,$TAG;
321                  push @FieldPOS,$POS;                  push @FieldPOS,$POS;
322                  push @FieldLEN,$LEN;                  push @FieldLEN,$LEN;
323    
324                    $fld_len += $LEN;
325          }          }
326    
327          # Get Variable Fields          # Get Variable Fields
328    
329          delete $self->{record};          read($self->{'fileMST'},$buff,$fld_len);
330    
331          for (my $i = 0 ; $i < $NVF ; $i++) {          for (my $i = 0 ; $i < $NVF ; $i++) {
332                  my $rec;                  # skip zero-sized fields
333                  read($self->{'fileMST'},$rec,$FieldLEN[$i]);                  next if ($FieldLEN[$i] == 0);
                 push @{$self->{record}->{$FieldTAG[$i]}}, $rec;  
         }  
         close(fileMST);  
334    
335          # The record is marked for deletion                  push @{$self->{record}->{$FieldTAG[$i]}}, substr($buff,$FieldPOS[$i],$FieldLEN[$i]);
         if ($STATUS==1) {  
                 return -1;  
336          }          }
337            close(fileMST);
338    
339          print Dumper($self) if ($self->{debug});          print Dumper($self) if ($self->{debug});
340    

Legend:
Removed from v.7  
changed lines
  Added in v.10

  ViewVC Help
Powered by ViewVC 1.1.26