]>
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"
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
38 #define UMODE_ALL 0x3FFF
40 #define AFLAG_STAFF 0x0001
41 #define AFLAG_DEVELOPER 0x0002
43 #define IsInvisible(x) ((x)->umodes & UMODE_INV)
44 #define IsWallops(x) ((x)->umodes & UMODE_WALLOPS)
45 #define IsDebug(x) ((x)->umodes & UMODE_DEBUG)
46 #define IsOper(x) ((x)->umodes & UMODE_OPER)
47 #define IsService(x) ((x)->umodes & UMODE_SERVICE)
48 #define IsXOper(x) ((x)->umodes & UMODE_XOPER)
49 #define IsDeaf(x) ((x)->umodes & UMODE_DEAF)
50 #define IsAccount(x) ((x)->umodes & UMODE_ACCOUNT)
51 #define IsHideChan(x) ((x)->umodes & UMODE_HIDECHAN)
52 #define IsHideHost(x) ((x)->umodes & UMODE_HIDEHOST)
53 #define IsSetHost(x) ((x)->umodes & UMODE_SETHOST)
54 #define IsRegPriv(x) ((x)->umodes & UMODE_REGPRIV)
55 #define IsHideIdle(x) ((x)->umodes & UMODE_HIDEIDLE)
56 #define IsParanoid(x) ((x)->umodes & UMODE_PARANOID)
58 #define SetInvisible(x) ((x)->umodes |= UMODE_INV)
59 #define SetWallops(x) ((x)->umodes |= UMODE_WALLOPS)
60 #define SetDebug(x) ((x)->umodes |= UMODE_DEBUG)
61 #define SetOper(x) ((x)->umodes |= UMODE_OPER)
62 #define SetService(x) ((x)->umodes |= UMODE_SERVICE)
63 #define SetXOper(x) ((x)->umodes |= UMODE_XOPER)
64 #define SetDeaf(x) ((x)->umodes |= UMODE_DEAF)
65 #define SetAccount(x) ((x)->umodes |= UMODE_ACCOUNT)
66 #define SetHideChan(x) ((x)->umodes |= UMODE_HIDECHAN)
67 #define SetHideHost(x) ((x)->umodes |= UMODE_HIDEHOST)
68 #define SetSetHost(x) ((x)->umodes |= UMODE_SETHOST)
69 #define SetRegPriv(x) ((x)->umodes |= UMODE_REGPRIV)
70 #define SetHideIdle(x) ((x)->umodes |= UMODE_HIDEIDLE)
71 #define SetParanoid(x) ((x)->umodes |= UMODE_PARANOID)
73 #define ClearInvisible(x) ((x)->umodes &= ~UMODE_INV)
74 #define ClearWallops(x) ((x)->umodes &= ~UMODE_WALLOPS)
75 #define ClearDebug(x) ((x)->umodes &= ~UMODE_DEBUG)
76 #define ClearOper(x) ((x)->umodes &= ~UMODE_OPER)
77 #define ClearService(x) ((x)->umodes &= ~UMODE_SERVICE)
78 #define ClearXOper(x) ((x)->umodes &= ~UMODE_XOPER)
79 #define ClearDeaf(x) ((x)->umodes &= ~UMODE_DEAF)
80 #define ClearAccount(x) ((x)->umodes &= ~UMODE_ACCOUNT)
81 #define ClearHideChan(x) ((x)->umodes &= ~UMODE_HIDECHAN)
82 #define ClearHideHost(x) ((x)->umodes &= ~UMODE_HIDEHOST)
83 #define ClearSetHost(x) ((x)->umodes &= ~UMODE_SETHOST)
84 #define ClearRegPriv(x) ((x)->umodes &= ~UMODE_REGPRIV)
85 #define ClearHideIdle(x) ((x)->umodes &= ~UMODE_HIDEIDLE)
86 #define ClearParanoid(x) ((x)->umodes &= ~UMODE_PARANOID)
88 #define IsStaff(x) ((x)->umodes & AFLAG_STAFF)
89 #define IsDeveloper(x) ((x)->umodes & AFLAG_DEVELOPER)
91 #define SetStaff(x) ((x)->umodes |= AFLAG_STAFF)
92 #define SetDeveloper(x) ((x)->umodes |= AFLAG_DEVELOPER)
94 #define ClearStaff(x) ((x)->umodes &= ~AFLAG_STAFF)
95 #define ClearDeveloper(x) ((x)->umodes &= ~AFLAG_DEVELOPER)
105 typedef struct realname
{
110 struct realname
*next
;
113 typedef struct nick
{
114 char nick
[NICKLEN
+1];
116 char ident
[USERLEN
+1];
119 sstring
*shident
; /* +h users: fake ident/host goes here */
122 char authname
[ACCOUNTLEN
+1];
123 authname
*auth
; /* This requires User ID numbers to work */
127 patricia_node_t
*ipnode
;
130 struct nick
*nextbyhost
;
131 struct nick
*nextbyrealname
;
132 struct nick
*nextbyauthname
;
133 /* These are extensions only used by other modules */
135 void *exts
[MAXNICKEXTS
];
138 #define p_ipaddr ipnode->prefix->sin
140 #define NICKHASHSIZE 60000
141 #define HOSTHASHSIZE 40000
142 #define REALNAMEHASHSIZE 40000
144 extern nick
*nicktable
[NICKHASHSIZE
];
145 extern nick
**servernicks
[MAXSERVERS
];
146 extern host
*hosttable
[HOSTHASHSIZE
];
147 extern realname
*realnametable
[REALNAMEHASHSIZE
];
148 extern const flag umodeflags
[];
149 extern const flag accountflags
[];
151 #define MAXNUMERIC 0x3FFFFFFF
153 #define homeserver(x) (((x)>>18)&(MAXSERVERS-1))
154 #define gethandlebynumericunsafe(x) (&(servernicks[homeserver(x)][(x)&(serverlist[homeserver(x)].maxusernum)]))
155 #define getnickbynumericunsafe(x) (servernicks[homeserver(x)][(x)&(serverlist[homeserver(x)].maxusernum)])
156 #define getnickbynumericstr(x) (getnickbynumeric(numerictolong((x),5)))
157 #define gethandlebynumeric(x) ((serverlist[homeserver(x)].linkstate==LS_INVALID) ? NULL : \
158 (gethandlebynumericunsafe(x)))
159 #define getnickbynumeric(x) ((gethandlebynumeric(x)==NULL)?NULL: \
160 ((*gethandlebynumeric(x)==NULL)?NULL: \
161 (((*gethandlebynumeric(x))->numeric==(x&MAXNUMERIC))?(*gethandlebynumeric(x)):NULL)))
163 /* nickalloc.c functions */
164 void initnickalloc();
165 realname
*newrealname();
166 void freerealname(realname
*rn
);
168 void freenick (nick
*np
);
170 void freehost (host
*hp
);
172 /* nick.c functions */
173 void handleserverchange(int hooknum
, void *arg
);
174 void deletenick(nick
*np
);
175 void addnicktohash(nick
*np
);
176 void removenickfromhash(nick
*np
);
177 nick
*getnickbynick(const char *nick
);
178 int registernickext(const char *name
);
179 int findnickext(const char *name
);
180 void releasenickext(int index
);
181 char *visiblehostmask(nick
*np
, char *buf
);
182 char *visibleuserhost(nick
*np
, char *buf
);
184 /* nickhandlers.c functions */
185 int handlenickmsg(void *source
, int cargc
, char **cargv
);
186 int handlequitmsg(void *source
, int cargc
, char **cargv
);
187 int handlekillmsg(void *source
, int cargc
, char **cargv
);
188 int handleusermodemsg(void *source
, int cargc
, char **cargv
);
189 int handlewhoismsg(void *source
, int cargc
, char **cargv
);
190 int handleaccountmsg(void *source
, int cargc
, char **cargv
);
191 int handlestatsmsg(void *source
, int cargc
, char **cargv
);
193 /* These functions have been replaced by macros
194 nick **gethandlebynumeric(long numeric);
195 nick *getnickbynumeric(long numeric);
196 nick *getnickbynumericstr(char *numericstr);
199 /* nickhelpers.c functions */
200 void initnickhelpers();
201 void fininickhelpers();
202 host
*findhost(const char *hostname
);
203 host
*findorcreatehost(const char *hostname
);
204 void releasehost(host
*hp
);
205 realname
*findrealname(const char *name
);
206 realname
*findorcreaterealname(const char *name
);
207 void releaserealname(realname
*rnp
);
209 unsigned int nexthostmarker();
210 unsigned int nextrealnamemarker();
211 unsigned int nextnickmarker();