Author: Kev <klmitch@mit.edu>
authorKevin L. Mitchell <klmitch@mit.edu>
Wed, 26 Apr 2000 20:14:57 +0000 (20:14 +0000)
committerKevin L. Mitchell <klmitch@mit.edu>
Wed, 26 Apr 2000 20:14:57 +0000 (20:14 +0000)
Log message:

Lots more sendcmdto_* and send_reply changes; added RPL_EXPLICIT and dealt
with most of those numerics; added sendrawto_one for explicitly sending
without a prefix

git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@204 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

16 files changed:
ChangeLog
include/ircd_reply.h
include/send.h
ircd/ircd.c
ircd/ircd_reply.c
ircd/ircd_snprintf.c
ircd/list.c
ircd/m_pong.c
ircd/res.c
ircd/s_bsd.c
ircd/s_debug.c
ircd/s_err.c
ircd/s_misc.c
ircd/s_serv.c
ircd/s_user.c
ircd/send.c

index 439769e39e736d6b8e6990c4a71c2b981c15ae48..b304c0b842da1f4d25fdf5d14455ae1e60a94960 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,47 @@
+2000-04-26  Kevin L. Mitchell  <klmitch@mit.edu>
+
+       * ircd/s_serv.c (exit_new_server): rewrite exit_new_server to be a
+       little less brain-dead
+
+       * ircd/s_misc.c: use sendcmdto_one, sendrawto_one, and send_reply
+
+       * ircd/s_debug.c: use send_reply with RPL_EXPLICIT for
+       RPL_STATSDEBUG
+
+       * ircd/res.c (cres_mem): use send_reply with RPL_EXPLICIT for
+       RPL_STATSDEBUG
+
+       * ircd/list.c (send_listinfo): use send_reply with RPL_EXPLICIT
+       for RPL_STATSDEBUG
+
+       * ircd/m_pong.c: use RPL_EXPLICIT for ERR_BADPING
+
+       * ircd/ircd.c: use RPL_EXPLICIT for ERR_BADPING
+
+       * ircd/s_user.c (register_user): use RPL_EXPLICIT for
+       ERR_INVALIDUSERNAME
+
+       * ircd/ircd_reply.c (send_reply): support RPL_EXPLICIT
+
+       * include/ircd_reply.h (RPL_EXPLICIT): somewhat of a hack to mark
+       a numeric as needing to use an explicit pattern, which will be the
+       first argument in the variable argument list
+
+       * ircd/s_user.c: use sendrawto_one instead of sendto_one to send
+       non-prefixed nospoof PING
+
+       * ircd/s_bsd.c: use sendrawto_one instead of sendto_one to send
+       non-prefixed SERVER login
+
+       * ircd/ircd.c (check_pings): fix last sendto_one calls (except for
+       a numeric usage further up)
+
+       * include/send.h: declare sendrawto_one
+
+       * ircd/send.c (sendrawto_one): new function to use ONLY for
+       non-prefixed commands, like PING to client, or PASS/SERVER on
+       server registration
+
 2000-04-25  Kevin L. Mitchell  <klmitch@mit.edu>
 
        * ircd/ircd_snprintf.c (doprintf): implement %H for possible
 #
 # ChangeLog for ircu2.10.11
 #
-# $Id: ChangeLog,v 1.102 2000-04-25 20:33:50 kev Exp $
+# $Id: ChangeLog,v 1.103 2000-04-26 20:14:56 kev Exp $
 #
 # Insert new changes at beginning of the change list.
 #
index 3006d9c32a5f929a227c9ac2db7da779b911d385..c792bdb21caafcbee7ae3af7ba1c0478ebd0abde 100644 (file)
@@ -30,5 +30,7 @@ extern int send_error_to_client(struct Client* cptr, int error, ...);
 extern int send_reply(struct Client *to, int reply, ...);
 extern int send_admin_info(struct Client* sptr, const struct ConfItem* data);
 
+#define RPL_EXPLICIT   0x40000000      /* first arg is a pattern to use */
+
 #endif /* INCLUDED_ircd_reply_h */
 
index 1db1c381034671c1ce33b8f55c763d1e922709e0..19b8cf639b7bdccb19ebcd7699d5cf1b5b4ef2b1 100644 (file)
@@ -66,6 +66,11 @@ extern char sendbuf[2048];
 
 #define IRC_BUFSIZE    512
 
+/* Send a raw message to one client; USE ONLY IF YOU MUST SEND SOMETHING
+ * WITHOUT A PREFIX!
+ */
+extern void sendrawto_one(struct Client *to, const char *pattern, ...);
+
 /* Send a command to one client */
 extern void sendcmdto_one(struct Client *from, const char *cmd,
                          const char *tok, struct Client *to,
index a7793acdf92ae8b07302a87c34cb3b33eb63372f..ad95a75eb24131e3b733b7efd1ab85106feb00a6 100644 (file)
@@ -27,6 +27,7 @@
 #include "hash.h"
 #include "ircd_alloc.h" /* set_nomem_handler */
 #include "ircd_log.h"
+#include "ircd_reply.h"
 #include "ircd_signal.h"
 #include "ircd_string.h"
 #include "jupe.h"
@@ -339,14 +340,11 @@ static time_t check_pings(void)
        * nospoof PONG.
        */
       if (*cptr->name && cptr->user && *cptr->user->username) {
-       /* XXX sendto_one used to send numeric XXX */
-        sendto_one(cptr,
-            ":%s %d %s :Your client may not be compatible with this server.",
-            me.name, ERR_BADPING, cptr->name);
-        sendto_one(cptr,
-            ":%s %d %s :Compatible clients are available at "
-            "ftp://ftp.undernet.org/pub/irc/clients",
-            me.name, ERR_BADPING, cptr->name);
+       send_reply(cptr, RPL_EXPLICIT | ERR_BADPING,
+                  ":Your client may not be compatible with this server.");
+       send_reply(cptr, RPL_EXPLICIT | ERR_BADPING,
+                  ":Compatible clients are available at "
+                  "ftp://ftp.undernet.org/pub/irc/clients");
       }    
       exit_client_msg(cptr,cptr,&me, "Ping Timeout");
       continue;
@@ -364,11 +362,10 @@ static time_t check_pings(void)
        */
       cptr->lasttime = CurrentTime - max_ping;
       
-      /* XXX sendto_one sending PING; must be very careful XXX */
       if (IsUser(cptr))
-        sendto_one(cptr, MSG_PING " :%s", me.name);
+       sendrawto_one(cptr, MSG_PING " :%s", me.name);
       else
-        sendto_one(cptr, "%s " TOK_PING " :%s", NumServ(&me), me.name);
+       sendcmdto_one(&me, CMD_PING, cptr, ":%s", me.name);
     } /* of if not ping sent... */
     
     expire=cptr->lasttime+max_ping*2;
index 3e1981a8f6456df2afa459bfcda611565b815dde..a4aae188c4e64e90f94d747a68ee748170418912 100644 (file)
@@ -101,18 +101,21 @@ int send_reply(struct Client *to, int reply, ...)
   assert(0 != to);
   assert(0 != reply);
 
-  num = get_error_numeric(reply); /* get information about reply... */
+  num = get_error_numeric(reply & ~RPL_EXPLICIT); /* get reply... */
 
-  vd.vd_format = num->format; /* select format... */
-
-  /* build buffer */
   va_start(vd.vd_args, reply);
-  if (MyUser(to))
-    ircd_snprintf(to, sndbuf, sizeof(sndbuf) - 2, ":%s %s %C %v", me.name,
-                 num->str, to, &vd);
+
+  if (reply & RPL_EXPLICIT) /* get right pattern */
+    vd.vd_format = (const char *) va_arg(vd.vd_args, char *);
   else
-    ircd_snprintf(to, sndbuf, sizeof(sndbuf) - 2, "%C %s %C %v", &me, num->str,
-                 to, &vd);
+    vd.vd_format = num->format;
+
+  assert(0 != vd.vd_format);
+
+  /* build buffer */
+  ircd_snprintf(to, sndbuf, sizeof(sndbuf) - 2, "%:#C %s %C %v", &me, num->str,
+               to, &vd);
+
   va_end(vd.vd_args);
 
   /* send it to the user */
index 01579a6b9d4ecbc08deb65248c5f81e0abf5afd4..991de2a27e8c5eb6a6ea5d5b8896f30ef266fcda 100644 (file)
@@ -19,6 +19,7 @@
  * $Id$
  */
 #include "client.h"
+#include "channel.h"
 #include "ircd_snprintf.h"
 #include "struct.h"
 
index f1089bb3a459a35f9cc2ad9c5aed092914b4e1d4..0eff954a852322ca6b5957fdd8dd3ac252266482 100644 (file)
@@ -25,6 +25,7 @@
 #include "client.h"
 #include "ircd.h"
 #include "ircd_alloc.h"
+#include "ircd_reply.h"
 #include "ircd_string.h"
 #include "listener.h"
 #include "match.h"
@@ -310,47 +311,39 @@ void free_class(struct ConfClass * tmp)
 }
 
 #ifdef  DEBUGMODE
-/* XXX uses sendto_one to send a RPL_STATSDEBUG -- no string for rpl */
 void send_listinfo(struct Client *cptr, char *name)
 {
   int inuse = 0, mem = 0, tmp = 0;
 
-  sendto_one(cptr, ":%s %d %s :Local: inuse: %d(%d)",
-      me.name, RPL_STATSDEBUG, name, inuse += cloc.inuse,
-      tmp = cloc.inuse * CLIENT_LOCAL_SIZE);
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":Local: inuse: %d(%d)",
+            inuse += cloc.inuse, tmp = cloc.inuse * CLIENT_LOCAL_SIZE);
   mem += tmp;
-  sendto_one(cptr, ":%s %d %s :Remote: inuse: %d(%d)",
-      me.name, RPL_STATSDEBUG, name,
-      crem.inuse, tmp = crem.inuse * CLIENT_REMOTE_SIZE);
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":Remote: inuse: %d(%d)",
+            crem.inuse, tmp = crem.inuse * CLIENT_REMOTE_SIZE);
   mem += tmp;
   inuse += crem.inuse;
-  sendto_one(cptr, ":%s %d %s :Users: inuse: %d(%d)",
-      me.name, RPL_STATSDEBUG, name, users.inuse,
-      tmp = users.inuse * sizeof(struct User));
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":Users: inuse: %d(%d)",
+            users.inuse, tmp = users.inuse * sizeof(struct User));
   mem += tmp;
-  inuse += users.inuse,
-      sendto_one(cptr, ":%s %d %s :Servs: inuse: %d(%d)",
-      me.name, RPL_STATSDEBUG, name, servs.inuse,
-      tmp = servs.inuse * sizeof(struct Server));
+  inuse += users.inuse;
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":Servs: inuse: %d(%d)",
+            servs.inuse, tmp = servs.inuse * sizeof(struct Server));
   mem += tmp;
-  inuse += servs.inuse,
-      sendto_one(cptr, ":%s %d %s :Links: inuse: %d(%d)",
-      me.name, RPL_STATSDEBUG, name, links.inuse,
-      tmp = links.inuse * sizeof(struct SLink));
+  inuse += servs.inuse;
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":Links: inuse: %d(%d)",
+            links.inuse, tmp = links.inuse * sizeof(struct SLink));
   mem += tmp;
-  inuse += links.inuse,
-      sendto_one(cptr, ":%s %d %s :Classes: inuse: %d(%d)",
-      me.name, RPL_STATSDEBUG, name, classs.inuse,
-      tmp = classs.inuse * sizeof(struct ConfClass));
+  inuse += links.inuse;
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":Classes: inuse: %d(%d)",
+            classs.inuse, tmp = classs.inuse * sizeof(struct ConfClass));
   mem += tmp;
-  inuse += classs.inuse,
-      sendto_one(cptr, ":%s %d %s :Confs: inuse: %d(%d)",
-      me.name, RPL_STATSDEBUG, name, GlobalConfCount,
-      tmp = GlobalConfCount * sizeof(struct ConfItem));
+  inuse += classs.inuse;
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":Confs: inuse: %d(%d)",
+            GlobalConfCount, tmp = GlobalConfCount * sizeof(struct ConfItem));
   mem += tmp;
-  inuse += GlobalConfCount,
-      sendto_one(cptr, ":%s %d %s :Totals: inuse %d %d",
-      me.name, RPL_STATSDEBUG, name, inuse, mem);
+  inuse += GlobalConfCount;
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":Totals: inuse %d %d",
+            inuse, mem);
 }
 
 #endif
index fb918c999b88c78214d103c7961727659def385d..40f9b18569b082bcebb53dbc0069c63163ffc908 100644 (file)
@@ -90,6 +90,7 @@
 #include "client.h"
 #include "hash.h"
 #include "ircd.h"
+#include "ircd_reply.h"
 #include "ircd_string.h"
 #include "msg.h"
 #include "numeric.h"
@@ -134,10 +135,7 @@ int ms_pong(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   if (!EmptyString(destination) && 0 != ircd_strcmp(destination, me.name)) {
     struct Client* acptr;
     if ((acptr = FindClient(destination))) {
-      if (MyUser(acptr))
-        sendto_one(acptr, ":%s PONG %s %s", sptr->name, origin, destination);
-      else
-        sendto_one(acptr, "%s " TOK_PONG " %s %s", NumServ(sptr), origin, destination);
+      sendcmdto_one(sptr, CMD_PONG, acptr, "%s %s", origin, destination);
     }
   }
   return 0;
@@ -172,9 +170,8 @@ int mr_pong(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
         return register_user(cptr, sptr, sptr->name, sptr->user->username);
     }
     else  
-      sendto_one(sptr, ":%s %d %s :To connect, type /QUOTE PONG %u",
-                 me.name, ERR_BADPING, (sptr->name) ? sptr->name : "*",
-                 sptr->cookie);
+      send_reply(sptr, RPL_EXPLICIT | ERR_BADPING,
+                ":To connect, type /QUOTE PONG %u", sptr->cookie);
   }
   return 0;
 }
index 8f60bc4cde9e70b0ce5b9892f0066c06f0830e9e..c708c3f40e89b8aa6aedee91f2f9a6314c126fb8 100644 (file)
@@ -16,6 +16,7 @@
 #include "ircd_alloc.h"
 #include "ircd_log.h"
 #include "ircd_osdep.h"
+#include "ircd_reply.h"
 #include "ircd_string.h"
 #include "msg.h"
 #include "numeric.h"
@@ -1723,16 +1724,16 @@ size_t cres_mem(struct Client* sptr)
       request_mem += MAXGETHOSTLEN + 1;
     ++request_count;
   }
-  /* XXX sendto_one used to send STATSDEBUG */
+
   if (cachedCount != cache_count) {
-    sendto_one(sptr, 
-               ":%s %d %s :Resolver: cache count mismatch: %d != %d",
-               me.name, RPL_STATSDEBUG, sptr->name, cachedCount, cache_count);
+    send_reply(sptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+              ":Resolver: cache count mismatch: %d != %d", cachedCount,
+              cache_count);
     assert(cachedCount == cache_count);
   }
-  sendto_one(sptr, ":%s %d %s :Resolver: cache %d(%d) requests %d(%d)",
-             me.name, RPL_STATSDEBUG, sptr->name, cache_count, cache_mem,
-             request_count, request_mem);
+  send_reply(sptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+            ":Resolver: cache %d(%d) requests %d(%d)", cache_count,
+            cache_mem, request_count, request_mem);
   return cache_mem + request_mem;
 }
 
index 4d9be9e639f699c85fe85583fd00a9060a01ef24..cb8bfdbd9e418a79e809c5d3e537dc993f3032c0 100644 (file)
@@ -406,9 +406,9 @@ static int completed_connection(struct Client* cptr)
     sendto_opmask_butone(0, SNO_OLDSNO, "Lost Server Line for %s", cptr->name);
     return 0;
   }
-  /* XXX sendto_one sending without a prefix; be careful! */
+
   if (!EmptyString(aconf->passwd))
-    sendto_one(cptr, "PASS :%s", aconf->passwd);
+    sendrawto_one(cptr, MSG_PASS " :%s", aconf->passwd);
 
 #if 0 
   /* dead code, already done in connect_server */
@@ -434,10 +434,10 @@ static int completed_connection(struct Client* cptr)
    */
   cptr->lasttime = CurrentTime;
   cptr->flags |= FLAGS_PINGSENT;
-  /* XXX sendto_one sending without a prefix; be careful! */
-  sendto_one(cptr, "SERVER %s 1 " TIME_T_FMT " " TIME_T_FMT " J%s %s%s :%s",
-             me.name, me.serv->timestamp, newts, MAJOR_PROTOCOL, 
-             NumServCap(&me), me.info);
+
+  sendrawto_one(cptr, MSG_SERVER " %s 1 %Tu %Tu J%s %s%s :%s",
+               me.name, me.serv->timestamp, newts, MAJOR_PROTOCOL, 
+               NumServCap(&me), me.info);
 
   return (IsDead(cptr)) ? 0 : 1;
 }
index 1c21ebce9cd0af2e9daadf877daa9215fbd573b2..bfa98281c4d99eb16eb2378554a72b30c36ea274 100644 (file)
@@ -27,6 +27,7 @@
 #include "hash.h"
 #include "ircd_alloc.h"
 #include "ircd_osdep.h"
+#include "ircd_reply.h"
 #include "ircd.h"
 #include "list.h"
 #include "numeric.h"
@@ -234,7 +235,7 @@ void debug(int level, const char *form, ...)
 static void debug_enumerator(struct Client* cptr, const char* msg)
 {
   assert(0 != cptr);
-  sendto_one(cptr, ":%s %d %s :%s", me.name, RPL_STATSDEBUG, cptr->name, msg);
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":%s", msg);
 }
 
 /*
@@ -248,8 +249,8 @@ void send_usage(struct Client *cptr, char *nick)
 {
   os_get_rusage(cptr, CurrentTime - me.since, debug_enumerator);
 
-  sendto_one(cptr, ":%s %d %s :DBUF alloc %d used %d",
-      me.name, RPL_STATSDEBUG, nick, DBufAllocCount, DBufUsedCount);
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":DBUF alloc %d used %d",
+            DBufAllocCount, DBufUsedCount);
 }
 #endif /* DEBUGMODE */
 
@@ -354,49 +355,46 @@ void count_memory(struct Client *cptr, char *nick)
   for (cltmp = classes; cltmp; cltmp = cltmp->next)
     cl++;
 
-  sendto_one(cptr, ":%s %d %s :Client Local %d(" SIZE_T_FMT
-      ") Remote %d(" SIZE_T_FMT ")",
-      me.name, RPL_STATSDEBUG, nick, lc, lcm, rc, rcm);
-  sendto_one(cptr, ":%s %d %s :Users %d(" SIZE_T_FMT
-      ") Invites %d(" SIZE_T_FMT ")",
-      me.name, RPL_STATSDEBUG, nick, us, us * sizeof(struct User), usi,
-      usi * sizeof(struct SLink));
-  sendto_one(cptr, 
-             ":%s %d %s :User channels %d(" SIZE_T_FMT ") Aways %d(" SIZE_T_FMT ")",
-             me.name, RPL_STATSDEBUG, nick, memberships,
-             memberships * sizeof(struct Membership), aw, awm);
-  sendto_one(cptr, ":%s %d %s :Attached confs %d(" SIZE_T_FMT ")",
-      me.name, RPL_STATSDEBUG, nick, lcc, lcc * sizeof(struct SLink));
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+            ":Client Local %d(%zu) Remote %d(%zu)", lc, lcm, rc, rcm);
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+            ":Users %d(%zu) Invites %d(%zu)", us, us * sizeof(struct User),
+            usi, usi * sizeof(struct SLink));
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+            ":User channels %d(%zu) Aways %d(%zu)", memberships,
+            memberships * sizeof(struct Membership), aw, awm);
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":Attached confs %d(%zu)",
+            lcc, lcc * sizeof(struct SLink));
 
   totcl = lcm + rcm + us * sizeof(struct User) + memberships * sizeof(struct Membership) + awm;
   totcl += lcc * sizeof(struct SLink) + usi * sizeof(struct SLink);
 
-  sendto_one(cptr, ":%s %d %s :Conflines %d(" SIZE_T_FMT ")",
-      me.name, RPL_STATSDEBUG, nick, co, com);
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":Conflines %d(%zu)", co,
+            com);
 
-  sendto_one(cptr, ":%s %d %s :Classes %d(" SIZE_T_FMT ")",
-      me.name, RPL_STATSDEBUG, nick, cl, cl * sizeof(struct ConfClass));
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":Classes %d(%zu)", cl,
+            cl * sizeof(struct ConfClass));
 
-  sendto_one(cptr, ":%s %d %s :Channels %d(" SIZE_T_FMT
-      ") Bans %d(" SIZE_T_FMT ")",
-      me.name, RPL_STATSDEBUG, nick, ch, chm, chb, chbm);
-  sendto_one(cptr, ":%s %d %s :Channel membrs %d(" SIZE_T_FMT ") invite %d(" SIZE_T_FMT ")",
-      me.name, RPL_STATSDEBUG, nick, memberships, memberships * sizeof(struct Membership),
-      chi, chi * sizeof(struct SLink));
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+            ":Channels %d(%zu) Bans %d(%zu)", ch, chm, chb, chbm);
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+            ":Channel membrs %d(%zu) invite %d(%zu)", memberships,
+            memberships * sizeof(struct Membership), chi,
+            chi * sizeof(struct SLink));
 
   totch = chm + chbm + chi * sizeof(struct SLink);
 
-  sendto_one(cptr, ":%s %d %s :Whowas users %d(" SIZE_T_FMT
-      ") away %d(" SIZE_T_FMT ")",
-      me.name, RPL_STATSDEBUG, nick, wwu, wwu * sizeof(struct User), wwa, wwam);
-  sendto_one(cptr, ":%s %d %s :Whowas array %d(" SIZE_T_FMT ")",
-      me.name, RPL_STATSDEBUG, nick, NICKNAMEHISTORYLENGTH, wwm);
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+            ":Whowas users %d(%zu) away %d(%zu)", wwu,
+            wwu * sizeof(struct User), wwa, wwam);
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":Whowas array %d(%zu)",
+            NICKNAMEHISTORYLENGTH, wwm);
 
   totww = wwu * sizeof(struct User) + wwam + wwm;
 
-  sendto_one(cptr, ":%s %d %s :Hash: client %d(" SIZE_T_FMT
-      "), chan is the same",
-      me.name, RPL_STATSDEBUG, nick, HASHSIZE, sizeof(void *) * HASHSIZE);
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+            ":Hash: client %d(%zu), chan is the same", HASHSIZE,
+            sizeof(void *) * HASHSIZE);
 
   /*
    * NOTE: this count will be accurate only for the exact instant that this
@@ -407,10 +405,9 @@ void count_memory(struct Client *cptr, char *nick)
    * are sent.
    */
   dbuf_count_memory(&dbufs_allocated, &dbufs_used);
-  sendto_one(cptr,
-      ":%s %d %s :DBufs allocated %d(" SIZE_T_FMT ") used %d(" SIZE_T_FMT ")",
-      me.name, RPL_STATSDEBUG, nick, DBufAllocCount, dbufs_allocated,
-      DBufUsedCount, dbufs_used);
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+            ":DBufs allocated %d(%zu) used %d(%zu)", DBufAllocCount,
+            dbufs_allocated, DBufUsedCount, dbufs_used);
 
   rm = cres_mem(cptr);
 
@@ -420,13 +417,12 @@ void count_memory(struct Client *cptr, char *nick)
   tot += sizeof(void *) * HASHSIZE * 3;
 
 #if !defined(NDEBUG)
-  sendto_one(cptr, ":%s %d %s :Allocations: " SIZE_T_FMT "(" SIZE_T_FMT ")",
-             me.name, RPL_STATSDEBUG, nick, fda_get_block_count(),
-             fda_get_byte_count());
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":Allocations: %zu(%zu)",
+            fda_get_block_count(), fda_get_byte_count());
 #endif
 
-  sendto_one(cptr, ":%s %d %s :Total: ww " SIZE_T_FMT " ch " SIZE_T_FMT
-      " cl " SIZE_T_FMT " co " SIZE_T_FMT " db " SIZE_T_FMT,
-      me.name, RPL_STATSDEBUG, nick, totww, totch, totcl, com, dbufs_allocated);
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+            ":Total: ww %zu ch %zu cl %zu co %zu db %zu", totww, totch,
+            totcl, com, dbufs_allocated);
 }
 
index 32fcee0e0b9f2e6f64763ceb58c8304115306cff..a57988b1ff9f003088be3a233e729ff652bb877a 100644 (file)
@@ -532,7 +532,7 @@ static Numeric replyTable[] = {
 /* 248 */
   { RPL_STATSULINE, "%c %s %s %s %d %d", "248" },
 /* 249 */
-  { 0 },
+  { RPL_STATSDEBUG, 0, "249" },
 /* 250 */
   { RPL_STATSCONN, ":Highest connection count: %d (%d clients)", "250" },
 /* 251 */
@@ -974,7 +974,7 @@ static Numeric replyTable[] = {
 /* 467 */
   { ERR_KEYSET, "%s :Channel key already set", "467" },
 /* 468 */
-  { ERR_INVALIDUSERNAME, "", "468" },
+  { ERR_INVALIDUSERNAME, 0, "468" },
 /* 469 */
   { 0 },
 /* 470 */
@@ -1064,7 +1064,7 @@ static Numeric replyTable[] = {
 /* 512 */
   { ERR_NOSUCHGLINE, "%s :No such gline", "512" },
 /* 513 */
-  { ERR_BADPING, "", "513" },
+  { ERR_BADPING, 0, "513" },
 /* 514 */
   { ERR_NOSUCHJUPE, "%s :No such jupe", "514" },
 /* 515 */
index c910a00db7a46f6fbf085932989bffe26ebf67f2..6564e0bcb7f9351d3f688706eae51f4c3fba73b9 100644 (file)
@@ -30,6 +30,7 @@
 #include "ircd.h"
 #include "ircd_alloc.h"
 #include "ircd_log.h"
+#include "ircd_reply.h"
 #include "ircd_string.h"
 #include "list.h"
 #include "match.h"
@@ -235,7 +236,7 @@ static void exit_one_client(struct Client* bcptr, const char* comment)
      * that the client can show the "**signoff" message).
      * (Note: The notice is to the local clients *only*)
      */
-    sendto_common_channels(bcptr, ":%s QUIT :%s", bcptr->name, comment);
+    sendcmdto_common_channels(bcptr, CMD_QUIT, ":%s", comment);
 
     remove_user_from_all_channels(bcptr);
 
@@ -269,7 +270,8 @@ static void exit_one_client(struct Client* bcptr, const char* comment)
   }
   else if (IsMe(bcptr))
   {
-    sendto_ops("ERROR: tried to exit me! : %s", comment);
+    sendto_opmask_butone(0, SNO_OLDSNO, "ERROR: tried to exit me! : %s",
+                        comment);
     return;                     /* ...must *never* exit self! */
   }
   else if (IsUnknown(bcptr) || IsConnecting(bcptr) || IsHandshake(bcptr))
@@ -390,19 +392,17 @@ int exit_client(struct Client *cptr,    /* Connection being handled by
 #ifdef ALLOW_SNO_CONNEXIT
 #ifdef SNO_CONNEXIT_IP
     if (IsUser(victim)) {
-      sprintf_irc(sendbuf,
-          ":%s NOTICE * :*** Notice -- Client exiting: %s (%s@%s) [%s] [%s]",
-          me.name, victim->name, victim->user->username, victim->user->host,
-          comment, ircd_ntoa((const char*) &victim->ip));
-      sendbufto_op_mask(SNO_CONNEXIT);
+      sendto_opmask_butone(0, SNO_CONNEXIT,
+                          "Client exiting: %s (%s@%s) [%s] [%s]",
+                          victim->name, victim->user->username,
+                          victim->user->host, comment,
+                          ircd_ntoa((const char *)&victim->ip));
     }
 #else /* SNO_CONNEXIT_IP */
     if (IsUser(victim)) {
-      sprintf_irc(sendbuf,
-          ":%s NOTICE * :*** Notice -- Client exiting: %s (%s@%s) [%s]",
-          me.name, victim->name, victim->user->username, victim->user->host,
-          comment);
-      sendbufto_op_mask(SNO_CONNEXIT);
+      sendto_opmask_butone(0, SNO_CONNEXIT, "Client exiting: %s (%s@%s) [%s]",
+                          victim->name, victim->user->username,
+                          victim->user->host, comment);
     }
 #endif /* SNO_CONNEXIT_IP */
 #endif /* ALLOW_SNO_CONNEXIT */
@@ -428,11 +428,11 @@ int exit_client(struct Client *cptr,    /* Connection being handled by
         && IsClient(victim))    /* Not a Ping struct or Log file */
     {
       if (IsServer(victim) || IsHandshake(victim))
-        sendto_one(victim, ":%s " TOK_SQUIT " %s 0 :%s", killer->name, me.name, comment);
+       sendcmdto_one(killer, CMD_SQUIT, victim, "%C 0 :%s", &me, comment);
       else if (!IsConnecting(victim)) {
         if (!IsDead(victim))
-          sendto_one(victim, "ERROR :Closing Link: %s by %s (%s)",
-                     victim->name, killer->name, comment);
+         sendrawto_one(victim, MSG_ERROR " :Closing Link: %s by %s (%s)",
+                       victim->name, killer->name, comment);
       }
       if ((IsServer(victim) || IsHandshake(victim) || IsConnecting(victim)) &&
           (killer == &me || (IsServer(killer) &&
@@ -446,14 +446,9 @@ int exit_client(struct Client *cptr,    /* Connection being handled by
         if (victim->serv->user && *victim->serv->by &&
             (acptr = findNUser(victim->serv->by))) {
           if (acptr->user == victim->serv->user) {
-            if (MyUser(acptr) || Protocol(acptr->from) < 10)
-              sendto_one(acptr,
-                         ":%s NOTICE %s :Link with %s cancelled: %s",
-                         me.name, acptr->name, victim->name, comment);
-            else
-              sendto_one(acptr,
-                         "%s NOTICE %s%s :Link with %s cancelled: %s",
-                         NumServ(&me), NumNick(acptr), victim->name, comment);
+           sendcmdto_one(&me, CMD_NOTICE, acptr,
+                         "%C :Link with %s cancelled: %s", acptr,
+                         victim->name, comment);
           }
           else {
             /*
@@ -464,8 +459,8 @@ int exit_client(struct Client *cptr,    /* Connection being handled by
           }
         }
         if (killer == &me)
-          sendto_lops_butone(acptr, "Link with %s cancelled: %s",
-                             victim->name, comment);
+         sendto_opmask_butone(acptr, SNO_OLDSNO, "Link with %s cancelled: %s",
+                              victim->name, comment);
       }
     }
     /*
@@ -480,14 +475,18 @@ int exit_client(struct Client *cptr,    /* Connection being handled by
     strcat(comment1, " ");
     strcat(comment1, victim->name);
     if (IsUser(killer))
-      sendto_lops_butone(killer, "%s SQUIT by %s [%s]:",
-                         (killer->user->server == victim ||
-                         killer->user->server == victim->serv->up) ? "Local" : "Remote",
-                         get_client_name(killer, HIDE_IP), killer->user->server->name);
+      sendto_opmask_butone(killer, SNO_OLDSNO, "%s SQUIT by %s [%s]:",
+                          (killer->user->server == victim ||
+                           killer->user->server == victim->serv->up) ?
+                          "Local" : "Remote",
+                          get_client_name(killer, HIDE_IP),
+                          killer->user->server->name);
     else if (killer != &me && victim->serv->up != killer)
-      sendto_ops("Received SQUIT %s from %s :", victim->name,
-                 IsServer(killer) ? killer->name : get_client_name(killer, HIDE_IP));
-    sendto_op_mask(SNO_NETWORK, "Net break: %s (%s)", comment1, comment);
+      sendto_opmask_butone(0, SNO_OLDSNO, "Received SQUIT %s from %s :",
+                          victim->name, IsServer(killer) ? killer->name :
+                          get_client_name(killer, HIDE_IP));
+    sendto_opmask_butone(0, SNO_NETWORK, "Net break: %s (%s)", comment1,
+                        comment);
   }
 
   /*
@@ -497,10 +496,10 @@ int exit_client(struct Client *cptr,    /* Connection being handled by
   for (dlp = me.serv->down; dlp; dlp = dlp->next) {
     if (dlp->value.cptr != killer->from && dlp->value.cptr != victim) {
       if (IsServer(victim))
-        sendto_one(dlp->value.cptr, ":%s " TOK_SQUIT " %s " TIME_T_FMT " :%s",
-                   killer->name, victim->name, victim->serv->timestamp, comment);
+       sendcmdto_one(killer, CMD_SQUIT, dlp->value.cptr, "%C %Tu :%s",
+                     victim, victim->serv->timestamp, comment);
       else if (IsUser(victim) && 0 == (victim->flags & FLAGS_KILLED))
-        sendto_one(dlp->value.cptr, "%s%s " TOK_QUIT " :%s", NumNick(victim), comment);
+       sendcmdto_one(victim, CMD_QUIT, dlp->value.cptr, ":%s", comment);
     }
   }
   /* Then remove the client structures */
@@ -599,29 +598,27 @@ void tstats(struct Client *cptr, char *name)
       sp->is_ni++;
   }
 
-  sendto_one(cptr, ":%s %d %s :accepts %u refused %u",
-      me.name, RPL_STATSDEBUG, name, sp->is_ac, sp->is_ref);
-  sendto_one(cptr, ":%s %d %s :unknown commands %u prefixes %u",
-      me.name, RPL_STATSDEBUG, name, sp->is_unco, sp->is_unpf);
-  sendto_one(cptr, ":%s %d %s :nick collisions %u unknown closes %u",
-      me.name, RPL_STATSDEBUG, name, sp->is_kill, sp->is_ni);
-  sendto_one(cptr, ":%s %d %s :wrong direction %u empty %u",
-      me.name, RPL_STATSDEBUG, name, sp->is_wrdi, sp->is_empt);
-  sendto_one(cptr, ":%s %d %s :numerics seen %u mode fakes %u",
-      me.name, RPL_STATSDEBUG, name, sp->is_num, sp->is_fake);
-  sendto_one(cptr, ":%s %d %s :auth successes %u fails %u",
-      me.name, RPL_STATSDEBUG, name, sp->is_asuc, sp->is_abad);
-  sendto_one(cptr, ":%s %d %s :local connections %u",
-      me.name, RPL_STATSDEBUG, name, sp->is_loc);
-  sendto_one(cptr, ":%s %d %s :Client Server", me.name, RPL_STATSDEBUG, name);
-  sendto_one(cptr, ":%s %d %s :connected %u %u",
-      me.name, RPL_STATSDEBUG, name, sp->is_cl, sp->is_sv);
-  sendto_one(cptr, ":%s %d %s :bytes sent %u.%uK %u.%uK",
-      me.name, RPL_STATSDEBUG, name,
-      sp->is_cks, sp->is_cbs, sp->is_sks, sp->is_sbs);
-  sendto_one(cptr, ":%s %d %s :bytes recv %u.%uK %u.%uK",
-      me.name, RPL_STATSDEBUG, name,
-      sp->is_ckr, sp->is_cbr, sp->is_skr, sp->is_sbr);
-  sendto_one(cptr, ":%s %d %s :time connected " TIME_T_FMT " " TIME_T_FMT,
-      me.name, RPL_STATSDEBUG, name, sp->is_cti, sp->is_sti);
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":accepts %u refused %u",
+            sp->is_ac, sp->is_ref);
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+            ":unknown commands %u prefixes %u", sp->is_unco, sp->is_unpf);
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+            ":nick collisions %u unknown closes %u", sp->is_kill, sp->is_ni);
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+            ":wrong direction %u empty %u", sp->is_wrdi, sp->is_empt);
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+            ":numerics seen %u mode fakes %u", sp->is_num, sp->is_fake);
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG,
+            ":auth successes %u fails %u", sp->is_asuc, sp->is_abad);
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":local connections %u",
+            sp->is_loc);
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":Client server");
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":connected %u %u",
+            sp->is_cl, sp->is_sv);
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":bytes sent %u.%uK %u.%uK",
+            sp->is_cks, sp->is_cbs, sp->is_sks, sp->is_sbs);
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":bytes recv %u.%uK %u.%uK",
+            sp->is_ckr, sp->is_cbr, sp->is_skr, sp->is_sbr);
+  send_reply(cptr, RPL_EXPLICIT | RPL_STATSDEBUG, ":time connected %Tu %Tu",
+            sp->is_cti, sp->is_sti);
 }
index 93baf6a72a67de42f636cb5eeaf51adfbb3ca476..a343e5da73e304eed94ae0a94731e7d23a074745 100644 (file)
@@ -33,6 +33,7 @@
 #include "ircd_alloc.h"
 #include "ircd_reply.h"
 #include "ircd_string.h"
+#include "ircd_snprintf.h"
 #include "ircd_xopen.h"
 #include "jupe.h"
 #include "list.h"
@@ -59,7 +60,7 @@
 
 unsigned int max_connection_count = 0;
 unsigned int max_client_count = 0;
-
+#if 0
 int exit_new_server(struct Client* cptr, struct Client* sptr,
                     const char* host, time_t timestamp, const char* fmt, ...)
 {
@@ -77,6 +78,26 @@ int exit_new_server(struct Client* cptr, struct Client* sptr,
   MyFree(buf);
   return 0;
 }
+#endif /* 0 */
+
+int exit_new_server(struct Client *cptr, struct Client *sptr, const char *host,
+                   time_t timestamp, const char *pattern, ...)
+{
+  struct VarData vd;
+  int retval = 0;
+
+  vd.vd_format = pattern;
+  va_start(vd.vd_args, pattern);
+
+  if (!IsServer(sptr))
+    retval = vexit_client_msg(cptr, cptr, &me, pattern, vd.vd_args);
+  else
+    sendcmdto_one(&me, CMD_SQUIT, cptr, "%s %Tu :%v", host, timestamp, &vd);
+
+  va_end(vd.vd_args);
+
+  return retval;
+}
 
 int a_kills_b_too(struct Client *a, struct Client *b)
 {
@@ -105,14 +126,13 @@ int server_estab(struct Client *cptr, struct ConfItem *aconf)
 
   if (IsUnknown(cptr)) {
     if (aconf->passwd[0])
-      sendto_one(cptr, "PASS :%s", aconf->passwd);
+      sendrawto_one(cptr, MSG_PASS " :%s", aconf->passwd);
     /*
      *  Pass my info to the new server
      */
-    sendto_one(cptr, "SERVER %s 1 " TIME_T_FMT " " TIME_T_FMT " J%s %s%s :%s",
-        me.name, me.serv->timestamp, cptr->serv->timestamp,
-        MAJOR_PROTOCOL, NumServCap(&me),
-        (me.info[0]) ? (me.info) : "IRCers United");
+    sendrawto_one(cptr, MSG_SERVER " %s 1 %Tu %Tu J%s %s%s :%s", me.name,
+                 me.serv->timestamp, cptr->serv->timestamp, MAJOR_PROTOCOL,
+                 NumServCap(&me), *me.info ? me.info : "IRCers United");
     /*
      * Don't charge this IP# for connecting
      * XXX - if this comes from a server port, it will not have been added
index f4456a4e91443d746843ab170f30f013fcc3100f..cca7606d97f8306ee16e23a54936e7b8ec46ab5b 100644 (file)
@@ -534,15 +534,14 @@ int register_user(struct Client *cptr, struct Client *sptr,
         strcmp(sptr->username, username) != 0))
     {
       ServerStats->is_ref++;
-      /* XXX sendto_one used with ERR_INVALIDUSERNAME--explanations */
-      sendto_one(cptr, ":%s %d %s :Your username is invalid.",
-                 me.name, ERR_INVALIDUSERNAME, cptr->name);
-      sendto_one(cptr,
-                 ":%s %d %s :Connect with your real username, in lowercase.",
-                 me.name, ERR_INVALIDUSERNAME, cptr->name);
-      sendto_one(cptr, ":%s %d %s :If your mail address were foo@bar.com, "
-                 "your username would be foo.",
-                 me.name, ERR_INVALIDUSERNAME, cptr->name);
+
+      send_reply(cptr, RPL_EXPLICIT | ERR_INVALIDUSERNAME,
+                ":Your username is invalid.");
+      send_reply(cptr, RPL_EXPLICIT | ERR_INVALIDUSERNAME,
+                ":Connect with your real username, in lowercase.");
+      send_reply(cptr, RPL_EXPLICIT | ERR_INVALIDUSERNAME,
+                ":If your mail address were foo@bar.com, your username "
+                "would be foo.");
       return exit_client(cptr, sptr, &me, "USER: Bad username");
     }
     Count_unknownbecomesclient(sptr, UserStats);
@@ -813,8 +812,7 @@ int set_nick_name(struct Client* cptr, struct Client* sptr,
       do {
         sptr->cookie = (ircrandom() & 0x7fffffff);
       } while (!sptr->cookie);
-      /* XXX sendto_one used to send PING--must be very careful! */
-      sendto_one(cptr, "PING :%u", sptr->cookie);
+      sendrawto_one(cptr, MSG_PING " :%u", sptr->cookie);
     }
     else if (*sptr->user->host && sptr->cookie == COOKIE_VERIFIED) {
       /*
index e118b0721ad40c7cccb389d5e5abf1a91ab1fb7a..17bbcf5e6b70a128675c5e47a1615a4fa4fc3fc6 100644 (file)
@@ -989,6 +989,22 @@ void sendto_highprot_butone(struct Client *cptr, int p, const char *pattern, ...
   va_end(vl);
 }
 
+/*
+ * Send a raw command to a single client; use *ONLY* if you absolutely
+ * must send a command without a prefix.
+ */
+void sendrawto_one(struct Client *to, const char *pattern, ...)
+{
+  char sndbuf[IRC_BUFSIZE];
+  va_list vl;
+
+  va_start(vl, pattern);
+  ircd_vsnprintf(to, sndbuf, sizeof(sndbuf) - 2, pattern, vl);
+  va_end(vl);
+
+  send_buffer(to, sndbuf);
+}
+
 /*
  * Send a (prefixed) command to a single client; select which of <cmd>
  * <tok> to use depending on if to is a server or not.  <from> is the