]>
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
38 #define UMODE_COMCHANS 0x8000
39 #define UMODE_COMCHANSRESTR 0x10000
41 #define UMODE_ALL 0x1FFFF
43 #define AFLAG_STAFF 0x0001
44 #define AFLAG_SUPPORT 0x0002
45 #define AFLAG_OPER 0x0004
46 #define AFLAG_ADMIN 0x0008
47 #define AFLAG_DEVELOPER 0x0010
49 #define AFLAG_ALL 0x001F
51 #define IsInvisible(x) ((x)->umodes & UMODE_INV)
52 #define IsWallops(x) ((x)->umodes & UMODE_WALLOPS)
53 #define IsDebug(x) ((x)->umodes & UMODE_DEBUG)
54 #define IsOper(x) ((x)->umodes & UMODE_OPER)
55 #define IsService(x) ((x)->umodes & UMODE_SERVICE)
56 #define IsXOper(x) ((x)->umodes & UMODE_XOPER)
57 #define IsDeaf(x) ((x)->umodes & UMODE_DEAF)
58 #define IsAccount(x) ((x)->umodes & UMODE_ACCOUNT)
59 #define IsHideChan(x) ((x)->umodes & UMODE_HIDECHAN)
60 #define IsHideHost(x) ((x)->umodes & UMODE_HIDEHOST)
61 #define IsSetHost(x) ((x)->umodes & UMODE_SETHOST)
62 #define IsRegPriv(x) ((x)->umodes & UMODE_REGPRIV)
63 #define IsHideIdle(x) ((x)->umodes & UMODE_HIDEIDLE)
64 #define IsParanoid(x) ((x)->umodes & UMODE_PARANOID)
65 #define IsComChans(x) ((x)->umodes & UMODE_COMCHANS)
66 #define IsComChansRestr(x) ((x)->umodes & UMODE_COMCHANSRESTR)
67 #define IsCloaked(x) ((x)->umodes & UMODE_CLOAKED)
69 #define SetInvisible(x) ((x)->umodes |= UMODE_INV)
70 #define SetWallops(x) ((x)->umodes |= UMODE_WALLOPS)
71 #define SetDebug(x) ((x)->umodes |= UMODE_DEBUG)
72 #define SetOper(x) ((x)->umodes |= UMODE_OPER)
73 #define SetService(x) ((x)->umodes |= UMODE_SERVICE)
74 #define SetXOper(x) ((x)->umodes |= UMODE_XOPER)
75 #define SetDeaf(x) ((x)->umodes |= UMODE_DEAF)
76 #define SetAccount(x) ((x)->umodes |= UMODE_ACCOUNT)
77 #define SetHideChan(x) ((x)->umodes |= UMODE_HIDECHAN)
78 #define SetHideHost(x) ((x)->umodes |= UMODE_HIDEHOST)
79 #define SetSetHost(x) ((x)->umodes |= UMODE_SETHOST)
80 #define SetRegPriv(x) ((x)->umodes |= UMODE_REGPRIV)
81 #define SetHideIdle(x) ((x)->umodes |= UMODE_HIDEIDLE)
82 #define SetParanoid(x) ((x)->umodes |= UMODE_PARANOID)
83 #define SetComChans(x) ((x)->umodes |= UMODE_COMCHANS)
84 #define SetComChansRestr(x) ((x)->umodes |= UMODE_COMCHANSRESTR)
85 #define SetCloaked(x) ((x)->umodes |= UMODE_CLOAKED)
87 #define ClearInvisible(x) ((x)->umodes &= ~UMODE_INV)
88 #define ClearWallops(x) ((x)->umodes &= ~UMODE_WALLOPS)
89 #define ClearDebug(x) ((x)->umodes &= ~UMODE_DEBUG)
90 #define ClearOper(x) ((x)->umodes &= ~UMODE_OPER)
91 #define ClearService(x) ((x)->umodes &= ~UMODE_SERVICE)
92 #define ClearXOper(x) ((x)->umodes &= ~UMODE_XOPER)
93 #define ClearDeaf(x) ((x)->umodes &= ~UMODE_DEAF)
94 #define ClearAccount(x) ((x)->umodes &= ~UMODE_ACCOUNT)
95 #define ClearHideChan(x) ((x)->umodes &= ~UMODE_HIDECHAN)
96 #define ClearHideHost(x) ((x)->umodes &= ~UMODE_HIDEHOST)
97 #define ClearSetHost(x) ((x)->umodes &= ~UMODE_SETHOST)
98 #define ClearRegPriv(x) ((x)->umodes &= ~UMODE_REGPRIV)
99 #define ClearHideIdle(x) ((x)->umodes &= ~UMODE_HIDEIDLE)
100 #define ClearParanoid(x) ((x)->umodes &= ~UMODE_PARANOID)
101 #define ClearComChans(x) ((x)->umodes &= ~UMODE_COMCHANS)
102 #define ClearComChansRestr(x) ((x)->umodes &= ~UMODE_COMCHANSRESTR)
103 #define ClearCloaked(x) ((x)->umodes &= ~UMODE_CLOAKED)
105 #define IsStaff(x) ((x)->flags & AFLAG_STAFF)
106 #define IsDeveloper(x) ((x)->flags & AFLAG_DEVELOPER)
107 #define IsSupport(x) ((x)->flags & AFLAG_SUPPORT)
108 #define IsAdmin(x) ((x)->flags & AFLAG_ADMIN)
109 #define IsOperFlag(x) ((x)->flags & AFLAG_OPER)
111 #define SetStaff(x) ((x)->flags |= AFLAG_STAFF)
112 #define SetDeveloper(x) ((x)->flags |= AFLAG_DEVELOPER)
113 #define SetSupport(x) ((x)->flags |= AFLAG_SUPPORT)
114 #define SetAdmin(x) ((x)->flags |= AFLAG_ADMIN)
115 #define SetOperFlag(x) ((x)->flags |= AFLAG_OPER)
117 #define ClearStaff(x) ((x)->flags &= ~AFLAG_STAFF)
118 #define ClearDeveloper(x) ((x)->flags &= ~AFLAG_DEVELOPER)
119 #define ClearSupport(x) ((x)->flags &= ~AFLAG_SUPPORT)
120 #define ClearAdmin(x) ((x)->flags &= ~AFLAG_ADMIN)
121 #define ClearOperFlag(x) ((x)->flags &= ~AFLAG_OPER)
123 #define NickOnServiceServer(target) SIsService(&serverlist[homeserver((target)->numeric)])
125 typedef struct host
{
133 typedef struct realname
{
138 struct realname
*next
;
141 typedef struct nick
{
142 char nick
[NICKLEN
+1];
144 char ident
[USERLEN
+1];
147 sstring
*shident
; /* +h users: fake ident/host goes here */
152 authname
*auth
; /* This requires User ID numbers to work */
156 struct irc_in_addr ipaddress
;
157 patricia_node_t
*ipnode
;
158 unsigned int cloak_count
;
159 struct nick
*cloak_extra
;
162 struct nick
*nextbyhost
;
163 struct nick
*nextbyrealname
;
164 struct nick
*nextbyauthname
;
165 /* These are extensions only used by other modules */
168 void *exts
[MAXNICKEXTS
];
171 #define NICKHASHSIZE 60000
172 #define HOSTHASHSIZE 40000
173 #define REALNAMEHASHSIZE 40000
175 extern nick
*nicktable
[NICKHASHSIZE
];
176 extern nick
**servernicks
[MAXSERVERS
];
177 extern host
*hosttable
[HOSTHASHSIZE
];
178 extern realname
*realnametable
[REALNAMEHASHSIZE
];
179 extern const flag umodeflags
[];
180 extern const flag accountflags
[];
181 extern char *NULLAUTHNAME
;
183 #define MAXNUMERIC 0x3FFFFFFF
185 #define homeserver(x) (((x)>>18)&(MAXSERVERS-1))
186 #define gethandlebynumericunsafe(x) (&(servernicks[homeserver(x)][(x)&(serverlist[homeserver(x)].maxusernum)]))
187 #define getnickbynumericunsafe(x) (servernicks[homeserver(x)][(x)&(serverlist[homeserver(x)].maxusernum)])
188 #define getnickbynumericstr(x) (getnickbynumeric(numerictolong((x),5)))
189 #define gethandlebynumeric(x) ((serverlist[homeserver(x)].linkstate==LS_INVALID) ? NULL : \
190 (gethandlebynumericunsafe(x)))
191 #define getnickbynumeric(x) ((gethandlebynumeric(x)==NULL)?NULL: \
192 ((*gethandlebynumeric(x)==NULL)?NULL: \
193 (((*gethandlebynumeric(x))->numeric==(x&MAXNUMERIC))?(*gethandlebynumeric(x)):NULL)))
195 /* nickalloc.c functions */
196 realname
*newrealname();
197 void freerealname(realname
*rn
);
199 void freenick(nick
*np
);
201 void freehost(host
*hp
);
203 /* nick.c functions */
204 void handleserverchange(int hooknum
, void *arg
);
205 void deletenick(nick
*np
);
206 void addnicktohash(nick
*np
);
207 void removenickfromhash(nick
*np
);
208 nick
*getnickbynick(const char *nick
);
209 int registernickext(const char *name
);
210 int findnickext(const char *name
);
211 void releasenickext(int index
);
212 char *visiblehostmask(nick
*np
, char *buf
);
213 char *visibleuserhost(nick
*np
, char *buf
);
214 int canseeuser(nick
*np
, nick
*cloaked
);
215 void addcloaktarget(nick
*cloaked
, nick
*target
);
216 void removecloaktarget(nick
*target
);
217 void clearcloaktargets(nick
*cloaked
);
219 /* nickhandlers.c functions */
220 int handlenickmsg(void *source
, int cargc
, char **cargv
);
221 int handlequitmsg(void *source
, int cargc
, char **cargv
);
222 int handlekillmsg(void *source
, int cargc
, char **cargv
);
223 int handleusermodemsg(void *source
, int cargc
, char **cargv
);
224 int handleaccountmsg(void *source
, int cargc
, char **cargv
);
225 int handleprivmsg(void *source
, int cargc
, char **cargv
);
226 int handleawaymsg(void *source
, int cargc
, char **cargv
);
227 int handleaddcloak(void *source
, int cargc
, char **cargv
);
228 int handleclearcloak(void *source
, int cargc
, char **cargv
);
230 /* These functions have been replaced by macros
231 nick **gethandlebynumeric(long numeric);
232 nick *getnickbynumeric(long numeric);
233 nick *getnickbynumericstr(char *numericstr);
236 /* nickhelpers.c functions */
237 void initnickhelpers();
238 void fininickhelpers();
239 host
*findhost(const char *hostname
);
240 host
*findorcreatehost(const char *hostname
);
241 void releasehost(host
*hp
);
242 realname
*findrealname(const char *name
);
243 realname
*findorcreaterealname(const char *name
);
244 void releaserealname(realname
*rnp
);
246 unsigned int nexthostmarker();
247 unsigned int nextrealnamemarker();
248 unsigned int nextnickmarker();