summaryrefslogtreecommitdiff
path: root/bin/allpingers-ini2xml
blob: 9add8ae5c25df346d1b0c2822af32c4a6192289e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/usr/bin/perl -wT

#   ini2xml: (c) 2002 Peter Palfrader <peter@palfrader.org>
#   $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<update>

=back

=head1 DESCRIPTION

FIXME

=back

=head1 BUGS

Please report them to the author.

=head1 AUTHOR

Peter  Palfrader, E<lt>peter@palfrader.orgE<gt>

=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{<?xml version="1.0"?>\n};
printf qq{<!--  A L L   P I N G E R S'   I N D E X                               -->
<!--                                                                   -->
<!-- Generated: %-54s -->
<!--                                                                   -->
<!-- This list can be found on the web on http://www.noreply.org/      -->
<!--                                                                   -->
<!-- If anything is wrong/broken/missing please mail the maintainer at -->
<!-- pingers\@palfrader.org                                             -->
}, scalar gmtime();
print qq{
<!DOCTYPE pingers [
<!ELEMENT pingers (pinger*)>
<!ATTLIST pingers
  version CDATA #FIXED "1"
  generated CDATA #REQUIRED
  >
<!ELEMENT pinger (
	baseurl?,
	rlist*,
	mlist*,
	rchain*,
	pgpring*,
	mixring?,
	type2list?
	)>
<!ATTLIST pinger
  name CDATA #REQUIRED
  >
<!ELEMENT baseurl (#PCDATA)>
<!ELEMENT rlist (#PCDATA)>
<!ATTLIST rlist
  version (1|2) "1"
  format (txt|html) "txt"
  >
<!ELEMENT mlist (#PCDATA)>
<!ATTLIST mlist
  version (1|2) "1"
  format (txt|html) "txt"
  >
<!ELEMENT rchain (#PCDATA)>
<!ATTLIST rchain
  format (txt|html) "txt"
  >
<!ELEMENT pgpring (#PCDATA)>
<!ATTLIST pgpring
  format (asc|pgp) "asc"
  keys (rsa|dsa|all) "all
  ">
<!ELEMENT mixring (#PCDATA)>
<!ELEMENT type2list (#PCDATA)>
]>
};

my $now = `822-date`;
chomp $now;
printf qq{<pingers version="1" generated="%s">\n}, $now;
for my $pinger (sort keys %pingers) {
	my $p = $pingers{$pinger};
	printf qq{\t<pinger name="%s">\n}, $pinger;
		printf (qq{\t\t<baseurl>%s</baseurl>\n}, $p->{'base'}) and delete $p->{'base'} if defined ($p->{'base'});

		printf (qq{\t\t<rlist version="1" format="txt">%s</rlist>\n}, $p->{'rlist'})and delete $p->{'rlist'} if defined ($p->{'rlist'});
		printf (qq{\t\t<rlist version="2" format="txt">%s</rlist>\n}, $p->{'rlist2'})and delete $p->{'rlist2'} if defined ($p->{'rlist2'});
		printf (qq{\t\t<rlist version="1" format="html">%s</rlist>\n}, $p->{'rlist_html'})and delete $p->{'rlist_html'} if defined ($p->{'rlist_html'});
		printf (qq{\t\t<rlist version="2" format="html">%s</rlist>\n}, $p->{'rlist2_html'})and delete $p->{'rlist2_html'} if defined ($p->{'rlist2_html'});

		printf (qq{\t\t<mlist version="1" format="txt">%s</mlist>\n}, $p->{'mlist'})and delete $p->{'mlist'} if defined ($p->{'mlist'});
		printf (qq{\t\t<mlist version="2" format="txt">%s</mlist>\n}, $p->{'mlist2'})and delete $p->{'mlist2'} if defined ($p->{'mlist2'});
		printf (qq{\t\t<mlist version="1" format="html">%s</mlist>\n}, $p->{'mlist_html'})and delete $p->{'mlist_html'} if defined ($p->{'mlist_html'});
		printf (qq{\t\t<mlist version="2" format="html">%s</mlist>\n}, $p->{'mlist2_html'})and delete $p->{'mlist2_html'} if defined ($p->{'mlist2_html'});

		printf (qq{\t\t<rchain format="txt">%s</rchain>\n}, $p->{'rchain'})and delete $p->{'rchain'} if defined ($p->{'rchain'});
		printf (qq{\t\t<rchain format="html">%s</rchain>\n}, $p->{'rchain_html'})and delete $p->{'rchain_html'} if defined ($p->{'rchain_html'});

		printf (qq{\t\t<pgpring format="asc" keys="all">%s</pgpring>\n}, $p->{'pgpring'})and delete $p->{'pgpring'} if defined ($p->{'pgpring'});
		printf (qq{\t\t<pgpring format="asc" keys="rsa">%s</pgpring>\n}, $p->{'pgpring_rsa'})and delete $p->{'pgpring_rsa'} if defined ($p->{'pgpring_rsa'});
		
		printf (qq{\t\t<mixring>%s</mixring>\n}, $p->{'mixring'})and delete $p->{'mixring'} if defined ($p->{'mixring'});
		printf (qq{\t\t<type2list>%s</type2list>\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</pinger>\n};
}
print qq{</pingers>\n};