Fix handling of NAMES #a,#b.
[ircu2.10.12-pk.git] / tools / convert-conf.py
index c9f8831614754e70bd7b5cc57560c41b28c64098..8e94a71b066728e2d928850ecbb0946d2a5774ce 100755 (executable)
@@ -22,7 +22,7 @@
 # Usage:
 #   convert-conf.py < old.conf > new.conf
 #
-# $Id: convert-conf.py,v 1.5 2005-04-17 02:18:55 isomer Exp $
+# $Id: convert-conf.py,v 1.8 2005-04-25 04:04:17 isomer Exp $
 #
 
 import sys
@@ -67,6 +67,9 @@ useable_features = [
        "HIS_REWRITE", "HIS_REMOTE", "HIS_NETSPLIT", "HIS_SERVERNAME", 
        "HIS_SERVERINFO", "HIS_URLSERVERS"
        ]
+deprecated_features = [ 
+                       "VIRTUAL_HOST",
+                       ]
 
 # [ "old feature" => ( local oper priv, global oper priv ) ]
 # None means don't add this
@@ -196,7 +199,7 @@ def do_oline(parts):
        opers.append(parts)
 
 cvtmap = {
-       'M': ('General', ('name', 'vhost', 'description', '', '!numeric'), ''),
+       'M': ('General', ('name', 'vhost', 'description', '-', '!numeric'), ''),
        'A': ('Admin', ('location', 'contact', 'contact'), ''),
        'Y': ('Class', ('name', '!pingfreq', '!connectfreq', '!maxlinks', '!sendq'), ''),
        'I': do_iline,
@@ -270,6 +273,11 @@ for line in f.readlines():
        for item in items:
                if idx >= len(parts):
                        break
+               # This field is ignored
+               if parts[idx]=="-":
+                       continue
+               if len(parts[idx]) and not len(item):
+                       sys.stderr.write("WARNING: Unknown field %i on line %i\n" % (idx,lno))
                if len(parts[idx]) and len(item):
                        if item[0] == '!':
                                print "\t%s = %s;" % (item[1:], istr(parts[idx]))
@@ -331,13 +339,18 @@ if len(connects.keys()):
                print "\tname = \"%s\";" % qstr(connects[i]["name"])
                print "\thost = \"%s\";" % qstr(connects[i]["host"])
                print "\tpassword = \"%s\";" % qstr(connects[i]["password"])
-               if connects[i]["port"]:
+               if connects[i].has_key("port"):
                        print "\tport = %s;" % connects[i]["port"]
                print "\tclass = \"%s\";" % qstr(connects[i]["class"])
                if connects[i].has_key("hub"):
                        print "\thub = \"%s\";" % qstr(connects[i]["hub"])
                else:
                        print "\tleaf;"
+               if not connects[i].has_key("port"):
+                       print "# You can now specify ports without implying autoconnect"
+                       print "#\tport = 4400;"
+                       print "\tautoconnect = no;"
+                       sys.stderr.write("NOTE: You should add a port for \"%s\", autoconnect is now specified seperately\n" % qstr(connects[i]["name"]))
                print "};"
                print
 
@@ -354,8 +367,11 @@ if len(feats):
                                print "# Option converted to locop privilege"
                        elif name.startswith("OPER_"):
                                print "# Option converted to oper privilege"
+                       elif name in deprecated_features:
+                               print "# Option is deprecated"
                        else:
-                               print "# Option no longer exists in 2.10.12"
+                               print "# Unknown option"
+                               sys.stderr.write("WARNING: Unknown option \"%s\"\n" % qstr(name))
                        print "#\t\"%s\" = \"%s\";" % (qstr(name), qstr(value))
        print "};"
        print