00001 /* 00002 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 00003 * hash.h: A header for the ircd hashtable code. 00004 * 00005 * Copyright (C) 2002 by the past and present ircd coders, and others. 00006 * 00007 * This program is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00020 * USA 00021 * 00022 * $Id: hash.h 33 2005-10-02 20:50:00Z knight $ 00023 */ 00024 00025 #ifndef INCLUDED_hash_h 00026 #define INCLUDED_hash_h 00027 00028 #define FNV1_32_INIT 0x811c9dc5 00029 #define FNV1_32_BITS 16 00030 #define FNV1_32_SIZE (1 << FNV1_32_BITS) /* 2^16 = 65536 */ 00031 #define HASHSIZE FNV1_32_SIZE 00032 00033 struct Client; 00034 struct Channel; 00035 struct ResvChannel; 00036 struct UserHost; 00037 00038 enum { 00039 HASH_TYPE_ID, 00040 HASH_TYPE_CLIENT, 00041 HASH_TYPE_CHANNEL, 00042 HASH_TYPE_USERHOST, 00043 HASH_TYPE_RESERVED 00044 }; 00045 00046 extern void init_hash(void); 00047 extern void hash_add_client(struct Client *); 00048 extern void hash_del_client(struct Client *); 00049 extern void hash_add_channel(struct Channel *); 00050 extern void hash_del_channel(struct Channel *); 00051 extern void hash_add_resv(struct ResvChannel *); 00052 extern void hash_del_resv(struct ResvChannel *); 00053 extern void hash_add_id(struct Client *); 00054 extern void hash_del_id(struct Client *); 00055 extern void hash_add_userhost(struct UserHost *); 00056 extern void hash_del_userhost(struct UserHost *); 00057 00058 extern struct UserHost *hash_find_userhost(const char *); 00059 extern struct Client *hash_find_id(const char *); 00060 extern struct Client *find_client(const char *); 00061 extern struct Client *find_server(const char *); 00062 extern struct Channel *hash_find_channel(const char *); 00063 extern void *hash_get_bucket(int, unsigned int); 00064 extern struct ResvChannel *hash_find_resv(const char *); 00065 00066 extern void free_list_task(struct ListTask *, struct Client *); 00067 extern void safe_list_channels(struct Client *, struct ListTask *, int, int); 00068 00069 extern unsigned int strhash(const char *); 00070 #endif /* INCLUDED_hash_h */