Apache-SessionX

 view release on metacpan or  search on metacpan

Makefile.PL  view on Meta::CPAN

        'require'   => 
            [
            'DBD::mysql',
            ],
        },

    'Oracle' => 
        {
        param =>
            {
            'Lock'      => 'Null',
            'Serialize' => 'Base64',
            'Commit'     => 1,
            'DataSource' => '?',
            'UserName'   => '?',
            'Password'   => '?',
            },
        'require'   => 
            [
            'DBD::Oracle',
            ],
        },
    'Sybase' =>
        {
        param =>
            {
            'Lock'      => 'Null',
            'Serialize' => 'Sybase',
            'Commit'     => 1,
            'DataSource' => '?',
            'UserName'   => '?',
            'Password'   => '?',
            },
        'require'   => 
            [
            'DBD::Sybase',
            ],
        },
    'Postgres' => 
        {
        param =>
            {
            'Lock'      => 'Null',
            'Serialize' => 'Base64',
            'Commit'     => 1,
            'DataSource' => '?',
            'UserName'   => '?',
            'Password'   => '?',
            },
        'require'   => 
            [
            'DBD::Pg',
            ],
        },
    ) ;

## ----------------------------------------------------------------------------

sub GetString
	{
	my ($prompt, $default) = @_ ;

	printf ("%s [%s]", $prompt, $default) ;
	chop ($_ = <STDIN>) ;
        #$_ = prompt ($prompt, $default) ;
	if (!/^\s*$/)
	    {return $_ ;}
	else
    	{
        if ($_ eq "")
	        {return $default ;}
	    else
            { return "" ; }
    
        }
    }

## ----------------------------------------------------------------------------

sub GetYesNo
	{
	my ($prompt, $default) = @_ ;
	my ($value) ;

	do
	    {
	    $value = lc (GetString ($prompt . "(y/n)", ($default?"y":"n"))) ;
	    }
	until (($value cmp "j") == 0 || ($value cmp "y") == 0 || ($value cmp "n" ) == 0) ;

	return ($value cmp "n") != 0 ;
	}


# --------------------------------------------------------------------------- 

print "\nChecking configuration...\n" ;

store:
foreach $store (sort keys %Store)
    {
    $data = $Store{$store} ;
    $info = $data -> {param}{Info} ||= $store ;
    if ($data -> {'require'})
        {
        foreach $require (@{$data -> {'require'}})
            {
            eval "require $require" ;
            if ($@)
                {
                print "Storage '$info' is unavailable because $require is not installed on your system\n" ;
                next store ;
                }
            }
        }
    push @avail, $store ;
    }

print "\nThe following ways to store session are available on your system:\n" ;

foreach $store (@avail)
    {
    $data = $Store{$store} ;
    $info = $data -> {param}{Info} ;

    printf (" - %-20s: %s\n", $store, $info) ;
    }


eval { require 'SessionX/Config.pm' ; } ;
if (!keys %Apache::SessionX::Config::param)
    {
    eval { require Apache::SessionX::Config ; } ;
    }

if (keys %Apache::SessionX::Config::param)
    {
    %param = %Apache::SessionX::Config::param ;
    @conf  = @Apache::SessionX::Config::confs ;
    $input = GetYesNo ("Found previous configuration. Modify it", 0) ;
    }
else
    {
    %param = map { $_ => {} } @avail ;
    $input = 1 ;
    }



( run in 1.301 second using v1.01-cache-2.11-cpan-6aa56a78535 )