rem: LOG(L_ERR, "enum_query(): Branch <%.*s>, q <%d>\n", result.len, result.s, q);
context: int enum_query_2(struct sip_msg* _msg, char* _suffix, char* _service){	char *user_s;	int user_len, i, j, first;	char name[MAX_DOMAIN_SIZE];	char uri[MAX_URI_SIZE];	char new_uri[MAX_URI_SIZE];	unsigned int priority, curr_prio;	qvalue_t q;	struct rdata* head;	struct rdata* l;	struct naptr_rdata* naptr;	str pattern, replacement, result, new_result;	char string[17];	str *suffix, *service;	suffix = (str*)_suffix;	service = (str*)_service;	if (parse_sip_msg_uri(_msg) < 0) {		LOG(L_ERR, "enum_query(): uri parsing failed\n");		return -1;	}	if (is_e164(&(_msg->parsed_uri.user)) == -1) {		LOG(L_ERR, "enum_query(): uri user is not an E164 number\n");		return -1;	}	user_s = _msg->parsed_uri.user.s;	user_len = _msg->parsed_uri.user.len;	memcpy(&(string[0]), user_s, user_len);	string[user_len] = (char)0;	j = 0;	for (i = user_len - 1; i > 0; i--) {		name[j] = user_s[i];		name[j + 1] = '.';		j = j + 2;	}	memcpy(name + j, suffix->s, suffix->len + 1);	head = get_record(name, T_NAPTR);	if (head == 0) {		DBG("enum_query(): No NAPTR record found for %s.\n", name);		return -1;	}	naptr_sort(&head);	q = MAX_Q - 10;	curr_prio = 0;	first = 1;	for (l = head; l; l = l->next) {		if (l->type != T_NAPTR) continue; /*should never happen*/		naptr = (struct naptr_rdata*)l->rdata;		if (naptr == 0) {			LOG(L_CRIT, "enum_query: BUG: null rdata\n");			continue;		}		DBG("enum_query(): order %u, pref %u, flen %u, flags '%.*s', slen %u, "		    "services '%.*s', rlen %u, regexp '%.*s'\n", naptr->order, naptr->pref,		    naptr->flags_len, (int)(naptr->flags_len), ZSW(naptr->flags),		    naptr->services_len,		    (int)(naptr->services_len), ZSW(naptr->services), naptr->regexp_len,		    (int)(naptr->regexp_len), ZSW(naptr->regexp));		if (sip_match(naptr, service) == 0) continue;		if (parse_naptr_regexp(&(naptr->regexp[0]), naptr->regexp_len,				       &pattern, &replacement) < 0) {			LOG(L_ERR, "enum_query(): parsing of NAPTR regexp failed\n");			continue;		}		result.s = &(uri[0]);		result.len = MAX_URI_SIZE;		/* Avoid making copies of pattern and replacement */		pattern.s[pattern.len] = (char)0;		replacement.s[replacement.len] = (char)0;		if (reg_replace(pattern.s, replacement.s, &(string[0]),				&result) < 0) {			pattern.s[pattern.len] = '!';			replacement.s[replacement.len] = '!';			LOG(L_ERR, "enum_query(): regexp replace failed\n");			continue;		}		DBG("enum_query(): resulted in replacement: '%.*s'\n",		    result.len, ZSW(result.s));		pattern.s[pattern.len] = '!';		replacement.s[replacement.len] = '!';				if (param.len > 0) {			if (result.len + param.len > MAX_URI_SIZE - 1) {				LOG(L_ERR, "ERROR: enum_query(): URI is too long\n");				continue;			}			new_result.s = &(new_uri[0]);			new_result.len = MAX_URI_SIZE;			if (add_uri_param(&result, &param, &new_result) == 0) {				LOG(L_ERR, "ERROR: enum_query(): Parsing of URI failed\n");				continue;			}			if (new_result.len > 0) {				result = new_result;			}		}		if (first) {			if (rewrite_uri(_msg, result.s, result.len) == -1) {				goto done;			}			set_ruri_q(q);			LOG(L_ERR, "enum_query(): R-URI <%.*s>, q <%d>\n", result.len, result.s, q);			first = 0;			curr_prio = ((naptr->order) << 16) + naptr->pref;		} else {			priority = ((naptr->order) << 16) + naptr->pref;			if (priority > curr_prio) {				q = q - 10;				curr_prio = priority;			}			if (append_branch(_msg, result.s, result.len, q) == -1) {				goto done;			}			LOG(L_ERR, "enum_query(): Branch <%.*s>, q <%d>\n", result.len, result.s, q);		}	}done:	free_rdata_list(head);	return first ? -1 : 1;}