]> jfr.im git - solanum.git/blobdiff - modules/m_pong.c
Add ACCOUNTEXTBAN ISUPPORT token
[solanum.git] / modules / m_pong.c
index 7900f48bbbb73a936e57c6ce162a0592f6fcaaa8..a56ab7e522faa4e8b609d1ab7fdba0e8abbe99b7 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_pong.c 522 2006-01-15 20:55:27Z jilles $
  */
 
 #include "stdinc.h"
 #include "s_conf.h"
 #include "send.h"
 #include "channel.h"
-#include "irc_string.h"
+#include "match.h"
 #include "msg.h"
 #include "parse.h"
 #include "hash.h"
 #include "modules.h"
 
-static int mr_pong(struct Client *, struct Client *, int, const char **);
-static int ms_pong(struct Client *, struct Client *, int, const char **);
+static const char pong_desc[] = "Provides the PONG command to respond to a PING message";
+
+static void mr_pong(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+static void ms_pong(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
 
 struct Message pong_msgtab = {
-       "PONG", 0, 0, 0, MFLG_SLOW | MFLG_UNREG,
+       "PONG", 0, 0, 0, 0,
        {{mr_pong, 0}, mg_ignore, mg_ignore, {ms_pong, 2}, mg_ignore, mg_ignore}
 };
 
 mapi_clist_av1 pong_clist[] = { &pong_msgtab, NULL };
-DECLARE_MODULE_AV1(pong, NULL, NULL, pong_clist, NULL, NULL, "$Revision: 522 $");
 
-static int
-ms_pong(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+DECLARE_MODULE_AV2(pong, NULL, NULL, pong_clist, NULL, NULL, NULL, NULL, pong_desc);
+
+static void
+ms_pong(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        struct Client *target_p;
        const char *destination;
@@ -69,17 +70,16 @@ ms_pong(struct Client *client_p, struct Client *source_p, int parc, const char *
        if(!EmptyString(destination) && !match(destination, me.name) &&
           irccmp(destination, me.id))
        {
-               if((target_p = find_client(destination)) || 
-                  (target_p = find_server(NULL, destination)))
-                       sendto_one(target_p, ":%s PONG %s %s", 
-                                  get_id(source_p, target_p), parv[1], 
+               if((target_p = find_client(destination)))
+                       sendto_one(target_p, ":%s PONG %s %s",
+                                  get_id(source_p, target_p), parv[1],
                                   get_id(target_p, target_p));
                else
                {
                        if(!IsDigit(*destination))
                                sendto_one_numeric(source_p, ERR_NOSUCHSERVER,
                                                   form_str(ERR_NOSUCHSERVER), destination);
-                       return 0;
+                       return;
                }
        }
 
@@ -87,50 +87,44 @@ ms_pong(struct Client *client_p, struct Client *source_p, int parc, const char *
        if(IsServer(source_p) && !HasSentEob(source_p))
        {
                if(MyConnect(source_p))
-                       sendto_realops_snomask(SNO_GENERAL, L_ALL,
+                       sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
                                             "End of burst (emulated) from %s (%d seconds)",
                                             source_p->name,
-                                            (signed int) (CurrentTime - source_p->localClient->firsttime));
+                                            (signed int) (rb_current_time() - source_p->localClient->firsttime));
                SetEob(source_p);
                eob_count++;
                call_hook(h_server_eob, source_p);
        }
-
-       return 0;
 }
 
-static int
-mr_pong(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+static void
+mr_pong(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        if(parc == 2 && !EmptyString(parv[1]))
        {
-               if(ConfigFileEntry.ping_cookie && source_p->user && source_p->name[0])
+               if(ConfigFileEntry.ping_cookie && source_p->flags & FLAGS_SENTUSER && source_p->name[0])
                {
-                       unsigned long incoming_ping = strtoul(parv[1], NULL, 16);
+                       uint32_t incoming_ping = strtoul(parv[1], NULL, 16);
                        if(incoming_ping)
                        {
                                if(source_p->localClient->random_ping == incoming_ping)
                                {
-                                       char buf[USERLEN + 1];
-                                       strlcpy(buf, source_p->username, sizeof(buf));
-                                       source_p->flags2 |= FLAGS2_PING_COOKIE;
-                                       register_local_user(client_p, source_p, buf);
+                                       source_p->flags |= FLAGS_PING_COOKIE;
+                                       register_local_user(client_p, source_p);
                                }
                                else
                                {
                                        sendto_one(source_p, form_str(ERR_WRONGPONG),
                                                   me.name, source_p->name,
                                                   source_p->localClient->random_ping);
-                                       return 0;
+                                       return;
                                }
                        }
                }
 
        }
        else
-               sendto_one(source_p, form_str(ERR_NOORIGIN), me.name, parv[0]);
+               sendto_one(source_p, form_str(ERR_NOORIGIN), me.name, source_p->name);
 
        source_p->flags &= ~FLAGS_PINGSENT;
-
-       return 0;
 }