#!/usr/bin/perl -wT # ini2xml: (c) 2002 Peter Palfrader # $Id$ # # This program is free software. you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA =pod =head1 NAME ini2xml convert pingers ini file to xml =over =head1 SYNOPSIS =item B =back =head1 DESCRIPTION FIXME =back =head1 BUGS Please report them to the author. =head1 AUTHOR Peter Palfrader, Epeter@palfrader.orgE =cut use strict; use Getopt::Long; use English; use FindBin qw{ $Bin }; ($Bin) = $Bin =~ m/^(.*)$/; chdir($Bin); $ENV{'PATH'} = '/bin:/usr/bin'; delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; my %pingers; { my $source; while(<>) { s/\s*(.*)\s*/$1/; next if (/^\s*#/); $source = $1, next if (/^\[(.*)\]$/); if (/(.+?)\s*=\s*(.+)/) { $pingers{$source}->{$1} = $2 if defined $source; }; }; }; print qq{\n}; printf qq{ }, scalar gmtime(); print qq{ ]> }; my $now = `date -R`; chomp $now; printf qq{\n}, $now; for my $pinger (sort keys %pingers) { my $p = $pingers{$pinger}; printf qq{\t\n}, $pinger; printf (qq{\t\t%s\n}, $p->{'base'}) and delete $p->{'base'} if defined ($p->{'base'}); printf (qq{\t\t%s\n}, $p->{'rlist'})and delete $p->{'rlist'} if defined ($p->{'rlist'}); printf (qq{\t\t%s\n}, $p->{'rlist2'})and delete $p->{'rlist2'} if defined ($p->{'rlist2'}); printf (qq{\t\t%s\n}, $p->{'rlist_html'})and delete $p->{'rlist_html'} if defined ($p->{'rlist_html'}); printf (qq{\t\t%s\n}, $p->{'rlist2_html'})and delete $p->{'rlist2_html'} if defined ($p->{'rlist2_html'}); printf (qq{\t\t%s\n}, $p->{'mlist'})and delete $p->{'mlist'} if defined ($p->{'mlist'}); printf (qq{\t\t%s\n}, $p->{'mlist2'})and delete $p->{'mlist2'} if defined ($p->{'mlist2'}); printf (qq{\t\t%s\n}, $p->{'mlist_html'})and delete $p->{'mlist_html'} if defined ($p->{'mlist_html'}); printf (qq{\t\t%s\n}, $p->{'mlist2_html'})and delete $p->{'mlist2_html'} if defined ($p->{'mlist2_html'}); printf (qq{\t\t%s\n}, $p->{'rchain'})and delete $p->{'rchain'} if defined ($p->{'rchain'}); printf (qq{\t\t%s\n}, $p->{'rchain_html'})and delete $p->{'rchain_html'} if defined ($p->{'rchain_html'}); printf (qq{\t\t%s\n}, $p->{'pgpring'})and delete $p->{'pgpring'} if defined ($p->{'pgpring'}); printf (qq{\t\t%s\n}, $p->{'pgpring_rsa'})and delete $p->{'pgpring_rsa'} if defined ($p->{'pgpring_rsa'}); printf (qq{\t\t%s\n}, $p->{'mixring'})and delete $p->{'mixring'} if defined ($p->{'mixring'}); printf (qq{\t\t%s\n}, $p->{'type2list'})and delete $p->{'type2list'} if defined ($p->{'type2list'}); for my $k (sort keys %$p) { warn("Unused key $k in $p\n"); }; printf qq{\t\n}; } print qq{\n};