aboutsummaryrefslogtreecommitdiffstats
path: root/irc_parse.h
diff options
context:
space:
mode:
authorFreeArtMan <dos21h@gmail.com>2017-02-25 00:29:59 +0000
committerFreeArtMan <dos21h@gmail.com>2017-02-25 00:29:59 +0000
commitb2e98d7936b57f11e0d37ad522d3382f682af071 (patch)
treed42edef4d156c3b1e431c810bdd3ef5950eed957 /irc_parse.h
parentc57abcff74e57baadd252d7d461b2648cdfbd8b2 (diff)
downloadagni-b2e98d7936b57f11e0d37ad522d3382f682af071.tar.gz
agni-b2e98d7936b57f11e0d37ad522d3382f682af071.zip
Added parser and socket connection code
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