Author: Isomer <perry@coders.net>
[ircu2.10.12-pk.git] / ircd / ircd_reply.c
index 9020eaa75abd01be3a2a304481bc198b67e26e30..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;
 }
@@ -125,17 +147,15 @@ int send_reply(struct Client *to, int reply, ...)
   return 0; /* convenience return */
 }
 
-int send_admin_info(struct Client* sptr, const struct ConfItem* admin)
+int send_admin_info(struct Client* sptr)
 {
+  const struct LocalConf* admin = conf_get_local();
   assert(0 != sptr);
-  if (admin) {
-    send_reply(sptr, RPL_ADMINME,    me.name);
-    send_reply(sptr, RPL_ADMINLOC1,  admin->host);
-    send_reply(sptr, RPL_ADMINLOC2,  admin->passwd);
-    send_reply(sptr, RPL_ADMINEMAIL, admin->name);
-  }
-  else
-    send_reply(sptr, ERR_NOADMININFO, me.name);
+
+  send_reply(sptr, RPL_ADMINME,    me.name);
+  send_reply(sptr, RPL_ADMINLOC1,  admin->location1);
+  send_reply(sptr, RPL_ADMINLOC2,  admin->location2);
+  send_reply(sptr, RPL_ADMINEMAIL, admin->contact);
   return 0;
 }