Add r3_tree_match_with_entry function to match with match_entry

This commit is contained in:
c9s 2014-05-18 12:32:20 +08:00
parent 58cd893dea
commit e6c7d3e45e
4 changed files with 14 additions and 20 deletions

View file

@ -124,6 +124,8 @@ void r3_tree_compile_patterns(node * n);
node * r3_tree_match(node * n, char * path, int path_len, match_entry * entry); node * r3_tree_match(node * n, char * path, int path_len, match_entry * entry);
node * r3_tree_match_with_entry(node * n, match_entry * entry);
bool r3_node_has_slug_edges(node *n); bool r3_node_has_slug_edges(node *n);
edge * r3_edge_create(char * pattern, int pattern_len, node * child); edge * r3_edge_create(char * pattern, int pattern_len, node * child);
@ -148,8 +150,6 @@ condition * condition_createl(char * path, int path_len);
int condition_cmp(condition *r1, condition *r2); int condition_cmp(condition *r1, condition *r2);
edge * r3_edge_route_create(condition * condition, node * child);
void r3_node_append_condition(node * n, condition * condition, void * data); void r3_node_append_condition(node * n, condition * condition, void * data);
void condition_free(condition * condition); void condition_free(condition * condition);

View file

@ -211,6 +211,11 @@ void match_entry_free(match_entry * entry) {
} }
node * r3_tree_match_with_entry(node * n, match_entry * entry) {
return r3_tree_match(n, entry->path, entry->path_len, entry);
}
/** /**
* This function matches the URL path and return the left node * This function matches the URL path and return the left node
* *
@ -573,22 +578,4 @@ void r3_node_append_condition(node * n, condition * condition, void * data) {
n->conditions[ n->condition_len++ ] = condition; n->conditions[ n->condition_len++ ] = condition;
} }
/**
* Create a condition-only edge. (without pattern)
*/
edge * r3_edge_route_create(condition * condition, node * child) {
edge * e = (edge*) malloc( sizeof(edge) );
/*
e->pattern = NULL;
e->pattern_len = 0;
e->child = child;
// e->condition = NULL;
*/
return e;
}
/*
char * r3_node_trace(node * n) {
}
*/

View file

@ -121,3 +121,7 @@
1400387232,11035725.37 1400387232,11035725.37
1400387264,11006703.61 1400387264,11006703.61
1400387291,11123431.08 1400387291,11123431.08
1400387303,10762934.26
1400387318,10842286.92
1400387384,10651069.93
1400387532,11055554.04

1 1400242718 5649455.80
121 1400387232 11035725.37
122 1400387264 11006703.61
123 1400387291 11123431.08
124 1400387303 10762934.26
125 1400387318 10842286.92
126 1400387384 10651069.93
127 1400387532 11055554.04

View file

@ -261,6 +261,9 @@ START_TEST(test_insert_route)
r3_tree_insert_route(n, r1, &var1); r3_tree_insert_route(n, r1, &var1);
r3_tree_insert_route(n, r2, &var2); r3_tree_insert_route(n, r2, &var2);
node *m;
m = r3_tree_match(n , "/qux/bar/corge", strlen("/qux/bar/corge"), NULL);
match_entry_free(entry); match_entry_free(entry);
condition_free(r1); condition_free(r1);
condition_free(r2); condition_free(r2);