]> jfr.im git - solanum.git/blobdiff - extensions/example_module.c
Merge pull request #161 from awilfox/av2desc
[solanum.git] / extensions / example_module.c
index 86623296da868df650e231ff4387902061dbc33c..63b9f7b9b17d6807124c932be97fcca99c4089dd 100644 (file)
@@ -15,8 +15,6 @@
  *   You should have received a copy of the GNU General Public License
  *   along with this program; if not, write to the Free Software
  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *   $Id: example_module.c 3161 2007-01-25 07:23:01Z nenolod $
  */
 
 /* List of ircd includes from ../include/ */
  * parv     == an array of the parameters
  */
 
-static int munreg_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
-static int mclient_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
-static int mserver_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
-static int mrclient_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
-static int moper_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
+static int munreg_test(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
+static int mclient_test(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
+static int mserver_test(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
+static int mrclient_test(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
+static int moper_test(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
 
 /* Show the commands this module can handle in a msgtab
  * and give the msgtab a name, here its test_msgtab
@@ -52,7 +50,7 @@ struct Message test_msgtab = {
   0,                    /* SET TO ZERO -- number of times command used by clients */
   0,                    /* SET TO ZERO -- number of times command used by clients */
   0,                    /* SET TO ZERO -- number of times command used by clients */
-  MFLG_SLOW,            /* ALWAYS SET TO MFLG_SLOW */
+  0,            /* ALWAYS SET TO 0 */
 
   /* the functions to call for each handler.  If not using the generic
    * handlers, the first param is the function to call, the second is the
@@ -94,7 +92,7 @@ mapi_clist_av1 test_clist[] = { &test_msgtab, NULL };
  * terminated with NULLs.
  */
 int doing_example_hook;
-mapi_hlist_av1 test_hlist[] = { 
+mapi_hlist_av1 test_hlist[] = {
        { "doing_example_hook", &doing_example_hook, },
        { NULL, NULL }
 };
@@ -111,6 +109,20 @@ mapi_hfn_list_av1 test_hfnlist[] = {
        { NULL, NULL }
 };
 
+/* The mapi_cap_list_av2 declares the capabilities this module adds.  This is
+ * for protocol usage. Here we declare both server and client capabilities.
+ * The first parameter is the cap type (server or client). The second is the
+ * name of the capability we wish to register. The third is the data attached
+ * to the cap (typically NULL). The last parameter is a pointer to an integer
+ * for the CAP index (recommended).
+ */
+unsigned int CAP_TESTCAP_SERVER, CAP_TESTCAP_CLIENT;
+mapi_cap_list_av2 test_cap_list[] = {
+       { MAPI_CAP_SERVER, "TESTCAP", NULL, &CAP_TESTCAP_SERVER },
+       { MAPI_CAP_CLIENT, "testcap", NULL, &CAP_TESTCAP_CLIENT },
+       { 0, NULL, NULL, NULL }
+};
+
 /* Here we tell it what to do when the module is loaded */
 static int
 modinit(void)
@@ -129,8 +141,8 @@ moddeinit(void)
        /* Again, nothing to do. */
 }
 
-/* DECLARE_MODULE_AV1() actually declare the MAPI header. */
-DECLARE_MODULE_AV1(
+/* DECLARE_MODULE_AV2() actually declare the MAPI header. */
+DECLARE_MODULE_AV2(
                          /* The first argument is the name */
                          example,
                          /* The second argument is the function to call on load */
@@ -143,8 +155,12 @@ DECLARE_MODULE_AV1(
                          test_hlist,
                          /* Then the hook function list, if we have one */
                          test_hfnlist,
-                         /* And finally the version number of this module. */
-                         "$Revision: 3161 $");
+                         /* Then the caps list, if we have one */
+                         test_cap_list,
+                         /* Then the version number of this module (NULL for bundled) */
+                         NULL,
+                         /* And finally, the description of this module */
+                         "This is an example module");
 
 /* Any of the above arguments can be NULL to indicate they aren't used. */
 
@@ -158,7 +174,7 @@ DECLARE_MODULE_AV1(
  * and the fairly normal C coding
  */
 static int
-munreg_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+munreg_test(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        if(parc < 2)
        {
@@ -180,7 +196,7 @@ munreg_test(struct Client *client_p, struct Client *source_p, int parc, const ch
  *      parv[1] = parameter
  */
 static int
-mclient_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+mclient_test(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        if(parc < 2)
        {
@@ -202,7 +218,7 @@ mclient_test(struct Client *client_p, struct Client *source_p, int parc, const c
  *      parv[1] = parameter
  */
 static int
-mrclient_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+mrclient_test(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        if(parc < 2)
        {
@@ -220,7 +236,7 @@ mrclient_test(struct Client *client_p, struct Client *source_p, int parc, const
  *      parv[1] = parameter
  */
 static int
-mserver_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+mserver_test(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        if(parc < 2)
        {
@@ -238,7 +254,7 @@ mserver_test(struct Client *client_p, struct Client *source_p, int parc, const c
  *      parv[1] = parameter
  */
 static int
-moper_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+moper_test(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        if(parc < 2)
        {