]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - src/hash.c
Remove silly a2client_p, entirely pointless since User.server removal.
[irc/rqf/shadowircd.git] / src / hash.c
index 86b22bcd2c4c1464e3f81904a8f0651983d9d915..9ff4b1259a72f0619f2f972922d9fdaafc0a47be 100644 (file)
@@ -21,7 +21,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *  $Id: hash.c 1321 2006-05-13 23:49:14Z nenolod $
+ *  $Id: hash.c 3177 2007-02-01 00:19:14Z jilles $
  */
 
 #include "stdinc.h"
@@ -45,9 +45,7 @@ dlink_list *clientTable;
 dlink_list *channelTable;
 dlink_list *idTable;
 dlink_list *resvTable;
-dlink_list *hostTable;
-dlink_list *helpTable;
-dlink_list *ndTable;
+dlink_list *hostTable; 
 
 /*
  * look in whowas.c for the missing ...[WW_MAX]; entry
@@ -95,11 +93,9 @@ init_hash(void)
 {
        clientTable = MyMalloc(sizeof(dlink_list) * U_MAX);
        idTable = MyMalloc(sizeof(dlink_list) * U_MAX);
-       ndTable = MyMalloc(sizeof(dlink_list) * U_MAX);
        channelTable = MyMalloc(sizeof(dlink_list) * CH_MAX);
        hostTable = MyMalloc(sizeof(dlink_list) * HOST_MAX);
        resvTable = MyMalloc(sizeof(dlink_list) * R_MAX);
-       helpTable = MyMalloc(sizeof(dlink_list) * HELP_MAX);
 }
 
 #ifndef RICER_HASHING
@@ -113,7 +109,8 @@ fnv_hash_upper(const unsigned char *s, int bits)
                h ^= ToUpper(*s++);
                h += (h<<1) + (h<<4) + (h<<7) + (h << 8) + (h << 24);
        }
-        h = (h >> bits) ^ (h & ((2^bits)-1));
+       if (bits < 32)
+               h = ((h >> bits) ^ h) & ((1<<bits)-1);
        return h;
 }
 
@@ -127,7 +124,8 @@ fnv_hash(const unsigned char *s, int bits)
                h ^= *s++;
                h += (h<<1) + (h<<4) + (h<<7) + (h << 8) + (h << 24);
        }
-        h = (h >> bits) ^ (h & ((2^bits)-1));
+       if (bits < 32)
+               h = ((h >> bits) ^ h) & ((1<<bits)-1);
        return h;
 }
 
@@ -141,7 +139,8 @@ fnv_hash_len(const unsigned char *s, int bits, int len)
                h ^= *s++;
                h += (h<<1) + (h<<4) + (h<<7) + (h << 8) + (h << 24);
        }
-        h = (h >> bits) ^ (h & ((2^bits)-1));
+       if (bits < 32)
+               h = ((h >> bits) ^ h) & ((1<<bits)-1);
        return h;
 }
 
@@ -155,7 +154,8 @@ fnv_hash_upper_len(const unsigned char *s, int bits, int len)
                h ^= ToUpper(*s++);
                h += (h<<1) + (h<<4) + (h<<7) + (h << 8) + (h << 24);
        }
-        h = (h >> bits) ^ (h & ((2^bits)-1));
+       if (bits < 32)
+               h = ((h >> bits) ^ h) & ((1<<bits)-1);
        return h;
 }
 #endif
@@ -211,19 +211,6 @@ hash_resv(const char *name)
        return fnv_hash_upper_len((const unsigned char *) name, R_MAX_BITS, 30);
 }
 
-static unsigned int
-hash_help(const char *name)
-{
-       unsigned int h = 0;
-
-       while(*name)
-       {
-               h += (unsigned int) (ToLower(*name++) & 0xDF);
-       }
-
-       return (h % HELP_MAX);
-}
-
 /* add_to_id_hash()
  *
  * adds an entry to the id hash table
@@ -294,25 +281,6 @@ add_to_resv_hash(const char *name, struct ConfItem *aconf)
        dlinkAddAlloc(aconf, &resvTable[hashv]);
 }
 
-void
-add_to_help_hash(const char *name, struct cachefile *hptr)
-{
-       unsigned int hashv;
-
-       if(EmptyString(name) || hptr == NULL)
-               return;
-
-       hashv = hash_help(name);
-       dlinkAddAlloc(hptr, &helpTable[hashv]);
-}
-
-void
-add_to_nd_hash(const char *name, struct nd_entry *nd)
-{
-       nd->hashv = hash_nick(name);
-       dlinkAdd(nd, &nd->hnode, &ndTable[nd->hashv]);
-}
-
 /* del_from_id_hash()
  *
  * removes an id from the id hash table
@@ -405,21 +373,6 @@ del_from_resv_hash(const char *name, struct ConfItem *aconf)
        dlinkFindDestroy(aconf, &resvTable[hashv]);
 }
 
-void
-clear_help_hash(void)
-{
-       dlink_node *ptr;
-       dlink_node *next_ptr;
-       int i;
-
-       HASH_WALK_SAFE(i, HELP_MAX, ptr, next_ptr, helpTable)
-       {
-               free_cachefile(ptr->data);
-               dlinkDestroy(ptr, &helpTable[i]);
-       }
-       HASH_WALK_END
-}
-
 /* find_id()
  *
  * finds a client entry from the id hash table
@@ -447,79 +400,6 @@ find_id(const char *name)
        return NULL;
 }
 
-/* hash_find_masked_server()
- * 
- * Whats happening in this next loop ? Well, it takes a name like
- * foo.bar.edu and proceeds to earch for *.edu and then *.bar.edu.
- * This is for checking full server names against masks although
- * it isnt often done this way in lieu of using matches().
- *
- * Rewrote to do *.bar.edu first, which is the most likely case,
- * also made const correct
- * --Bleep
- */
-static struct Client *
-hash_find_masked_server(struct Client *source_p, const char *name)
-{
-       char buf[HOSTLEN + 1];
-       char *p = buf;
-       char *s;
-       struct Client *server;
-
-       if('*' == *name || '.' == *name)
-               return NULL;
-
-       /* copy it across to give us a buffer to work on */
-       strlcpy(buf, name, sizeof(buf));
-
-       while ((s = strchr(p, '.')) != 0)
-       {
-               *--s = '*';
-               /*
-                * Dont need to check IsServer() here since nicknames cant
-                * have *'s in them anyway.
-                */
-               if((server = find_server(source_p, s)))
-                       return server;
-               p = s + 2;
-       }
-
-       return NULL;
-}
-
-/* find_any_client()
- *
- * finds a client/server/masked server entry from the hash
- */
-struct Client *
-find_any_client(const char *name)
-{
-       struct Client *target_p;
-       dlink_node *ptr;
-       unsigned int hashv;
-
-       s_assert(name != NULL);
-       if(EmptyString(name))
-               return NULL;
-
-       /* hunting for an id, not a nick */
-       if(IsDigit(*name))
-               return (find_id(name));
-
-       hashv = hash_nick(name);
-
-       DLINK_FOREACH(ptr, clientTable[hashv].head)
-       {
-               target_p = ptr->data;
-
-               if(irccmp(name, target_p->name) == 0)
-                       return target_p;
-       }
-
-       /* wasnt found, look for a masked server */
-       return hash_find_masked_server(NULL, name);
-}
-
 /* find_client()
  *
  * finds a client/server entry from the client hash table
@@ -612,8 +492,7 @@ find_server(struct Client *source_p, const char *name)
                                return target_p;
        }
 
-       /* wasnt found, look for a masked server */
-       return hash_find_masked_server(source_p, name);
+       return NULL;
 }
 
 /* find_hostname()
@@ -761,30 +640,6 @@ hash_find_resv(const char *name)
        return NULL;
 }
 
-struct cachefile *
-hash_find_help(const char *name, int flags)
-{
-       struct cachefile *hptr;
-       dlink_node *ptr;
-       unsigned int hashv;
-
-       if(EmptyString(name))
-               return NULL;
-
-       hashv = hash_help(name);
-
-       DLINK_FOREACH(ptr, helpTable[hashv].head)
-       {
-               hptr = ptr->data;
-
-               if((irccmp(name, hptr->name) == 0) &&
-                  (hptr->flags & flags))
-                       return hptr;
-       }
-
-       return NULL;
-}
-
 void
 clear_resv_hash(void)
 {
@@ -807,29 +662,6 @@ clear_resv_hash(void)
        HASH_WALK_END
 }
 
-struct nd_entry *
-hash_find_nd(const char *name)
-{
-       struct nd_entry *nd;
-       dlink_node *ptr;
-       unsigned int hashv;
-
-       if(EmptyString(name))
-               return NULL;
-
-       hashv = hash_nick(name);
-
-       DLINK_FOREACH(ptr, ndTable[hashv].head)
-       {
-               nd = ptr->data;
-
-               if(!irccmp(name, nd->name))
-                       return nd;
-       }
-
-       return NULL;
-}
-
 static void
 output_hash(struct Client *source_p, const char *name, int length, int *counts, int deepest)
 {