]> jfr.im git - solanum.git/blobdiff - include/modules.h
modules: AV2: use unsigned int for capability IDs instead of signed int
[solanum.git] / include / modules.h
index d61061adc795eec045ccd920b10c899920a9457a..9de461418a10482cdcd69a658f40b91a45a91d37 100644 (file)
@@ -20,8 +20,6 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
- *
- *  $Id: modules.h 6 2005-09-10 01:02:21Z nenolod $
  */
 
 #ifndef INCLUDED_modules_h
 #include "setup.h"
 #include "parse.h"
 
-#define MAPI_RATBOX 1
+#define MAPI_CHARYBDIS 2
 
-#if defined(HAVE_SHL_LOAD)
-#include <dl.h>
-#endif
-#if !defined(STATIC_MODULES) && defined(HAVE_DLFCN_H)
-#include <dlfcn.h>
-#endif
+#include <ltdl.h>
 
 #include "msg.h"
 #include "hook.h"
@@ -46,20 +39,18 @@ struct module
 {
        char *name;
        const char *version;
-       void *address;
+       const char *description;
+       lt_dlhandle address;
        int core;
+       int origin;
        int mapi_version;
-       void * mapi_header; /* actually struct mapi_mheader_av<mapi_version>    */
-};
-
-struct module_path
-{
-       char path[MAXPATHLEN];
+       void *mapi_header; /* actually struct mapi_mheader_av<mapi_version> */
 };
 
 #define MAPI_MAGIC_HDR 0x4D410000
 
 #define MAPI_V1                (MAPI_MAGIC_HDR | 0x1)
+#define MAPI_V2                (MAPI_MAGIC_HDR | 0x2)
 
 #define MAPI_MAGIC(x)  ((x) & 0xffff0000)
 #define MAPI_VERSION(x)        ((x) & 0x0000ffff)
@@ -68,36 +59,61 @@ typedef struct Message* mapi_clist_av1;
 
 typedef struct
 {
-       const char *    hapi_name;
-       int *           hapi_id;
+       const char *hapi_name;
+       int *hapi_id;
 } mapi_hlist_av1;
 
 typedef struct
 {
-       const char *    hapi_name;
-       hookfn          fn;
+       const char *hapi_name;
+       hookfn fn;
 } mapi_hfn_list_av1;
 
+
+#define MAPI_CAP_CLIENT                1
+#define MAPI_CAP_SERVER                2
+
+typedef struct
+{
+       int cap_index;          /* Which cap index does this belong to? */
+       const char *cap_name;   /* Capability name */
+       void *cap_ownerdata;    /* Not used much but why not... */
+       unsigned int *cap_id;           /* May be set to non-NULL to store cap id */
+} mapi_cap_list_av2;
+
 struct mapi_mheader_av1
 {
-       int               mapi_version;                         /* Module API version           */
-       int             (*mapi_register)        (void);         /* Register function;
-                                                                  ret -1 = failure (unload)    */
-       void            (*mapi_unregister)      (void);         /* Unregister function.         */
-       mapi_clist_av1  * mapi_command_list;                    /* List of commands to add.     */
-       mapi_hlist_av1  * mapi_hook_list;                       /* List of hooks to add.        */
-       mapi_hfn_list_av1 *mapi_hfn_list;                       /* List of hook_add_hook's to do */
-       const char *      mapi_module_version;                  /* Module's version (freeform)  */
+       int mapi_version;                       /* Module API version */
+       int (*mapi_register)(void);             /* Register function; ret -1 = failure (unload) */
+       void (*mapi_unregister)(void);          /* Unregister function. */
+       mapi_clist_av1 *mapi_command_list;      /* List of commands to add. */
+       mapi_hlist_av1 *mapi_hook_list;         /* List of hooks to add. */
+       mapi_hfn_list_av1 *mapi_hfn_list;       /* List of hook_add_hook's to do */
+       const char *mapi_module_version;        /* Module's version (freeform) */
 };
 
-#ifndef STATIC_MODULES
-# define DECLARE_MODULE_AV1(name,reg,unreg,cl,hl,hfnlist, v) \
+#define MAPI_ORIGIN_UNKNOWN    0               /* Unknown provenance (AV1 etc.) */
+#define MAPI_ORIGIN_EXTENSION  1               /* Charybdis extension */
+#define MAPI_ORIGIN_CORE       2               /* Charybdis core module */
+
+struct mapi_mheader_av2
+{
+       int mapi_version;                       /* Module API version */
+       int (*mapi_register)(void);             /* Register function; ret -1 = failure (unload) */
+       void (*mapi_unregister)(void);          /* Unregister function. */
+       mapi_clist_av1 *mapi_command_list;      /* List of commands to add. */
+       mapi_hlist_av1 *mapi_hook_list;         /* List of hooks to add. */
+       mapi_hfn_list_av1 *mapi_hfn_list;       /* List of hook_add_hook's to do */
+       mapi_cap_list_av2 *mapi_cap_list;       /* List of CAPs to add */
+       const char *mapi_module_version;        /* Module's version (freeform), replaced with ircd version if NULL */
+       const char *mapi_module_description;    /* Module's description (freeform) */
+};
+
+#define DECLARE_MODULE_AV1(name, reg, unreg, cl, hl, hfnlist, v) \
        struct mapi_mheader_av1 _mheader = { MAPI_V1, reg, unreg, cl, hl, hfnlist, v}
-#else
-# define DECLARE_MODULE_AV1(name,reg,unreg,cl,hl,hfnlist, v) \
-       struct mapi_mheader_av1 name ## _mheader = { MAPI_V1, reg, unreg, cl, hl, hfnlist, v}
-void load_static_modules(void);
-#endif
+
+#define DECLARE_MODULE_AV2(name, reg, unreg, cl, hl, hfnlist, caplist, v, desc) \
+       struct mapi_mheader_av2 _mheader = { MAPI_V2, reg, unreg, cl, hl, hfnlist, caplist, v, desc}
 
 /* add a path */
 void mod_add_path(const char *path);
@@ -113,10 +129,9 @@ extern void load_all_modules(int warn);
 extern void load_core_modules(int);
 
 extern int unload_one_module(const char *, int);
-extern int load_one_module(const char *, int);
-extern int load_a_module(const char *, int, int);
+extern int load_one_module(const char *, int, int);
+extern int load_a_module(const char *, int, int, int);
 extern int findmodule_byname(const char *);
-extern char *irc_basename(const char *);
 extern void modules_init(void);
 
 #endif /* INCLUDED_modules_h */