MAJOR=4
MINOR=54
DEVNAME=tty54
 ?÷     	#!/usr/bin/perl
#                              -*- Mode: Cperl -*-
# ucfq ---
# Author           : Manoj Srivastava ( srivasta@glaurung.internal.golden-gryphon.com )
# Created On       : Wed Apr 12 14:51:16 2006
# Created On Node  : glaurung.internal.golden-gryphon.com
# Last Modified By : Manoj Srivastava
# Last Modified On : Fri Apr 14 19:30:45 2006
# Last Machine Used: glaurung.internal.golden-gryphon.com
# Update Count     : 81
# Status           : Unknown, Use with caution!
# HISTORY          :
# Description      :
#
# arch-tag: 1390e09f-ee31-4d7f-a968-bd539ea061a0
#
=head1 NAME

ucfq - query ucf registry and hashfile about configuration file details.

=cut

use strict;


package ucf;

use strict;
use Getopt::Long;

# set the version and revision
($main::MYNAME     = $main::0) =~ s|.*/||;
$main::Author      = "Manoj Srivastava";
$main::AuthorMail  = "srivasta\@debian.org";

=head1 SYNOPSIS

 usage: ucfq [options] (file|package)[file|package  ...]

=cut


{  # scope for ultra-private meta-object for class attributes

  my %Ucf =
    (
     Optdesc  =>
     {
      'help|h'         => sub {print ucf->Usage();     exit 0;},
      'with-colons|w!' => sub {$::ConfOpts{"Colons"}= "$_[1]";},
      'state-dir=s'    => sub {$::ConfOpts{"StateDir"}= "$_[1]";},
      'debug|d'        => sub {$::ConfOpts{"DEBUG"}+= "$_[1]";},
      'verbose|v'      => sub {$::ConfOpts{"VERBOSE"}+= "$_[1]";}
     },
     Usage => qq(Usage: $main::MYNAME [options]
Author: $main::Author <$main::AuthorMail>
  where options are:
 --help                This message.
 --debug               Turn on debugging mode.
 --verbose             Make the script more verbose.
 --with-colons         A compact, machine readable version of the output.
 --state-dir </path/>  Set the state directory to /path/ instead of the
                       default /var/lib/ucf.

),
     Defaults =>
     {
      "Colons"   => 0,
      "DEBUG"    => 0,
      "VERBOSE"  => 0,
      "StateDir" => '/var/lib/ucf'
     }
    );
  # tri-natured: function, class method, or object method
  sub _classobj {
    my $obclass = shift || __PACKAGE__;
    my $class   = ref($obclass) || $obclass;
    no strict "refs";   # to convert sym ref to real one
    return \%$class;
  }

  for my $datum (keys %Ucf ) {
    no strict "refs";
    *$datum = sub {
      use strict "refs";
      my ($self, $newvalue) = @_;
      $Ucf{$datum} = $newvalue if @_ > 1;
      return $Ucf{$datum};
    }
  }
}

=head1 OPTIONS

=over 3

=item B<--help> B<h> Print out a usage message.

=item B<--debug> B<-d> Turn on debugging mode.

=item B<--verbose> B<-v> Make the script more verbose..

=item B<--with-colons> B<-w>

=over 2

Normally, the script presents the information in a human readable
tabular format, but that may be harder for a machine to parse. With
this option, the output is a compact, colon separated line, with no
dividers, headers, or footer.

=back

=item B<--state-dr> dir

=over 2

Set the state directory to C</path/to/dir> instead of the default
C</var/lib/ucf>.  Used mostly for testing.

=back

=back

=cut


=head1 DESCRIPTION


This script takes a set of arguments, each of which is a package or a
path to a configuration file, and outputs the associated package, if
any, if the file exists on disk, and whether it has been modfied by te
user.  The output is either a human readable tabular form, or a
compact colon-separated machine friendly format.

This script can potentially be used in package C<postinst> scripts
during purge to query the system for configuration files that may
still exist on the system, and whether these files have been locally
modified by the user -- assuming that the package registered all the
configuration files with B<ucf> using C<ucfr>.

=cut




=head1 INTERNALS

=head2 Class Methods

All class methods mediate access to class variables.  All class
methods can be invoked with zero or one parameters. When invoked with
the optional parameter, the class method sets the value of the
underlying class data.  In either case, the value of the underlyi