]> jfr.im git - irc/gameservirc.git/blame - gameserv/hash.cpp
Shrunk the dependencies immensely with forward declarations in all H files instead...
[irc/gameservirc.git] / gameserv / hash.cpp
CommitLineData
c260a8d7 1#include "extern.h"
821ea0a0 2#include <ctype.h>
c260a8d7 3
4unsigned long sHASH(const unsigned char *name);
5unsigned long iHASH(const unsigned char *name);
6List<aClient> players[U_TABLE_SIZE];
7
8unsigned long sHASH(const unsigned char *name)
9{
10 unsigned long h = 0, g;
11
12 while (*name)
13 {
14 h = (h << 4) + (*name++); // Case sensitive for numerics
15 if ((g = (h & 0xF0000000)))
16 h ^= g >> 24;
17 h &= ~g;
18 }
19 return h % U_TABLE_SIZE;
20}
21
22unsigned long iHASH(const unsigned char *name)
23{
24 unsigned long h = 0, g;
25
26 while (*name)
27 {
28 h = (h << 4) + tolower(*name++);
29 if ((g = (h & 0xF0000000)))
30 h ^= g >> 24;
31 h &= ~g;
32 }
33 return h % U_TABLE_SIZE;
34}
35
36