]> jfr.im git - solanum.git/blobdiff - modules/m_chghost.c
extensions/umode_hide_idle_time: mask times for hidden sources (#373)
[solanum.git] / modules / m_chghost.c
index 72e19622288ab1d124498c81db2c6da132951ca2..e493278e71eab4786b0983873e5b13e276ae9761 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005 William Pitcock <nenolod -at- nenolod.net>
+ * Copyright (c) 2005 Ariadne Conill <ariadne -at- dereferenced.org>
  * and Jilles Tjoelker <jilles -at- stack.nl>
  * All rights reserved.
  *
@@ -13,8 +13,7 @@
 #include "send.h"
 #include "channel.h"
 #include "client.h"
-#include "common.h"
-#include "config.h"
+#include "defaults.h"
 #include "ircd.h"
 #include "numeric.h"
 #include "s_conf.h"
 #include "whowas.h"
 #include "monitor.h"
 
-static int me_realhost(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
-static int ms_chghost(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
-static int me_chghost(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
-static int mo_chghost(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+static const char chghost_desc[] = "Provides commands used to change and retrieve client hostnames";
+
+static void me_realhost(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+static void ms_chghost(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+static void me_chghost(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+static void mo_chghost(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
 
 struct Message realhost_msgtab = {
        "REALHOST", 0, 0, 0, 0,
@@ -45,40 +46,40 @@ struct Message chghost_msgtab = {
 
 mapi_clist_av1 chghost_clist[] = { &chghost_msgtab, &realhost_msgtab, NULL };
 
-DECLARE_MODULE_AV1(chghost, NULL, NULL, chghost_clist, NULL, NULL, "$Revision: 3424 $");
+DECLARE_MODULE_AV2(chghost, NULL, NULL, chghost_clist, NULL, NULL, NULL, NULL, chghost_desc);
 
 /* clean_host()
  *
  * input       - host to check
- * output      - 0 if erroneous, else 1
+ * output      - false if erroneous, else true
  * side effects -
  */
-static int
+static bool
 clean_host(const char *host)
 {
        int len = 0;
        const char *last_slash = 0;
 
        if (*host == '\0' || *host == ':')
-               return 0;
+               return false;
 
        for(; *host; host++)
        {
                len++;
 
                if(!IsHostChar(*host))
-                       return 0;
+                       return false;
                if(*host == '/')
                        last_slash = host;
        }
 
        if(len > HOSTLEN)
-               return 0;
+               return false;
 
        if(last_slash && IsDigit(last_slash[1]))
-               return 0;
+               return false;
 
-       return 1;
+       return true;
 }
 
 /*
@@ -90,12 +91,12 @@ clean_host(const char *host)
  * I don't think that's a big problem as the whole thing is a
  * race condition.
  */
-static int
+static void
 me_realhost(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p,
        int parc, const char *parv[])
 {
        if (!IsPerson(source_p))
-               return 0;
+               return;
 
        del_from_hostname_hash(source_p->orighost, source_p);
        rb_strlcpy(source_p->orighost, parv[1], sizeof source_p->orighost);
@@ -104,16 +105,15 @@ me_realhost(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sou
        else
                ClearDynSpoof(source_p);
        add_to_hostname_hash(source_p->orighost, source_p);
-       return 0;
 }
 
-static int
+static bool
 do_chghost(struct Client *source_p, struct Client *target_p,
                const char *newhost, int is_encap)
 {
        if (!clean_host(newhost))
        {
-               sendto_realops_snomask(SNO_GENERAL, is_encap ? L_ALL : L_NETWIDE, "%s attempted to change hostname for %s to %s (invalid)",
+               sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s attempted to change hostname for %s to %s (invalid)",
                                IsServer(source_p) ? source_p->name : get_oper_name(source_p),
                                target_p->name, newhost);
                /* sending this remotely may disclose important
@@ -121,7 +121,7 @@ do_chghost(struct Client *source_p, struct Client *target_p,
                if (is_encap ? MyClient(target_p) : !ConfigServerHide.flatten_links)
                        sendto_one_notice(target_p, ":*** Notice -- %s attempted to change your hostname to %s (invalid)",
                                        source_p->name, newhost);
-               return 0;
+               return false;
        }
        change_nick_user_host(target_p, target_p->name, target_p->username, newhost, 0, "Changing host");
        if (irccmp(target_p->host, target_p->orighost))
@@ -140,7 +140,7 @@ do_chghost(struct Client *source_p, struct Client *target_p,
                sendto_one_notice(source_p, ":Changed hostname for %s to %s", target_p->name, target_p->host);
        if (!IsServer(source_p) && !IsService(source_p))
                sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s changed hostname for %s to %s", get_oper_name(source_p), target_p->name, target_p->host);
-       return 1;
+       return true;
 }
 
 /*
@@ -148,14 +148,14 @@ do_chghost(struct Client *source_p, struct Client *target_p,
  * parv[1] = target
  * parv[2] = host
  */
-static int
+static void
 ms_chghost(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p,
        int parc, const char *parv[])
 {
        struct Client *target_p;
 
        if (!(target_p = find_person(parv[1])))
-               return -1;
+               return;
 
        if (do_chghost(source_p, target_p, parv[2], 0))
        {
@@ -167,7 +167,7 @@ ms_chghost(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sour
                        use_id(source_p), use_id(target_p), parv[2]);
        }
 
-       return 0;
+       return;
 }
 
 /*
@@ -175,18 +175,16 @@ ms_chghost(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sour
  * parv[1] = target
  * parv[2] = host
  */
-static int
+static void
 me_chghost(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p,
        int parc, const char *parv[])
 {
        struct Client *target_p;
 
        if (!(target_p = find_person(parv[1])))
-               return -1;
+               return;
 
        do_chghost(source_p, target_p, parv[2], 1);
-
-       return 0;
 }
 
 /*
@@ -197,7 +195,7 @@ me_chghost(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sour
 /* Disable this because of the abuse potential -- jilles
  * No, make it toggleable via ./configure. --nenolod
  */
-static int
+static void
 mo_chghost(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p,
        int parc, const char *parv[])
 {
@@ -208,20 +206,20 @@ mo_chghost(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sour
        {
                sendto_one(source_p, form_str(ERR_NOPRIVS),
                           me.name, source_p->name, "admin");
-               return 0;
+               return;
        }
 
        if (!(target_p = find_named_person(parv[1])))
        {
                sendto_one_numeric(source_p, ERR_NOSUCHNICK,
                                form_str(ERR_NOSUCHNICK), parv[1]);
-               return 0;
+               return;
        }
 
        if (!clean_host(parv[2]))
        {
                sendto_one_notice(source_p, ":Hostname %s is invalid", parv[2]);
-               return 0;
+               return;
        }
 
        do_chghost(source_p, target_p, parv[2], 0);
@@ -236,7 +234,5 @@ mo_chghost(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sour
        sendto_one_numeric(source_p, ERR_DISABLED, form_str(ERR_DISABLED),
                        "CHGHOST");
 #endif
-
-       return 0;
 }