Depending on which of its arguments where NULL, that macro called network / user
modules or not. While this is nice in that it avoids crashes, this behavior
actually surprised me and I'd rather have the caller explicitly say what it
wanted to do.
This macro is replaced with explicit calls to {GLOBAL,USER,NETWORKMODULECALL}.
Since there are actually module calls which do provide a CClient*, but may
happen before login (OnUnknownUserRaw() and the 3 CAP hooks), those are changed
to get the client pointer as their first argument. This should make it more
obvious that these module calls are special.
This commit should make it easier to catch bugs like the recent
OnClientDisconnected() with m_pUser == NULL.
Signed-off-by: Uli Schlachter <psychon@znc.in>
For every available module call implementation, we got this:
Modules.cpp: In member function ‘bool CModules::OnGetAvailableMods(std::__debug::set<CModInfo>&, CModInfo::EModuleType)’:
Modules.cpp:149:72: error: ‘pNetwork’ may be used uninitialized in this function [-Werror=uninitialized]
Modules.cpp:808:260: note: ‘pNetwork’ was declared here
Modules.cpp:148:54: error: ‘pOldUser’ may be used uninitialized in this function [-Werror=uninitialized]
Modules.cpp:808:168: note: ‘pOldUser’ was declared here
I guess GCC saw that m_pNetwork and m_pUser could be changed by the module call
to a non-NULL value which means we would really use an uninitialized value...
Signed-off-by: Uli Schlachter <psychon@znc.in>
No module in extra/ comes with any data currently, so this was tested by moving
perform to extra/. The install is untested.
Signed-off-by: Uli Schlachter <psychon@znc.in>
This moves the version check into the function which loads the module info. That
way, we just need a single dlsym() call per module and thus can't get any errors
from the second dlsym() call. And IMHO this feels nicer anyway. ;-)
Signed-off-by: Uli Schlachter <psychon@znc.in>
Now there're only 2 functions which modules export:
ZNCModVersion() and ZNCModInfo().
ZNCModInfo() returns CModInfo instance, which contains
description, globality, function for loading the module. It needs to be
deleted afterwise.
Some modules (e.g. webadmin) don't handle messages to *module in any way. Make
it clear to the user why they didn't get any reply back in this case.
Signed-off-by: Uli Schlachter <psychon@znc.in>
This causes every piece of code which wants to use CFile or CDir to have to
include FileUtils.h. This causes quite some noise.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Both these headers only really need CFile* which can be handled with a forward
declaration.
To make this possible, some methods are moved from the header file into the
corresponding implementation file, because they used CFile or CDir static
members.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Instead of doing ugly stuff to shorten the "Loaded Module [foo]" message, we now
just always generate the shorter version of that message. The code paths which
didn't do this shortening now prepend that message themselves.
The result is that every message looks the same as it did before, but the code
for generating these is a little nicer.
Signed-off-by: Uli Schlachter <psychon@znc.in>
This removes the following module hooks:
OnConfigLine()
OnWriteConfig()
OnWriteUserConfig()
OnWriteChanConfig()
Modules could use these hooks for writing/reading their own stuff to/from
znc.conf. However, no module (ever?) did this and IMHO no module should ever do
this either. Modules can save stuff via SetNV(), module arguments (SetArgs())
and in their GetSavePath().
Signed-off-by: Uli Schlachter <psychon@znc.in>
This module hook is called to generate messages for unknown commands. This hook
has a default implementation that actually does something!
Signed-off-by: Uli Schlachter <psychon@znc.in>
With this, modules can use AddCommand() to register commands. CModule will
dispatch all calls to OnModCommand() to the correct command handler.
If a module calls AddHelpCommand(), it will also generate help output.
Signed-off-by: Uli Schlachter <psychon@znc.in>
There are only some "minor" functions that are still undocumented now.
This also sneaks in an API change: A useless file mode argument to
MCString::ReadFromDisk() is gone. Opening a file doesn't ask for a file mode.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2157 726aef4b-f618-498e-8847-2d620e286838
The new hooks OnServerCapAccepted() and OnServerCapRejected() are replaced by
OnServerCapResult(). This should force people who want to use this to handle
possible failures in requesting the capability.
Again, thanks to DarthGandalf for the patch.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2100 726aef4b-f618-498e-8847-2d620e286838
This introduces the code for modules to request CAPs on the IRC server. They
will get a callback when the capability was accepted or rejected.
Thanks to DarthGandalf for this patch. This should turn DarthGandalf and tomaw
into happy znc users again. ;)
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2099 726aef4b-f618-498e-8847-2d620e286838
Thanks to vBm for running cppcheck against znc and sharing the results.
This should fix all the "foo can be const" messages.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2081 726aef4b-f618-498e-8847-2d620e286838
OnUnknownUserRaw() and OnClientCapRequest() were both getting a CClient* as
their first argument, but the proper way to pass a CClient* argument to a module
is via GetClient(). Since recently, all the places where this module hooks are
called do this properly, so we can remove this bogus argument.
No module that is part of znc is affected by this change.
Let's see how many external ones break. ;)
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2077 726aef4b-f618-498e-8847-2d620e286838
This commit should make sure that all module calls are done through either
MODULECALL, GLOBALMODULECALL or ALLMODULECALL. Also, in the process some module
calls where ("accidentally" ;) ) fixed to set correct values for a global
module's m_pUser during a module call.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2076 726aef4b-f618-498e-8847-2d620e286838
This commit adds new module calls which make it possibly to announce new
capabilities from a module.
Thanks to DarthGandalf for the patch and for not going mad from my comments. :)
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2071 726aef4b-f618-498e-8847-2d620e286838
Unless this flag is used, znc will no longer look for modules in ./modules/
because this might be exploitable by lucky attackers.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1927 726aef4b-f618-498e-8847-2d620e286838
This new class waits for the first line from the client and checks if it's an
HTTP request and then passes the connection on to the irc or http code.
Before this, the IRC parser handled this as a special case which wasn't as
nice-looking as this is. :)
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1925 726aef4b-f618-498e-8847-2d620e286838