added gnutls backend and moved backend code into new files
[ircu2.10.12-pk.git] / ircd / m_version.c
index 1366879cb1ee9b1a8455378c1f31fc5b8edbc854..656332e3a5bdc8e931975ff8166591c73b2fd992 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_log.h"
 #include "ircd_reply.h"
+#include "ircd_snprintf.h"
 #include "ircd_string.h"
+#include "match.h"
 #include "msg.h"
 #include "numeric.h"
 #include "numnicks.h"
 #include "supported.h"
 #include "version.h"
 
-#include <assert.h>
+/* #include <assert.h> -- Now using assert in ircd_log.h */
 
 /*
  * m_version - generic message handler
  *
  *   parv[0] = sender prefix
- *   parv[1] = remote server
+ *   parv[1] = servername
  */
 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])))
-    {
-      send_reply(sptr, ERR_NOSUCHSERVER, parv[1]);
-      return 0;
-    }
-    parv[1] = cli_name(acptr);
-  }
-
-  if (hunt_server_cmd(sptr, CMD_VERSION, cptr, 0, ":%C", 1, parc, parv) ==
-      HUNTED_ISME)
-  {
-    char featurebuf[512];
-    
-    sprintf_irc(featurebuf,FEATURES,FEATURESVALUES);
-    
-    send_reply(sptr, RPL_VERSION, version, debugmode, cli_name(&me),
-              debug_serveropts());
-    send_reply(sptr, RPL_ISUPPORT, featurebuf);
-  }
+  if (parc > 1 && match(parv[1], cli_name(&me)))
+    return send_reply(sptr, ERR_NOPRIVILEGES);
 
+  send_reply(sptr, RPL_VERSION, version, debugmode, cli_name(&me),
+             debug_serveropts());
+  send_supported(sptr);
   return 0;
 }
 
 /*
- * ms_version - server message handler
+ * mo_version - oper message handler
  *
  *   parv[0] = sender prefix
- *   parv[1] = remote server
+ *   parv[1] = servername
  */
-int ms_version(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
+int mo_version(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 {
   struct Client *acptr;
 
@@ -158,24 +138,26 @@ int ms_version(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
     parv[1] = cli_name(acptr);
   }
 
-  if (hunt_server_cmd(sptr, CMD_VERSION, cptr, 0, ":%C", 1, parc, parv) ==
-      HUNTED_ISME)
+  if (hunt_server_cmd(sptr, CMD_VERSION, cptr, feature_int(FEAT_HIS_REMOTE),
+                                                           ":%C", 1,
+                                                           parc, parv)
+                      == HUNTED_ISME)
   {
     send_reply(sptr, RPL_VERSION, version, debugmode, cli_name(&me),
               debug_serveropts());
+    send_supported(sptr);
   }
 
   return 0;
 }
 
-#if 0
 /*
- * m_version
+ * ms_version - server message handler
  *
  *   parv[0] = sender prefix
- *   parv[1] = remote server
+ *   parv[1] = servername
  */
-int m_version(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
+int ms_version(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 {
   struct Client *acptr;
 
@@ -183,18 +165,18 @@ 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]); /* XXX DEAD */
+      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) == /* XXX DEAD */
+  if (hunt_server_cmd(sptr, CMD_VERSION, cptr, 0, ":%C", 1, parc, parv) ==
       HUNTED_ISME)
-    sendto_one(sptr, rpl_str(RPL_VERSION), /* XXX DEAD */
-        me.name, parv[0], version, debugmode, me.name, serveropts);
+  {
+    send_reply(sptr, RPL_VERSION, version, debugmode, cli_name(&me),
+              debug_serveropts());
+  }
 
   return 0;
 }
-#endif /* 0 */
-