* Inputs:
* - patricia tree object
* - name of node to lookup
+ * - whether to do a direct or fuzzy match
*
* Outputs:
* - on success, the dtree node requested
* - none
*/
struct irc_radixtree_leaf *
-irc_radixtree_elem_find(struct irc_radixtree *dict, const char *key)
+irc_radixtree_elem_find(struct irc_radixtree *dict, const char *key, int fuzzy)
{
char ckey_store[256];
}
/* Now, if the key is in the tree, delem contains it. */
- if ((delem != NULL) && strcmp(delem->leaf.key, ckey))
+ if ((delem != NULL) && !fuzzy && strcmp(delem->leaf.key, ckey))
delem = NULL;
if (ckey_buf != NULL)
if (key != NULL)
{
STATE_CUR(state) = NULL;
- STATE_NEXT(state) = irc_radixtree_elem_find(dtree, key);
+ STATE_NEXT(state) = irc_radixtree_elem_find(dtree, key, 1);
/* make STATE_CUR point to selected item and STATE_NEXT point to
* next item in the tree */
void *data;
struct irc_radixtree_leaf *leaf;
- leaf = irc_radixtree_elem_find(dict, key);
+ leaf = irc_radixtree_elem_find(dict, key, 0);
if (leaf == NULL)
return NULL;
void *
irc_radixtree_retrieve(struct irc_radixtree *dtree, const char *key)
{
- struct irc_radixtree_leaf *delem = irc_radixtree_elem_find(dtree, key);
+ struct irc_radixtree_leaf *delem = irc_radixtree_elem_find(dtree, key, 0);
if (delem != NULL)
return delem->data;