<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl -w
# This file was preprocessed, do not edit!


package Debconf::DbDriver;
use Debconf::Log qw{:all};
use strict;
use base 1.01; # ensure that they don't have a broken perl installation



use fields qw(name readonly required backup failed
              accept_type reject_type accept_name reject_name);

our %drivers;


sub new {
	my Debconf::DbDriver $this=shift;
	unless (ref $this) {
		$this = fields::new($this);
	}
	$this-&gt;{required}=1;
	$this-&gt;{readonly}=0;
	$this-&gt;{failed}=0;
	my %params=@_;
	foreach my $field (keys %params) {
		if ($field eq 'readonly' || $field eq 'required' || $field eq 'backup') {
			$this-&gt;{$field}=1,next if lc($params{$field}) eq "true";
			$this-&gt;{$field}=0,next if lc($params{$field}) eq "false";
		}
		elsif ($field=~/^(accept|reject)_/) {
			$this-&gt;{$field}=qr/$params{$field}/i;
		}
		$this-&gt;{$field}=$params{$field};
	}
	unless (exists $this-&gt;{name}) {
		$this-&gt;{name}="(unknown)";
		$this-&gt;error("no name specified");
	}
	$drivers{$this-&gt;{name}} = $this;
	$this-&gt;init;
	return $this;
}


sub init {}


sub error {
	my $this=shift;

	if ($this-&gt;{required}) {
		warn('DbDriver "'.$this-&gt;{name}.'":', @_);
		exit 1;
	}
	else {
		warn('DbDriver "'.$this-&gt;{name}.'" warning:', @_);
	}
}


sub driver {
	my $this=shift;
	my $name=shift;
	
	return $drivers{$name};
}


sub accept {
	my $this=shift;
	my $name=shift;
	my $type=shift;
	
	return if $this-&gt;{failed};
	
	if ((exists $this-&gt;{accept_name} &amp;&amp; $name !~ /$this-&gt;{accept_name}/) ||
	    (exists $this-&gt;{reject_name} &amp;&amp; $name =~ /$this-&gt;{reject_name}/)) {
		debug "db $this-&gt;{name}" =&gt; "reject $name";
		return;
	}

	if (exists $this-&gt;{accept_type} || exists $this-&gt;{reject_type}) {
		if (! defined $type || ! length $type) {
			my $template = Debconf::Template-&gt;get($this-&gt;getfield($name, 'template'));
			return 1 unless $template; # no type to act on
			$type=$template-&gt;type || '';
		}
		return if exists $this-&gt;{accept_type} &amp;&amp; $type !~ /$this-&gt;{accept_type}/;
		return if exists $this-&gt;{reject_type} &amp;&amp; $type =~ /$this-&gt;{reject_type}/;
	}

	return 1;
}


sub ispassword {
	my $this=shift;
	my $item=shift;

	my $template=$this-&gt;getfield($item, 'template');
	return unless defined $template;
	$template=Debconf::Template-&gt;get($template);
	return unless $template;
	my $type=$template-&gt;type || '';
	return 1 if $type eq 'password';
	return 0;
}


1
</pre></body></html>