char *test_search_exact() { void *res = TSTree_search(node, bdata(&test1), blength(&test1)); mu_assert(res == valueA, "got the wrong value back, should get A not B."); res = TSTree_search(node, "TESTNO", strlen("TESTNO")); mu_assert(res == NULL, "Should not find anything."); return NULL; }
bstring match_url(TSTree * routes, bstring url) { bstring route = TSTree_search(routes, bdata(url), blength(url)); if (route == NULL) { printf("No exact match found, trying prefix.\n"); route = TSTree_search_prefix(routes, bdata(url), blength(url)); } return route; }
bstring match_url(TSTree *routes , bstring url) { /*just use TSTree_search and search_prefix to search urls */ bstring route = TSTree_search(routes , bdata(url) , blength(url)); if(route == NULL ){ printf("no exact match found , trying prefix .\n"); route = TSTree_search_prefix(routes , bdata(url) , blength(url)); } return route; }