1ae5560d3187b3db6ea8049761dd83786ea679e0
[NeonServV5.git] / src / UserNode.h
1 /* UserNode.h - NeonServ v5.1
2  * Copyright (C) 2011  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
31 #define USERFLAG_SCRIPTFLAG1        0x40000000
32 #define USERFLAG_SCRIPTFLAG2        0x80000000
33
34 struct ChanUser;
35 struct language;
36
37 struct UserNode {
38     char nick[NICKLEN+1];
39     char ident[USERLEN+1];
40     char host[HOSTLEN+1];
41     char realname[REALLEN+1];
42     char auth[AUTHLEN+1];
43     unsigned int flags;
44     time_t created, last_who;
45     struct ChanUser *channel;
46     struct language *language;
47     
48     struct UserNode *next;
49 };
50
51 #define isNetworkService(USER) (USER->flags & (USERFLAG_ISBOT | USERFLAG_ISIRCOP | USERFLAG_ISSERVER))
52 #define isBot(USER) (USER->flags & (USERFLAG_ISBOT))
53
54 void init_UserNode();
55 void free_UserNode();
56 int is_valid_nick(const char *nick);
57 struct UserNode* getUserByNick(const char *nick);
58 struct UserNode* getUserByMask(const char *mask);
59 int countUsersWithHost(char *host);
60 char *getAuthFakehost(char *auth);
61 struct UserNode* searchUserByNick(const char *nick);
62 struct UserNode* getAllUsers(struct UserNode *last);
63 int getUserCount();
64 struct UserNode* addUser(const char *nick);
65 struct UserNode* addUserMask(const char *mask);
66 struct UserNode* createTempUser(const char *mask);
67 int renameUser(struct UserNode* user, const char *new_nick);
68 void delUser(struct UserNode* user, int freeUser);
69 void clearTempUsers();
70
71 #endif