]>
jfr.im git - irc/quakenet/newserv.git/blob - nick/nick.h
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 "../patricia/patricia.h"
15 #include "../authext/authext.h"
20 #define MAXNICKEXTS 10
23 #define UMODE_INV 0x0001
24 #define UMODE_WALLOPS 0x0002
25 #define UMODE_DEBUG 0x0004
26 #define UMODE_OPER 0x0008
27 #define UMODE_SERVICE 0x0010
28 #define UMODE_XOPER 0x0020
29 #define UMODE_DEAF 0x0040
30 #define UMODE_ACCOUNT 0x0080
31 #define UMODE_HIDECHAN 0x0100
32 #define UMODE_HIDEHOST 0x0200
33 #define UMODE_SETHOST 0x0400
34 #define UMODE_REGPRIV 0x0800
35 #define UMODE_HIDEIDLE 0x1000
36 #define UMODE_PARANOID 0x2000
37 #define UMODE_CLOAKED 0x4000
39 #define UMODE_ALL 0x7FFF
41 #define AFLAG_STAFF 0x0001
42 #define AFLAG_SUPPORT 0x0002
43 #define AFLAG_OPER 0x0004
44 #define AFLAG_ADMIN 0x0008
45 #define AFLAG_DEVELOPER 0x0010
47 #define AFLAG_ALL 0x001F
49 #define IsInvisible(x) ((x)->umodes & UMODE_INV)
50 #define IsWallops(x) ((x)->umodes & UMODE_WALLOPS)
51 #define IsDebug(x) ((x)->umodes & UMODE_DEBUG)
52 #define IsOper(x) ((x)->umodes & UMODE_OPER)
53 #define IsService(x) ((x)->umodes & UMODE_SERVICE)
54 #define IsXOper(x) ((x)->umodes & UMODE_XOPER)
55 #define IsDeaf(x) ((x)->umodes & UMODE_DEAF)
56 #define IsAccount(x) ((x)->umodes & UMODE_ACCOUNT)
57 #define IsHideChan(x) ((x)->umodes & UMODE_HIDECHAN)
58 #define IsHideHost(x) ((x)->umodes & UMODE_HIDEHOST)
59 #define IsSetHost(x) ((x)->umodes & UMODE_SETHOST)
60 #define IsRegPriv(x) ((x)->umodes & UMODE_REGPRIV)
61 #define IsHideIdle(x) ((x)->umodes & UMODE_HIDEIDLE)
62 #define IsParanoid(x) ((x)->umodes & UMODE_PARANOID)
63 #define IsCloaked(x) ((x)->umodes & UMODE_CLOAKED)
65 #define SetInvisible(x) ((x)->umodes |= UMODE_INV)
66 #define SetWallops(x) ((x)->umodes |= UMODE_WALLOPS)
67 #define SetDebug(x) ((x)->umodes |= UMODE_DEBUG)
68 #define SetOper(x) ((x)->umodes |= UMODE_OPER)
69 #define SetService(x) ((x)->umodes |= UMODE_SERVICE)
70 #define SetXOper(x) ((x)->umodes |= UMODE_XOPER)
71 #define SetDeaf(x) ((x)->umodes |= UMODE_DEAF)
72 #define SetAccount(x) ((x)->umodes |= UMODE_ACCOUNT)
73 #define SetHideChan(x) ((x)->umodes |= UMODE_HIDECHAN)
74 #define SetHideHost(x) ((x)->umodes |= UMODE_HIDEHOST)
75 #define SetSetHost(x) ((x)->umodes |= UMODE_SETHOST)
76 #define SetRegPriv(x) ((x)->umodes |= UMODE_REGPRIV)
77 #define SetHideIdle(x) ((x)->umodes |= UMODE_HIDEIDLE)
78 #define SetParanoid(x) ((x)->umodes |= UMODE_PARANOID)
79 #define SetCloaked(x) ((x)->umodes |= UMODE_CLOAKED)
81 #define ClearInvisible(x) ((x)->umodes &= ~UMODE_INV)
82 #define ClearWallops(x) ((x)->umodes &= ~UMODE_WALLOPS)
83 #define ClearDebug(x) ((x)->umodes &= ~UMODE_DEBUG)
84 #define ClearOper(x) ((x)->umodes &= ~UMODE_OPER)
85 #define ClearService(x) ((x)->umodes &= ~UMODE_SERVICE)
86 #define ClearXOper(x) ((x)->umodes &= ~UMODE_XOPER)
87 #define ClearDeaf(x) ((x)->umodes &= ~UMODE_DEAF)
88 #define ClearAccount(x) ((x)->umodes &= ~UMODE_ACCOUNT)
89 #define ClearHideChan(x) ((x)->umodes &= ~UMODE_HIDECHAN)
90 #define ClearHideHost(x) ((x)->umodes &= ~UMODE_HIDEHOST)
91 #define ClearSetHost(x) ((x)->umodes &= ~UMODE_SETHOST)
92 #define ClearRegPriv(x) ((x)->umodes &= ~UMODE_REGPRIV)
93 #define ClearHideIdle(x) ((x)->umodes &= ~UMODE_HIDEIDLE)
94 #define ClearParanoid(x) ((x)->umodes &= ~UMODE_PARANOID)
95 #define ClearCloaked(x) ((x)->umodes &= ~UMODE_CLOAKED)
97 #define IsStaff(x) ((x)->flags & AFLAG_STAFF)
98 #define IsDeveloper(x) ((x)->flags & AFLAG_DEVELOPER)
99 #define IsSupport(x) ((x)->flags & AFLAG_SUPPORT)
100 #define IsAdmin(x) ((x)->flags & AFLAG_ADMIN)
101 #define IsOperFlag(x) ((x)->flags & AFLAG_OPER)
103 #define SetStaff(x) ((x)->flags |= AFLAG_STAFF)
104 #define SetDeveloper(x) ((x)->flags |= AFLAG_DEVELOPER)
105 #define SetSupport(x) ((x)->flags |= AFLAG_SUPPORT)
106 #define SetAdmin(x) ((x)->flags |= AFLAG_ADMIN)
107 #define SetOperFlag(x) ((x)->flags |= AFLAG_OPER)
109 #define ClearStaff(x) ((x)->flags &= ~AFLAG_STAFF)
110 #define ClearDeveloper(x) ((x)->flags &= ~AFLAG_DEVELOPER)
111 #define ClearSupport(x) ((x)->flags &= ~AFLAG_SUPPORT)
112 #define ClearAdmin(x) ((x)->flags &= ~AFLAG_ADMIN)
113 #define ClearOperFlag(x) ((x)->flags &= ~AFLAG_OPER)
115 #define NickOnServiceServer(target) SIsService(&serverlist[homeserver((target)->numeric)])
117 typedef struct host
{
125 typedef struct realname
{
130 struct realname
*next
;
133 typedef struct nick
{
134 char nick
[NICKLEN
+1];
136 char ident
[USERLEN
+1];
139 sstring
*shident
; /* +h users: fake ident/host goes here */
144 authname
*auth
; /* This requires User ID numbers to work */
148 struct irc_in_addr ipaddress
;
149 patricia_node_t
*ipnode
;
150 unsigned int cloak_count
;
151 struct nick
*cloak_extra
;
154 struct nick
*nextbyhost
;
155 struct nick
*nextbyrealname
;
156 struct nick
*nextbyauthname
;
157 /* These are extensions only used by other modules */
159 void *exts
[MAXNICKEXTS
];
162 #define NICKHASHSIZE 60000
163 #define HOSTHASHSIZE 40000
164 #define REALNAMEHASHSIZE 40000
166 extern nick
*nicktable
[NICKHASHSIZE
];
167 extern nick
**servernicks
[MAXSERVERS
];
168 extern host
*hosttable
[HOSTHASHSIZE
];
169 extern realname
*realnametable
[REALNAMEHASHSIZE
];
170 extern const flag umodeflags
[];
171 extern const flag accountflags
[];
172 extern char *NULLAUTHNAME
;
174 #define MAXNUMERIC 0x3FFFFFFF
176 #define homeserver(x) (((x)>>18)&(MAXSERVERS-1))
177 #define gethandlebynumericunsafe(x) (&(servernicks[homeserver(x)][(x)&(serverlist[homeserver(x)].maxusernum)]))
178 #define getnickbynumericunsafe(x) (servernicks[homeserver(x)][(x)&(serverlist[homeserver(x)].maxusernum)])
179 #define getnickbynumericstr(x) (getnickbynumeric(numerictolong((x),5)))
180 #define gethandlebynumeric(x) ((serverlist[homeserver(x)].linkstate==LS_INVALID) ? NULL : \
181 (gethandlebynumericunsafe(x)))
182 #define getnickbynumeric(x) ((gethandlebynumeric(x)==NULL)?NULL: \
183 ((*gethandlebynumeric(x)==NULL)?NULL: \
184 (((*gethandlebynumeric(x))->numeric==(x&MAXNUMERIC))?(*gethandlebynumeric(x)):NULL)))
186 /* nickalloc.c functions */
187 realname
*newrealname();
188 void freerealname(realname
*rn
);
190 void freenick(nick
*np
);
192 void freehost(host
*hp
);
194 /* nick.c functions */
195 void handleserverchange(int hooknum
, void *arg
);
196 void deletenick(nick
*np
);
197 void addnicktohash(nick
*np
);
198 void removenickfromhash(nick
*np
);
199 nick
*getnickbynick(const char *nick
);
200 int registernickext(const char *name
);
201 int findnickext(const char *name
);
202 void releasenickext(int index
);
203 char *visiblehostmask(nick
*np
, char *buf
);
204 char *visibleuserhost(nick
*np
, char *buf
);
205 int canseeuser(nick
*np
, nick
*cloaked
);
206 void addcloaktarget(nick
*cloaked
, nick
*target
);
207 void removecloaktarget(nick
*target
);
208 void clearcloaktargets(nick
*cloaked
);
210 /* nickhandlers.c functions */
211 int handlenickmsg(void *source
, int cargc
, char **cargv
);
212 int handlequitmsg(void *source
, int cargc
, char **cargv
);
213 int handlekillmsg(void *source
, int cargc
, char **cargv
);
214 int handleusermodemsg(void *source
, int cargc
, char **cargv
);
215 int handleaccountmsg(void *source
, int cargc
, char **cargv
);
216 int handleprivmsg(void *source
, int cargc
, char **cargv
);
217 int handleawaymsg(void *source
, int cargc
, char **cargv
);
218 int handleaddcloak(void *source
, int cargc
, char **cargv
);
219 int handleclearcloak(void *source
, int cargc
, char **cargv
);
221 /* These functions have been replaced by macros
222 nick **gethandlebynumeric(long numeric);
223 nick *getnickbynumeric(long numeric);
224 nick *getnickbynumericstr(char *numericstr);
227 /* nickhelpers.c functions */
228 void initnickhelpers();
229 void fininickhelpers();
230 host
*findhost(const char *hostname
);
231 host
*findorcreatehost(const char *hostname
);
232 void releasehost(host
*hp
);
233 realname
*findrealname(const char *name
);
234 realname
*findorcreaterealname(const char *name
);
235 void releaserealname(realname
*rnp
);
237 unsigned int nexthostmarker();
238 unsigned int nextrealnamemarker();
239 unsigned int nextnickmarker();