]> jfr.im git - solanum.git/blobdiff - extensions/m_remove.c
modules: add origin field to V2
[solanum.git] / extensions / m_remove.c
index df6743b160cc3aee491ae87c8767ffd12cb8ef64..4d6e74d7c2344a8aca6bd6efa96ce6c03051190f 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: m_kick.c 3317 2007-03-28 23:17:06Z jilles $
  */
 
 #include "stdinc.h"
 unsigned int CAP_REMOVE;
 static char part_buf[REASONLEN + 1];
 
-static int m_remove(struct Client *, struct Client *, int, const char **);
+static int m_remove(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
 static void remove_quote_part(hook_data_privmsg_channel *);
 
 struct Message remove_msgtab = {
-       "REMOVE", 0, 0, 0, MFLG_SLOW,
+       "REMOVE", 0, 0, 0, 0,
        {mg_unreg, {m_remove, 3}, {m_remove, 3}, {m_remove, 3}, mg_ignore, {m_remove, 3}}
 };
 
@@ -57,25 +55,17 @@ mapi_hfn_list_av1 remove_hfnlist[] = {
        { "privmsg_channel", (hookfn) remove_quote_part },
        { NULL, NULL }
 };
+mapi_cap_list_av2 remove_cap_list[] = {
+       { MAPI_CAP_SERVER, "REMOVE", NULL, &CAP_REMOVE },
+       { 0, NULL, NULL, NULL }
+};
 
-static int
-modinit(void)
-{
-       CAP_REMOVE = capability_put(serv_capindex, "REMOVE");
-
-       return 0;
-}
-
-static void
-moddeinit(void)
-{
-       capability_orphan(serv_capindex, "REMOVE");
-}
+const char description[] = "Provides the REMOVE command, an alternative to KICK";
 
-DECLARE_MODULE_AV1(remove, modinit, moddeinit, remove_clist, NULL, remove_hfnlist, "$Revision: 3317 $");
+DECLARE_MODULE_AV2(remove, MAPI_ORIGIN_EXTENSION, NULL, NULL, remove_clist, NULL, remove_hfnlist, remove_cap_list, NULL, description);
 
 static int
-m_remove(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[])
 {
        struct membership *msptr;
        struct Client *who;
@@ -114,7 +104,7 @@ m_remove(struct Client *client_p, struct Client *source_p, int parc, const char
                        return 0;
                }
 
-               if(get_channel_access(source_p, msptr, MODE_ADD) < CHFL_CHANOP)
+               if(get_channel_access(source_p, chptr, msptr, MODE_ADD, NULL) < CHFL_CHANOP)
                {
                        if(MyConnect(source_p))
                        {
@@ -227,16 +217,12 @@ m_remove(struct Client *client_p, struct Client *source_p, int parc, const char
 static void
 remove_quote_part(hook_data_privmsg_channel *data)
 {
-       size_t ret;
        if (data->approved || EmptyString(data->text) || data->msgtype != MESSAGE_TYPE_PART)
                return;
 
-       rb_strlcpy(part_buf, "\"", sizeof(part_buf));
-       ret = rb_strlcat(part_buf, data->text, sizeof(part_buf));
-       if (ret >= sizeof(part_buf) - 1)
-               part_buf[REASONLEN - 1] = '"';
-       else
-               rb_strlcat(part_buf, "\"", sizeof(part_buf));
+       rb_strlcpy(part_buf, "\"", sizeof(part_buf) - 1);
+       rb_strlcat(part_buf, data->text, sizeof(part_buf) - 1);
+       rb_strlcat(part_buf, "\"", sizeof(part_buf));
 
        data->text = part_buf;
 }