Merge branch 'development'
[NeonServV5.git] / src / tools.h
1 /* tools.h - NeonServ v5.6
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 _tools_h
18 #define _tools_h
19
20 #include "main.h"
21
22 #define TABLE_FLAG_USE_POINTER   0x01
23 #define TABLE_FLAG_COL_BOLD      0x02
24 #define TABLE_FLAG_COL_CONTENTS  0x04
25 #define TABLE_FLAG_COL_SKIP_NULL 0x08
26
27 struct ClientSocket;
28 struct UserNode;
29 struct ChanNode;
30
31 struct Table {
32     char ***contents;
33     int length;
34     int width;
35     int flags;
36     int *col_flags;
37     
38     int entrys;
39     int *maxwidth;
40     
41     char **table_lines; //we just store this to free it in table_free
42 };
43
44 struct ModeBuffer {
45     struct ClientSocket *client;
46     struct ChanNode *chan;
47     char addModes[MAXMODES];
48     char delModes[MAXMODES];
49     char *addModesParams[MAXMODES];
50     char *delModesParams[MAXMODES];
51     int addCount;
52     int delCount;
53 };
54
55 #define modeBufferSimpleMode(MODEBUF,ADD,MODE) modeBufferSet(MODEBUF, ADD, MODE, NULL) 
56 #define modeBufferOp(MODEBUF,USER) modeBufferSet(MODEBUF, 1, 'o', USER)
57 #define modeBufferDeop(MODEBUF,USER) modeBufferSet(MODEBUF, 0, 'o', USER) 
58 #define modeBufferHalfop(MODEBUF,USER) modeBufferSet(MODEBUF, 1, 'h', USER)
59 #define modeBufferDehalfop(MODEBUF,USER) modeBufferSet(MODEBUF, 0, 'h', USER) 
60 #define modeBufferVoice(MODEBUF,USER) modeBufferSet(MODEBUF, 1, 'v', USER)
61 #define modeBufferDevoice(MODEBUF,USER) modeBufferSet(MODEBUF, 0, 'v', USER) 
62 #define modeBufferBan(MODEBUF,MASK) modeBufferSet(MODEBUF, 1, 'b', MASK) 
63 #define modeBufferUnban(MODEBUF,MASK) modeBufferSet(MODEBUF, 0, 'b', MASK) 
64
65 #ifndef DND_FUNCTIONS
66 /* MODULAR ACCESSIBLE */ int match(const char *mask, const char *name);
67
68 /* MODULAR ACCESSIBLE */ struct Table *table_init(int width, int length, int flags);
69 /* MODULAR ACCESSIBLE */ int table_add(struct Table *table, char **entry);
70 /* MODULAR ACCESSIBLE */ int table_change(struct Table *table, int row, char **entry);
71 /* MODULAR ACCESSIBLE */ int table_change_field(struct Table *table, int row, int col, char *entry);
72 /* MODULAR ACCESSIBLE */ int table_set_bold(struct Table *table, int collum, int bold);
73 /* MODULAR ACCESSIBLE */ char **table_end(struct Table *table);
74 /* MODULAR ACCESSIBLE */ void table_free(struct Table *table);
75
76 /* MODULAR ACCESSIBLE */ char* timeToStr(struct UserNode *user, int seconds, int items, char *buf);
77 /* MODULAR ACCESSIBLE */ int strToTime(struct UserNode *user, char *str);
78 /* MODULAR ACCESSIBLE */ int getCurrentSecondsOfDay();
79
80 /* MODULAR ACCESSIBLE */ struct ModeBuffer* initModeBuffer(struct ClientSocket *client, struct ChanNode *chan);
81 /* MODULAR ACCESSIBLE */ void modeBufferSet(struct ModeBuffer *modeBuf, int add, char mode, char *param);
82 /* MODULAR ACCESSIBLE */ void flushModeBuffer(struct ModeBuffer *modeBuf);
83 /* MODULAR ACCESSIBLE */ void freeModeBuffer(struct ModeBuffer *modeBuf);
84
85 /* MODULAR ACCESSIBLE */ int is_ircmask(const char *text);
86
87 /* MODULAR ACCESSIBLE */ char* generate_banmask(struct UserNode *user, char *buffer); 
88 /* MODULAR ACCESSIBLE */ char* make_banmask(char *input, char* buffer);
89 /* MODULAR ACCESSIBLE */ int isFakeHost(char *host);
90
91 /* MODULAR ACCESSIBLE */ int mask_match(char *mask, struct UserNode *user);
92
93 /* MODULAR ACCESSIBLE */ unsigned long crc32(const char *text);
94
95 /* MODULAR ACCESSIBLE */ int stricmp (const char *s1, const char *s2);
96 /* MODULAR ACCESSIBLE */ int stricmplen (const char *s1, const char *s2, int len);
97
98 void init_tools();
99
100 #endif
101 #endif