#include "../lib/array.h"
#include "../server/server.h"
#include "../lib/base64.h"
+#include "../lib/irc_ipv6.h"
+#include "../patricia/patricia.h"
+
+#include "../authext/authext.h"
+
#include <time.h>
-#define MAXNICKEXTS 5
-#define MAXAUTHNAMEEXTS 5
+#ifndef MAXNICKEXTS
+#define MAXNICKEXTS 6
+#endif
#define UMODE_INV 0x0001
#define UMODE_WALLOPS 0x0002
#define UMODE_SETHOST 0x0400
#define UMODE_REGPRIV 0x0800
#define UMODE_HIDEIDLE 0x1000
+#define UMODE_PARANOID 0x2000
-#define UMODE_ALL 0x1FFF
+#define UMODE_ALL 0x3FFF
+
+#define AFLAG_STAFF 0x0001
+#define AFLAG_SUPPORT 0x0002
+#define AFLAG_OPER 0x0004
+#define AFLAG_ADMIN 0x0008
+#define AFLAG_DEVELOPER 0x0010
+
+#define AFLAG_ALL 0x001F
#define IsInvisible(x) ((x)->umodes & UMODE_INV)
#define IsWallops(x) ((x)->umodes & UMODE_WALLOPS)
#define IsSetHost(x) ((x)->umodes & UMODE_SETHOST)
#define IsRegPriv(x) ((x)->umodes & UMODE_REGPRIV)
#define IsHideIdle(x) ((x)->umodes & UMODE_HIDEIDLE)
+#define IsParanoid(x) ((x)->umodes & UMODE_PARANOID)
#define SetInvisible(x) ((x)->umodes |= UMODE_INV)
#define SetWallops(x) ((x)->umodes |= UMODE_WALLOPS)
#define SetSetHost(x) ((x)->umodes |= UMODE_SETHOST)
#define SetRegPriv(x) ((x)->umodes |= UMODE_REGPRIV)
#define SetHideIdle(x) ((x)->umodes |= UMODE_HIDEIDLE)
+#define SetParanoid(x) ((x)->umodes |= UMODE_PARANOID)
#define ClearInvisible(x) ((x)->umodes &= ~UMODE_INV)
#define ClearWallops(x) ((x)->umodes &= ~UMODE_WALLOPS)
#define ClearSetHost(x) ((x)->umodes &= ~UMODE_SETHOST)
#define ClearRegPriv(x) ((x)->umodes &= ~UMODE_REGPRIV)
#define ClearHideIdle(x) ((x)->umodes &= ~UMODE_HIDEIDLE)
+#define ClearParanoid(x) ((x)->umodes &= ~UMODE_PARANOID)
+
+#define IsStaff(x) ((x)->flags & AFLAG_STAFF)
+#define IsDeveloper(x) ((x)->flags & AFLAG_DEVELOPER)
+#define IsSupport(x) ((x)->flags & AFLAG_SUPPORT)
+#define IsAdmin(x) ((x)->flags & AFLAG_ADMIN)
+#define IsOperFlag(x) ((x)->flags & AFLAG_OPER)
+
+#define SetStaff(x) ((x)->flags |= AFLAG_STAFF)
+#define SetDeveloper(x) ((x)->flags |= AFLAG_DEVELOPER)
+#define SetSupport(x) ((x)->flags |= AFLAG_SUPPORT)
+#define SetAdmin(x) ((x)->flags |= AFLAG_ADMIN)
+#define SetOperFlag(x) ((x)->flags |= AFLAG_OPER)
+
+#define ClearStaff(x) ((x)->flags &= ~AFLAG_STAFF)
+#define ClearDeveloper(x) ((x)->flags &= ~AFLAG_DEVELOPER)
+#define ClearSupport(x) ((x)->flags &= ~AFLAG_SUPPORT)
+#define ClearAdmin(x) ((x)->flags &= ~AFLAG_ADMIN)
+#define ClearOperFlag(x) ((x)->flags &= ~AFLAG_OPER)
typedef struct host {
sstring *name;
struct realname *next;
} realname;
-typedef struct authname {
- unsigned long userid;
- int usercount;
- unsigned int marker;
- struct nick *nicks;
- struct authname *next;
- /* These are extensions only used by other modules */
- void *exts[MAXAUTHNAMEEXTS];
-} authname;
-
typedef struct nick {
char nick[NICKLEN+1];
long numeric;
realname *realname;
sstring *shident; /* +h users: fake ident/host goes here */
sstring *sethost;
+ sstring *opername;
flag_t umodes;
- char authname[ACCOUNTLEN+1];
+ char *authname;
authname *auth; /* This requires User ID numbers to work */
time_t timestamp;
time_t accountts;
- unsigned long ipaddress;
+ patricia_node_t *ipnode;
unsigned int marker;
struct nick *next;
struct nick *nextbyhost;
void *exts[MAXNICKEXTS];
} nick;
+#define p_ipaddr ipnode->prefix->sin
+
#define NICKHASHSIZE 60000
#define HOSTHASHSIZE 40000
#define REALNAMEHASHSIZE 40000
-#define AUTHNAMEHASHSIZE 60000
extern nick *nicktable[NICKHASHSIZE];
extern nick **servernicks[MAXSERVERS];
extern host *hosttable[HOSTHASHSIZE];
extern realname *realnametable[REALNAMEHASHSIZE];
-extern authname *authnametable[AUTHNAMEHASHSIZE];
extern const flag umodeflags[];
+extern const flag accountflags[];
#define MAXNUMERIC 0x3FFFFFFF
void freenick (nick *np);
host *newhost();
void freehost (host *hp);
-authname *newauthname();
-void freeauthname (authname *hp);
/* nick.c functions */
void handleserverchange(int hooknum, void *arg);
int registernickext(const char *name);
int findnickext(const char *name);
void releasenickext(int index);
-int registerauthnameext(const char *name);
-int findauthnameext(const char *name);
-void releaseauthnameext(int index);
char *visiblehostmask(nick *np, char *buf);
+char *visibleuserhost(nick *np, char *buf);
/* nickhandlers.c functions */
int handlenickmsg(void *source, int cargc, char **cargv);
int handlewhoismsg(void *source, int cargc, char **cargv);
int handleaccountmsg(void *source, int cargc, char **cargv);
int handlestatsmsg(void *source, int cargc, char **cargv);
+int handleprivmsg(void *source, int cargc, char **cargv);
/* These functions have been replaced by macros
nick **gethandlebynumeric(long numeric);
/* nickhelpers.c functions */
void initnickhelpers();
+void fininickhelpers();
host *findhost(const char *hostname);
host *findorcreatehost(const char *hostname);
void releasehost(host *hp);
realname *findrealname(const char *name);
realname *findorcreaterealname(const char *name);
void releaserealname(realname *rnp);
-authname *findauthname(unsigned long userid);
-authname *findorcreateauthname(unsigned long userid);
-void releaseauthname(authname *anp);
unsigned int nexthostmarker();
unsigned int nextrealnamemarker();
-unsigned int nextauthnamemarker();
unsigned int nextnickmarker();
#endif