Module API: New function is_module_loaded("name"): return 1 / 0

This commit is contained in:
Bram Matthys 2017-11-20 09:43:43 +01:00
parent 92afdb56b5
commit d63bc7e187
No known key found for this signature in database
GPG key ID: BF8116B163EAAE98
2 changed files with 21 additions and 0 deletions
include
src

View file

@ -800,3 +800,4 @@ extern void send_cap_notify(int add, char *token);
extern void sendbufto_one(aClient *to, char *msg, unsigned int quick);
extern MODVAR int current_serial;
extern char *spki_fingerprint(aClient *acptr);
extern int is_module_loaded(char *name);

View file

@ -1715,3 +1715,23 @@ const char *our_dlerror(void)
return errbuf;
}
#endif
/** Check if a module is loaded.
* @param name Name of the module (eg: 'floodprot')
* @returns 1 if module is loaded, 0 if not.
* @notes The name is checked against the module name,
* this can be a problem if two modules have the same name.
*/
int is_module_loaded(char *name)
{
Module *mi;
for (mi = Modules; mi; mi = mi->next)
{
if (mi->flags & MODFLAG_DELAYED)
continue; /* unloading (delayed) */
if (!strcasecmp(mi->header->name, name))
return 1;
}
return 0;
}