added IPNode for storing real IP's of users
[NeonServV5.git] / src / UserNode.h
index f905437aae542a80341aafa035dafb29f4d625a4..bf07e7e133e97701b69e4e7d21e1dea382f3b20e 100644 (file)
@@ -1,3 +1,19 @@
+/* UserNode.h - 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License 
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. 
+ */
 #ifndef _UserNode_h
 #define _UserNode_h
 #include "main.h"
 #define USERFLAG_LOADED_SETTINGS    0x0040
 #define USERFLAG_REPLY_PRIVMSG      0x0080
 #define USERFLAG_GOD_MODE           0x0100
+#define USERFLAG_HAS_USERID         0x0200
+#define USERFLAG_IS_ON_WHO_QUEUE    0x0400 /* prevents the user struct from beeing freed too early */
+#define USERFLAG_FREE_AFTER_WHO     0x0800 /* user struct is no more referenced - free it after WHO */
 
+#define USERFLAG_WAS_REGISTRING     0x20000000 /* only set for event_join if the quit reason was Registered */
 #define USERFLAG_SCRIPTFLAG1        0x40000000
 #define USERFLAG_SCRIPTFLAG2        0x80000000
 
 struct ChanUser;
 struct language;
+struct IPNode;
 
 struct UserNode {
     char nick[NICKLEN+1];
@@ -24,15 +45,19 @@ struct UserNode {
     char host[HOSTLEN+1];
     char realname[REALLEN+1];
     char auth[AUTHLEN+1];
+    struct IPNode *ip;
     unsigned int flags;
-    time_t created;
+    time_t created, last_who;
     struct ChanUser *channel;
     struct language *language;
     
+    int user_id;
+    
     struct UserNode *next;
 };
 
-#define isNetworkService(USER) (USER->flags & (USERFLAG_ISBOT | USERFLAG_ISIRCOP))
+#define isNetworkService(USER) (USER->flags & (USERFLAG_ISBOT | USERFLAG_ISIRCOP | USERFLAG_ISSERVER))
+#define isBot(USER) (USER->flags & (USERFLAG_ISBOT))
 
 void init_UserNode();
 void free_UserNode();
@@ -43,10 +68,12 @@ int countUsersWithHost(char *host);
 char *getAuthFakehost(char *auth);
 struct UserNode* searchUserByNick(const char *nick);
 struct UserNode* getAllUsers(struct UserNode *last);
+struct UserNode* getUsersWithAuth(const char *auth, struct UserNode *last);
 int getUserCount();
 struct UserNode* addUser(const char *nick);
 struct UserNode* addUserMask(const char *mask);
-struct UserNode* createTempUser(const char *mask);
+struct UserNode* createTempUser(const char *nick);
+struct UserNode* createTempUserMask(const char *mask);
 int renameUser(struct UserNode* user, const char *new_nick);
 void delUser(struct UserNode* user, int freeUser);
 void clearTempUsers();