###
###  Copyright 2000-2007 University of Illinois Board of Trustees
###  All rights reserved. 
###
###  PSGConf::Action::GenerateFile::ftpaccess - action to generate ftpaccess
###
###  Campus Information Technologies and Educational Services
###  University of Illinois at Urbana-Champaign
###


package PSGConf::Action::GenerateFile::ftpaccess;

use strict;

use PSGConf::Action::GenerateFile;

our @ISA = qw(PSGConf::Action::GenerateFile);


###############################################################################
###  generate method
###############################################################################

sub generate
{
	my ($self, $fh, $psgconf) = @_;

	### print classes
	map {
		print $fh "class\t$_\n";
	} @{$self->{classes}};

	### print autogroups
	map {
		print $fh "autogroup\t$_\t$self->{autogroups}->{$_}\n";
	} sort keys %{$self->{autogroups}};

	### print limits
	map {
		print $fh "limit\t$_\n";
	} @{$self->{limits}};

	### print options
	map {
		print $fh "$_\t$self->{options}->{$_}\n";
	} sort keys %{$self->{options}};

	### print messages
	map {
		print $fh "message\t$self->{messages}->{$_}\t$_\n";
	} sort keys %{$self->{messages}};

	### print readme
	map {
		print $fh "readme\t$self->{readmes}->{$_}\t$_\n";
	} sort keys %{$self->{readmes}};

	### print uploads
	map {
		print $fh "upload\t$_\t$self->{uploads}->{$_}\n";
	} sort keys %{$self->{uploads}};

	### print literal config text
	print $fh "\n$self->{literal}\n"
		if (defined($self->{literal}));

	return 1;
}


###############################################################################
###  documentation
###############################################################################

1;

__END__

=head1 NAME

PSGConf::Action::GenerateFile::ftpaccess - generate ftpaccess file

=head1 SYNOPSIS

  use PSGConf::Action::GenerateFile::ftpaccess;

  $psgconf->register_actions(
		PSGConf::Action::GenerateFile::ftpaccess->new(
			'name'		=> '/etc/ftpaccess',
			'classes'	=> [ ... ],
			'limits'	=> [ ... ],
			'autogroup'	=> { ... },
			'options'	=> { ... },
			'messages'	=> { ... },
			'readmes'	=> { ... },
			'uploads'	=> { ... },
			'literal_config' => '...',
			...
		),
		...
	);

=head1 DESCRIPTION

The B<PSGConf::Action::GenerateFile::ftpaccess> module provides a
B<PSGConf> action class for generating the B<wu_ftpd> F<ftpaccess>
file.

The B<PSGConf::Action::GenerateFile::ftpaccess> class is derived from the
B<PSGConf::Action::GenerateFile> class, but it defines/overrides the
following methods:

=over 4

=item generate()

Generates the F<ftpaccess> file.

=back

In addition to the attributes supported by
the B<PSGConf::Action::GenerateFile> class, the
B<PSGConf::Action::GenerateFile::ftpaccess> class supports the following
attributes:

=over 4

=item I<classes>

A list of class definitions.

=item I<autogroup>

A hash mapping group names to class definitions. 

=item I<limits>

A list of limit definitions.

=item I<options>

A hash mapping options to their values.

=item I<messages>

A hash mapping a directory to a given message file.

=item I<readmes>

A hash mapping a directory to a given README file.

=item I<uploads>

A hash mapping a directory to an upload statement.

=item I<literal_config>

Literal text to be appended to the file.

=back

=head1 BUGS

The attributes are not well organized or laid out.  They expose too much
of the file format to the caller.

The I<literal_config> attribute is an ugly hack.

=head1 SEE ALSO

L<perl>

L<PSGConf>

L<PSGConf::Action::GenerateFile>

=cut



syntax highlighted by Code2HTML, v. 0.9.1