<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package AptPkg::Config;

require 5.005_62;
use strict;
use warnings;
use AptPkg;
use AptPkg::hash;
use Carp;

require Exporter;

our @ISA = qw(Exporter AptPkg::hash);
our @EXPORT_OK = qw($_config);
our @EXPORT = ();

our $VERSION = 1.7;
our $_config = __PACKAGE__-&gt;new($AptPkg::_config::_config);

sub get
{
    my $xs = shift-&gt;_xs;
    return $xs-&gt;FindAny(@_) unless @_ and $_[0] =~ /(.+)::$/;

    # special case where name ends with ::
    my $tree = $xs-&gt;Tree($1);
    return unless $tree and $tree = $tree-&gt;Child;

    my @r;
    while ($tree)
    {
	my $v = $tree-&gt;Value;
	push @r, $v if defined $v;
	$tree = $tree-&gt;Next;
    }

    wantarray ? @r : "@r"; # what *should* this return in a scalar context?
}

sub get_file	{ shift-&gt;_xs-&gt;FindFile(@_) }
sub get_dir	{ shift-&gt;_xs-&gt;FindDir(@_) }
sub get_bool	{ shift-&gt;_xs-&gt;FindB(@_) }
sub set		{ shift-&gt;_xs-&gt;Set(@_) }
sub exists	{ shift-&gt;_xs-&gt;ExistsAny(@_) }
sub dump	{ shift-&gt;_xs-&gt;Dump(@_) }
sub read_file	{ shift-&gt;_xs-&gt;ReadConfigFile(@_) }
sub read_dir	{ shift-&gt;_xs-&gt;ReadConfigDir(@_) }

sub init
{
    AptPkg::_init_config shift-&gt;_xs;
}

sub system
{
    require AptPkg::System;
    AptPkg::_init_system shift-&gt;_xs;
}

sub parse_cmdline
{
    AptPkg::_parse_cmdline shift-&gt;_xs, @_;
}

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

    return if $method eq 'DESTROY';

    my $self = shift;
    my $xs = $self-&gt;_xs;
    my $sub = $xs-&gt;can($method);

    croak "method `$method' not implemented" unless $sub;

    unshift @_, $xs;
    goto &amp;$sub;
}

package AptPkg::Config::Iter;

sub new
{
    my $class = shift;
    my $obj = shift;
    my $self = $obj-&gt;_xs-&gt;Tree(@_);
    bless \$self, $class;
}

sub next
{
    my $self = shift;
    my $tree = $$self or return;
    my $key = $tree-&gt;FullTag;

    $$self = $tree-&gt;Child || $tree-&gt;Next;
    until ($$self)
    {
	last unless $tree = $tree-&gt;Parent;
	$$self = $tree-&gt;Next;
    }

    $key;
}

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