Author: Kev <klmitch@mit.edu>
[ircu2.10.12-pk.git] / ircd / m_version.c
index 0eb12302fa0decb31339d9c609010a340062835b..082deefcfaa1160920fe78fec36148dc70996b05 100644 (file)
  *            note:   it is guaranteed that parv[0]..parv[parc-1] are all
  *                    non-NULL pointers.
  */
-#if 0
-/*
- * No need to include handlers.h here the signatures must match
- * and we don't need to force a rebuild of all the handlers everytime
- * we add a new one to the list. --Bleep
- */
-#include "handlers.h"
-#endif /* 0 */
+#include "config.h"
+
 #include "client.h"
 #include "hash.h"
 #include "ircd.h"
+#include "ircd_features.h"
+#include "ircd_policy.h"
 #include "ircd_reply.h"
+#include "ircd_snprintf.h"
 #include "ircd_string.h"
 #include "msg.h"
 #include "numeric.h"
@@ -98,6 +95,7 @@
 #include "s_debug.h"
 #include "s_user.h"
 #include "send.h"
+#include "supported.h"
 #include "version.h"
 
 #include <assert.h>
@@ -116,16 +114,23 @@ int m_version(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   {
     if (!(acptr = find_match_server(parv[1])))
     {
-      sendto_one(sptr, err_str(ERR_NOSUCHSERVER), me.name, parv[0], parv[1]);
+      send_reply(sptr, ERR_NOSUCHSERVER, parv[1]);
       return 0;
     }
-    parv[1] = acptr->name;
+    parv[1] = cli_name(acptr);
   }
 
-  if (hunt_server(0, cptr, sptr, "%s%s " TOK_VERSION " :%s", 1, parc, parv) ==
-      HUNTED_ISME)
-    sendto_one(sptr, rpl_str(RPL_VERSION),
-        me.name, parv[0], version, debugmode, me.name, serveropts);
+  if (hunt_server_cmd(sptr, CMD_VERSION, cptr, HEAD_IN_SAND_REMOTE, ":%C", 1,
+                     parc, parv) == HUNTED_ISME)
+  {
+    char featurebuf[512];
+    
+    ircd_snprintf(0, featurebuf, sizeof(featurebuf), FEATURES, FEATURESVALUES);
+    
+    send_reply(sptr, RPL_VERSION, version, debugmode, cli_name(&me),
+              debug_serveropts());
+    send_reply(sptr, RPL_ISUPPORT, featurebuf);
+  }
 
   return 0;
 }
@@ -144,47 +149,18 @@ int ms_version(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   {
     if (!(acptr = find_match_server(parv[1])))
     {
-      sendto_one(sptr, err_str(ERR_NOSUCHSERVER), me.name, parv[0], parv[1]);
+      send_reply(sptr, ERR_NOSUCHSERVER, parv[1]);
       return 0;
     }
-    parv[1] = acptr->name;
+    parv[1] = cli_name(acptr);
   }
 
-  if (hunt_server(0, cptr, sptr, "%s%s " TOK_VERSION " :%s", 1, parc, parv) ==
+  if (hunt_server_cmd(sptr, CMD_VERSION, cptr, 0, ":%C", 1, parc, parv) ==
       HUNTED_ISME)
-    sendto_one(sptr, rpl_str(RPL_VERSION),
-        me.name, parv[0], version, debugmode, me.name, serveropts);
-
-  return 0;
-}
-
-#if 0
-/*
- * m_version
- *
- *   parv[0] = sender prefix
- *   parv[1] = remote server
- */
-int m_version(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
-{
-  struct Client *acptr;
-
-  if (MyConnect(sptr) && parc > 1)
   {
-    if (!(acptr = find_match_server(parv[1])))
-    {
-      sendto_one(sptr, err_str(ERR_NOSUCHSERVER), me.name, parv[0], parv[1]);
-      return 0;
-    }
-    parv[1] = acptr->name;
+    send_reply(sptr, RPL_VERSION, version, debugmode, cli_name(&me),
+              debug_serveropts());
   }
 
-  if (hunt_server(0, cptr, sptr, "%s%s " TOK_VERSION " :%s", 1, parc, parv) ==
-      HUNTED_ISME)
-    sendto_one(sptr, rpl_str(RPL_VERSION),
-        me.name, parv[0], version, debugmode, me.name, serveropts);
-
   return 0;
 }
-#endif /* 0 */
-