From cb24c5433cefc0d82c834520b5bdc1ad855e58e2 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Wed, 10 Jul 2002 11:49:41 +0000 Subject: Moved from XML to Data::Dumper --- Echolot/Config.pm | 30 ++++++++++++------------------ Echolot/Storage/File.pm | 28 +++++++++++----------------- NEWS | 13 +++++++++++++ pingd | 4 +--- pingd.conf | 29 +++++++++++++---------------- tools/convert-xml-to-datadumper | 14 ++++++++++++++ 6 files changed, 64 insertions(+), 54 deletions(-) create mode 100644 NEWS create mode 100755 tools/convert-xml-to-datadumper diff --git a/Echolot/Config.pm b/Echolot/Config.pm index ebe2a29..8861873 100644 --- a/Echolot/Config.pm +++ b/Echolot/Config.pm @@ -1,7 +1,7 @@ package Echolot::Config; # (c) 2002 Peter Palfrader -# $Id: Config.pm,v 1.17 2002/07/07 01:12:00 weasel Exp $ +# $Id: Config.pm,v 1.18 2002/07/10 11:49:41 weasel Exp $ # =pod @@ -39,9 +39,8 @@ The configuration file is searched in those places in that order: use strict; use warnings; -use XML::Parser; -use XML::Dumper; use Carp; +use English; my $CONFIG; @@ -138,10 +137,15 @@ sub init($) { die ("no Configuration file found\n") unless defined $configfile; { - my $parser = new XML::Parser(Style => 'Tree'); - my $tree = $parser->parsefile($configfile); - my $dump = new XML::Dumper; - $CONFIG = $dump->xml2pl($tree); + local $/ = undef; + open(CONFIGCODE, $configfile) or + carp("Could not open configfile '$configfile': $!"); + my $config_code = ; + close (CONFIGCODE); + ($config_code) = $config_code =~ /^(.*)$/s; + eval ($config_code); + ($EVAL_ERROR) and + carp("Evaling config code from '$configfile' returned error: $EVAL_ERROR"); } for my $key (keys %$DEFAULT) { @@ -160,17 +164,7 @@ sub get() { }; sub dump() { - # FIXME XML::Dumper bug workaround - # There is a bug in pl2xml that changes data passed (cf. Debian Bug #148969 and #148970 - # at http://bugs.debian.org/148969 and http://bugs.debian.org/148970 - require Data::Dumper; - my $storedata; - eval ( Data::Dumper->Dump( [ $CONFIG ], [ 'storedata' ] )); - - my $dump = new XML::Dumper; - my $data = $dump->pl2xml($storedata); - - print $data; + print Data::Dumper->Dump( [ $CONFIG ], [ 'CONFIG' ] ); }; 1; diff --git a/Echolot/Storage/File.pm b/Echolot/Storage/File.pm index 021bff6..5de1b6c 100644 --- a/Echolot/Storage/File.pm +++ b/Echolot/Storage/File.pm @@ -1,7 +1,7 @@ package Echolot::Storage::File; # (c) 2002 Peter Palfrader -# $Id: File.pm,v 1.27 2002/07/07 01:12:00 weasel Exp $ +# $Id: File.pm,v 1.28 2002/07/10 11:49:41 weasel Exp $ # =pod @@ -20,8 +20,7 @@ This package provides several functions for data storage for echolot. use strict; use warnings; -use XML::Parser; -use XML::Dumper; +use Data::Dumper; use IO::Handle; use English; use Carp qw{cluck confess}; @@ -163,11 +162,14 @@ sub metadata_read($) { seek($self->{'METADATA_FH'}, 0, SEEK_SET) or cluck("Cannot seek to start of metadata file: $!"), return 0; - eval { - my $parser = new XML::Parser(Style => 'Tree'); - my $tree = $parser->parse( $self->{'METADATA_FH'} ); - my $dump = new XML::Dumper; - $self->{'METADATA'} = $dump->xml2pl($tree); + { + local $/ = undef; + my $fh = $self->{'METADATA_FH'}; + my $metadata_code = <$fh>; + ($metadata_code) = $metadata_code =~ /^(.*)$/s; + my $METADATA; + eval ($metadata_code); + $self->{'METADATA'} = $METADATA; }; $EVAL_ERROR and cluck("Error when reading from metadata file: $EVAL_ERROR"), @@ -191,15 +193,7 @@ sub metadata_read($) { sub metadata_write($) { my ($self) = @_; - # FIXME XML::Dumper bug workaround - # There is a bug in pl2xml that changes data passed (cf. Debian Bug #148969 and #148970 - # at http://bugs.debian.org/148969 and http://bugs.debian.org/148970 - require Data::Dumper; - my $storedata; - eval ( Data::Dumper->Dump( [ $self->{'METADATA'} ], [ 'storedata' ] )); - - my $dump = new XML::Dumper; - my $data = $dump->pl2xml($storedata); + my $data = Data::Dumper->Dump( [ $self->{'METADATA'} ], [ 'METADATA' ] ); my $fh = $self->{'METADATA_FH'}; seek($fh, 0, SEEK_SET) or diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..27ed6b6 --- /dev/null +++ b/NEWS @@ -0,0 +1,13 @@ +Changes in version 2.0 beta2 - 2002-07-10 + * Moved from XML to Data::Dumper + Use convert-xml-to-datadumper in the tools directory to + convert your setup: + pingd stop + mv pingd.conf pingd.conf.old + mv data/metadata data/metadata.old + convert-xml-to-datadumper CONFIG < pingd.conf.old > pingd.conf + convert-xml-to-datadumper METADATA < data/metadata.old > data/metadata + pingd start + +Changes in version 2.0 beta1 - 2002-07-07 + * Initial public beta test diff --git a/pingd b/pingd index cc82401..15246ff 100755 --- a/pingd +++ b/pingd @@ -1,7 +1,7 @@ #!/usr/bin/perl -wT # (c) 2002 Peter Palfrader -# $Id: pingd,v 1.21 2002/07/07 01:11:59 weasel Exp $ +# $Id: pingd,v 1.22 2002/07/10 11:49:41 weasel Exp $ # =pod @@ -205,8 +205,6 @@ Please report them at EURL:http://savannah.gnu.org/bugs/?group=echolotE =cut use strict; -use XML::Parser; -use XML::Dumper; use Getopt::Long; use English; use Carp; diff --git a/pingd.conf b/pingd.conf index 4f28e3c..7bef62f 100644 --- a/pingd.conf +++ b/pingd.conf @@ -1,17 +1,14 @@ - - +# vim:set syntax=perl: - - - /home/pinger/echolot - unconfigured - pinger - example.com - - - /home/pinger/Mix - /home/pinger/Mix/mix - - - - +$CONFIG = { + 'homedir' => '/home/pinger/echolot', + 'sitename' => 'unconfigured', + + 'my_localpart' => 'pinger', + 'my_domain' => 'example.com', + + 'Pinger::Mix' => { + 'mix' => '/home/pinger/Mix/mix', + 'mixdir' => '/home/pinger/Mix' + } + }; diff --git a/tools/convert-xml-to-datadumper b/tools/convert-xml-to-datadumper new file mode 100755 index 0000000..26d8c27 --- /dev/null +++ b/tools/convert-xml-to-datadumper @@ -0,0 +1,14 @@ +#!/usr/bin/perl -w + +use strict; +use XML::Parser; +use XML::Dumper; +use Data::Dumper; + + +my $parser = new XML::Parser(Style => 'Tree'); +my $tree = $parser->parse( join ('', ) ); +my $dump = new XML::Dumper; +my $CONFIG = $dump->xml2pl($tree); + +print Data::Dumper->Dump([ $CONFIG ], [ $ARGV[0] ]); -- cgit v1.2.3