modules: add origin field to V2
This commit is contained in:
parent
c168ef1864
commit
c63aeb44e9
3 changed files with 35 additions and 7 deletions
|
@ -62,7 +62,7 @@ mapi_cap_list_av2 remove_cap_list[] = {
|
||||||
|
|
||||||
const char description[] = "Provides the REMOVE command, an alternative to KICK";
|
const char description[] = "Provides the REMOVE command, an alternative to KICK";
|
||||||
|
|
||||||
DECLARE_MODULE_AV2(remove, NULL, NULL, remove_clist, NULL, remove_hfnlist, remove_cap_list, NULL, description);
|
DECLARE_MODULE_AV2(remove, MAPI_ORIGIN_EXTENSION, NULL, NULL, remove_clist, NULL, remove_hfnlist, remove_cap_list, NULL, description);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
m_remove(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
m_remove(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
||||||
|
|
|
@ -42,6 +42,7 @@ struct module
|
||||||
const char *description;
|
const char *description;
|
||||||
lt_dlhandle address;
|
lt_dlhandle address;
|
||||||
int core;
|
int core;
|
||||||
|
int origin;
|
||||||
int mapi_version;
|
int mapi_version;
|
||||||
void *mapi_header; /* actually struct mapi_mheader_av<mapi_version> */
|
void *mapi_header; /* actually struct mapi_mheader_av<mapi_version> */
|
||||||
};
|
};
|
||||||
|
@ -91,9 +92,15 @@ struct mapi_mheader_av1
|
||||||
const char *mapi_module_version; /* Module's version (freeform) */
|
const char *mapi_module_version; /* Module's version (freeform) */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define MAPI_ORIGIN_UNKNOWN 0 /* Unknown provenance (AV1 etc.) */
|
||||||
|
#define MAPI_ORIGIN_EXTERNAL 1 /* Came from outside charybdis */
|
||||||
|
#define MAPI_ORIGIN_EXTENSION 2 /* Charybdis bundled extension */
|
||||||
|
#define MAPI_ORIGIN_CORE 3 /* Charybdis core module */
|
||||||
|
|
||||||
struct mapi_mheader_av2
|
struct mapi_mheader_av2
|
||||||
{
|
{
|
||||||
int mapi_version; /* Module API version */
|
int mapi_version; /* Module API version */
|
||||||
|
int mapi_origin; /* Module provenance */
|
||||||
int (*mapi_register)(void); /* Register function; ret -1 = failure (unload) */
|
int (*mapi_register)(void); /* Register function; ret -1 = failure (unload) */
|
||||||
void (*mapi_unregister)(void); /* Unregister function. */
|
void (*mapi_unregister)(void); /* Unregister function. */
|
||||||
mapi_clist_av1 *mapi_command_list; /* List of commands to add. */
|
mapi_clist_av1 *mapi_command_list; /* List of commands to add. */
|
||||||
|
@ -107,8 +114,8 @@ struct mapi_mheader_av2
|
||||||
#define DECLARE_MODULE_AV1(name, reg, unreg, cl, hl, hfnlist, v) \
|
#define DECLARE_MODULE_AV1(name, reg, unreg, cl, hl, hfnlist, v) \
|
||||||
struct mapi_mheader_av1 _mheader = { MAPI_V1, reg, unreg, cl, hl, hfnlist, v}
|
struct mapi_mheader_av1 _mheader = { MAPI_V1, reg, unreg, cl, hl, hfnlist, v}
|
||||||
|
|
||||||
#define DECLARE_MODULE_AV2(name, reg, unreg, cl, hl, hfnlist, caplist, v, desc) \
|
#define DECLARE_MODULE_AV2(name, origin, reg, unreg, cl, hl, hfnlist, caplist, v, desc) \
|
||||||
struct mapi_mheader_av2 _mheader = { MAPI_V2, reg, unreg, cl, hl, hfnlist, caplist, v, desc}
|
struct mapi_mheader_av2 _mheader = { MAPI_V2, origin, reg, unreg, cl, hl, hfnlist, caplist, v, desc}
|
||||||
|
|
||||||
/* add a path */
|
/* add a path */
|
||||||
void mod_add_path(const char *path);
|
void mod_add_path(const char *path);
|
||||||
|
|
|
@ -791,6 +791,7 @@ load_a_module(const char *path, int warn, int core)
|
||||||
lt_dlhandle tmpptr;
|
lt_dlhandle tmpptr;
|
||||||
char *mod_basename;
|
char *mod_basename;
|
||||||
const char *ver, *description = NULL;
|
const char *ver, *description = NULL;
|
||||||
|
int origin = 0;
|
||||||
|
|
||||||
int *mapi_version;
|
int *mapi_version;
|
||||||
|
|
||||||
|
@ -910,6 +911,7 @@ load_a_module(const char *path, int warn, int core)
|
||||||
/* New in MAPI v2 - version replacement */
|
/* New in MAPI v2 - version replacement */
|
||||||
ver = mheader->mapi_module_version ? mheader->mapi_module_version : ircd_version;
|
ver = mheader->mapi_module_version ? mheader->mapi_module_version : ircd_version;
|
||||||
description = mheader->mapi_module_description;
|
description = mheader->mapi_module_description;
|
||||||
|
origin = mheader->mapi_origin;
|
||||||
|
|
||||||
if(mheader->mapi_cap_list)
|
if(mheader->mapi_cap_list)
|
||||||
{
|
{
|
||||||
|
@ -972,16 +974,35 @@ load_a_module(const char *path, int warn, int core)
|
||||||
modlist[num_mods]->name = rb_strdup(mod_basename);
|
modlist[num_mods]->name = rb_strdup(mod_basename);
|
||||||
modlist[num_mods]->mapi_header = mapi_version;
|
modlist[num_mods]->mapi_header = mapi_version;
|
||||||
modlist[num_mods]->mapi_version = MAPI_VERSION(*mapi_version);
|
modlist[num_mods]->mapi_version = MAPI_VERSION(*mapi_version);
|
||||||
|
modlist[num_mods]->origin = origin;
|
||||||
num_mods++;
|
num_mods++;
|
||||||
|
|
||||||
if(warn == 1)
|
if(warn == 1)
|
||||||
{
|
{
|
||||||
|
const char *o;
|
||||||
|
|
||||||
|
switch(origin)
|
||||||
|
{
|
||||||
|
case MAPI_ORIGIN_EXTERNAL:
|
||||||
|
o = "external";
|
||||||
|
break;
|
||||||
|
case MAPI_ORIGIN_EXTENSION:
|
||||||
|
o = "extension";
|
||||||
|
break;
|
||||||
|
case MAPI_ORIGIN_CORE:
|
||||||
|
o = "core";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
o = "unknown";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
sendto_realops_snomask(SNO_GENERAL, L_ALL,
|
sendto_realops_snomask(SNO_GENERAL, L_ALL,
|
||||||
"Module %s [version: %s; MAPI version: %d; description: \"%s\"] loaded at 0x%lx",
|
"Module %s [version: %s; MAPI version: %d; origin: %s; description: \"%s\"] loaded at 0x%lx",
|
||||||
mod_basename, ver, MAPI_VERSION(*mapi_version), description,
|
mod_basename, ver, MAPI_VERSION(*mapi_version), o, description,
|
||||||
(unsigned long) tmpptr);
|
(unsigned long) tmpptr);
|
||||||
ilog(L_MAIN, "Module %s [version: %s; MAPI version: %d; description: \"%s\"] loaded at 0x%lx",
|
ilog(L_MAIN, "Module %s [version: %s; MAPI version: %d; origin: %s; description: \"%s\"] loaded at 0x%lx",
|
||||||
mod_basename, ver, MAPI_VERSION(*mapi_version), description, (unsigned long) tmpptr);
|
mod_basename, ver, MAPI_VERSION(*mapi_version), o, description, (unsigned long) tmpptr);
|
||||||
}
|
}
|
||||||
rb_free(mod_basename);
|
rb_free(mod_basename);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue