]> jfr.im git - solanum.git/blobdiff - modules/m_resv.c
modules: Add AV2 descriptions to all m_r* modules
[solanum.git] / modules / m_resv.c
index af727478de988cd83a8b4f26ebe87d11459a544f..8f010bcf6cce51fbe89f325dd3a914339b1ed975 100644 (file)
@@ -19,8 +19,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$
  */
 
 #include "stdinc.h"
 #include "bandbi.h"
 #include "operhash.h"
 
-static int mo_resv(struct Client *, struct Client *, int, const char **);
-static int ms_resv(struct Client *, struct Client *, int, const char **);
-static int me_resv(struct Client *, struct Client *, int, const char **);
-static int mo_unresv(struct Client *, struct Client *, int, const char **);
-static int ms_unresv(struct Client *, struct Client *, int, const char **);
-static int me_unresv(struct Client *, struct Client *, int, const char **);
+static int mo_resv(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+static int ms_resv(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+static int me_resv(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+static int mo_unresv(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+static int ms_unresv(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+static int me_unresv(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+static const char resv_desc[] =
+       "Provides management of reserved nicknames and channels using (UN)RESV";
 
 struct Message resv_msgtab = {
-       "RESV", 0, 0, 0, MFLG_SLOW | MFLG_UNREG,
+       "RESV", 0, 0, 0, 0,
        {mg_ignore, mg_not_oper, {ms_resv, 4}, {ms_resv, 4}, {me_resv, 5}, {mo_resv, 3}}
 };
 
 struct Message unresv_msgtab = {
-       "UNRESV", 0, 0, 0, MFLG_SLOW | MFLG_UNREG,
+       "UNRESV", 0, 0, 0, 0,
        {mg_ignore, mg_not_oper, {ms_unresv, 3}, {ms_unresv, 3}, {me_unresv, 2}, {mo_unresv, 2}}
 };
 
 mapi_clist_av1 resv_clist[] = { &resv_msgtab, &unresv_msgtab, NULL };
 
-DECLARE_MODULE_AV1(resv, NULL, NULL, resv_clist, NULL, NULL, "$Revision$");
+DECLARE_MODULE_AV2(resv, NULL, NULL, resv_clist, NULL, NULL, NULL, NULL, resv_desc);
 
 static void parse_resv(struct Client *source_p, const char *name,
                       const char *reason, int temp_time, int propagated);
@@ -73,12 +73,11 @@ static void remove_resv(struct Client *source_p, const char *name, int propagate
 
 /*
  * mo_resv()
- *      parv[0] = sender prefix
  *      parv[1] = channel/nick to forbid
  *      parv[2] = reason
  */
 static int
-mo_resv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+mo_resv(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        const char *name;
        const char *reason;
@@ -151,13 +150,12 @@ mo_resv(struct Client *client_p, struct Client *source_p, int parc, const char *
 }
 
 /* ms_resv()
- *     parv[0] = sender prefix
  *     parv[1] = target server
  *     parv[2] = channel/nick to forbid
  *     parv[3] = reason
  */
 static int
-ms_resv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+ms_resv(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        /* parv[0]  parv[1]        parv[2]  parv[3]
         * oper     target server  resv     reason
@@ -175,7 +173,7 @@ ms_resv(struct Client *client_p, struct Client *source_p, int parc, const char *
 }
 
 static int
-me_resv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+me_resv(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        /* time name 0 :reason */
        if(!IsPerson(source_p))
@@ -219,12 +217,6 @@ parse_resv(struct Client *source_p, const char *name, const char *reason, int te
                        return;
                }
 
-               if(strchr(reason, '"'))
-               {
-                       sendto_one_notice(source_p, ":Invalid character '\"' in comment");
-                       return;
-               }
-
                aconf = make_conf();
                aconf->status = CONF_RESV_CHANNEL;
                aconf->port = 0;
@@ -293,12 +285,6 @@ parse_resv(struct Client *source_p, const char *name, const char *reason, int te
                        return;
                }
 
-               if(strchr(reason, '"'))
-               {
-                       sendto_one_notice(source_p, ":Invalid character '\"' in comment");
-                       return;
-               }
-
                if(!valid_wild_card_simple(name))
                {
                        sendto_one_notice(source_p,
@@ -373,6 +359,7 @@ parse_resv(struct Client *source_p, const char *name, const char *reason, int te
                }
 
                rb_dlinkAddAlloc(aconf, &resv_conf_list);
+               resv_nick_fnc(aconf->host, aconf->passwd, temp_time);
        }
        else
                sendto_one_notice(source_p, ":You have specified an invalid resv: [%s]", name);
@@ -433,11 +420,10 @@ cluster_resv(struct Client *source_p, int temp_time, const char *name, const cha
 
 /*
  * mo_unresv()
- *     parv[0] = sender prefix
  *     parv[1] = channel/nick to unforbid
  */
 static int
-mo_unresv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+mo_unresv(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        int propagated = 1;
 
@@ -474,12 +460,11 @@ mo_unresv(struct Client *client_p, struct Client *source_p, int parc, const char
 }
 
 /* ms_unresv()
- *     parv[0] = sender prefix
  *     parv[1] = target server
  *     parv[2] = resv to remove
  */
 static int
-ms_unresv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+ms_unresv(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        /* parv[0]  parv[1]        parv[2]
         * oper     target server  resv to remove
@@ -497,7 +482,7 @@ ms_unresv(struct Client *client_p, struct Client *source_p, int parc, const char
 }
 
 static int
-me_unresv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+me_unresv(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        /* name */
        if(!IsPerson(source_p))
@@ -524,13 +509,14 @@ remove_resv(struct Client *source_p, const char *name, int propagated)
 {
        struct ConfItem *aconf = NULL;
        rb_dlink_node *ptr;
+       time_t now;
 
        if(IsChannelName(name))
        {
                if((aconf = hash_find_resv(name)) == NULL)
                {
                        if(propagated && rb_dlink_list_length(&cluster_conf_list))
-                               cluster_generic(source_p, "UNXLINE", SHARED_UNXLINE, CAP_CLUSTER, "%s", name);
+                               cluster_generic(source_p, "UNRESV", SHARED_UNRESV, CAP_CLUSTER, "%s", name);
 
                        sendto_one_notice(source_p, ":No RESV for %s", name);
                        return;
@@ -551,8 +537,9 @@ remove_resv(struct Client *source_p, const char *name, int propagated)
                                               "%s has removed the global RESV for: [%s]",
                                               get_oper_name(source_p), name);
                        ilog(L_KLINE, "UR %s %s", get_oper_name(source_p), name);
-                       if(aconf->created < rb_current_time())
-                               aconf->created = rb_current_time();
+                       now = rb_current_time();
+                       if(aconf->created < now)
+                               aconf->created = now;
                        else
                                aconf->created++;
                        aconf->hold = aconf->created;
@@ -565,7 +552,7 @@ remove_resv(struct Client *source_p, const char *name, int propagated)
                                        (unsigned long)aconf->created,
                                        0,
                                        (int)(aconf->lifetime - aconf->created));
-                       deactivate_conf(aconf, ptr);
+                       deactivate_conf(aconf, ptr, now);
                        return;
                }
                else if(propagated && rb_dlink_list_length(&cluster_conf_list) > 0)
@@ -603,7 +590,7 @@ remove_resv(struct Client *source_p, const char *name, int propagated)
                if(aconf == NULL)
                {
                        if(propagated && rb_dlink_list_length(&cluster_conf_list))
-                               cluster_generic(source_p, "UNXLINE", SHARED_UNXLINE, CAP_CLUSTER, "%s", name);
+                               cluster_generic(source_p, "UNRESV", SHARED_UNRESV, CAP_CLUSTER, "%s", name);
 
                        sendto_one_notice(source_p, ":No RESV for %s", name);
                        return;
@@ -624,8 +611,9 @@ remove_resv(struct Client *source_p, const char *name, int propagated)
                                               "%s has removed the global RESV for: [%s]",
                                               get_oper_name(source_p), name);
                        ilog(L_KLINE, "UR %s %s", get_oper_name(source_p), name);
-                       if(aconf->created < rb_current_time())
-                               aconf->created = rb_current_time();
+                       now = rb_current_time();
+                       if(aconf->created < now)
+                               aconf->created = now;
                        else
                                aconf->created++;
                        aconf->hold = aconf->created;
@@ -638,7 +626,7 @@ remove_resv(struct Client *source_p, const char *name, int propagated)
                                        (unsigned long)aconf->created,
                                        0,
                                        (int)(aconf->lifetime - aconf->created));
-                       deactivate_conf(aconf, ptr);
+                       deactivate_conf(aconf, ptr, now);
                        return;
                }
                else if(propagated && rb_dlink_list_length(&cluster_conf_list) > 0)