<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::Pipe;
use strict;
use Debconf::Log qw(:all);
use base 'Debconf::DbDriver::Cache';


use fields qw(infd outfd format);


sub init {
	my $this=shift;

	$this-&gt;{format} = "822" unless exists $this-&gt;{format};

	$this-&gt;error("No format specified") unless $this-&gt;{format};
	eval "use Debconf::Format::$this-&gt;{format}";
	if ($@) {
		$this-&gt;error("Error setting up format object $this-&gt;{format}: $@");
	}
	$this-&gt;{format}="Debconf::Format::$this-&gt;{format}"-&gt;new;
	if (not ref $this-&gt;{format}) {
		$this-&gt;error("Unable to make format object");
	}

	my $fh;
	if (defined $this-&gt;{infd}) {
		if ($this-&gt;{infd} ne 'none') {
			open ($fh, "&lt;&amp;=$this-&gt;{infd}") or
				$this-&gt;error("could not open file descriptor #$this-&gt;{infd}: $!");
		}
	}
	else {	
		open ($fh, '-');
	}

	$this-&gt;SUPER::init(@_);

	debug "db $this-&gt;{name}" =&gt; "loading database";

	if (defined $fh) {
		while (! eof $fh) {
			my ($item, $cache)=$this-&gt;{format}-&gt;read($fh);
			$this-&gt;{cache}-&gt;{$item}=$cache;
		}
		close $fh;
	}
}


sub shutdown {
	my $this=shift;

	return if $this-&gt;{readonly};

	my $fh;
	if (defined $this-&gt;{outfd}) {
		if ($this-&gt;{outfd} ne 'none') {
			open ($fh, "&gt;&amp;=$this-&gt;{outfd}") or
				$this-&gt;error("could not open file descriptor #$this-&gt;{outfd}: $!");
		}
	}
	else {
		open ($fh, '&gt;-');
	}
	
	if (defined $fh) {
		$this-&gt;{format}-&gt;beginfile;
		foreach my $item (sort keys %{$this-&gt;{cache}}) {
			next unless defined $this-&gt;{cache}-&gt;{$item}; # skip deleted
			$this-&gt;{format}-&gt;write($fh, $this-&gt;{cache}-&gt;{$item}, $item)
				or $this-&gt;error("could not write to pipe: $!");
		}
		$this-&gt;{format}-&gt;endfile;
		close $fh or $this-&gt;error("could not close pipe: $!");
	}

	return 1;
}


sub load {
	return undef;
}


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