1#!/usr/local/bin/perl -w 2###################################################################### 3# 4# DNS/Config.pm 5# 6# $Id: Config.pm,v 1.4 2003/02/16 10:15:31 awolf Exp $ 7# $Revision: 1.4 $ 8# $Author: awolf $ 9# $Date: 2003/02/16 10:15:31 $ 10# 11# Copyright (C)2001-2003 Andy Wolf. All rights reserved. 12# 13# This library is free software; you can redistribute it and/or 14# modify it under the same terms as Perl itself. 15# 16###################################################################### 17 18package DNS::Config; 19 20use strict; 21 22my $VERSION = '0.66'; 23my $REVISION = sprintf("%d.%02d", q$Revision: 1.4 $ =~ /(\d+)\.(\d+)/); 24 25sub new { 26 my($pkg) = @_; 27 my $class = ref($pkg) || $pkg; 28 29 my $self = { 30 'STATEMENTS' => [] 31 }; 32 33 bless $self, $class; 34 35 return $self; 36} 37 38sub add { 39 my($self, $statement) = @_; 40 41 if(ref($statement) eq 'ARRAY') { 42 push @{ $self->{'STATEMENTS'} }, @$statement; 43 } 44 else { 45 push @{ $self->{'STATEMENTS'} }, ($statement); 46 } 47 48 return $self; 49} 50 51sub delete { 52 my($self, $statement) = @_; 53 54 for(my $i=0 ; $i < scalar @{$self->{'STATEMENTS'}} ; $i++) { 55 next unless( defined( $self->{'STATEMENTS'}->[$i] ) ); 56 splice @{ $self->{'STATEMENTS'} }, $i, 1 if($self->{'STATEMENTS'}->[$i] == $statement); 57 } 58 59 return $self; 60} 61 62sub debug { 63 my($self) = @_; 64 65 eval { 66 use Data::Dumper; 67 68 print Dumper($self); 69 }; 70 71 return; 72} 73 74sub statements { 75 my($self, $type) = @_; 76 my @result; 77 78 if($type) { 79 foreach (@{ $self->{'STATEMENTS'} }) { 80 push @result, $_ if(ref($_) eq $type); 81 } 82 } 83 else { 84 @result = @{ $self->{'STATEMENTS'} }; 85 } 86 87 return @result; 88} 89 901; 91 92__END__ 93 94=pod 95 96=head1 NAME 97 98DNS::Config - DNS Configuration 99 100=head1 SYNOPSIS 101 102use DNS::Config; 103 104my $config = new DNS::Config(); 105 106$config->debug(); 107 108 109=head1 ABSTRACT 110 111This class represents a configuration for a domain name service 112daemon (DNS). 113 114 115=head1 DESCRIPTION 116 117A domain name service daemon configuration knows about the zone 118information actively provided to the service users as well as 119lots of other configuration data. 120 121This class allows to represent this configuration data in a more 122or less generic way. Another class, the file adaptor, then knows 123how to write the information to a file in a daemon specific 124format. 125 126So far this class is strongly related to the ISCs Bind domain 127name service daemon but it is inteded to get more generic in 128upcoming releases. Your help is welcome. 129 130 131=head1 AUTHOR 132 133Copyright (C)2001-2003 Andy Wolf. All rights reserved. 134 135This library is free software; you can redistribute it and/or 136modify it under the same terms as Perl itself. 137 138Please address bug reports and comments to: 139zonemaster@users.sourceforge.net 140 141 142=head1 SEE ALSO 143 144L<DNS::Config::File>, L<DNS::Config::Server>, L<DNS::Config::Statement> 145 146 147=cut 148