From: The List Server Administrator at UNH <listadm@metaphor.unh.edu>
                                           (currently Bill Costa)

NOTES from a user

       This program works fine on my V7.2 copy of ListProc but I do
       not know if it is correct for later versions.  And even if it
       does work for the latest version, the encoding for this bit
       vector could be changed in a future version.

#Begin script


#!/usr/local/bin/perl
###########################################################################
#
#       This script was created by Rob von Behren, of CREN.  Comments
#       and suggested changes should be sent to jrvb@cren.net.
#
#       last modification 3/12/96
#
###########################################################################
#
#	settings  <list>|all  [s1]  [s2]  ....
#
#       Check ListProc lists for specific settings, or print out 
#       all settings.  The command can be run either on a particular
#       list or on all lists.
#
#       list|all     act on list <list> or on all lists.
#
#       s1, s2       specific settings to check on.  If no settings are
#                    specified, all settings are returned
#
###########################################################################




###########################################################################
#  Definitions
###########################################################################

%list_flags = (
	     "LIST_CLOSED",                 0x1,
	     "LIST_PRIVATE",                0x2,
	     "LIST_POST_BY_ALL",            0x4,
	     "LIST_POST_BY_OWNERS",         0x8,
	     "LIST_HIDDEN",                 0x10,
	     "LIST_ARCHIVE",                0x20,
	     "LIST_ARCHIVE_DIGEST",         0x40,
	     "LIST_ARCHIVE_COMPRESS",	    0x80,
	     "LIST_STATS_TO_SUBSCRIBERS",   0x100,
	     "LIST_STATS_TO_ALL",	    0x200,
	     "LIST_REVIEW_TO_SUBSCRIBERS",  0x400,
	     "LIST_REVIEW_TO_ALL",	    0x800,
	     "LIST_FILES_TO_SUBSCRIBERS",   0x1000,
	     "LIST_FILES_TO_ALL",	    0x2000,
	     "LIST_MODERATED",		    0x4000,
	     "LIST_MODERATED_EDIT",	    0x8000,
	     "LIST_DIGEST_DAILY",	    0x10000,
	     "LIST_DIGEST_WEEKLY",	    0x20000,
	     "LIST_DIGEST_MONTHLY",	    0x40000,
	     "LIST_CEILING",		    0x80000,
	     "LIST_COMMENT",		    0x100000,
	     "LIST_DEFAULT",		    0x200000,
	     "LIST_AUTO_DELETE",	    0x400000,
	     "LIST_REFLECTOR",		    0x800000,
	     "LIST_CONFIRM_SENDER",	    0x1000000,
	     "LIST_MANAGER_CONTROL",	    0x2000000,
	     "LIST_FORWARD_REJECTS",	    0x4000000,
	     "LIST_REPLY_TO_LIST_ALWAYS",   0x8000000,
	     "LIST_REPLY_TO_LIST",	    0x10000000,
	     "LIST_REPLY_TO_SENDER_ALWAYS", 0x20000000,
	     "LIST_REPLY_TO_SENDER",	    0x40000000,
	     "LIST_KEEP_RESENT_LINES",	    0x80000000,	# top; 32nd bit

	     "LIST_PUBLISHED",		    0x1	        # Second mask values
	     );

$hi_flags = "LIST_PUBLISHED";

$other_options = "digest archive comment ceiling passwd creation_date " .
    "moderator errors-to";

###########################################################################
#  Do initial checking, and process command line
###########################################################################

#check command line format
die "Format: settings  <list>|all  [s1]  [s2]  ....\n\n"
    unless (@ARGV > 0);

#check for LPDIR environment variable
$lpdir = $ENV{'LPDIR'};
die "This script requires that the LPDIR directory point to the " .
    "ListProc directory\n" unless ($lpdir ne '');

#create a list of lists to process
($temp=shift(@ARGV))  =~ tr/a-z/A-Z/;
if($temp eq "ALL")
{
    chop(@lists = `ls $lpdir/lists`);
}
else
{
    @lists = ("$temp");
}

#get a list of the settings to check for (an empty list returns all settings)
@to_check = @ARGV;
if(@to_check < 1)
{
    @to_check = keys(list_flags);
}




###########################################################################
#  Check the settings for the specified lists, and output to STDOUT 
###########################################################################
while( @lists )
{
    #Get a list to process, and print out a header
    $list = shift(@lists);
    print "\n\nSettings for list $list\n";


    #if the list config file exists, show the settings
    if( -r "$lpdir/lists/$list/config" )
    {
	@temp_to_check = @to_check;
	while( @temp_to_check )
	{
	    $option = shift(@temp_to_check);
	    &report_settings($list,$option);
	}
    }
    #otherwise, print an error
    else
    {
	print "Can't find list config file: $lpdir/lists/$list/config\n";
    }

}







###########################################################################
#  report_settings  list-directory option
###########################################################################
sub report_settings
{
    local($l,$o) = @_;
    local($config) = "$lpdir/lists/$l/config";

    #Check a setting that is in the list flags
    if(index(join('',keys %list_flags),$o)  >  -1)
    {
	local($temp) = `grep -i mask $config`;
	chop $temp;
	local($op,$hi,$lo) = split(/ /,$temp);
	
	#deal with the special case that $o is one of the flags from the 
	#high mask word.
	if(index($hi_mask,$o) != -1)
	{
	    if($hi & $list_flags{$o}) {print "$o:\t yes\n";}
	    else {print "$o:\t no\n";}
	}
	else
	{
	    if($lo & $list_flags{$o}) {print "$o:\t yes\n";}
	    else {print "$o:\t no\n";}
	}
    }

    #The setting is illegitimate
    elsif(index($other_options,$o) == -1)
    {
	print "$o:  Invalid config option\n";
    }
    
    #Check other settings
    else 
    {
	local($conf_line) = `grep -i $o $config`;
	chop($conf_line);
	if($conf_line eq '' ) {print "$o: not set\n";}
	else {print "$conf_line\n";}
    }
}
