tried to reorder the program structure and build process
[NeonServV5.git] / src / tools.h
diff --git a/src/tools.h b/src/tools.h
new file mode 100644 (file)
index 0000000..54a0cfa
--- /dev/null
@@ -0,0 +1,71 @@
+#ifndef _tools_h
+#define _tools_h
+
+#include "main.h"
+
+#define TABLE_FLAG_USE_POINTER  0x01
+#define TABLE_FLAG_COL_BOLD     0x02
+#define TABLE_FLAG_COL_CONTENTS 0x04
+
+struct ClientSocket;
+struct UserNode;
+struct ChanNode;
+
+struct Table {
+    char ***contents;
+    int length;
+    int width;
+    int flags;
+    int *col_flags;
+    
+    int entrys;
+    int *maxwidth;
+    
+    char **table_lines; //we just store this to free it in table_free
+};
+
+struct ModeBuffer {
+    struct ClientSocket *client;
+    struct ChanNode *chan;
+    char addModes[MAXMODES];
+    char delModes[MAXMODES];
+    char *addModesParams[MAXMODES];
+    char *delModesParams[MAXMODES];
+    int addCount;
+    int delCount;
+};
+
+int match(const char *mask, const char *name);
+
+struct Table *table_init(int width, int length, int flags);
+int table_add(struct Table *table, char **entry);
+int table_change(struct Table *table, int row, char **entry);
+int table_change_field(struct Table *table, int row, int col, char *entry);
+int table_set_bold(struct Table *table, int collum, int bold);
+char **table_end(struct Table *table);
+void table_free(struct Table *table);
+
+char* timeToStr(struct UserNode *user, int seconds, int items, char *buf);
+int strToTime(struct UserNode *user, char *str);
+
+struct ModeBuffer* initModeBuffer(struct ClientSocket *client, struct ChanNode *chan);
+#define modeBufferSimpleMode(MODEBUF,ADD,MODE) modeBufferSet(MODEBUF, ADD, MODE, NULL) 
+#define modeBufferOp(MODEBUF,USER) modeBufferSet(MODEBUF, 1, 'o', USER)
+#define modeBufferDeop(MODEBUF,USER) modeBufferSet(MODEBUF, 0, 'o', USER) 
+#define modeBufferVoice(MODEBUF,USER) modeBufferSet(MODEBUF, 1, 'v', USER)
+#define modeBufferDevoice(MODEBUF,USER) modeBufferSet(MODEBUF, 0, 'v', USER) 
+#define modeBufferBan(MODEBUF,MASK) modeBufferSet(MODEBUF, 1, 'b', MASK) 
+#define modeBufferUnban(MODEBUF,MASK) modeBufferSet(MODEBUF, 0, 'b', MASK) 
+void modeBufferSet(struct ModeBuffer *modeBuf, int add, char mode, char *param);
+void flushModeBuffer(struct ModeBuffer *modeBuf);
+void freeModeBuffer(struct ModeBuffer *modeBuf);
+
+int is_ircmask(const char *text);
+
+char* generate_banmask(struct UserNode *user, char *buffer); 
+char* make_banmask(char *input, char* buffer);
+int isFakeHost(char *host);
+
+void init_tools();
+
+#endif
\ No newline at end of file