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

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

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

revision 1.3 by dams, Thu May 1 17:47:52 2003 UTC revision 1.4 by dams, Fri May 2 10:02:39 2003 UTC
# Line 31  use Libconf::Libconf; Line 31  use Libconf::Libconf;
31    
32  sub new {  sub new {
33      my ($pkg, $filename) = @_;      my ($pkg, $filename) = @_;
     my %self;  
34      my $libconf = Libconf::new('Libconf', $filename, 'resolv', '');      my $libconf = Libconf::new('Libconf', $filename, 'resolv', '');
35      tie my @nameserver_wrapper, 'Libconf::Glueconf::Resolv::Nameserver::Wrapper', $libconf;      tie my %wrapper, 'Libconf::Glueconf::Resolv::Wrapper', $libconf;
36      $self{nameserver} = \@nameserver_wrapper;      bless \%wrapper, $pkg;
     tie my $domain_wrapper, 'Libconf::Glueconf::Resolv::Domain::Wrapper', $libconf;  
     $self{domain} = \$domain_wrapper;  
     tie my @search_wrapper, 'Libconf::Glueconf::Resolv::Search::Wrapper', $libconf;  
     $self{search} = \@search_wrapper;  
     tie my @sortlist_wrapper, 'Libconf::Glueconf::Resolv::Sortlist::Wrapper', $libconf;  
     $self{sortlist} = \@sortlist_wrapper;  
     tie my @options_wrapper, 'Libconf::Glueconf::Resolv::Options::Wrapper', $libconf;  
     $self{options} = \@options_wrapper;  
     $self{libconf} = $libconf;  
     bless \%self, $pkg;  
37  }  }
38    
39  sub readConf {  sub readConf {
# Line 58  sub writeConf { Line 47  sub writeConf {
47      $obj->{libconf}->writeConf();      $obj->{libconf}->writeConf();
48  }  }
49    
50    package Libconf::Glueconf::Resolv::Wrapper;
51    
52    sub debug { Libconf::debug(@_) }
53    
54    sub TIEHASH {
55        my ($pkg, $libconf) = @_;
56        debug;
57        my %hash;
58        tie my @nameserver_wrapper, 'Libconf::Glueconf::Resolv::Nameserver::Wrapper', $libconf;
59        $hash{nameserver} = \@nameserver_wrapper;
60        tie my $domain_wrapper, 'Libconf::Glueconf::Resolv::Domain::Wrapper', $libconf;
61        $hash{domain} = \$domain_wrapper;
62        tie my @search_wrapper, 'Libconf::Glueconf::Resolv::Search::Wrapper', $libconf;
63        $hash{search} = \@search_wrapper;
64        tie my @sortlist_wrapper, 'Libconf::Glueconf::Resolv::Sortlist::Wrapper', $libconf;
65        $hash{sortlist} = \@sortlist_wrapper;
66        tie my @options_wrapper, 'Libconf::Glueconf::Resolv::Options::Wrapper', $libconf;
67        $hash{options} = \@options_wrapper;
68        bless {
69               hash => \%hash,
70               libconf => $libconf
71              }, $pkg;
72    }
73    
74    sub CLEAR {
75        my ($obj) = @_;
76        debug;
77        $obj->{hash} = {};
78    }
79    
80    sub DELETE {
81        my ($obj, $key) = @_;
82        debug "key: $key";
83        delete $obj->{hash};
84    }
85    
86    sub FIRSTKEY {
87        my ($obj) = @_;
88        debug;
89        my $a = keys %{$obj->{hash}};
90        scalar each %{$obj->{hash}};
91    }
92    
93    sub EXISTS {
94        my ($obj, $key) = @_;
95        debug "key : $key";
96        exists $obj->{hash};
97    }
98    
99    sub NEXTKEY {
100        my ($obj, $lastkey) = @_;
101        debug "lastkey : $lastkey";
102        scalar each %{$obj->{hash}};
103    }
104    
105    sub STORE {
106        my ($obj, $key, $value) = @_;
107        debug "key : $key - value : $value";
108        $obj->{hash}{$key} = $value;
109    }
110    
111    sub FETCH {
112        my ($obj, $key) = @_;
113        debug "key : $key";
114        $key eq 'libconf' ? $obj->{libconf} : $obj->{hash}{$key};
115    }
116    
117    
118  package Libconf::Glueconf::Resolv::Nameserver::Wrapper;  package Libconf::Glueconf::Resolv::Nameserver::Wrapper;
119    
120  sub debug { Libconf::debug(@_) }  sub debug { Libconf::debug(@_) }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

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