mtree README does not mention about return value of mt_match function. however, code has this:
if(mt_match_prefix(msg, tr, &tomatch, mval)<0) { LM_DBG("no prefix found in [%.*s] for [%.*s]\n", tname.len, tname.s, tomatch.len, tomatch.s); goto error; }
lock_get( mt_lock ); mt_tree_refcnt--; lock_release( mt_lock ); return 1;
error: lock_get( mt_lock ); mt_tree_refcnt--; lock_release( mt_lock ); return -1;
so it looks like mt_match would return 1 if match succeeded and -1 if it did not.
however, this does not work if mode param has value 2, because in that case result of mt_add_tvalues is returned:
if ((it->type==MT_TREE_SVAL) || (it->type==MT_TREE_IVAL)) { if (mode == 2) return mt_add_tvalues(msg, it, tomatch);
mt_add_values, in turn, always returns 0 in case there is no error.
would it be ok if i make mt_add_tvalues to return -1 if no match is found? i could then also document the return value.
-- juha