]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - modules/m_resv.c
Forgot version.c.SH for libratbox/.
[irc/rqf/shadowircd.git] / modules / m_resv.c
index 1659373645f59b26bad3587b5b7d803a91b62d89..92e57309c3b3389347cb07d59f06b9bb45bca222 100644 (file)
@@ -36,8 +36,7 @@
 #include "s_conf.h"
 #include "s_newconf.h"
 #include "hash.h"
-#include "s_log.h"
-#include "sprintf_irc.h"
+#include "logger.h"
 
 static int mo_resv(struct Client *, struct Client *, int, const char **);
 static int ms_resv(struct Client *, struct Client *, int, const char **);
@@ -84,6 +83,13 @@ mo_resv(struct Client *client_p, struct Client *source_p, int parc, const char *
        int temp_time;
        int loc = 1;
 
+       if(!IsOperResv(source_p))
+       {
+               sendto_one(source_p, form_str(ERR_NOPRIVS),
+                          me.name, source_p->name, "resv");
+               return 0;
+       }
+
        /* RESV [time] <name> [ON <server>] :<reason> */
 
        if((temp_time = valid_temp_time(parv[loc])) >= 0)
@@ -125,7 +131,7 @@ mo_resv(struct Client *client_p, struct Client *source_p, int parc, const char *
                if(match(target_server, me.name) == 0)
                        return 0;
        }
-       else if(dlink_list_length(&cluster_conf_list) > 0)
+       else if(rb_dlink_list_length(&cluster_conf_list) > 0)
                cluster_resv(source_p, temp_time, name, reason);
 
        parse_resv(source_p, name, reason, temp_time);
@@ -217,13 +223,13 @@ parse_resv(struct Client *source_p, const char *name,
                aconf = make_conf();
                aconf->status = CONF_RESV_CHANNEL;
                aconf->port = 0;
-               DupString(aconf->name, name);
-               DupString(aconf->passwd, reason);
+               aconf->name = rb_strdup(name);
+               aconf->passwd = rb_strdup(reason);
                add_to_resv_hash(aconf->name, aconf);
 
                if(temp_time > 0)
                {
-                       aconf->hold = CurrentTime + temp_time;
+                       aconf->hold = rb_current_time() + temp_time;
 
                        sendto_realops_snomask(SNO_GENERAL, L_ALL,
                                     "%s added temporary %d min. RESV for [%s] [%s]",
@@ -275,13 +281,13 @@ parse_resv(struct Client *source_p, const char *name,
                aconf = make_conf();
                aconf->status = CONF_RESV_NICK;
                aconf->port = 0;
-               DupString(aconf->name, name);
-               DupString(aconf->passwd, reason);
-               dlinkAddAlloc(aconf, &resv_conf_list);
+               aconf->name = rb_strdup(name);
+               aconf->passwd = rb_strdup(reason);
+               rb_dlinkAddAlloc(aconf, &resv_conf_list);
 
                if(temp_time > 0)
                {
-                       aconf->hold = CurrentTime + temp_time;
+                       aconf->hold = rb_current_time() + temp_time;
 
                        sendto_realops_snomask(SNO_GENERAL, L_ALL,
                                     "%s added temporary %d min. RESV for [%s] [%s]",
@@ -330,9 +336,9 @@ cluster_resv(struct Client *source_p, int temp_time, const char *name,
                const char *reason)
 {
        struct remote_conf *shared_p;
-       dlink_node *ptr;
+       rb_dlink_node *ptr;
 
-       DLINK_FOREACH(ptr, cluster_conf_list.head)
+       RB_DLINK_FOREACH(ptr, cluster_conf_list.head)
        {
                shared_p = ptr->data;
 
@@ -370,6 +376,13 @@ cluster_resv(struct Client *source_p, int temp_time, const char *name,
 static int
 mo_unresv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
+       if(!IsOperResv(source_p))
+       {
+               sendto_one(source_p, form_str(ERR_NOPRIVS),
+                          me.name, source_p->name, "resv");
+               return 0;
+       }
+
        if((parc == 4) && (irccmp(parv[2], "ON") == 0))
        {
                if(!IsOperRemoteBan(source_p))
@@ -385,7 +398,7 @@ mo_unresv(struct Client *client_p, struct Client *source_p, int parc, const char
                if(match(parv[3], me.name) == 0)
                        return 0;
        }
-       else if(dlink_list_length(&cluster_conf_list) > 0)
+       else if(rb_dlink_list_length(&cluster_conf_list) > 0)
                cluster_generic(source_p, "UNRESV", SHARED_UNRESV, CAP_CLUSTER,
                                "%s", parv[1]);
 
@@ -470,9 +483,9 @@ remove_resv(struct Client *source_p, const char *name)
        }
        else
        {
-               dlink_node *ptr;
+               rb_dlink_node *ptr;
 
-               DLINK_FOREACH(ptr, resv_conf_list.head)
+               RB_DLINK_FOREACH(ptr, resv_conf_list.head)
                {
                        aconf = ptr->data;
 
@@ -502,7 +515,7 @@ remove_resv(struct Client *source_p, const char *name)
                        ilog(L_KLINE, "UR %s %s", get_oper_name(source_p), name);
                }
                /* already have ptr from the loop above.. */
-               dlinkDestroy(ptr, &resv_conf_list);
+               rb_dlinkDestroy(ptr, &resv_conf_list);
        }
        free_conf(aconf);
 
@@ -530,7 +543,7 @@ remove_resv_from_file(struct Client *source_p, const char *name)
        int error_on_write = 0;
        int found_resv = 0;
 
-       ircsprintf(temppath, "%s.tmp", ConfigFileEntry.resvfile);
+       rb_sprintf(temppath, "%s.tmp", ConfigFileEntry.resvfile);
        filename = get_conf_name(RESV_TYPE);
 
        if((in = fopen(filename, "r")) == NULL)
@@ -563,7 +576,7 @@ remove_resv_from_file(struct Client *source_p, const char *name)
                        break;
                }
 
-               strlcpy(buff, buf, sizeof(buff));
+               rb_strlcpy(buff, buf, sizeof(buff));
 
                if((p = strchr(buff, '\n')) != NULL)
                        *p = '\0';