BIND-Config-Parser-0.01/0040755000372000037200000000000010257617073013311 5ustar mattmattBIND-Config-Parser-0.01/MANIFEST0100644000372000037200000000025710257616754014450 0ustar mattmattChanges 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 BIND-Config-Parser-0.01/MANIFEST.SKIP0100644000372000037200000000011410257616754015205 0ustar mattmatt\B\.svn\b ^MANIFEST.bak$ ^Makefile$ ^blib/ ^pm_to_blib$ ^BIND-Config-Parser BIND-Config-Parser-0.01/README0100644000372000037200000000073710257616754014202 0ustar mattmattBIND::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 BIND-Config-Parser-0.01/lib/0040755000372000037200000000000010257617073014057 5ustar mattmattBIND-Config-Parser-0.01/lib/BIND/0040755000372000037200000000000010257617073014573 5ustar mattmattBIND-Config-Parser-0.01/lib/BIND/Config/0040755000372000037200000000000010257617073016000 5ustar mattmattBIND-Config-Parser-0.01/lib/BIND/Config/Parser.pm0100644000372000037200000001120610257616754017574 0ustar mattmattpackage 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: 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( "", ); 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 grammar. It is in a similar vein to C. 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 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 or C, 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 Ematt@bodgit-n-scarper.comE. =head1 SEE ALSO L, L, L. =cut BIND-Config-Parser-0.01/META.yml0100644000372000037200000000054510257617073014563 0ustar mattmatt# 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 BIND-Config-Parser-0.01/Makefile.PL0100644000372000037200000000041010257616754015260 0ustar mattmattuse ExtUtils::MakeMaker; WriteMakefile( 'NAME' => 'BIND::Config::Parser', 'VERSION_FROM' => 'lib/BIND/Config/Parser.pm', 'PREREQ_PM' => { 'Parse::RecDescent' => 0, }, ($] >= 5.005 ? ( 'AUTHOR' => 'Matt Dainty ', ) : () ), ); BIND-Config-Parser-0.01/perl-BIND-Config-Parser.spec0100644000372000037200000000734310257616754020307 0ustar mattmatt# # - BIND::Config::Parser - # This spec file was automatically generated by cpan2rpm [ver: 2.026] # The following arguments were used: # BIND-Config-Parser-0.01.tar.gz # For more information on cpan2rpm please visit: http://perl.arix.com/ # %define pkgname BIND-Config-Parser %define filelist %{pkgname}-%{version}-filelist %define NVR %{pkgname}-%{version}-%{release} %define maketest 1 name: perl-BIND-Config-Parser summary: BIND-Config-Parser - Parse BIND Config file. version: 0.01 release: 1 vendor: Matt Dainty packager: Arix International license: Artistic group: Applications/CPAN url: http://www.cpan.org buildroot: %{_tmppath}/%{name}-%{version}-%(id -u -n) buildarch: noarch prefix: %(echo %{_prefix}) source: BIND-Config-Parser-0.01.tar.gz %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. # # This package was generated automatically with the cpan2rpm # utility. To get this software or for more information # please visit: http://perl.arix.com/ # %prep %setup -q -n %{pkgname}-%{version} chmod -R u+w %{_builddir}/%{pkgname}-%{version} %build grep -rsl '^#!.*perl' . | grep -v '.bak$' |xargs --no-run-if-empty \ %__perl -MExtUtils::MakeMaker -e 'MY->fixin(@ARGV)' CFLAGS="$RPM_OPT_FLAGS" %{__perl} Makefile.PL `%{__perl} -MExtUtils::MakeMaker -e ' print qq|PREFIX=%{buildroot}%{_prefix}| if \$ExtUtils::MakeMaker::VERSION =~ /5\.9[1-6]|6\.0[0-5]/ '` %{__make} %if %maketest %{__make} test %endif %install [ "%{buildroot}" != "/" ] && rm -rf %{buildroot} %{makeinstall} `%{__perl} -MExtUtils::MakeMaker -e ' print \$ExtUtils::MakeMaker::VERSION <= 6.05 ? qq|PREFIX=%{buildroot}%{_prefix}| : qq|DESTDIR=%{buildroot}| '` [ -x /usr/lib/rpm/brp-compress ] && /usr/lib/rpm/brp-compress # SuSE Linux if [ -e /etc/SuSE-release -o -e /etc/UnitedLinux-release ] then %{__mkdir_p} %{buildroot}/var/adm/perl-modules %{__cat} `find %{buildroot} -name "perllocal.pod"` \ | %{__sed} -e s+%{buildroot}++g \ > %{buildroot}/var/adm/perl-modules/%{name} fi # remove special files find %{buildroot} -name "perllocal.pod" \ -o -name ".packlist" \ -o -name "*.bs" \ |xargs -i rm -f {} # no empty directories find %{buildroot}%{_prefix} \ -type d -depth \ -exec rmdir {} \; 2>/dev/null %{__perl} -MFile::Find -le ' find({ wanted => \&wanted, no_chdir => 1}, "%{buildroot}"); print "%doc Changes README"; for my $x (sort @dirs, @files) { push @ret, $x unless indirs($x); } print join "\n", sort @ret; sub wanted { return if /auto$/; local $_ = $File::Find::name; my $f = $_; s|^\Q%{buildroot}\E||; return unless length; return $files[@files] = $_ if -f $f; $d = $_; /\Q$d\E/ && return for reverse sort @INC; $d =~ /\Q$_\E/ && return for qw|/etc %_prefix/man %_prefix/bin %_prefix/share|; $dirs[@dirs] = $_; } sub indirs { my $x = shift; $x =~ /^\Q$_\E\// && $x ne $_ && return 1 for @dirs; } ' > %filelist [ -z %filelist ] && { echo "ERROR: empty %files listing" exit -1 } %clean [ "%{buildroot}" != "/" ] && rm -rf %{buildroot} %files -f %filelist %defattr(-,root,root) %changelog * Sun Jun 26 2005 Matt Dainty - Initial build. BIND-Config-Parser-0.01/Changes0100644000372000037200000000015010257616754014602 0ustar mattmattRevision history for Perl extension BIND::Config::Parser. 0.01 Sun Jun 26 2005 - Initial version.