/[libconf]/libconf/perl-Libconf/Glueconf/Samba.pm
ViewVC logotype

Diff of /libconf/perl-Libconf/Glueconf/Samba.pm

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

revision 1.1 by dams, Tue Jun 3 21:41:53 2003 UTC revision 1.2 by dams, Fri Jul 11 17:54:51 2003 UTC
# Line 118  sub NEXTKEY { Line 118  sub NEXTKEY {
118  sub STORE {  sub STORE {
119      my ($obj, $key, $value) = @_;      my ($obj, $key, $value) = @_;
120      debug "key : $key - value : $value";      debug "key : $key - value : $value";
121      ref $value eq 'HASH' or die 'trying to store anything else than hash ref';      ref $value eq 'HASH' or die 'trying to store something else than hash ref';
122      my $index;      my $index;
123      my @pos = $obj->{libconf}->findAtomPos({ type => 'SECTION', section_name => $key, sections => [] });      my $pos = $obj->{libconf}->findAtomPos({ type => 'SECTION', section_name => $key, sections => [] });
124      if (@pos == 0) {      defined $pos or $pos = $obj->{libconf}->appendAtom({ section_name => $key, type => 'SECTION' });
         $index = $obj->{libconf}->appendAtom({ section_name => $key, type => 'SECTION' });  
     } else {  
         $index = $pos[0];  
     }  
125      my %hash;      my %hash;
126      tie %hash, 'Libconf::Glueconf::Samba::SectionWrapper', $obj->{libconf}, $index;      tie %hash, 'Libconf::Glueconf::Samba::SectionWrapper', $obj->{libconf}, $pos;
127      %hash = %$value;      %hash = %$value;
128  }  }
129    
# Line 151  sub TIEHASH { Line 147  sub TIEHASH {
147      debug "beginning : $beginning";      debug "beginning : $beginning";
148      my $atom = $libconf->getAtom($beginning);      my $atom = $libconf->getAtom($beginning);
149      my @depth = @{$atom->{sections}};      my @depth = @{$atom->{sections}};
150        scalar(keys %{$depth[0]}) == 0 and shift @depth;
151      push @depth, { name => $atom->{section_name} };      push @depth, { name => $atom->{section_name} };
152    
153      my $key = $beginning+1;      my $key = $beginning+1;
154      foreach ($beginning+1..$libconf->size()-1) {      foreach ($beginning+1..$libconf->size()-1) {
155          my $atom = $libconf->getAtom($_);          my $atom = $libconf->getAtom($_);
156          if (!(@{$atom->{sections}} >= @depth)) {          @{$atom->{sections}} >= @depth and next;
             $key++;  
             next;  
         }  
157          Libconf::compare_depth($atom->{sections}, \@depth) or last;          Libconf::compare_depth($atom->{sections}, \@depth) or last;
158        } continue {
159          $key++;          $key++;
160      }      }
161      my %hash = (      my %hash = (
# Line 169  sub TIEHASH { Line 164  sub TIEHASH {
164                  sections => \@depth,                  sections => \@depth,
165                  lastatom => $key,                  lastatom => $key,
166                 );                 );
 #    print Data::Dumper->Dump([%hash],['hash']) . "\n";  
167      debug "firstatom : $hash{firstatom} - lastatom : $hash{lastatom}";      debug "firstatom : $hash{firstatom} - lastatom : $hash{lastatom}";
168      return bless \%hash, $pkg;      return bless \%hash, $pkg;
 #     bless {  
 #            libconf => $libconf,  
 #            firstatom => $beginning,  
 #            sections => \@depth,  
 #            lastatom => $key,  
 #           }, $pkg;  
169  }  }
170    
171  sub CLEAR {  sub CLEAR {
# Line 188  sub CLEAR { Line 176  sub CLEAR {
176  #    $obj->{lastatom} = $obj->{firstatom} + 1;  #    $obj->{lastatom} = $obj->{firstatom} + 1;
177  }  }
178    
 #sub DESTROY {  
 #}  
   
179  sub DELETE {  sub DELETE {
180      my ($obj, $key) = @_;      my ($obj, $key) = @_;
181      debug "key : $key";      debug "key : $key";
182    #    my @pos = $obj->{libconf}->findAtomPos( { type => 'SECTION', section_name => $key, sections => [ ] },
183    #                                            $obj->{firstatom}+1,
184    #                                            $obj->{lastatom}-1);
185      foreach ($obj->{firstatom}+1..$obj->{lastatom}-1) {      foreach ($obj->{firstatom}+1..$obj->{lastatom}-1) {
186          my $atom = $obj->{libconf}->getAtom($_);          my $atom = $obj->{libconf}->getAtom($_);
187          if ($atom->{type} eq 'SECTION' &&          if ($atom->{type} eq 'SECTION' &&

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26