Move check_if_ipmask() from support.* to match.*.
[ircu2.10.12-pk.git] / ircd / hash.c
index 1e25937d38ddde55457d901d622d8c4b78b4812b..21539c34391f3cddc0a20e0dc9ffa71a803cfd82 100644 (file)
  *
  * $Id$
  */
+#include "config.h"
+
 #include "hash.h"
 #include "client.h"
 #include "channel.h"
 #include "ircd_chattr.h"
 #include "ircd_string.h"
 #include "ircd.h"
+#include "msg.h"
 #include "send.h"
 #include "struct.h"
-#include "support.h"
 #include "sys.h"
 
 #include <assert.h>
@@ -177,9 +179,9 @@ static struct Channel *channelTable[HASHSIZE];
    be symmetric, if HASHEQ(a,b) then HASHEQ(b,a), obvious ok but... :) */
 #define HASHEQ(x,y) ((ToLower(x)) == (ToLower(y)))
 
-/* hash_init
+/* init_hash
  * Initialize the maps used by hash functions and clear the tables */
-void hash_init(void)
+void init_hash(void)
 {
   int           i;
   int           j;
@@ -280,9 +282,9 @@ static HASHREGS strhash(const char *n)
  */
 int hAddClient(struct Client *cptr)
 {
-  HASHREGS hashv = strhash(cptr->name);
+  HASHREGS hashv = strhash(cli_name(cptr));
 
-  cptr->hnext = clientTable[hashv];
+  cli_hnext(cptr) = clientTable[hashv];
   clientTable[hashv] = cptr;
 
   return 0;
@@ -311,22 +313,22 @@ int hAddChannel(struct Channel *chptr)
  */
 int hRemClient(struct Client *cptr)
 {
-  HASHREGS hashv = strhash(cptr->name);
+  HASHREGS hashv = strhash(cli_name(cptr));
   struct Client *tmp = clientTable[hashv];
 
   if (tmp == cptr) {
-    clientTable[hashv] = cptr->hnext;
-    cptr->hnext = cptr;
+    clientTable[hashv] = cli_hnext(cptr);
+    cli_hnext(cptr) = cptr;
     return 0;
   }
 
   while (tmp) {
-    if (tmp->hnext == cptr) {
-      tmp->hnext = tmp->hnext->hnext;
-      cptr->hnext = cptr;
+    if (cli_hnext(tmp) == cptr) {
+      cli_hnext(tmp) = cli_hnext(cli_hnext(tmp));
+      cli_hnext(cptr) = cptr;
       return 0;
     }
-    tmp = tmp->hnext;
+    tmp = cli_hnext(tmp);
   }
   return -1;
 }
@@ -354,7 +356,7 @@ int hChangeClient(struct Client *cptr, const char *newname)
   assert(0 != cptr);
   hRemClient(cptr);
 
-  cptr->hnext = clientTable[newhash];
+  cli_hnext(cptr) = clientTable[newhash];
   clientTable[newhash] = cptr;
   return 0;
 }
@@ -399,12 +401,12 @@ struct Client* hSeekClient(const char *name, int TMask)
   struct Client *cptr = clientTable[hashv];
 
   if (cptr) {
-    if (0 == (cptr->status & TMask) || 0 != ircd_strcmp(name, cptr->name)) {
+    if (0 == (cli_status(cptr) & TMask) || 0 != ircd_strcmp(name, cli_name(cptr))) {
       struct Client* prev;
-      while (prev = cptr, cptr = cptr->hnext) {
-        if ((cptr->status & TMask) && (0 == ircd_strcmp(name, cptr->name))) {
-          prev->hnext = cptr->hnext;
-          cptr->hnext = clientTable[hashv];
+      while (prev = cptr, cptr = cli_hnext(cptr)) {
+        if ((cli_status(cptr) & TMask) && (0 == ircd_strcmp(name, cli_name(cptr)))) {
+          cli_hnext(prev) = cli_hnext(cptr);
+          cli_hnext(cptr) = clientTable[hashv];
           clientTable[hashv] = cptr;
           break;
         }
@@ -456,13 +458,13 @@ int m_hash(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
   struct Channel* ch;
   int i;
   
-  sendto_one(sptr, "NOTICE %s :Hash Table Statistics", parv[0]);
+  sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :Hash Table Statistics", sptr);
 
   for (i = 0; i < HASHSIZE; ++i) {
     if ((cl = clientTable[i])) {
       int len = 0;
       ++buckets;
-      for ( ; cl; cl = cl->hnext)
+      for ( ; cl; cl = cli_hnext(cl))
         ++len; 
       if (len > max_chain)
         max_chain = len;
@@ -470,8 +472,8 @@ int m_hash(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
     }
   } 
 
-  sendto_one(sptr, "NOTICE %s :Client: entries: %d buckets: %d max chain: %d",
-             parv[0], count, buckets, max_chain);
+  sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :Client: entries: %d buckets: %d "
+               "max chain: %d", sptr, count, buckets, max_chain);
 
   buckets = 0;
   count   = 0;
@@ -489,8 +491,8 @@ int m_hash(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
     }
   } 
 
-  sendto_one(sptr, "NOTICE %s :Channel: entries: %d buckets: %d max chain: %d",
-             parv[0], count, buckets, max_chain);
+  sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :Channel: entries: %d buckets: %d "
+               "max chain: %d", sptr, count, buckets, max_chain);
   return 0;
 }