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


package Debconf::Question;
use warnings;
use strict;
use Debconf::Db;
use Debconf::Template;
use Debconf::Iterator;
use Debconf::Log qw(:all);


use fields qw(name priority);

our %question;


sub new {
	my Debconf::Question $this=shift;
	my $name=shift;
	my $owner=shift;
	my $type=shift || die "no type given for question";
	die "A question called \"$name\" already exists"
		if exists $question{$name};
	unless (ref $this) {
		$this = fields::new($this);
	}
	$this-&gt;{name}=$name;
	return unless defined $this-&gt;addowner($owner, $type);
	$this-&gt;flag('seen', 'false');
	return $question{$name}=$this;
}


sub get {
	my Debconf::Question $this=shift;
	my $name=shift;
	return $question{$name} if exists $question{$name};
	if ($Debconf::Db::config-&gt;exists($name)) {
		$this = fields::new($this);
		$this-&gt;{name}=$name;
		return $question{$name}=$this;
	}
	return;
}


sub iterator {
	my $this=shift;

	my $real_iterator=$Debconf::Db::config-&gt;iterator;
	return Debconf::Iterator-&gt;new(callback =&gt; sub {
		return unless my $name=$real_iterator-&gt;iterate;
		return $this-&gt;get($name);
	});
}


sub _expand_vars {
	my $this=shift;
	my $text=shift;

	return '' unless defined $text;

	my @vars=$Debconf::Db::config-&gt;variables($this-&gt;{name});

	my $rest=$text;
	my $result='';
	my $variable;
	my $varval;
	my $escape;
	while ($rest =~ m/^(.*?)(\\)?\$\{([^{}]+)\}(.*)$/sg) {
		$result.=$1;  # copy anything before the variable
		$escape=$2;
		$variable=$3;
		$rest=$4; # continue trying to expand rest of text
		if (defined $escape &amp;&amp; length $escape) {
			$result.="\${$variable}";
		}
		else {
			$varval=$Debconf::Db::config-&gt;getvariable($this-&gt;{name}, $variable);
			$result.=$varval if defined($varval); # expand the variable
		}
	}
	$result.=$rest; # add on anything that's left.

	return $result;
}


sub description {
	my $this=shift;
	return $this-&gt;_expand_vars($this-&gt;template-&gt;description);
}


sub extended_description {
	my $this=shift;
	return $this-&gt;_expand_vars($this-&gt;template-&gt;extended_description);
}


sub choices {
	my $this=shift;

	return $this-&gt;_expand_vars($this-&gt;template-&gt;choices);
}


sub choices_split {
	my $this=shift;

	my @items;
	my $item='';
	for my $chunk (split /(\\[, ]|,\s+)/, $this-&gt;choices) {
		if ($chunk=~/^\\([, ])$/) {
			$item.=$1;
		} elsif ($chunk=~/^,\s+$/) {
			push @items, $item;
			$item='';
		} else {
			$item.=$chunk;
		}
	}
	push @items, $item if $item ne '';
	return @items;
}


sub variable {
	my $this=shift;
	my $var=shift;

	if (@_) {
		return $Debconf::Db::config-&gt;setvariable($this-&gt;{name}, $var, shift);
	}
	else {
		return $Debconf::Db::config-&gt;getvariable($this-&gt;{name}, $var);
	}
}


sub flag {
	my $this=shift;
	my $flag=shift;

	if ($flag eq 'isdefault') {
		debug developer =&gt; "The isdefault flag is deprecated, use the seen flag instead";
		if (@_) {
			my $value=(shift eq 'true') ? 'false' : 'true';
			$Debconf::Db::config-&gt;setflag($this-&gt;{name}, 'seen', $value);
		}
		return ($Debconf::Db::config-&gt;getflag($this-&gt;{name}, 'seen') eq 'true') ? 'false' : 'true';
	}

	if (@_) {
		return $Debconf::Db::config-&gt;setflag($this-&gt;{name}, $flag, shift);
	}
	else {
		return $Debconf::Db::config-&gt;getflag($this-&gt;{name}, $flag);
	}
}


sub value {
	my $this = shift;

	unless (@_) {
		my $ret=$Debconf::Db::config-&gt;getfield($this-&gt;{name}, 'value');
		return $ret if defined $ret;
		return $this-&gt;template-&gt;default if ref $this-&gt;template;
	} else {
		return $Debconf::Db::config-&gt;setfield($this-&gt;{name}, 'value', shift);
	}
}


sub value_split {
	my $this=shift;

	my $value=$this-&gt;value;
	$value='' if ! defined $value;
	my @items;
	my $item='';
	for my $chunk (split /(\\[, ]|,\s+)/, $value) {
		if ($chunk=~/^\\([, ])$/) {
			$item.=$1;
		} elsif ($chunk=~/^,\s+$/) {
			push @items, $item;
			$item='';
		} else {
			$item.=$chunk;
		}
	}
	push @items, $item if $item ne '';
	return @items;
}


sub addowner {
	my $this=shift;

	return $Debconf::Db::config-&gt;addowner($this-&gt;{name}, shift, shift);
}


sub removeowner {
	my $this=shift;

	my $template=$Debconf::Db::config-&gt;getfield($this-&gt;{name}, 'template');
	return unless $Debconf::Db::config-&gt;removeowner($this-&gt;{name}, shift);
	if (length $template and
	    not $Debconf::Db::config-&gt;exists($this-&gt;{name})) {
		$Debconf::Db::templates-&gt;removeowner($template, $this-&gt;{name});
		delete $question{$this-&gt;{name}};
	}
}


sub owners {
	my $this=shift;

	return join(", ", sort($Debconf::Db::config-&gt;owners($this-&gt;{name})));
}


sub template {
	my $this=shift;
	if (@_) {
		my $oldtemplate=$Debconf::Db::config-&gt;getfield($this-&gt;{name}, 'template');
		my $newtemplate=shift;
		if (not defined $oldtemplate or $oldtemplate ne $newtemplate) {
			$Debconf::Db::templates-&gt;removeowner($oldtemplate, $this-&gt;{name})
				if defined $oldtemplate and length $oldtemplate;

			$Debconf::Db::config-&gt;setfield($this-&gt;{name}, 'template', $newtemplate);

			$Debconf::Db::templates-&gt;addowner($newtemplate, $this-&gt;{name},
				$Debconf::Db::templates-&gt;getfield($newtemplate, "type"));
		}
	}
	return Debconf::Template-&gt;get(
		$Debconf::Db::config-&gt;getfield($this-&gt;{name}, 'template'));
}


sub name {
	my $this=shift;

	return $this-&gt;{name};
}


sub priority {
	my $this=shift;

	$this-&gt;{priority}=shift if @_;

	return $this-&gt;{priority};
}


sub AUTOLOAD {
	(my $field = our $AUTOLOAD) =~ s/.*://;

	no strict 'refs';
	*$AUTOLOAD = sub {
		my $this=shift;

		if (@_) {
			return $Debconf::Db::config-&gt;setfield($this-&gt;{name}, $field, shift);
		}
		my $ret=$Debconf::Db::config-&gt;getfield($this-&gt;{name}, $field);
		unless (defined $ret) {
			$ret = $this-&gt;template-&gt;$field() if ref $this-&gt;template;
		}
		if (defined $ret) {
			if ($field =~ /^(?:description|extended_description|choices)-/i) {
				return $this-&gt;_expand_vars($ret);
			} else {
				return $ret;
			}
		}
	};
	goto &amp;$AUTOLOAD;
}

sub DESTROY {
}


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