Another year is about to end... So we have to update these damn copyright information :P
[NeonServV5.git] / src / UserNode.h
1 /* UserNode.h - NeonServ v5.3
2  * Copyright (C) 2011-2012  Philipp Kreil (pk910)
3  * 
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  * 
14  * You should have received a copy of the GNU General Public License 
15  * along with this program. If not, see <http://www.gnu.org/licenses/>. 
16  */
17 #ifndef _UserNode_h
18 #define _UserNode_h
19 #include "main.h"
20
21 #define USERFLAG_ISBOT              0x0001
22 #define USERFLAG_ISAUTHED           0x0002
23 #define USERFLAG_ISIRCOP            0x0004
24 #define USERFLAG_ISTMPUSER          0x0008
25 #define USERFLAG_ISSERVER           0x0010
26 #define USERFLAG_FREETMPUSER        0x0020
27 #define USERFLAG_LOADED_SETTINGS    0x0040
28 #define USERFLAG_REPLY_PRIVMSG      0x0080
29 #define USERFLAG_GOD_MODE           0x0100
30 #define USERFLAG_HAS_USERID         0x0200
31
32 #define USERFLAG_WAS_REGISTRING     0x20000000 /* only set for event_join if the quit reason was Registered */
33 #define USERFLAG_SCRIPTFLAG1        0x40000000
34 #define USERFLAG_SCRIPTFLAG2        0x80000000
35
36 struct ChanUser;
37 struct language;
38
39 struct UserNode {
40     char nick[NICKLEN+1];
41     char ident[USERLEN+1];
42     char host[HOSTLEN+1];
43     char realname[REALLEN+1];
44     char auth[AUTHLEN+1];
45     unsigned int flags;
46     time_t created, last_who;
47     struct ChanUser *channel;
48     struct language *language;
49     
50     int user_id;
51     
52     struct UserNode *next;
53 };
54
55 #define isNetworkService(USER) (USER->flags & (USERFLAG_ISBOT | USERFLAG_ISIRCOP | USERFLAG_ISSERVER))
56 #define isBot(USER) (USER->flags & (USERFLAG_ISBOT))
57
58 void init_UserNode();
59 void free_UserNode();
60 int is_valid_nick(const char *nick);
61 struct UserNode* getUserByNick(const char *nick);
62 struct UserNode* getUserByMask(const char *mask);
63 int countUsersWithHost(char *host);
64 char *getAuthFakehost(char *auth);
65 struct UserNode* searchUserByNick(const char *nick);
66 struct UserNode* getAllUsers(struct UserNode *last);
67 struct UserNode* getUsersWithAuth(const char *auth, struct UserNode *last);
68 int getUserCount();
69 struct UserNode* addUser(const char *nick);
70 struct UserNode* addUserMask(const char *mask);
71 struct UserNode* createTempUser(const char *mask);
72 int renameUser(struct UserNode* user, const char *new_nick);
73 void delUser(struct UserNode* user, int freeUser);
74 void clearTempUsers();
75
76 #endif