#ifndef __IRC_PARSE_H #define __IRC_PARSE_H #include #include #include #include #include #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