Author: Kev <klmitch@mit.edu>
[ircu2.10.12-pk.git] / ircd / s_numeric.c
index 7cf0feff7f37444939604de7c959ec123e07c8d2..5d9803c43114500e47b7514eb067deaf040c8858 100644 (file)
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id$
  */
-
-#include "sys.h"
-#include "h.h"
-#include "struct.h"
-#include "s_serv.h"
-#include "s_bsd.h"
-#include "send.h"
-#include "support.h"
-#include "parse.h"
-#include "numeric.h"
+#include "s_numeric.h"
 #include "channel.h"
-#include "ircd.h"
+#include "client.h"
 #include "hash.h"
+#include "ircd.h"
+#include "ircd_snprintf.h"
 #include "numnicks.h"
-#include "s_numeric.h"
-
-RCSTAG_CC("$Id$");
+#include "send.h"
+#include "struct.h"
 
-static char buffer[1024];
 
 /*
  * do_numeric()
@@ -48,13 +41,12 @@ static char buffer[1024];
  * the savy approach is NEVER generate an error in response to an... error :)
  */
 
-int do_numeric(int numeric, int nnn, aClient *cptr, aClient *sptr,
+int do_numeric(int numeric, int nnn, struct Client *cptr, struct Client *sptr,
     int parc, char *parv[])
 {
-  aClient *acptr = NULL;
-  aChannel *achptr = NULL;
-  char *p, *b;
-  int i;
+  struct Client *acptr = 0;
+  struct Channel *achptr = 0;
+  char num[4];
 
   /* Avoid trash, we need it to come from a server and have a target  */
   if ((parc < 2) || !IsServer(sptr))
@@ -71,33 +63,20 @@ int do_numeric(int numeric, int nnn, aClient *cptr, aClient *sptr,
   else
     acptr = (nnn) ? (findNUser(parv[1])) : (FindUser(parv[1]));
 
-  if (((!acptr) || (acptr->from == cptr)) && !achptr)
+  if (((!acptr) || (cli_from(acptr) == cptr)) && !achptr)
     return 0;
 
   /* Remap low number numerics, not that I understand WHY.. --Nemesi  */
   if (numeric < 100)
     numeric += 100;
 
-  /* Rebuild the buffer with all the parv[] without wasting cycles :) */
-  b = buffer;
-  if (parc > 2)
-  {
-    for (i = 2; i < (parc - 1); i++)
-      for (*b++ = ' ', p = parv[i]; *p; p++)
-       *b++ = *p;
-    for (*b++ = ' ', *b++ = ':', p = parv[parc - 1]; *p; p++)
-      *b++ = *p;
-  }
-  *b = '\000';
-
-  /* Since .06 this will implicitly use numeric nicks when needed     */
+  ircd_snprintf(0, num, sizeof(num), "%03d", numeric);
 
   if (acptr)
-    sendto_prefix_one(acptr, sptr, ":%s %d %s%s",
-       sptr->name, numeric, acptr->name, buffer);
+    sendcmdto_one(sptr, num, num, acptr, "%C %s", acptr, parv[2]);
   else
-    sendto_channel_butone(cptr, sptr, achptr, ":%s %d %s%s",
-       sptr->name, numeric, achptr->chname, buffer);
+    sendcmdto_channel_butone(sptr, num, num, achptr, cptr,
+                            SKIP_DEAF | SKIP_BURST, "%H %s", achptr, parv[2]);
 
   return 0;
 }