ircu2.10.12 pk910 fork
[ircu2.10.12-pk.git] / include / whowas.h
1 /*
2  * IRC - Internet Relay Chat, include/whowas.h
3  * Copyright (C) 1990 Markku Savela
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 1, or (at your option)
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 /** @file
20  * @brief Globally visible declarations to manipulate whowas information.
21  * @version $Id: whowas.h 1229 2004-10-05 04:14:44Z entrope $
22  */
23 #ifndef INCLUDED_whowas_h
24 #define INCLUDED_whowas_h
25 #ifndef INCLUDED_sys_types_h
26 #include <sys/types.h>        /* size_t */
27 #define INCLUDED_sys_types_h
28 #endif
29
30 struct Client;
31
32 /*
33  * General defines
34  */
35
36 #define BITS_PER_COL            3   /**< Magic number used by whowas hash function. */
37 #define BITS_PER_COL_MASK       0x7 /**< Mask with #BITS_PER_COL least significant bits set. */
38 #define WW_MAX_INITIAL          16  /**< Magic number used by whowas hash function. */
39
40 #define MAX_SUB (1 << BITS_PER_COL) /**< Magic number used by whowas hash function. */
41 #define WW_MAX_INITIAL_MASK (WW_MAX_INITIAL - 1) /**< Magic number used by whowas hash function. */
42 #define WW_MAX (WW_MAX_INITIAL * MAX_SUB) /**< Size of whowas hash table. */
43
44 /*
45  * Structures
46  */
47
48 /** Tracks previously used nicknames. */
49 struct Whowas {
50   unsigned int hashv;           /**< Hash value for nickname. */
51   char *name;                   /**< Client's old nickname. */
52   char *username;               /**< Client's username. */
53   char *hostname;               /**< Client's hostname. */
54   char *realhost;               /**< Client's real hostname. */
55   char *servername;             /**< Name of client's server. */
56   char *realname;               /**< Client's realname (user info). */
57   char *away;                   /**< Client's away message. */
58   time_t logoff;                /**< When the client logged off. */
59   struct Client *online;        /**< Needed for get_history() (nick chasing). */
60   struct Whowas *hnext;         /**< Next entry with the same hash value. */
61   struct Whowas **hprevnextp;   /**< Pointer to previous next pointer. */
62   struct Whowas *cnext;         /**< Next entry with the same 'online' pointer. */
63   struct Whowas **cprevnextp;   /**< Pointer to previous next pointer. */
64   struct Whowas *wnext;         /**< Next entry in whowas linked list. */
65   struct Whowas *wprev;         /**< Pointer to previous next pointer. */
66 };
67
68 /*
69  * Proto types
70  */
71 extern struct Whowas* whowashash[];
72
73 extern unsigned int hash_whowas_name(const char *name);
74
75 extern struct Client *get_history(const char *nick, time_t timelimit);
76 extern void add_history(struct Client *cptr, int still_on);
77 extern void off_history(const struct Client *cptr);
78 extern void initwhowas(void);
79 extern void count_whowas_memory(int *wwu, size_t *wwm, int *wwa, size_t *wwam);
80
81 extern void whowas_realloc(void);
82
83 #endif /* INCLUDED_whowas_h */