summaryrefslogtreecommitdiff
path: root/src/modules.cpp
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-02-02 16:47:25 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-02-02 16:47:25 +0000
commitf2256deeefe9a9f57f6f6b902604c01138ad16cc (patch)
tree2180cffd6bec0487e3d8b5a7d5894b258782e39c /src/modules.cpp
parentf288993a85681c09e3d92d8c3ab9742826923e99 (diff)
Executable include for MOTD and more
This introduces an <execfiles> tag that reads files from the output of a command, in the same way as executable includes. The files specified here can also be used anywhere a file is used (opermotd, randquote, etc) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12354 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules.cpp')
-rw-r--r--src/modules.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/modules.cpp b/src/modules.cpp
index 558923332..d4ba9145a 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -686,13 +686,26 @@ void FileReader::CalcSize()
void FileReader::LoadFile(const std::string &filename)
{
- file_cache c;
- c.clear();
- if (ServerInstance->Config->ReadFile(c,filename.c_str()))
+ std::map<std::string, file_cache>::iterator file = ServerInstance->Config->Files.find(filename);
+ if (file != ServerInstance->Config->Files.end())
{
- this->fc = c;
- this->CalcSize();
+ this->fc = file->second;
}
+ else
+ {
+ FILE* f = fopen(filename.c_str(), "r");
+ if (!f)
+ return;
+ char linebuf[MAXBUF*10];
+ while (fgets(linebuf, sizeof(linebuf), f))
+ {
+ int len = strlen(linebuf);
+ if (len)
+ fc.push_back(std::string(linebuf, len - 1));
+ }
+ fclose(f);
+ }
+ CalcSize();
}