]> jfr.im git - irc/gameservirc.git/blob - gameserv/hash.cpp
updated the TODO
[irc/gameservirc.git] / gameserv / hash.cpp
1 #include "extern.h"
2 #include <ctype.h>
3
4 unsigned long sHASH(const unsigned char *name);
5 unsigned long iHASH(const unsigned char *name);
6 List<aClient> players[U_TABLE_SIZE];
7
8 unsigned 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
22 unsigned 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