54a0cfa9e7ec8489732350b022f785f1e15e0fc9
[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 #define TABLE_FLAG_COL_CONTENTS 0x04
9
10 struct ClientSocket;
11 struct UserNode;
12 struct ChanNode;
13
14 struct Table {
15     char ***contents;
16     int length;
17     int width;
18     int flags;
19     int *col_flags;
20     
21     int entrys;
22     int *maxwidth;
23     
24     char **table_lines; //we just store this to free it in table_free
25 };
26
27 struct ModeBuffer {
28     struct ClientSocket *client;
29     struct ChanNode *chan;
30     char addModes[MAXMODES];
31     char delModes[MAXMODES];
32     char *addModesParams[MAXMODES];
33     char *delModesParams[MAXMODES];
34     int addCount;
35     int delCount;
36 };
37
38 int match(const char *mask, const char *name);
39
40 struct Table *table_init(int width, int length, int flags);
41 int table_add(struct Table *table, char **entry);
42 int table_change(struct Table *table, int row, char **entry);
43 int table_change_field(struct Table *table, int row, int col, char *entry);
44 int table_set_bold(struct Table *table, int collum, int bold);
45 char **table_end(struct Table *table);
46 void table_free(struct Table *table);
47
48 char* timeToStr(struct UserNode *user, int seconds, int items, char *buf);
49 int strToTime(struct UserNode *user, char *str);
50
51 struct ModeBuffer* initModeBuffer(struct ClientSocket *client, struct ChanNode *chan);
52 #define modeBufferSimpleMode(MODEBUF,ADD,MODE) modeBufferSet(MODEBUF, ADD, MODE, NULL) 
53 #define modeBufferOp(MODEBUF,USER) modeBufferSet(MODEBUF, 1, 'o', USER)
54 #define modeBufferDeop(MODEBUF,USER) modeBufferSet(MODEBUF, 0, 'o', USER) 
55 #define modeBufferVoice(MODEBUF,USER) modeBufferSet(MODEBUF, 1, 'v', USER)
56 #define modeBufferDevoice(MODEBUF,USER) modeBufferSet(MODEBUF, 0, 'v', USER) 
57 #define modeBufferBan(MODEBUF,MASK) modeBufferSet(MODEBUF, 1, 'b', MASK) 
58 #define modeBufferUnban(MODEBUF,MASK) modeBufferSet(MODEBUF, 0, 'b', MASK) 
59 void modeBufferSet(struct ModeBuffer *modeBuf, int add, char mode, char *param);
60 void flushModeBuffer(struct ModeBuffer *modeBuf);
61 void freeModeBuffer(struct ModeBuffer *modeBuf);
62
63 int is_ircmask(const char *text);
64
65 char* generate_banmask(struct UserNode *user, char *buffer); 
66 char* make_banmask(char *input, char* buffer);
67 int isFakeHost(char *host);
68
69 void init_tools();
70
71 #endif