summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2002-07-10 11:49:41 +0000
committerPeter Palfrader <peter@palfrader.org>2002-07-10 11:49:41 +0000
commitcb24c5433cefc0d82c834520b5bdc1ad855e58e2 (patch)
treecf8440f01f04727f62df39daa710d29a0b761ae9
parenta13d3a3cde9174d2a6e2bb8d9c9a0f392883674e (diff)
Moved from XML to Data::Dumperecholot-2.0beta2
-rw-r--r--Echolot/Config.pm30
-rw-r--r--Echolot/Storage/File.pm28
-rw-r--r--NEWS13
-rwxr-xr-xpingd4
-rw-r--r--pingd.conf29
-rwxr-xr-xtools/convert-xml-to-datadumper14
6 files changed, 64 insertions, 54 deletions
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 <peter@palfrader.org>
-# $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 = <CONFIGCODE>;
+ 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 <peter@palfrader.org>
-# $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 <peter@palfrader.org>
-# $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 E<lt>URL:http://savannah.gnu.org/bugs/?group=echolotE<gt>
=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 syn=xml: -->
-<!-- $Id: pingd.conf,v 1.13 2002/07/06 23:26:32 weasel Exp $ -->
+# vim:set syntax=perl:
-<perldata>
- <hash>
- <item key="homedir">/home/pinger/echolot</item>
- <item key="sitename">unconfigured</item>
- <item key="my_localpart">pinger</item>
- <item key="my_domain">example.com</item>
- <item key="Pinger::Mix">
- <hash>
- <item key="mixdir">/home/pinger/Mix</item>
- <item key="mix">/home/pinger/Mix/mix</item>
- </hash>
- </item>
- </hash>
-</perldata>
+$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 ('', <stdin>) );
+my $dump = new XML::Dumper;
+my $CONFIG = $dump->xml2pl($tree);
+
+print Data::Dumper->Dump([ $CONFIG ], [ $ARGV[0] ]);