/usr/share/perl5/Debconf/DbDriver/Cache.pm is in debconf 1.5.49.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | #!/usr/bin/perl -w
# This file was preprocessed, do not edit!
package Debconf::DbDriver::Cache;
use strict;
use Debconf::Log qw{:all};
use base 'Debconf::DbDriver';
use fields qw(cache dirty);
sub iterator {
my $this=shift;
my $subiterator=shift;
my @items=keys %{$this->{cache}};
my $iterator=Debconf::Iterator->new(callback => sub {
while (my $item = pop @items) {
next unless defined $this->{cache}->{$item};
return $item;
}
return unless $subiterator;
my $ret;
do {
$ret=$subiterator->iterate;
} while defined $ret and exists $this->{cache}->{$ret};
return $ret;
});
return $iterator;
}
sub exists {
my $this=shift;
my $item=shift;
return $this->{cache}->{$item}
if exists $this->{cache}->{$item};
return 0;
}
sub init {
my $this=shift;
$this->{cache} = {} unless exists $this->{cache};
}
sub cacheadd {
my $this=shift;
my $item=shift;
my $entry=shift;
return if exists $this->{cache}->{$item};
$this->{cache}->{$item}=$entry;
$this->{dirty}->{$item}=0;
}
sub cachedata {
my $this=shift;
my $item=shift;
return $this->{cache}->{$item};
}
sub cached {
my $this=shift;
my $item=shift;
unless (exists $this->{cache}->{$item}) {
debug "db $this->{name}" => "cache miss on $item";
$this->load($item);
}
return $this->{cache}->{$item};
}
sub shutdown {
my $this=shift;
return if $this->{readonly};
my $ret=1;
foreach my $item (keys %{$this->{cache}}) {
if (not defined $this->{cache}->{$item}) {
$ret=undef unless defined $this->remove($item);
delete $this->{cache}->{$item};
}
elsif ($this->{dirty}->{$item}) {
$ret=undef unless defined $this->save($item, $this->{cache}->{$item});
$this->{dirty}->{$item}=0;
}
}
return $ret;
}
sub addowner {
my $this=shift;
my $item=shift;
my $owner=shift;
my $type=shift;
return if $this->{readonly};
$this->cached($item);
if (! defined $this->{cache}->{$item}) {
return if ! $this->accept($item, $type);
debug "db $this->{name}" => "creating in-cache $item";
$this->{cache}->{$item}={
owners => {},
fields => {},
variables => {},
flags => {},
}
}
if (! exists $this->{cache}->{$item}->{owners}->{$owner}) {
$this->{cache}->{$item}->{owners}->{$owner}=1;
$this->{dirty}->{$item}=1;
}
return $owner;
}
sub removeowner {
my $this=shift;
my $item=shift;
my $owner=shift;
return if $this->{readonly};
return unless $this->cached($item);
if (exists $this->{cache}->{$item}->{owners}->{$owner}) {
delete $this->{cache}->{$item}->{owners}->{$owner};
$this->{dirty}->{$item}=1;
}
unless (keys %{$this->{cache}->{$item}->{owners}}) {
$this->{cache}->{$item}=undef;
$this->{dirty}->{$item}=1;
}
return $owner;
}
sub owners {
my $this=shift;
my $item=shift;
return unless $this->cached($item);
return keys %{$this->{cache}->{$item}->{owners}};
}
sub getfield {
my $this=shift;
my $item=shift;
my $field=shift;
return unless $this->cached($item);
return $this->{cache}->{$item}->{fields}->{$field};
}
sub setfield {
my $this=shift;
my $item=shift;
my $field=shift;
my $value=shift;
return if $this->{readonly};
return unless $this->cached($item);
$this->{dirty}->{$item}=1;
return $this->{cache}->{$item}->{fields}->{$field} = $value;
}
sub removefield {
my $this=shift;
my $item=shift;
my $field=shift;
return if $this->{readonly};
return unless $this->cached($item);
$this->{dirty}->{$item}=1;
return delete $this->{cache}->{$item}->{fields}->{$field};
}
sub fields {
my $this=shift;
my $item=shift;
return unless $this->cached($item);
return keys %{$this->{cache}->{$item}->{fields}};
}
sub getflag {
my $this=shift;
my $item=shift;
my $flag=shift;
return unless $this->cached($item);
return $this->{cache}->{$item}->{flags}->{$flag}
if exists $this->{cache}->{$item}->{flags}->{$flag};
return 'false';
}
sub setflag {
my $this=shift;
my $item=shift;
my $flag=shift;
my $value=shift;
return if $this->{readonly};
return unless $this->cached($item);
$this->{dirty}->{$item}=1;
return $this->{cache}->{$item}->{flags}->{$flag} = $value;
}
sub flags {
my $this=shift;
my $item=shift;
return unless $this->cached($item);
return keys %{$this->{cache}->{$item}->{flags}};
}
sub getvariable {
my $this=shift;
my $item=shift;
my $variable=shift;
return unless $this->cached($item);
return $this->{cache}->{$item}->{variables}->{$variable};
}
sub setvariable {
my $this=shift;
my $item=shift;
my $variable=shift;
my $value=shift;
return if $this->{readonly};
return unless $this->cached($item);
$this->{dirty}->{$item}=1;
return $this->{cache}->{$item}->{variables}->{$variable} = $value;
}
sub variables {
my $this=shift;
my $item=shift;
return unless $this->cached($item);
return keys %{$this->{cache}->{$item}->{variables}};
}
1
|