merge str_array.h

This commit is contained in:
c9s 2014-05-26 21:39:36 +08:00
parent a99547bea5
commit 7aaed3e5d7
10 changed files with 28 additions and 46 deletions

View file

@ -14,7 +14,30 @@
#include <pcre.h> #include <pcre.h>
#include "r3_define.h" #include "r3_define.h"
#include "str_array.h"
typedef struct _str_array {
char **tokens;
int len;
int cap;
} str_array;
str_array * str_array_create(int cap);
bool str_array_is_full(str_array * l);
bool str_array_resize(str_array *l, int new_cap);
bool str_array_append(str_array * list, char * token);
void str_array_free(str_array *l);
void str_array_dump(str_array *l);
str_array * split_route_pattern(char *pattern, int pattern_len);
#define str_array_fetch(t,i) t->tokens[i]
#define str_array_len(t) t->len
#define str_array_cap(t) t->cap
#define node_edge_pattern(node,i) node->edges[i]->pattern #define node_edge_pattern(node,i) node->edges[i]->pattern
@ -192,4 +215,7 @@ enum { NODE_COMPARE_STR, NODE_COMPARE_PCRE, NODE_COMPARE_OPCODE };
enum { OP_EXPECT_MORE_DIGITS = 1, OP_EXPECT_MORE_WORDS, OP_EXPECT_NOSLASH, OP_EXPECT_NODASH, OP_EXPECT_MORE_ALPHA }; enum { OP_EXPECT_MORE_DIGITS = 1, OP_EXPECT_MORE_WORDS, OP_EXPECT_NOSLASH, OP_EXPECT_NODASH, OP_EXPECT_MORE_ALPHA };
#endif /* !R3_NODE_H */ #endif /* !R3_NODE_H */

View file

@ -1,37 +0,0 @@
/*
* str_array.h
* Copyright (C) 2014 c9s <c9s@c9smba.local>
*
* Distributed under terms of the MIT license.
*/
#ifndef TOKEN_H
#define TOKEN_H
#include "r3_define.h"
typedef struct _str_array {
char **tokens;
int len;
int cap;
} str_array;
str_array * str_array_create(int cap);
bool str_array_is_full(str_array * l);
bool str_array_resize(str_array *l, int new_cap);
bool str_array_append(str_array * list, char * token);
void str_array_free(str_array *l);
void str_array_dump(str_array *l);
str_array * split_route_pattern(char *pattern, int pattern_len);
#define str_array_fetch(t,i) t->tokens[i]
#define str_array_len(t) t->len
#define str_array_cap(t) t->cap
#endif /* !TOKEN_H */

View file

@ -21,7 +21,6 @@
#include "r3.h" #include "r3.h"
#include "r3_str.h" #include "r3_str.h"
#include "str_array.h"
#include "zmalloc.h" #include "zmalloc.h"
edge * r3_edge_create(char * pattern, int pattern_len, node * child) { edge * r3_edge_create(char * pattern, int pattern_len, node * child) {

View file

@ -10,7 +10,6 @@
#include "r3.h" #include "r3.h"
#include "r3_str.h" #include "r3_str.h"
#include "str_array.h"
#include "zmalloc.h" #include "zmalloc.h"
// String value as the index http://judy.sourceforge.net/doc/JudySL_3x.htm // String value as the index http://judy.sourceforge.net/doc/JudySL_3x.htm

View file

@ -10,7 +10,6 @@
#include <assert.h> #include <assert.h>
#include "r3.h" #include "r3.h"
#include "r3_str.h" #include "r3_str.h"
#include "str_array.h"
#include "zmalloc.h" #include "zmalloc.h"
int r3_pattern_to_opcode(char * pattern, int len) { int r3_pattern_to_opcode(char * pattern, int len) {

View file

@ -8,7 +8,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
#include "str_array.h" #include "r3.h"
#include "r3_str.h" #include "r3_str.h"
#include "zmalloc.h" #include "zmalloc.h"

View file

@ -12,7 +12,6 @@
#include "r3.h" #include "r3.h"
#include "r3_str.h" #include "r3_str.h"
#include "str_array.h"
#include "zmalloc.h" #include "zmalloc.h"
#include "bench.h" #include "bench.h"

View file

@ -11,7 +11,6 @@
#include "r3.h" #include "r3.h"
#include "r3_str.h" #include "r3_str.h"
#include "r3_gvc.h" #include "r3_gvc.h"
#include "str_array.h"
#include "bench.h" #include "bench.h"
START_TEST (test_gvc_render_dot) START_TEST (test_gvc_render_dot)

View file

@ -10,7 +10,6 @@
#include <stdlib.h> #include <stdlib.h>
#include "r3.h" #include "r3.h"
#include "r3_str.h" #include "r3_str.h"
#include "str_array.h"
#include "zmalloc.h" #include "zmalloc.h"
START_TEST (test_pattern_to_opcode) START_TEST (test_pattern_to_opcode)

View file

@ -4,7 +4,6 @@
#include <stdlib.h> #include <stdlib.h>
#include "r3.h" #include "r3.h"
#include "r3_str.h" #include "r3_str.h"
#include "str_array.h"
#include "zmalloc.h" #include "zmalloc.h"
#include "bench.h" #include "bench.h"