00001 00014 /* 00015 * Copyright (c) 1996-1997 Chip Norkus 00016 * Copyright (c) 1997 Max Byrd 00017 * Copyright (c) 1997 Greg Poma 00018 * All rights reserved. 00019 * 00020 * Redistribution and use in source and binary forms, with or without 00021 * modification, are permitted provided that the following conditions 00022 * are met: 00023 * 1. Redistributions of source code must retain the above copyright 00024 * notice, this list of conditions and the following disclaimer. 00025 * 2. Redistributions in binary form must reproduce the above copyright 00026 * notice, this list of conditions and the following disclaimer in the 00027 * documentation and/or other materials provided with the distribution. 00028 * 3. Neither the name of the authors nor the names of its contributors 00029 * may be used to endorse or promote products derived from this software 00030 * without specific prior written permission. 00031 * 00032 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 00033 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00034 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00035 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 00036 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00037 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00038 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00039 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00040 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00041 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00042 * SUCH DAMAGE. 00043 */ 00044 00045 /* 00046 * hash.c, simple hash table dealings.... 00047 */ 00048 #include "services.h" 00049 #include "queue.h" 00050 #include "nickserv.h" 00051 #include "hash.h" 00052 #include "chanserv.h" 00053 00054 UserHashEnt UserHash[NICKHASHSIZE]; 00055 RegNickHashEnt RegNickHash[NICKHASHSIZE]; 00056 RegNickIdHashEnt RegNickIdHash[IDHASHSIZE]; 00057 ChanHashEnt ChanHash[CHANHASHSIZE]; 00058 RegChanHashEnt RegChanHash[CHANHASHSIZE]; 00059 CloneHashEnt CloneHash[CLONEHASHSIZE]; 00060 ChanTrigHashEnt ChanTrigHash[CHANTRIGHASHSIZE]; 00061 00062 00068 u_int16_t 00069 getHashKey(const char *hname) 00070 { 00071 const u_char *name; 00072 u_int16_t hash; 00073 00074 hash = 0x5555; 00075 name = (const u_char *)hname; 00076 00077 if (!hname) { 00078 dlogEntry("getHashKey: hashing NULL, returning 0"); 00079 00080 return 0; 00081 } 00082 00083 for ( ; *name ; name++) { 00084 hash = (hash << 3) | (hash >> 13); 00085 hash ^= tolower(*name); 00086 } 00087 00088 return (hash); 00089 }