]> jfr.im git - solanum.git/blobdiff - extensions/example_module.c
add help for `chm_regmsg`
[solanum.git] / extensions / example_module.c
index 87ba344bc12d69d30ecf101f055ed564887e9de9..d20fd42bbd4c9991436da34b32a4aadfd318978d 100644 (file)
 #include "ircd.h"
 #include "send.h"
 
+/* This string describes the module. Always declare it a static const char[].
+ * It is preferred for stylistic reasons to put it first.
+ *
+ * Make it short, sweet, and to the point.
+ */
+static const char example_desc[] = "This is an example Solanum module.";
+
 /* Declare the void's initially up here, as modules dont have an
  * include file, we will normally have client_p, source_p, parc
  * and parv[] where:
  * parv     == an array of the parameters
  */
 
-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[]);
+static void munreg_test(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
+static void mclient_test(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
+static void mserver_test(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
+static void mrclient_test(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
+static void 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
  */
 
 struct Message test_msgtab = {
-  "TEST",               /* the /COMMAND you want */
-  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 */
-  0,            /* ALWAYS SET TO 0 */
+       "TEST",         /* the /COMMAND you want */
+       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 */
+       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
-   * required number of parameters.  NOTE: If you specify a min para of 2,
-   * then parv[1] must *also* be non-empty.
-   */
-  {
-    {munreg_test, 0},   /* function call for unregistered clients, 0 parms required */
-    {mclient_test, 0},  /* function call for local clients, 0 parms required */
-    {mrclient_test, 0}, /* function call for remote clients, 0 parms required */
-    {mserver_test, 0},  /* function call for servers, 0 parms required */
-    mg_ignore,          /* function call for ENCAP, unused in this test */
-    {moper_test, 0}     /* function call for operators, 0 parms required */
-  }
+       /* 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
+        * required number of parameters.  NOTE: If you specify a min para of 2,
+        * then parv[1] must *also* be non-empty.
+        */
+       {
+               {munreg_test, 0},   /* function call for unregistered clients, 0 parms required */
+               {mclient_test, 0},  /* function call for local clients, 0 parms required */
+               {mrclient_test, 0}, /* function call for remote clients, 0 parms required */
+               {mserver_test, 0},  /* function call for servers, 0 parms required */
+               mg_ignore,          /* function call for ENCAP, unused in this test */
+               {moper_test, 0}     /* function call for operators, 0 parms required */
+       }
 };
 /*
  * There are also some macros for the above function calls and parameter counts.
@@ -105,10 +112,24 @@ mapi_hlist_av1 test_hlist[] = {
 static void show_example_hook(void *unused);
 
 mapi_hfn_list_av1 test_hfnlist[] = {
-       { "doing_example_hook", (hookfn) show_example_hook },
+       { "doing_example_hook", show_example_hook },
        { 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)
@@ -127,26 +148,29 @@ moddeinit(void)
        /* Again, nothing to do. */
 }
 
-/* DECLARE_MODULE_AV1() actually declare the MAPI header. */
-DECLARE_MODULE_AV1(
-                         /* The first argument is the name */
-                         example,
-                         /* The second argument is the function to call on load */
-                         modinit,
-                         /* And the function to call on unload */
-                         moddeinit,
-                         /* Then the MAPI command list */
-                         test_clist,
-                         /* Next the hook list, if we have one. */
-                         test_hlist,
-                         /* Then the hook function list, if we have one */
-                         test_hfnlist,
-                         /* And finally the version number of this module. */
-                         "$Revision: 3161 $");
+/* 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 */
+       modinit,
+       /* And the function to call on unload */
+       moddeinit,
+       /* Then the MAPI command list */
+       test_clist,
+       /* Next the hook list, if we have one. */
+       test_hlist,
+       /* Then the hook function list, if we have one */
+       test_hfnlist,
+       /* 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 */
+       example_desc);
 
 /* Any of the above arguments can be NULL to indicate they aren't used. */
 
-
 /*
  * mr_test
  *      parv[1] = parameter
@@ -155,7 +179,7 @@ DECLARE_MODULE_AV1(
 /* Here we have the functions themselves that we declared above,
  * and the fairly normal C coding
  */
-static int
+static void
 munreg_test(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        if(parc < 2)
@@ -169,15 +193,13 @@ munreg_test(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sou
 
        /* illustration of how to call a hook function */
        call_hook(doing_example_hook, NULL);
-
-       return 0;
 }
 
 /*
  * mclient_test
  *      parv[1] = parameter
  */
-static int
+static void
 mclient_test(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        if(parc < 2)
@@ -191,15 +213,13 @@ mclient_test(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *so
 
        /* illustration of how to call a hook function */
        call_hook(doing_example_hook, NULL);
-
-       return 0;
 }
 
 /*
  * mrclient_test
  *      parv[1] = parameter
  */
-static int
+static void
 mrclient_test(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        if(parc < 2)
@@ -210,14 +230,13 @@ mrclient_test(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *s
        {
                sendto_one_notice(source_p, ":You are a remote client, and sent parameters: %s", parv[1]);
        }
-       return 0;
 }
 
 /*
  * mserver_test
  *      parv[1] = parameter
  */
-static int
+static void
 mserver_test(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        if(parc < 2)
@@ -228,14 +247,13 @@ mserver_test(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *so
        {
                sendto_one_notice(source_p, ":You are a server, and sent parameters: %s", parv[1]);
        }
-       return 0;
 }
 
 /*
  * moper_test
  *      parv[1] = parameter
  */
-static int
+static void
 moper_test(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        if(parc < 2)
@@ -246,7 +264,6 @@ moper_test(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sour
        {
                sendto_one_notice(source_p, ":You are an operator, and sent parameters: %s", parv[1]);
        }
-       return 0;
 }
 
 static void