changed Makefile; build all commands as an own file
[NeonServV5.git] / UserNode.c
index e857cb7f46785bf4597f6d97e876751f7986e1b7..2ced2eb5b88d3f3129173b9b867a0fbf3823d048 100644 (file)
@@ -1,5 +1,6 @@
 #include "UserNode.h"
 #include "ChanUser.h"
+#include "tools.h"
 
 static struct UserNode **userList;
 
@@ -114,6 +115,45 @@ int countUsersWithHost(char *host) {
     return count;
 }
 
+char *getAuthFakehost(char *auth) {
+    int i;
+    struct UserNode *user;
+    for(i = 0; i < VALID_NICK_CHARS_FIRST_LEN+1; i++) {
+        for(user = userList[i]; user; user = user->next) {
+            if((user->flags & USERFLAG_ISAUTHED) && !strcmp(user->auth, auth) && isFakeHost(user->host)) {
+                return user->host;
+            }
+        }
+    }
+    return NULL;
+}
+
+struct UserNode* getAllUsers(struct UserNode *last) {
+    if(last == NULL || last->next == NULL) {
+        int cindex;
+        if(last == NULL)
+            cindex = 0;
+        else
+            cindex = get_nicklist_entry(last->nick[0]) + 1;
+        while(userList[cindex] == NULL && cindex <= VALID_NICK_CHARS_FIRST_LEN)
+            cindex++;
+        if(cindex > VALID_NICK_CHARS_FIRST_LEN) return NULL;
+        return userList[cindex];
+    } else
+        return last->next;
+}
+
+int getUserCount() {
+    int i, count = 0;
+    struct UserNode *user;
+    for(i = 0; i < VALID_NICK_CHARS_FIRST_LEN+1; i++) {
+        for(user = userList[i]; user; user = user->next) {
+            count++;
+        }
+    }
+    return count;
+}
+
 struct UserNode* addUser(const char *nick) {
     int userListIndex = get_nicklist_entry(*nick);
     if(userListIndex == -1 || !is_valid_nick(nick))