]>
jfr.im git - irc/quakenet/newserv.git/blob - nick/nick.h
f57cbc5f746e5df047f381a91fe9998632b0a107
6 #include "../lib/sstring.h"
7 #include "../irc/irc_config.h"
8 #include "../lib/flags.h"
9 #include "../lib/array.h"
10 #include "../server/server.h"
11 #include "../lib/base64.h"
12 #include "../lib/irc_ipv6.h"
13 #include "../lib/patricia.h"
17 #define MAXAUTHNAMEEXTS 5
19 #define UMODE_INV 0x0001
20 #define UMODE_WALLOPS 0x0002
21 #define UMODE_DEBUG 0x0004
22 #define UMODE_OPER 0x0008
23 #define UMODE_SERVICE 0x0010
24 #define UMODE_XOPER 0x0020
25 #define UMODE_DEAF 0x0040
26 #define UMODE_ACCOUNT 0x0080
27 #define UMODE_HIDECHAN 0x0100
28 #define UMODE_HIDEHOST 0x0200
29 #define UMODE_SETHOST 0x0400
30 #define UMODE_REGPRIV 0x0800
31 #define UMODE_HIDEIDLE 0x1000
33 #define UMODE_ALL 0x1FFF
35 #define IsInvisible(x) ((x)->umodes & UMODE_INV)
36 #define IsWallops(x) ((x)->umodes & UMODE_WALLOPS)
37 #define IsDebug(x) ((x)->umodes & UMODE_DEBUG)
38 #define IsOper(x) ((x)->umodes & UMODE_OPER)
39 #define IsService(x) ((x)->umodes & UMODE_SERVICE)
40 #define IsXOper(x) ((x)->umodes & UMODE_XOPER)
41 #define IsDeaf(x) ((x)->umodes & UMODE_DEAF)
42 #define IsAccount(x) ((x)->umodes & UMODE_ACCOUNT)
43 #define IsHideChan(x) ((x)->umodes & UMODE_HIDECHAN)
44 #define IsHideHost(x) ((x)->umodes & UMODE_HIDEHOST)
45 #define IsSetHost(x) ((x)->umodes & UMODE_SETHOST)
46 #define IsRegPriv(x) ((x)->umodes & UMODE_REGPRIV)
47 #define IsHideIdle(x) ((x)->umodes & UMODE_HIDEIDLE)
49 #define SetInvisible(x) ((x)->umodes |= UMODE_INV)
50 #define SetWallops(x) ((x)->umodes |= UMODE_WALLOPS)
51 #define SetDebug(x) ((x)->umodes |= UMODE_DEBUG)
52 #define SetOper(x) ((x)->umodes |= UMODE_OPER)
53 #define SetService(x) ((x)->umodes |= UMODE_SERVICE)
54 #define SetXOper(x) ((x)->umodes |= UMODE_XOPER)
55 #define SetDeaf(x) ((x)->umodes |= UMODE_DEAF)
56 #define SetAccount(x) ((x)->umodes |= UMODE_ACCOUNT)
57 #define SetHideChan(x) ((x)->umodes |= UMODE_HIDECHAN)
58 #define SetHideHost(x) ((x)->umodes |= UMODE_HIDEHOST)
59 #define SetSetHost(x) ((x)->umodes |= UMODE_SETHOST)
60 #define SetRegPriv(x) ((x)->umodes |= UMODE_REGPRIV)
61 #define SetHideIdle(x) ((x)->umodes |= UMODE_HIDEIDLE)
63 #define ClearInvisible(x) ((x)->umodes &= ~UMODE_INV)
64 #define ClearWallops(x) ((x)->umodes &= ~UMODE_WALLOPS)
65 #define ClearDebug(x) ((x)->umodes &= ~UMODE_DEBUG)
66 #define ClearOper(x) ((x)->umodes &= ~UMODE_OPER)
67 #define ClearService(x) ((x)->umodes &= ~UMODE_SERVICE)
68 #define ClearXOper(x) ((x)->umodes &= ~UMODE_XOPER)
69 #define ClearDeaf(x) ((x)->umodes &= ~UMODE_DEAF)
70 #define ClearAccount(x) ((x)->umodes &= ~UMODE_ACCOUNT)
71 #define ClearHideChan(x) ((x)->umodes &= ~UMODE_HIDECHAN)
72 #define ClearHideHost(x) ((x)->umodes &= ~UMODE_HIDEHOST)
73 #define ClearSetHost(x) ((x)->umodes &= ~UMODE_SETHOST)
74 #define ClearRegPriv(x) ((x)->umodes &= ~UMODE_REGPRIV)
75 #define ClearHideIdle(x) ((x)->umodes &= ~UMODE_HIDEIDLE)
85 typedef struct realname
{
90 struct realname
*next
;
93 typedef struct authname
{
98 struct authname
*next
;
99 /* These are extensions only used by other modules */
100 void *exts
[MAXAUTHNAMEEXTS
];
103 typedef struct nick
{
104 char nick
[NICKLEN
+1];
106 char ident
[USERLEN
+1];
109 sstring
*shident
; /* +h users: fake ident/host goes here */
112 char authname
[ACCOUNTLEN
+1];
113 authname
*auth
; /* This requires User ID numbers to work */
116 patricia_node_t
*ipnode
;
119 struct nick
*nextbyhost
;
120 struct nick
*nextbyrealname
;
121 struct nick
*nextbyauthname
;
122 /* These are extensions only used by other modules */
124 void *exts
[MAXNICKEXTS
];
127 #define p_ipaddr ipnode->prefix->sin
129 #define NICKHASHSIZE 60000
130 #define HOSTHASHSIZE 40000
131 #define REALNAMEHASHSIZE 40000
132 #define AUTHNAMEHASHSIZE 60000
134 extern nick
*nicktable
[NICKHASHSIZE
];
135 extern nick
**servernicks
[MAXSERVERS
];
136 extern host
*hosttable
[HOSTHASHSIZE
];
137 extern realname
*realnametable
[REALNAMEHASHSIZE
];
138 extern authname
*authnametable
[AUTHNAMEHASHSIZE
];
139 extern const flag umodeflags
[];
140 extern patricia_tree_t
*iptree
;
142 #define MAXNUMERIC 0x3FFFFFFF
144 #define homeserver(x) (((x)>>18)&(MAXSERVERS-1))
145 #define gethandlebynumericunsafe(x) (&(servernicks[homeserver(x)][(x)&(serverlist[homeserver(x)].maxusernum)]))
146 #define getnickbynumericunsafe(x) (servernicks[homeserver(x)][(x)&(serverlist[homeserver(x)].maxusernum)])
147 #define getnickbynumericstr(x) (getnickbynumeric(numerictolong((x),5)))
148 #define gethandlebynumeric(x) ((serverlist[homeserver(x)].linkstate==LS_INVALID) ? NULL : \
149 (gethandlebynumericunsafe(x)))
150 #define getnickbynumeric(x) ((gethandlebynumeric(x)==NULL)?NULL: \
151 ((*gethandlebynumeric(x)==NULL)?NULL: \
152 (((*gethandlebynumeric(x))->numeric==(x&MAXNUMERIC))?(*gethandlebynumeric(x)):NULL)))
154 /* nickalloc.c functions */
155 void initnickalloc();
156 realname
*newrealname();
157 void freerealname(realname
*rn
);
159 void freenick (nick
*np
);
161 void freehost (host
*hp
);
162 authname
*newauthname();
163 void freeauthname (authname
*hp
);
165 /* nick.c functions */
166 void handleserverchange(int hooknum
, void *arg
);
167 void deletenick(nick
*np
);
168 void addnicktohash(nick
*np
);
169 void removenickfromhash(nick
*np
);
170 nick
*getnickbynick(const char *nick
);
171 int registernickext(const char *name
);
172 int findnickext(const char *name
);
173 void releasenickext(int index
);
174 int registerauthnameext(const char *name
);
175 int findauthnameext(const char *name
);
176 void releaseauthnameext(int index
);
177 char *visiblehostmask(nick
*np
, char *buf
);
178 int registernodeext(const char *name
);
179 int findnodeext(const char *name
);
180 void releasenodeext(int index
);
182 /* nickhandlers.c functions */
183 int handlenickmsg(void *source
, int cargc
, char **cargv
);
184 int handlequitmsg(void *source
, int cargc
, char **cargv
);
185 int handlekillmsg(void *source
, int cargc
, char **cargv
);
186 int handleusermodemsg(void *source
, int cargc
, char **cargv
);
187 int handlewhoismsg(void *source
, int cargc
, char **cargv
);
188 int handleaccountmsg(void *source
, int cargc
, char **cargv
);
189 int handlestatsmsg(void *source
, int cargc
, char **cargv
);
191 /* These functions have been replaced by macros
192 nick **gethandlebynumeric(long numeric);
193 nick *getnickbynumeric(long numeric);
194 nick *getnickbynumericstr(char *numericstr);
197 /* nickhelpers.c functions */
198 void initnickhelpers();
199 host
*findhost(const char *hostname
);
200 host
*findorcreatehost(const char *hostname
);
201 void releasehost(host
*hp
);
202 realname
*findrealname(const char *name
);
203 realname
*findorcreaterealname(const char *name
);
204 void releaserealname(realname
*rnp
);
205 authname
*findauthname(unsigned long userid
);
206 authname
*findorcreateauthname(unsigned long userid
);
207 void releaseauthname(authname
*anp
);
209 unsigned int nexthostmarker();
210 unsigned int nextrealnamemarker();
211 unsigned int nextauthnamemarker();
212 unsigned int nextnickmarker();