From 797faf1430c1284c112e3255d0c65836aad858db Mon Sep 17 00:00:00 2001 From: Alex Badea Date: Tue, 9 Apr 2002 22:40:56 +0000 Subject: [PATCH] Author: Alex Badea Log message: Added a configuration file converter (2.10.11 -> 2.10.12), fixing a conf parser bug in the process. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@719 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- ChangeLog | 9 +++ ircd-patch | 20 +++++- ircd/ircd_parser.y | 4 +- tools/convert-conf.py | 148 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 177 insertions(+), 4 deletions(-) create mode 100755 tools/convert-conf.py diff --git a/ChangeLog b/ChangeLog index 5d924a5..ce60e52 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2002-04-10 Alex Badea + + * ircd/ircd_parser.y: fixed a "features" block parse bug + + * tools/convert-conf.py: added a configuration file converter + from 2.10.11 to 2.10.12 format + + * ircd-patch: added GPL information to top of file + 2002-04-09 Alex Badea * configure.in: added a human-readable report of configured diff --git a/ircd-patch b/ircd-patch index f91c1ba..560b1d6 100755 --- a/ircd-patch +++ b/ircd-patch @@ -1,11 +1,27 @@ #!/bin/sh # -# ircd-patch +# IRC - Internet Relay Chat, ircd-patch # Copyright (C) 2002 Alex Badea # -# $Id: ircd-patch,v 1.3 2002-04-02 11:24:29 isomer Exp $ +# 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# $Id: ircd-patch,v 1.4 2002-04-09 22:40:56 vampire Exp $ +# # # Experimental centralized patch system for ircu +# Run with no arguments to get help. # # Return codes: # 0 - success diff --git a/ircd/ircd_parser.y b/ircd/ircd_parser.y index 81a15fe..b570dc4 100644 --- a/ircd/ircd_parser.y +++ b/ircd/ircd_parser.y @@ -845,12 +845,12 @@ featureitems: featureitems featureitem | featureitem; featureitem: QSTRING { - stringno = 0; + stringlist[0] = $1; + stringno = 1; } '=' stringlist ';'; stringlist: QSTRING { - stringlist[0] = $1; stringlist[1] = $1; stringno = 2; } posextrastrings diff --git a/tools/convert-conf.py b/tools/convert-conf.py new file mode 100755 index 0000000..64a2dea --- /dev/null +++ b/tools/convert-conf.py @@ -0,0 +1,148 @@ +#!/usr/bin/env python +# +# IRC - Internet Relay Chat, tools/convert-conf.py +# Copyright (C) 2002 Alex Badea +# +# 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# +# Configuration file converter from 2.10.11 to 2.10.12 format +# Usage: +# convert-conf.py < old.conf > new.conf +# +# $Id: convert-conf.py,v 1.1 2002-04-09 22:40:56 vampire Exp $ +# + +import sys +from string import * + +if len(sys.argv) > 1: + f = open(sys.argv[1], "r") +else: + f = sys.stdin + +servers = {} +jupes = [] +feats = [] + +def do_uline(parts): + if not servers.has_key(parts[1]): + servers[parts[1]] = ['*', 0, 0, 0] + servers[parts[1]][1] = 1 + if len(parts[2]): + jupes.append(parts[2]) + +def do_hline(parts): + if not servers.has_key(parts[3]): + servers[parts[3]] = ['*', 0, 0, 0] + servers[parts[3]][0] = parts[1] + servers[parts[3]][2] = 1 + +def do_lline(parts): + if not servers.has_key(parts[3]): + servers[parts[3]] = ['*', 0, 0, 0] + servers[parts[3]][0] = parts[1] + servers[parts[3]][3] = 1 + +def do_pline(parts): + print "#", join(parts, ":") + print "Port {" + print "\tport = %s;" % parts[4] + if len(parts[1]): + print "\tmask = \"%s\";" % parts[1] + if len(parts[2]): + print "\tvhost = \"%s\";" % parts[2] + if count(parts[3], 'S'): + print "\tserver = yes;" + if count(parts[3], 'H'): + print "\thidden = yes;" + print "};" + print + +def do_fline(parts): + feats.append((parts[1], parts[2])) + +cvtmap = { + 'M': ('General', ('name', 'vhost', 'description', '', '!numeric'), ''), + 'A': ('Admin', ('location', 'contact', 'contact'), ''), + 'Y': ('Class', ('name', '!pingfreq', '!connectfreq', '!maxlinks', '!sendq'), ''), + 'I': ('Client', ('ip', 'password', 'host', '', 'class'), ''), + 'T': ('motd', ('host', 'file'), ''), + 'U': do_uline, + 'H': do_hline, + 'L': do_lline, + 'K': ('Kill', ('host', 'reason'), ''), + 'k': ('Kill', ('host', 'reason'), ''), + 'C': ('Connect', ('host', 'password', 'name', '!port', 'class'), ''), + 'D': ('CRULE', ('server', '', 'rule'), '\tall = yes;'), + 'd': ('CRULE', ('server', '', 'rule'), ''), + 'O': ('Operator', ('host', 'password', 'name', '', 'class'), '\tlocal = no;'), + 'o': ('Operator', ('host', 'password', 'name', '', 'class'), '\tlocal = yes;'), + 'P': do_pline, + 'F': do_fline +} + +for line in f.readlines(): + line = strip(line) + parts = split(line, ":") + if not len(parts): + continue + if not cvtmap.has_key(parts[0]): + continue + if callable(cvtmap[parts[0]]): + cvtmap[parts[0]](parts) + continue + (block, items, extra) = cvtmap[parts[0]] + print "#", line + print block, "{" + idx = 1 + for item in items: + if idx >= len(parts): + break + if len(parts[idx]) and len(item): + if item[0] == '!': + print "\t%s = %s;" % (item[1:], parts[idx]) + else: + print "\t%s = \"%s\";" % (item, parts[idx]) + idx = idx + 1 + if len(extra): + print extra + print "};" + print + +for server in servers.keys(): + (mask, uw, hub, leaf) = servers[server] + print "Server {" + print "\tname = \"%s\";" % server + print "\tmask = \"%s\";" % mask + if uw: print "\tuworld = yes;" + if hub: print "\thub = yes;" + if leaf: print "\tleaf = yes;" + print "};" + print + +if len(jupes): + print "Jupe {" + for nick in jupes: + print "\tnick = \"%s\";" % nick + print "};" + print + +if len(feats): + print "features {" + for (name, value) in feats: + print "\t\"%s\" = \"%s\";" % (name, value) + print "};" + print -- 2.20.1