Another year is about to end... So we have to update these damn copyright information :P
[NeonServV5.git] / src / UserNode.c
index 452d17dd0ae027699415bdb6a45f3eb12c40a2a5..fe68f3e796eb99ca823b70fdfb1fec86a9f723bf 100644 (file)
@@ -1,5 +1,5 @@
-/* UserNode.c - NeonServ v5.1
- * Copyright (C) 2011  Philipp Kreil (pk910)
+/* UserNode.c - NeonServ v5.3
+ * Copyright (C) 2011-2012  Philipp Kreil (pk910)
  * 
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -17,6 +17,7 @@
 #include "UserNode.h"
 #include "ChanUser.h"
 #include "tools.h"
+#include "IRCEvents.h"
 
 static struct UserNode **userList;
 
@@ -159,6 +160,20 @@ struct UserNode* getAllUsers(struct UserNode *last) {
         return last->next;
 }
 
+struct UserNode* getUsersWithAuth(const char *auth, struct UserNode *last) {
+    int cindex = (last ? get_nicklist_entry(last->nick[0]) : 0);
+    struct UserNode *cuser = last;
+    while(cindex <= VALID_NICK_CHARS_FIRST_LEN) {
+        for(cuser = (cuser ? cuser->next : userList[cindex]); cuser; cuser = cuser->next) {
+            if((cuser->flags & USERFLAG_ISAUTHED) && !strcmp(cuser->auth, auth))
+                return cuser;
+        }
+        cindex++;
+        cuser = NULL;
+    }
+    return NULL;
+}
+
 int getUserCount() {
     int i, count = 0;
     struct UserNode *user;
@@ -324,6 +339,7 @@ int renameUser(struct UserNode* user, const char *new_nick) {
 void delUser(struct UserNode* user, int freeUser) {
     int userListIndex = get_nicklist_entry(user->nick[0]);
     if(userListIndex == -1) return;
+    event_freeuser(user);
     struct UserNode *cuser, *last_user = NULL;
     for(cuser = userList[userListIndex]; cuser; cuser = cuser->next) {
         if(cuser == user) {