1
0
mirror of https://github.com/anope/anope.git synced 2026-06-27 11:36:38 +02:00

Nuke struct Uid from the core. (hooray!)

git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1296 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
Robin Burchell w00t@inspircd.org
2008-10-01 22:07:10 +00:00
parent e46bc26a06
commit 60b861ee25
5 changed files with 29 additions and 102 deletions
-3
View File
@@ -1049,9 +1049,6 @@ E User *nextuser(void);
E User *find_byuid(const char *uid);
E User *first_uid(void);
E User *next_uid(void);
E Uid *new_uid(const char *nick, char *uid);
E Uid *find_uid(const char *nick);
E Uid *find_nickuid(const char *uid);
E Server *findserver_uid(Server * s, const char *name);
E char *TS6SID;
E char *TS6UPLINK;
-10
View File
@@ -252,7 +252,6 @@ typedef struct csmode_ CSMode;
typedef struct cumode_ CUMode;
typedef struct csmodeutil_ CSModeUtil;
typedef struct session_ Session;
typedef struct uid_ Uid;
#include "bots.h"
@@ -393,15 +392,6 @@ struct ircdcapab_ {
uint32 nickchars;
};
/* tiny struct needed for P10 and other UID servers so we can track
services UID
*/
struct uid_ {
Uid *next, *prev;
char nick[NICKMAX];
char *uid;
};
/*************************************************************************/
/* Config Details */
/*************************************************************************/
-2
View File
@@ -16,7 +16,6 @@ BotInfo::BotInfo(const char *nnick)
this->nick = sstrdup(nnick);
this->lastmsg = time(NULL);
this->uid = ts6_uid_retrieve(); // XXX is this safe? has ts6 been setup yet?
new_uid(nnick, (char *)this->uid.c_str()); // XXX: this is required because we still pass nick prefix to protocol modules, DO AWAY WITH IT.
insert_bot(this); // XXX, this is ugly, but it needs to stay until hashing of bots is redone in STL.
nbots++;
}
@@ -29,7 +28,6 @@ BotInfo::BotInfo(const char *nnick, const char *nuser, const char *nhost, const
this->real = sstrdup(nreal);
this->lastmsg = time(NULL);
this->uid = ts6_uid_retrieve(); // XXX is this safe? has ts6 been setup yet?
new_uid(nnick, (char *)this->uid.c_str()); // XXX: this is required because we still pass nick prefix to protocol modules, DO AWAY WITH IT.
insert_bot(this); // XXX, this is ugly, but it needs to stay until hashing of bots is redone in STL.
nbots++;
}
+11 -20
View File
@@ -589,30 +589,21 @@ void insert_bot(BotInfo * bi)
BotInfo *findbot(const char *nick)
{
BotInfo *bi;
Uid *ud;
BotInfo *bi;
/* to keep make strict happy */
ud = NULL;
if (!nick || !*nick)
return NULL;
if (!nick || !*nick)
return NULL;
for (bi = botlists[tolower(*nick)]; bi; bi = bi->next)
{
if (!stricmp(nick, bi->nick))
return bi;
for (bi = botlists[tolower(*nick)]; bi; bi = bi->next) {
if (UseTS6 && ircd->ts6) {
ud = find_nickuid(nick);
}
if (!stricmp(nick, bi->nick)) {
return bi;
}
if (ud && UseTS6 && ircd->ts6) {
if (!stricmp(ud->nick, bi->nick)) {
return bi;
}
}
}
if (nick == bi->uid)
return bi;
}
return NULL;
return NULL;
}
/*************************************************************************/
+18 -67
View File
@@ -18,7 +18,6 @@
User *userlist[1024];
#define HASH2(nick) (((nick)[0]&31)<<5 | ((nick)[1]&31))
Uid *uidlist[1024];
int32 usercnt = 0, opcnt = 0;
uint32 maxusercnt = 0;
@@ -27,11 +26,11 @@ time_t maxusertime;
/*************************************************************************/
/*************************************************************************/
User::User(const std::string &nick)
User::User(const std::string &snick)
{
User **list;
// XXX: we could do well to steal CoreException from insp
if (nick.empty())
if (snick.empty())
throw "what the craq, empty nick passed to constructor";
// XXX: we should also duplicate-check here.
@@ -47,7 +46,7 @@ User::User(const std::string &nick)
moduleData = NULL;
timestamp = my_signon = svid = mode = invalid_pw_time = lastmemosend = lastnickreg = lastmail = 0;
strscpy(this->nick, nick.c_str(), NICKMAX);
strscpy(this->nick, snick.c_str(), NICKMAX);
list = &userlist[HASH(this->nick)];
this->next = *list;
@@ -56,7 +55,7 @@ User::User(const std::string &nick)
*list = this;
this->na = findnick(nick);
this->na = findnick(snick);
if (this->na)
this->na->u = this;
@@ -119,17 +118,17 @@ void User::SetNewNick(const std::string &newnick)
alog("debug: %s changed nick to %s", this->nick, newnick.c_str());
}
void User::SetDisplayedHost(const std::string &host)
void User::SetDisplayedHost(const std::string &shost)
{
if (host.empty())
if (shost.empty())
throw "empty host? in MY services? it seems it's more likely than I thought.";
if (this->vhost)
free(this->vhost);
this->vhost = sstrdup(host.c_str());
this->vhost = sstrdup(shost.c_str());
if (debug)
alog("debug: %s changed vhost to %s", this->nick, host.c_str());
alog("debug: %s changed vhost to %s", this->nick, shost.c_str());
update_host(this);
}
@@ -149,51 +148,51 @@ void User::SetIdent(const std::string &ident)
update_host(this);
}
void User::SetRealname(const std::string &realname)
void User::SetRealname(const std::string &srealname)
{
if (realname.empty())
if (srealname.empty())
throw "realname empty in SetRealname";
if (this->realname)
free(this->realname);
this->realname = sstrdup(realname.c_str());
this->realname = sstrdup(srealname.c_str());
if (this->na && (nick_identified(this) ||
(!(this->na->nc->flags & NI_SECURE) && nick_recognized(this))))
{
if (this->na->last_realname)
free(this->na->last_realname);
this->na->last_realname = sstrdup(realname.c_str());
this->na->last_realname = sstrdup(srealname.c_str());
}
if (debug)
alog("debug: %s changed realname to %s", this->nick, realname.c_str());
alog("debug: %s changed realname to %s", this->nick, srealname.c_str());
}
User::~User()
{
struct u_chanlist *c, *c2;
struct u_chaninfolist *ci, *ci2;
char *realname;
char *srealname;
if (LogUsers)
{
realname = normalizeBuffer(this->realname);
srealname = normalizeBuffer(this->realname);
if (ircd->vhost)
{
alog("LOGUSERS: %s (%s@%s => %s) (%s) left the network (%s).",
this->nick, this->username, this->host,
(this->vhost ? this->vhost : "(none)"), realname, this->server->name);
(this->vhost ? this->vhost : "(none)"), srealname, this->server->name);
}
else
{
alog("LOGUSERS: %s (%s@%s) (%s) left the network (%s).",
this->nick, this->username, this->host,
realname, this->server->name);
srealname, this->server->name);
}
free(realname);
free(srealname);
}
send_event(EVENT_USER_LOGOFF, 1, this->nick);
@@ -486,54 +485,6 @@ User *next_uid(void)
return current_uid;
}
Uid *new_uid(const char *nick, char *uid)
{
Uid *u, **list;
u = (Uid *)scalloc(sizeof(Uid), 1);
if (!nick || !uid) {
return NULL;
}
strscpy(u->nick, nick, NICKMAX);
list = &uidlist[HASH2(u->nick)];
u->next = *list;
if (*list)
(*list)->prev = u;
*list = u;
u->uid = sstrdup(uid);
return u;
}
Uid *find_uid(const char *nick)
{
Uid *u;
int i;
for (i = 0; i < 1024; i++) {
for (u = uidlist[i]; u; u = u->next) {
if (!stricmp(nick, u->nick)) {
return u;
}
}
}
return NULL;
}
Uid *find_nickuid(const char *uid)
{
Uid *u;
int i;
for (i = 0; i < 1024; i++) {
for (u = uidlist[i]; u; u = u->next) {
if (!stricmp(uid, u->uid)) {
return u;
}
}
}
return NULL;
}
/*************************************************************************/
/*************************************************************************/