added basic ssl support to ircu
[ircu2.10.12-pk.git] / ircd / m_error.c
index ffe19ff6e682a8fac873fce294ffac47a8e97f32..561fbcffffb44cfe5a673ecb1dda083f135dfbc3 100644 (file)
@@ -85,6 +85,7 @@
 #include "hash.h"
 #include "ircd.h"
 #include "ircd_alloc.h"
+#include "ircd_log.h"
 #include "ircd_reply.h"
 #include "ircd_string.h"
 #include "numeric.h"
 #include "s_misc.h"
 #include "send.h"
 
-#include <assert.h>
+/* #include <assert.h> -- Now using assert in ircd_log.h */
 #include <string.h>
 
+/*
+ * mr_error - unregistered client message handler
+ *
+ * parv[0] = sender prefix
+ * parv[parc-1] = text
+ */
+int mr_error(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
+{
+  const char *para;
+
+  if (!IsHandshake(cptr) && !IsConnecting(cptr))
+    return 0; /* ignore ERROR from regular clients */
+
+  para = (parc > 1 && *parv[parc - 1] != '\0') ? parv[parc - 1] : "<>";
+
+  Debug((DEBUG_ERROR, "Received ERROR message from %s: %s", cli_name(sptr), para));
+
+  if (cptr == sptr)
+    sendto_opmask_butone(0, SNO_OLDSNO, "ERROR :from %C -- %s", cptr, para);
+  else
+    sendto_opmask_butone(0, SNO_OLDSNO, "ERROR :from %C via %C -- %s", sptr,
+                        cptr, para);
+
+  if (cli_serv(sptr))
+  {
+    MyFree(cli_serv(sptr)->last_error_msg);
+    DupString(cli_serv(sptr)->last_error_msg, para);
+  }
+
+  return 0;
+}
+
 /*
  * ms_error - server message handler
  *