added cmd_kick, cmd_kickban & all the functions depending on
[NeonServV5.git] / tools.h
1 #ifndef _tools_h
2 #define _tools_h
3
4 #include "main.h"
5
6 #define TABLE_FLAG_USE_POINTER 0x01
7 #define TABLE_FLAG_COL_BOLD    0x02
8
9 struct ClientSocket;
10 struct UserNode;
11 struct ChanNode;
12
13 struct Table {
14     char ***contents;
15     int length;
16     int width;
17     int flags;
18     int *col_flags;
19     
20     int entrys;
21     int *maxwidth;
22     
23     char **table_lines; //we just store this to free it in table_free
24 };
25
26 struct ModeBuffer {
27     struct ClientSocket *client;
28     struct ChanNode *chan;
29     char addModes[MAXMODES];
30     char delModes[MAXMODES];
31     char *addModesParams[MAXMODES];
32     char *delModesParams[MAXMODES];
33     int addCount;
34     int delCount;
35 };
36
37 int match(const char *mask, const char *name);
38
39 struct Table *table_init(int width, int length, int flags);
40 int table_add(struct Table *table, char **entry);
41 int table_set_bold(struct Table *table, int collum, int bold);
42 char **table_end(struct Table *table);
43 void table_free(struct Table *table);
44
45 char* timeToStr(struct UserNode *user, int seconds, int items, char *buf);
46 int strToTime(struct UserNode *user, char *str);
47
48 struct ModeBuffer* initModeBuffer(struct ClientSocket *client, struct ChanNode *chan);
49 #define modeBufferSimpleMode(MODEBUF,ADD,MODE) modeBufferSet(MODEBUF, ADD, MODE, NULL) 
50 #define modeBufferOp(MODEBUF,USER) modeBufferSet(MODEBUF, 1, 'o', USER)
51 #define modeBufferDeop(MODEBUF,USER) modeBufferSet(MODEBUF, 0, 'o', USER) 
52 #define modeBufferVoice(MODEBUF,USER) modeBufferSet(MODEBUF, 1, 'v', USER)
53 #define modeBufferDevoice(MODEBUF,USER) modeBufferSet(MODEBUF, 0, 'v', USER) 
54 #define modeBufferBan(MODEBUF,MASK) modeBufferSet(MODEBUF, 1, 'b', MASK) 
55 void modeBufferSet(struct ModeBuffer *modeBuf, int add, char mode, char *param);
56 void flushModeBuffer(struct ModeBuffer *modeBuf);
57 void freeModeBuffer(struct ModeBuffer *modeBuf);
58
59 int is_ircmask(const char *text);
60
61 char* generate_banmask(struct UserNode *user, char *buffer); 
62
63 void init_tools();
64
65 #endif