summaryrefslogtreecommitdiff
path: root/src/users.c
diff options
context:
space:
mode:
authortrystan trystan@31f1291d-b8d6-0310-a050-a5561fc1590b <trystan trystan@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2005-01-23 07:32:56 +0000
committertrystan trystan@31f1291d-b8d6-0310-a050-a5561fc1590b <trystan trystan@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2005-01-23 07:32:56 +0000
commit01f32cf2881f781fa934623361a146e55fcca8b6 (patch)
treec48dfedffd26ef58826ed918c9b4c1d029eb6252 /src/users.c
parentba7b29bba7ea10b4813d42efbc79c3a0bb01c461 (diff)
BUILD : 1.7.7 (555) BUGS : N/A NOTES : TS6 support, Ratbox support, lots of little bug fixes, updated documentation
git-svn-id: svn://svn.anope.org/anope/trunk@555 31f1291d-b8d6-0310-a050-a5561fc1590b git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@408 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/users.c')
-rw-r--r--src/users.c105
1 files changed, 104 insertions, 1 deletions
diff --git a/src/users.c b/src/users.c
index 74d78bf58..732c26e29 100644
--- a/src/users.c
+++ b/src/users.c
@@ -17,6 +17,9 @@
#define HASH(nick) (((nick)[0]&31)<<5 | ((nick)[1]&31))
User *userlist[1024];
+#define HASH2(nick) (((nick)[0]&31)<<5 | ((nick)[1]&31))
+Uid *uidlist[1024];
+
int32 usercnt = 0, opcnt = 0;
uint32 maxusercnt = 0;
time_t maxusertime;
@@ -222,6 +225,9 @@ void delete_user(User * user)
free(user->vhost);
}
}
+ if (user->uid) {
+ free(user->uid);
+ }
Anope_Free(user->realname);
if (debug >= 2) {
alog("debug: delete_user(): remove from channels");
@@ -363,6 +369,99 @@ User *nextuser(void)
return current;
}
+User *find_byuid(const char *uid)
+{
+ User *u, *next;
+
+ u = first_uid();
+ while (u) {
+ next = next_uid();
+ if (!stricmp(uid, u->uid)) {
+ return u;
+ }
+ u = next;
+ }
+ return NULL;
+}
+
+User *first_uid(void)
+{
+ next_index = 0;
+ while (next_index < 1024 && current == NULL) {
+ current = userlist[next_index++];
+ }
+ if (debug >= 2) {
+ alog("debug: first_uid() returning %s %s",
+ current ? current->nick : "NULL (end of list)",
+ current ? current->uid : "");
+ }
+ return current;
+}
+
+User *next_uid(void)
+{
+ if (current)
+ current = current->next;
+ if (!current && next_index < 1024) {
+ while (next_index < 1024 && current == NULL)
+ current = userlist[next_index++];
+ }
+ if (debug >= 2) {
+ alog("debug: next_uid() returning %s %s",
+ current ? current->nick : "NULL (end of list)",
+ current ? current->uid : "");
+ }
+ return current;
+}
+
+Uid *new_uid(const char *nick, char *uid)
+{
+ Uid *u, **list;
+
+ u = 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;
+}
+
/*************************************************************************/
/*************************************************************************/
@@ -509,7 +608,11 @@ User *do_nick(const char *source, char *nick, char *username, char *host,
user->timestamp = ts;
user->my_signon = time(NULL);
user->vhost = vhost ? sstrdup(vhost) : sstrdup(host);
- user->uid = uid; /* p10 stuff */
+ if (uid) {
+ user->uid = sstrdup(uid); /* p10/ts6 stuff */
+ } else {
+ user->uid = NULL;
+ }
user->vident = sstrdup(username);
if (CheckClones) {