Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37558896
en ru br
ALT Linux repos
S:0.01-alt1

Group :: Development/Perl
RPM: perl-BIND-Config-Parser

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

pax_global_header00006660000000000000000000000064114260433040014507gustar00rootroot0000000000000052 comment=9920ef1df2f19eca35ab88b4e5fb2a2cae30ebae
perl-BIND-Config-Parser-0.01/000075500000000000000000000000001142604330400155365ustar00rootroot00000000000000perl-BIND-Config-Parser-0.01/.gear/000075500000000000000000000000001142604330400165325ustar00rootroot00000000000000perl-BIND-Config-Parser-0.01/.gear/rules000064400000000000000000000000631142604330400176060ustar00rootroot00000000000000tar: . name=@name@-@version@ base=@name@-@version@
perl-BIND-Config-Parser-0.01/Changes000064400000000000000000000001501142604330400170250ustar00rootroot00000000000000Revision history for Perl extension BIND::Config::Parser.

0.01 Sun Jun 26 2005
- Initial version.
perl-BIND-Config-Parser-0.01/MANIFEST000064400000000000000000000002571142604330400166730ustar00rootroot00000000000000Changes
lib/BIND/Config/Parser.pm
Makefile.PL
MANIFEST This list of files
MANIFEST.SKIP
META.yml Module meta-data (added by MakeMaker)
perl-BIND-Config-Parser.spec
README
perl-BIND-Config-Parser-0.01/MANIFEST.SKIP000064400000000000000000000001141142604330400174300ustar00rootroot00000000000000\B\.svn\b
^MANIFEST.bak$
^Makefile$
^blib/
^pm_to_blib$
^BIND-Config-Parser
perl-BIND-Config-Parser-0.01/META.yml000064400000000000000000000005451142604330400170130ustar00rootroot00000000000000# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: BIND-Config-Parser
version: 0.01
version_from: lib/BIND/Config/Parser.pm
installdirs: site
requires:
Parse::RecDescent: 0

distribution_type: module
generated_by: ExtUtils::MakeMaker version 6.17
perl-BIND-Config-Parser-0.01/Makefile.PL000064400000000000000000000004101142604330400175030ustar00rootroot00000000000000use ExtUtils::MakeMaker;

WriteMakefile(
'NAME' => 'BIND::Config::Parser',
'VERSION_FROM' => 'lib/BIND/Config/Parser.pm',
'PREREQ_PM' => {
'Parse::RecDescent' => 0,
},
($] >= 5.005 ? (
'AUTHOR' => 'Matt Dainty <matt@bodgit-n-scarper.com>',
) : () ),
);
perl-BIND-Config-Parser-0.01/README000064400000000000000000000007371142604330400164250ustar00rootroot00000000000000BIND::Config::Parser version 0.01
=================================

INSTALLATION

To install this module type the following:

perl Makefile.PL
make
make install

DEPENDENCIES

This module requires these other modules and libraries:

Parse::RecDescent

COPYRIGHT AND LICENSE

Copyright (c) 2005 Matt Dainty.

This library is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.

AUTHORS

Matt Dainty <matt@bodgit-n-scarper.com>
perl-BIND-Config-Parser-0.01/lib/000075500000000000000000000000001142604330400163045ustar00rootroot00000000000000perl-BIND-Config-Parser-0.01/lib/BIND/000075500000000000000000000000001142604330400170205ustar00rootroot00000000000000perl-BIND-Config-Parser-0.01/lib/BIND/Config/000075500000000000000000000000001142604330400202255ustar00rootroot00000000000000perl-BIND-Config-Parser-0.01/lib/BIND/Config/Parser.pm000064400000000000000000000112061142604330400220170ustar00rootroot00000000000000package BIND::Config::Parser;

# $Id: Parser.pm 35 2005-06-26 18:58:24Z $

use warnings;
use strict;

use Parse::RecDescent;

use vars qw( $VERSION );

$VERSION = '0.01';

$::RD_AUTOACTION = q{ $item[1] };

my $grammar = q{

program:
<skip: qr{\s*
(?:(?://|\#)[^\n]*\n\s*|/\*(?:[^*]+|\*(?!/))*\*/\s*)*
}x> statement(s) eofile { $item[2] }

statement:
simple | nested

simple:
value(s) ';'

nested:
value value(s?) '{' statement(s?) '}' ';'
{ [ $item[1], $item[2], $item[4] ] }

value:
/[\w.\/=-]+/ | /"[\w.\/ =-]+"/

eofile:
/^\Z/
};

sub new {
my $class = shift;

my $self = {
'_open_block' => \&_handle_open_block,
'_close_block' => \&_handle_close_block,
'_statement' => \&_handle_statement,
};

$self->{ '_parser' } = new Parse::RecDescent( $grammar )
|| die "Bad grammar\n";

bless $self, $class;

return $self;
}

sub parse_file
{
my $self = shift;

my $namedconf = shift
|| die "Missing named.conf argument\n";

open NAMEDCONF, $namedconf
|| die "Can't open '$namedconf': $!\n";
my $text = join( "", <NAMEDCONF> );
close NAMEDCONF;

defined( my $tree = $self->{ '_parser' }->program( $text ) )
|| die "Bad text\n";

$self->_recurse( $tree );
}

sub open_block_handler
{
my $self = shift;

return $self->{ '_open_block' };
}

sub set_open_block_handler
{
my $self = shift;

$self->{ '_open_block' } = shift;
}

sub close_block_handler
{
my $self = shift;

return $self->{ '_close_block' };
}

sub set_close_block_handler
{
my $self = shift;

$self->{ '_close_block' } = shift;
}

sub statement_handler
{
my $self = shift;

return $self->{ '_statement' };
}

sub set_statement_handler
{
my $self = shift;

$self->{ '_statement' } = shift;
}

sub _recurse
{
my $self = shift;
my $tree = shift;

foreach my $node ( @{ $tree } ) {
if ( ref( $node->[-1] ) eq 'ARRAY' ) {

# If the last child of the node is an array then the
# node must be a nested statement, so handle the
# opening line, recurse through the contents and
# close with the curly brace

$self->open_block_handler->( $node->[0],
@{ $node->[1] } );
$self->_recurse( $node->[-1] );
$self->close_block_handler->();
} else {

# Normal single-line statement

$self->statement_handler->( @{ $node } );
}
}
}

sub _handle_open_block {}
sub _handle_close_block {}
sub _handle_statement {}

1;

__END__

=head1 NAME

BIND::Config::Parser - Parse BIND Config file.

=head1 SYNOPSIS

use BIND::Config::Parser;

# Create the parser
my $parser = new BIND::Config::Parser;

my $indent = 0;

# Set up callback handlers
$parser->set_open_block_handler( sub {
print "\t" x $indent, join( " ", @_ ), " {\n";
$indent++;
} );
$parser->set_close_block_handler( sub {
$indent--;
print "\t" x $indent, "};\n";
} );
$parser->set_statement_handler( sub {
print "\t" x $indent, join( " ", @_ ), ";\n";
} );

# Parse the file
$parser->parse_file( "named.conf" );

=head1 DESCRIPTION

BIND::Config::Parser provides a lightweight parser to the configuration
file syntax of BIND v8 and v9 using a C<Parse::RecDescent> grammar.

It is in a similar vein to C<BIND::Conf_Parser>. However, as it has no
knowledge of the directives, it doesn't need to be kept updated as new
directives are added, it simply knows how to carve up a BIND configuration
file into logical chunks.

=head1 CONSTRUCTOR

=over 4

=item new( );

Create a new C<BIND::Config::Parser> object.

=back

=head1 METHODS

=over 4

=item set_open_block_handler( CODE_REF );

Set the code to be called when a configuration block is opened. At least one
argument will be passed; the name of that block, for example C<options> or
C<zone>, etc. as well as any additional items up to but not including the
opening curly brace.

=item set_close_block_handler( CODE_REF );

Set the code to be called when a configuration block is closed. No arguments
are passed.

=item set_statement_handler( CODE_REF );

Set the code to be called on a single line configuration element. At least one
argument will be passed; the name of that element, as well as any additional
items up to but not including the ending semi-colon.

=item parse_file( FILENAME );

Parse FILENAME, triggering the above defined handlers on the relevant sections.

=back

=head1 TODO

Probably the odd one or two things. I'm fairly sure the grammar is correct.

=head1 COPYRIGHT AND LICENSE

Copyright (c) 2005 Matt Dainty.

This library is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.

=head1 AUTHORS

Matt Dainty E<lt>matt@bodgit-n-scarper.comE<gt>.

=head1 SEE ALSO

L<perl>, L<Parse::RecDescent>, L<BIND::Conf_Parser>.

=cut
perl-BIND-Config-Parser-0.01/perl-BIND-Config-Parser.spec000064400000000000000000000022221142604330400225210ustar00rootroot00000000000000%define module BIND-Config-Parser
%define m_distro BIND-Config-Parser
%define m_name BIND::Config::Parser
%define m_author_id unknown
%define _enable_test 1

Name: perl-BIND-Config-Parser
Version: 0.01
Release: alt1

Summary: Parse BIND Config file

License: Artistic
Group: Development/Perl
Url: http://www.cpan.org

Packager: Egor Glukhov <kaman@altlinux.org>

BuildArch: noarch
Source: %name-%version.tar

# Automatically added by buildreq on Tue Aug 03 2010
BuildRequires: perl-Parse-RecDescent perl-devel

%description
BIND::Config::Parser provides a lightweight parser to the configuration
file syntax of BIND v8 and v9 using a "Parse::RecDescent" grammar.

It is in a similar vein to "BIND::Conf_Parser". However, as it has no
knowledge of the directives, it doesn't need to be kept updated as new
directives are added, it simply knows how to carve up a BIND configuration
file into logical chunks.

%prep
%setup

%build
%perl_vendor_build

%install
%perl_vendor_install
rm -rf -- %buildroot%perl_vendor_man3dir/

%files
%perl_vendor_privlib/BIND/*

%changelog
* Tue Aug 03 2010 Egor Glukhov <kaman@altlinux.org> 0.01-alt1
- initial build for ALT Linux Sisyphus

 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin