]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
added <include file> tags (next make paths relative)
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 29 May 2005 15:18:30 +0000 (15:18 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 29 May 2005 15:18:30 +0000 (15:18 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1552 e03df62e-2008-0410-955e-edbf42e46eb7

src/inspircd_io.cpp

index 754a25284d4d472c570bae97021637cfd4fc91f8..e28290ec5c531b6074dd53feec8da2af57adade7 100644 (file)
@@ -311,13 +311,38 @@ bool LoadConf(const char* filename, std::stringstream *target, std::stringstream
                                {
                                        if ((buffer[0] != '#') && (buffer[0] != '\r')  && (buffer[0] != '\n'))
                                        {
-                                               bool error = false;
-                                               std::string data = ConfProcess(buffer,linenumber++,errorstream,error,filename);
-                                               if (error)
+                                               if (!strncmp(buffer,"<include file=\"",15))
                                                {
-                                                       return false;
+                                                       char* buf = buffer;
+                                                       // include file directive
+                                                       buf += 15;      // advance to filename
+                                                       for (int j = 0; j < strlen(buffer); j++)
+                                                       {
+                                                               if (buf[j] == '"')
+                                                               {
+                                                                       buf[j] = '\0';
+                                                                       break;
+                                                               }
+                                                       }
+                                                       log(DEFAULT,"Opening included file '%s'",buf);
+                                                       std::stringstream merge(stringstream::in | stringstream::out);
+                                                       // recursively call LoadConf and get the new data, use the same errorstream
+                                                       LoadConf(buf, &merge, errorstream);
+                                                       // append &merge to the end of the file
+                                                       std::string newstuff = merge.str();
+                                                       // append the new stuff to the end of the line
+                                                       *target << newstuff;
+                                               }
+                                               else
+                                               {
+                                                       bool error = false;
+                                                       std::string data = ConfProcess(buffer,linenumber++,errorstream,error,filename);
+                                                       if (error)
+                                                       {
+                                                               return false;
+                                                       }
+                                                       *target << data;
                                                }
-                                               *target << data;
                                        }
                                        else linenumber++;
                                }