diff options
| author | 2016-03-13 16:27:49 +0000 | |
|---|---|---|
| committer | 2016-03-13 16:27:49 +0000 | |
| commit | fbb00b1778c9a58180e8fa960f2a57a79b5ea760 (patch) | |
| tree | 463408e99085ad98c35fe5f51281bf2667cc89dc /lib/ASM/XML.pm | |
| parent | 2638f623e8405ffad402e258bdba4f90cf7228de (diff) | |
BOOM GOES THE XML
This likely introduces twenty new bugs, but on the other hand it avoids
twenty thousand other issues (most of them relating to XML::Simple
doing the utterly wrong things all the time and configuration merely
mitigating the issues, rather than fixing the core problem)
so chances are it's more than worth it.
We check if there's shiny new JSON-based config in place already; if
not, we try to load XML config and convert it to the new format. The old
config files are left untouched in case we fucked up somehow.
Diffstat (limited to 'lib/ASM/XML.pm')
| -rw-r--r-- | lib/ASM/XML.pm | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/lib/ASM/XML.pm b/lib/ASM/XML.pm deleted file mode 100644 index 7588699..0000000 --- a/lib/ASM/XML.pm +++ /dev/null @@ -1,70 +0,0 @@ -package ASM::XML; -no autovivification; -use warnings; -use strict; - -use XML::Simple qw(:strict); -use IO::All; -no if $] >= 5.017011, warnings => 'experimental::smartmatch'; - -$::xs1 = XML::Simple->new( KeyAttr => ['id'], Cache => [ qw/memcopy/ ]); - -sub readXML { - my ( $p ) = $::cset; - my @fchan = ( 'event', keys %::RISKS ); - $::settings = $::xs1->XMLin( "$p/settings.xml", ForceArray => ['host'], - 'GroupTags' => { altnicks => 'altnick', server => 'host', - autojoins => 'autojoin' }); - $::channels = $::xs1->XMLin( "$p/channels.xml", ForceArray => \@fchan ); - $::users = $::xs1->XMLin( "$p/users.xml", ForceArray => 'person'); - $::mysql = $::xs1->XMLin( "$p/mysql.xml", ForceArray => ['ident', 'geco'], - 'GroupTags' => { ignoredidents => 'ident', ignoredgecos => 'geco' }); - $::dnsbl = $::xs1->XMLin( "$p/dnsbl.xml", ForceArray => []); - $::rules = $::xs1->XMLin( "$p/rules.xml", ForceArray => []); - $::restrictions = $::xs1->XMLin( "$p/restrictions.xml", ForceArray => ['host', 'nick', 'account']); - $::blacklist = $::xs1->XMLin( "$p/blacklist.xml", ForceArray => 'string'); -} - -sub writeXML { - writeSettings(); - writeChannels(); - writeUsers(); - writeRestrictions(); - writeBlacklist(); - writeMysql(); -} - -sub writeMysql { - $::settingschanged=1; - $::xs1->XMLout($::mysql, RootName => 'mysql', KeyAttr => ['id']) > io("$::cset/mysql.xml"); -} - -sub writeChannels { - $::settingschanged=1; - $::xs1->XMLout($::channels, RootName => 'channels', KeyAttr => ['id'], NumericEscape => 2) > io("$::cset/channels.xml"); -} - -sub writeUsers { - $::settingschanged=1; - $::xs1->XMLout($::users, RootName => 'people', KeyAttr => ['id']) > io("$::cset/users.xml"); -} - -sub writeSettings { - $::settingschanged=1; - $::xs1->XMLout($::settings, RootName => 'settings', - GroupTags => { altnicks => 'altnick', server => 'host', autojoins => 'autojoin' }, NoAttr => 1) > io("$::cset/settings.xml"); -} - -sub writeRestrictions { - $::settingschanged=1; - $::xs1->XMLout($::restrictions, RootName => 'restrictions', KeyAttr => ['id'], - GroupTags => { hosts => "host", nicks => "nick", accounts => "account"}) > io("$::cset/restrictions.xml"); -} - -sub writeBlacklist { - $::settingschanged=1; - $::xs1->XMLout($::blacklist, RootName => 'blacklist', KeyAttr => ['id'], NumericEscape => 2) > io("$::cset/blacklist.xml"); -} - -return 1; -# vim: ts=2:sts=2:sw=2:expandtab |
