Author: Isomer <perry@coders.net>
[ircu2.10.12-pk.git] / ircd / ircd_reply.c
index 742923d442b312b5dff430ea6b8de45d481e1766..5e33b1bf932d926e1a43c41dafd1c8967256105c 100644 (file)
@@ -27,6 +27,7 @@
 #include "ircd.h"
 #include "ircd_snprintf.h"
 #include "numeric.h"
+#include "msg.h"
 #include "s_conf.h"
 #include "s_debug.h"
 #include "send.h"
 #include <assert.h>
 #include <string.h>
 
+/* Report a protocol violation warning to anyone listening.  This can be
+ * easily used to cleanup the last couple of parts of the code up.
+ */
+int protocol_violation(struct Client* cptr, const char* pattern, ...)
+{
+       va_list vl;
+       char buffer[512];
+       assert(pattern);
+       assert(cptr);
+       va_start(vl,pattern);
+       ircd_snprintf(0,buffer,sizeof(buffer)-2, 
+               "Protocol Violation from %C: %v",vl);
+       sendcmdto_flag_butone(&me, CMD_DESYNCH, NULL, FLAGS_DEBUG, 
+               ":%s", cptr, buffer);
+       va_end(vl);
+       return 0;
+}
+
 int need_more_params(struct Client* cptr, const char* cmd)
 {
+  if (!MyUser(cptr))
+    protocol_violation(cptr,"Not enough parameters for %s",cmd);
   send_reply(cptr, ERR_NEEDMOREPARAMS, cmd);
   return 0;
 }