r3/include/token.h

41 lines
788 B
C
Raw Normal View History

2014-05-14 23:52:45 -04:00
/*
* token.h
* Copyright (C) 2014 c9s <c9s@c9smba.local>
*
* Distributed under terms of the MIT license.
*/
#ifndef TOKEN_H
#define TOKEN_H
typedef unsigned char bool;
#define FALSE 0
#define TRUE 1
2014-05-15 00:21:45 -04:00
typedef struct _token_array {
2014-05-14 23:52:45 -04:00
char **tokens;
int len;
int cap;
2014-05-15 00:21:45 -04:00
} token_array;
2014-05-14 23:52:45 -04:00
2014-05-15 00:21:45 -04:00
token_array * token_array_create(int cap);
2014-05-14 23:52:45 -04:00
2014-05-15 00:21:45 -04:00
bool token_array_is_full(token_array * l);
2014-05-14 23:52:45 -04:00
2014-05-15 00:21:45 -04:00
bool token_array_resize(token_array *l, int new_cap);
2014-05-14 23:52:45 -04:00
2014-05-15 00:21:45 -04:00
bool token_array_append(token_array * list, char * token);
2014-05-14 23:52:45 -04:00
2014-05-15 00:21:45 -04:00
void token_array_free(token_array *l);
2014-05-14 23:52:45 -04:00
2014-05-15 00:47:14 -04:00
void token_array_dump(token_array *l);
token_array * split_route_pattern(char *pattern, int pattern_len);
2014-05-15 01:39:50 -04:00
#define token_array_fetch(t,i) t->tokens[i]
#define token_array_len(t) t->len
#define token_array_cap(t) t->cap
2014-05-14 23:52:45 -04:00
#endif /* !TOKEN_H */