added gnutls backend and moved backend code into new files
[ircu2.10.12-pk.git] / ircd / m_links.c
index 60b3d049ef2cc1af5b49085a4790d006a4ba917c..68bf87fd92fc1edc781f9b1c37b0f4847ac2a681 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 "ircd.h"
+#include "ircd_defs.h"
+#include "ircd_features.h"
+#include "ircd_log.h"
 #include "ircd_reply.h"
 #include "ircd_string.h"
 #include "match.h"
@@ -99,7 +96,7 @@
 #include "send.h"
 #include "struct.h"
 
-#include <assert.h>
+/* #include <assert.h> -- Now using assert in ircd_log.h */
 
 /*
  * m_links - generic message handler
@@ -118,53 +115,15 @@ int m_links(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   char *mask;
   struct Client *acptr;
 
-  if (parc > 2)
-  {
-    if (hunt_server_cmd(sptr, CMD_LINKS, cptr, 1, "%C :%s", 1, parc, parv) !=
-        HUNTED_ISME)
-      return 0;
-    mask = parv[2];
-  }
-  else
-    mask = parc < 2 ? 0 : parv[1];
-
-  for (acptr = GlobalClientList, collapse(mask); acptr; acptr = acptr->next)
+  if (feature_bool(FEAT_HIS_LINKS) && !IsAnOper(sptr))
   {
-    if (!IsServer(acptr) && !IsMe(acptr))
-      continue;
-    if (!BadPtr(mask) && match(mask, acptr->name))
-      continue;
-    send_reply(sptr, RPL_LINKS, acptr->name, acptr->serv->up->name,
-#ifndef GODMODE
-        acptr->hopcount, acptr->serv->prot,
-#else /* GODMODE */
-        acptr->hopcount, acptr->serv->prot, acptr->serv->timestamp,
-        NumServ(acptr),
-#endif /* GODMODE */
-        (acptr->info[0] ? acptr->info : "(Unknown Location)"));
+    send_reply(sptr, RPL_ENDOFLINKS, parc < 2 ? "*" : parv[1]);
+    sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :%s %s", sptr,
+                  "/LINKS has been disabled, from CFV-165.  Visit ", 
+                  feature_str(FEAT_HIS_URLSERVERS));
+    return 0;
   }
 
-  send_reply(sptr, RPL_ENDOFLINKS, BadPtr(mask) ? "*" : mask);
-  return 0;
-}
-
-/*
- * ms_links - server message handler
- *
- * parv[0] = sender prefix
- * parv[1] = servername mask
- *
- * or
- *
- * parv[0] = sender prefix
- * parv[1] = server to query
- * parv[2] = servername mask
- */
-int ms_links(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
-{
-  char *mask;
-  struct Client *acptr;
-
   if (parc > 2)
   {
     if (hunt_server_cmd(sptr, CMD_LINKS, cptr, 1, "%C :%s", 1, parc, parv) !=
@@ -175,30 +134,24 @@ int ms_links(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   else
     mask = parc < 2 ? 0 : parv[1];
 
-  for (acptr = GlobalClientList, collapse(mask); acptr; acptr = acptr->next)
+  for (acptr = GlobalClientList, collapse(mask); acptr; acptr = cli_next(acptr))
   {
     if (!IsServer(acptr) && !IsMe(acptr))
       continue;
-    if (!BadPtr(mask) && match(mask, acptr->name))
+    if (!BadPtr(mask) && match(mask, cli_name(acptr)))
       continue;
-    send_reply(sptr, RPL_LINKS, acptr->name, acptr->serv->up->name,
-#ifndef GODMODE
-        acptr->hopcount, acptr->serv->prot,
-#else /* GODMODE */
-        acptr->hopcount, acptr->serv->prot, acptr->serv->timestamp,
-        NumServ(acptr),
-#endif /* GODMODE */
-        (acptr->info[0] ? acptr->info : "(Unknown Location)"));
+    send_reply(sptr, RPL_LINKS, cli_name(acptr), cli_name(cli_serv(acptr)->up),
+        cli_hopcount(acptr), cli_serv(acptr)->prot,
+        ((cli_info(acptr))[0] ? cli_info(acptr) : "(Unknown Location)"));
   }
 
   send_reply(sptr, RPL_ENDOFLINKS, BadPtr(mask) ? "*" : mask);
+
   return 0;
 }
 
-
-#if 0
 /*
- * m_links
+ * ms_links - server message handler
  *
  * parv[0] = sender prefix
  * parv[1] = servername mask
@@ -209,41 +162,33 @@ int ms_links(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
  * parv[1] = server to query
  * parv[2] = servername mask
  */
-int m_links(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
-{
-  char *mask;
-  struct Client *acptr;
-
-  if (parc > 2)
-  {
-    if (hunt_server(1, cptr, sptr, "%s%s LINKS %s :%s", 1, parc, parv) != /* XXX DEAD */
-        HUNTED_ISME)
-      return 0;
-    mask = parv[2];
-  }
-  else
-    mask = parc < 2 ? 0 : parv[1];
-
-  for (acptr = GlobalClientList, collapse(mask); acptr; acptr = acptr->next)
-  {
-    if (!IsServer(acptr) && !IsMe(acptr))
-      continue;
-    if (!BadPtr(mask) && match(mask, acptr->name))
-      continue;
-    sendto_one(sptr, rpl_str(RPL_LINKS), /* XXX DEAD */
-        me.name, parv[0], acptr->name, acptr->serv->up->name,
-#ifndef GODMODE
-        acptr->hopcount, acptr->serv->prot,
-#else /* GODMODE */
-        acptr->hopcount, acptr->serv->prot, acptr->serv->timestamp,
-        NumServ(acptr),
-#endif /* GODMODE */
-        (acptr->info[0] ? acptr->info : "(Unknown Location)"));
-  }
-
-  sendto_one(sptr, rpl_str(RPL_ENDOFLINKS), me.name, parv[0], /* XXX DEAD */
-      BadPtr(mask) ? "*" : mask);
-  return 0;
-}
-#endif /* 0 */
-
+int
+ms_links(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
+ {
+   char *mask;
+   struct Client *acptr;
+
+   if (parc > 2)
+   {
+     if (hunt_server_cmd(sptr, CMD_LINKS, cptr, 1, "%C :%s", 1, parc, parv) !=
+         HUNTED_ISME)
+       return 0;
+     mask = parv[2];
+   }
+   else
+     mask = parc < 2 ? 0 : parv[1];
+   for (acptr = GlobalClientList, collapse(mask); acptr; acptr = cli_next(acptr))
+   {
+     if (!IsServer(acptr) && !IsMe(acptr))
+       continue;
+     if (!BadPtr(mask) && match(mask, cli_name(acptr)))
+       continue;
+     send_reply(sptr, RPL_LINKS, cli_name(acptr), cli_name(cli_serv(acptr)->up),
+                cli_hopcount(acptr), cli_serv(acptr)->prot,
+                ((cli_info(acptr))[0] ? cli_info(acptr) : "(Unknown Location)"));
+   }
+   send_reply(sptr, RPL_ENDOFLINKS, BadPtr(mask) ? "*" : mask);
+   return 0;
+ }