summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-05-29 15:18:30 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-05-29 15:18:30 +0000
commitef70e0ac9cd103adcfc1b879c0a6c946fd53413b (patch)
tree0dade3d45305f11d034ebd9033bd4020939d1825
parent4cc7c2ba94faf1fe7443876a04ea6ad2203bcffe (diff)
added <include file> tags (next make paths relative)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1552 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/inspircd_io.cpp35
1 files changed, 30 insertions, 5 deletions
diff --git a/src/inspircd_io.cpp b/src/inspircd_io.cpp
index 754a25284..e28290ec5 100644
--- a/src/inspircd_io.cpp
+++ b/src/inspircd_io.cpp
@@ -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++;
}