]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Default to the XML config format.
authorPeter Powell <petpow@saberuk.com>
Sat, 6 Apr 2013 10:46:56 +0000 (11:46 +0100)
committerPeter Powell <petpow@saberuk.com>
Sat, 6 Apr 2013 10:47:56 +0000 (11:47 +0100)
docs/conf/inspircd.conf.example
docs/conf/modules.conf.example
include/configparser.h
src/configparser.cpp

index 631db7376f192899d5ff2ab0fbf526c9538f073b..2988ccc0b86e4cac36fb9ef52701660c93c8ed4c 100644 (file)
 #                                                                      #
 ########################################################################
 
+#-#-#-#-#-#-#-#-#-#  CONFIGURATION FORMAT  #-#-#-#-#-#-#-#-#-#-#-#-#-#-
+#                                                                     #
+# In order to maintain compatibility with older configuration files,  #
+# you can change the configuration parser to parse as it did in       #
+# previous releases. When using the "compat" format, you need to use  #
+# C++ escape sequences (e.g. \n) instead of XML ones (e.g. &nl;) and  #
+# can not use <define> to create macros.                              #
+#<config format="compat">
+
 #-#-#-#-#-#-#-#-#-#  INCLUDE CONFIGURATION  #-#-#-#-#-#-#-#-#-#-#-#-#-#
 #                                                                     #
 # This optional tag allows you to include another config file         #
 #                                                                     #
 # Variables may be redefined and may reference other variables.       #
 # Value expansion happens at the time the tag is read.                #
-#                                                                     #
-# Using variable definitions REQUIRES that the config format be       #
-# changed to "xml" from the default "compat" that uses escape         #
-# sequences such as "\"" and "\n", and does not support <define>      #
-<config format="xml">
 <define name="bindip" value="1.2.2.3">
 <define name="localips" value="&bindip;/24">
 
index bd64f69f5c3db2c28608a768427fbae75139ae81..6d0c2cbdbd388a5b990896b365578f3cf088e023 100644 (file)
 # ranktoset  The numeric rank required to set/unset this mode. Defaults to rank.
 # depriv     Can you remove the mode from yourself? Defaults to yes.
 #<customprefix name="founder" letter="q" prefix="~" rank="50000" ranktoset="50000">
-#<customprefix name="admin" letter="a" prefix="&" rank="40000" ranktoset="50000">
+#<customprefix name="admin" letter="a" prefix="&amp;" rank="40000" ranktoset="50000">
 #<customprefix name="halfop" letter="h" prefix="%" rank="20000" ranktoset="30000">
 #<customprefix name="halfvoice" letter="V" prefix="-" rank="1" ranktoset="20000">
 
index 999d79e2460d452122e290e2c82f47c6fdded4c1..9b2cd4527db963c8481922344b96054e8051cea7 100644 (file)
@@ -31,7 +31,7 @@ struct fpos
 
 enum ParseFlags
 {
-       FLAG_USE_XML = 1,
+       FLAG_USE_COMPAT = 1,
        FLAG_NO_EXEC = 2,
        FLAG_NO_INC = 4
 };
index 7d9eab651a88f81719e9f4b216cc8db090652301..25b919b818164ed3a6c997b09fb7267b5cfa7116 100644 (file)
@@ -119,7 +119,7 @@ struct Parser
                while (1)
                {
                        ch = next();
-                       if (ch == '&' && (flags & FLAG_USE_XML))
+                       if (ch == '&' && !(flags & FLAG_USE_COMPAT))
                        {
                                std::string varname;
                                while (1)
@@ -141,7 +141,7 @@ struct Parser
                                        throw CoreException("Undefined XML entity reference '&" + varname + ";'");
                                value.append(var->second);
                        }
-                       else if (ch == '\\' && !(flags & FLAG_USE_XML))
+                       else if (ch == '\\' && (flags & FLAG_USE_COMPAT))
                        {
                                int esc = next();
                                if (esc == 'n')
@@ -211,7 +211,7 @@ struct Parser
                }
                else if (name == "define")
                {
-                       if (!(flags & FLAG_USE_XML))
+                       if (flags & FLAG_USE_COMPAT)
                                throw CoreException("<define> tags may only be used in XML-style config (add <config format=\"xml\">)");
                        std::string varname = tag->getString("name");
                        std::string value = tag->getString("value");
@@ -223,9 +223,9 @@ struct Parser
                {
                        std::string format = tag->getString("format");
                        if (format == "xml")
-                               flags |= FLAG_USE_XML;
+                               flags &= ~FLAG_USE_COMPAT;
                        else if (format == "compat")
-                               flags &= ~FLAG_USE_XML;
+                               flags |= FLAG_USE_COMPAT;
                        else if (!format.empty())
                                throw CoreException("Unknown configuration format " + format);
                }