#!/usr/bin/eperl
###
#
# Copyright (c) Ensim Corporation 2000, 2001   All Rights Reserved.
#
# This software is furnished under a license and may be used and copied
# only  in  accordance  with  the  terms  of such  license and with the
# inclusion of the above copyright notice. This software or any other
# copies thereof may not be provided or otherwise made available to any
# other person. No title to and ownership of the software is hereby
# transferred.
#
# The information in this software is subject to change without notice
# and  should  not be  construed  as  a commitment by Ensim Corporation.
# Ensim assumes no responsibility for the use or  reliability  of its
# software on equipment which is not supplied by Ensim.
#
# Exit codes (on failure error message goes to stderr):
#  0 - success
#  1 - failure
# 
# Boolean arguments on the command line are given as 0 or 1. All the
# command line arguments are encoded to avoid problems with escapes.
#
# All functions defined here either return an error message if an
# error occured and "" if everything went well or allways return a
# valid value, but exit (with code 1) printing an error message if an
# error occurs. This second type of functions have _e appended to
# their name. Functions are allowed to print results onto stdout, but
# errors are printed only in the main program.
#
###

# --------------------------------------------------------------------------
# Copyright (c) Ensim Corporation 2000, 2001
# ENSIM CORPORATION - ALL RIGHTS RESERVED
# --------------------------------------------------------------------------
# $Id: get_mlist,v 1.1.1.1 2008-03-01 00:21:36 aarefyev Exp $
# $Name: not supported by cvs2svn $
# --------------------------------------------------------------------------

# create_list.cgi

push @INC, ($ENV{'OCW_SVCPATH'} || "/usr/lib/opcenter")."/cmdline_common";
push @INC, ($ENV{'OCW_SVCPATH'} || "/usr/lib/opcenter")."/sendmail";

require '/usr/lib/opcenter/cmdline_common/CmdLineCoder.pm';;
require '/usr/lib/opcenter/majordomo/mymajordomo-lib.pl';
require '/usr/lib/opcenter/majordomo/majordomo.pm';
require '/usr/lib/opcenter/majordomo/ctime.pl';

&CmdLineCoder::decode_args();
local $listname = @ARGV[0];
$conf = &get_config();

local $plist = &majordomo::get_list($listname, $conf);
local %list = %$plist;
#&majordomo::mydbg(" -----------in getmlist: list:"); 
#(map {&majordomo::mydbg("[$_] => [$list{$_}]\n")}(keys %list));


#need to encode this list to give it back up
local $rv='';
local $flag = 0;
foreach $l (%list) {
	# using & as the delim
        if ($flag==0)  {# its the key 
	  $rv = "$rv" . CmdLineCoder::encode_string("$l") . "=";
	  $flag = 1;
	}
	else  {# its the value
	  $rv = "$rv" . CmdLineCoder::encode_string("$l") . "&";
	  $flag = 0;
	}
}
chop($rv);
print $rv, "\n";
