]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/inspircd_io.cpp
Optimisations
[user/henk/code/inspircd.git] / src / inspircd_io.cpp
index 3d8af7e4ac88411ca0877f0903498c5c3ad4cef2..8cb4f9dd2fd6022cdb73a2628e327ef0f19d90ef 100644 (file)
@@ -692,7 +692,8 @@ void ServerConfig::Read(bool bail, userrec* user)
 
                if (bail)
                {
-                       printf("There were errors in your configuration:\n%s",errstr.str().c_str());
+                       /* Unneeded because of the log() aboive? */
+                       // printf("There were errors in your configuration:\n%s",errstr.str().c_str());
                        Exit(0);
                }
                else
@@ -1044,6 +1045,12 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const char* filename, std::o
                if((ch == '#') && !in_quote)
                        in_comment = true;
                
+               if(((ch == '\n') || (ch == '\r')) && in_quote)
+               {
+                       errorstream << "Got a newline within a quoted section, this is probably a typo: " << filename << ":" << linenumber << std::endl;
+                       return false;
+               }
+               
                switch(ch)
                {
                        case '\n':
@@ -1067,7 +1074,7 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const char* filename, std::o
                        {
                                if(!in_quote)
                                {
-                                       errorstream << "Got another opening < when the first one wasn't closed on line " << linenumber << std::endl;
+                                       errorstream << "Got another opening < when the first one wasn't closed: " << filename << ":" << linenumber << std::endl;
                                        return false;
                                }
                        }
@@ -1075,7 +1082,7 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const char* filename, std::o
                        {
                                if(in_quote)
                                {
-                                       errorstream << "We're in a quote but outside a tag, interesting. Line: " << linenumber << std::endl;
+                                       errorstream << "We're in a quote but outside a tag, interesting. " << filename << ":" << linenumber << std::endl;
                                        return false;
                                }
                                else
@@ -1104,11 +1111,11 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const char* filename, std::o
                        {
                                if(in_quote)
                                {
-                                       errorstream << "Found a (closing) \" outside a tag on line " << linenumber << std::endl;
+                                       errorstream << "Found a (closing) \" outside a tag: " << filename << ":" << linenumber << std::endl;
                                }
                                else
                                {
-                                       errorstream << "Found a (opening) \" outside a tag on line " << linenumber << std::endl;
+                                       errorstream << "Found a (opening) \" outside a tag: " << filename << ":" << linenumber << std::endl;
                                }
                        }
                }
@@ -1133,7 +1140,7 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const char* filename, std::o
                                }
                                else
                                {
-                                       errorstream << "Got a closing > when we weren't inside a tag on line " << linenumber << std::endl;
+                                       errorstream << "Got a closing > when we weren't inside a tag: " << filename << ":" << linenumber << std::endl;
                                        return false;
                                }
                        }
@@ -1160,7 +1167,7 @@ bool ServerConfig::ParseLine(ConfigDataHash &target, std::string &line, long lin
        
        got_name = got_key = in_quote = false;
        
-       std::cout << "ParseLine(data, '" << line << "', " << linenumber << ", stream)" << std::endl;
+       // std::cout << "ParseLine(data, '" << line << "', " << linenumber << ", stream)" << std::endl;
        
        for(std::string::iterator c = line.begin(); c != line.end(); c++)
        {
@@ -1223,7 +1230,8 @@ bool ServerConfig::ParseLine(ConfigDataHash &target, std::string &line, long lin
                                                
                                                if((tagname == "include") && (current_key == "file"))
                                                {
-                                                       this->DoInclude(target, current_value, errorstream);
+                                                       if(!this->DoInclude(target, current_value, errorstream))
+                                                               return false;
                                                }
                                                
                                                current_key.clear();
@@ -1243,8 +1251,6 @@ bool ServerConfig::ParseLine(ConfigDataHash &target, std::string &line, long lin
        
        /* Finished parsing the tag, add it to the config hash */
        target.insert(std::pair<std::string, KeyValList > (tagname, results));
-       std::cout << "Finished parsing " << tagname << std::endl;
-       std::cout << "Count of <server> tag: " << target.count("server") << std::endl;
        
        return true;
 }
@@ -1312,7 +1318,7 @@ bool ServerConfig::ConfValue(ConfigDataHash &target, const std::string &tag, con
        }
        else
        {
-               log(DEBUG, "ConfValue got an out-of-range index %d", index);
+               log(DEBUG, "ConfValue got an out-of-range index %d", pos);
        }
        
        return false;
@@ -1378,7 +1384,7 @@ int ServerConfig::ConfVarEnum(ConfigDataHash &target, const std::string &tag, in
        }
        else
        {
-               log(DEBUG, "ConfVarEnum got an out-of-range index %d", index);
+               log(DEBUG, "ConfVarEnum got an out-of-range index %d", pos);
        }
        
        return 0;
@@ -1393,7 +1399,7 @@ int ServerConfig::ConfVarEnum(ConfigDataHash &target, const std::string &tag, in
  */ 
 bool BindSocket(int sockfd, struct sockaddr_in client, struct sockaddr_in server, int port, char* addr)
 {
-       memset((char *)&server,0,sizeof(server));
+       memset(&server,0,sizeof(server));
        struct in_addr addy;
        bool resolved = false;
        char resolved_addr[128];
@@ -1465,11 +1471,11 @@ int OpenTCPSocket()
        }
        else
        {
-               setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (const char*)&on, sizeof(on));
+               setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
                /* This is BSD compatible, setting l_onoff to 0 is *NOT* http://web.irc.org/mla/ircd-dev/msg02259.html */
                linger.l_onoff = 1;
                linger.l_linger = 1;
-               setsockopt(sockfd, SOL_SOCKET, SO_LINGER, (const char*)&linger,sizeof(linger));
+               setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &linger,sizeof(linger));
                return (sockfd);
        }
 }