summaryrefslogtreecommitdiff
path: root/irc_parse.h
diff options
context:
space:
mode:
Diffstat (limited to 'irc_parse.h')
-rw-r--r--irc_parse.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/irc_parse.h b/irc_parse.h
new file mode 100644
index 0000000..4933f43
--- /dev/null
+++ b/irc_parse.h
@@ -0,0 +1,51 @@
+#ifndef __IRC_PARSE_H
+#define __IRC_PARSE_H
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+
+#include "util.h"
+
+//points to one token in da string
+#define IRC_TKT_NONE 0
+#define IRC_TKT_HOST 1
+#define IRC_TKT_CMD 2
+#define IRC_TKT_PARAM 3
+typedef struct irc_token_el
+{
+ int type;
+ int size;
+ char *token;
+} irc_token_el;
+
+#define IRC_TK_MAX_SIZE 100
+typedef struct irc_token
+{
+ int size; //how many tokens
+ int max_size; //allocate token spaces
+ irc_token_el **tk_list;
+} irc_token;
+
+
+
+//create default token list, with prealocated, token structures
+irc_token* token_create();
+//create new string(with extra byte that have NULL at the end), for token andd to list
+int token_add(irc_token *tk, char *s, char *e);
+//compare token by index with string
+int token_cmp(irc_token *tk, int idx, char *str);
+//return new string that could be freed
+char* token_new_str(irc_token *tk, int idx);
+//number of tokens
+int token_len(irc_token *tk);
+//clean all tokens
+void token_destroy(irc_token *tk);
+
+//return number of parse tokens
+irc_token* irc_parse(char *str, int sz);
+
+
+#endif \ No newline at end of file