예제 #1
0
/* Return the value of the "rn" parameter if exists, otherwise the user name.
 * The user name is normalized if needed, i.e. visual separators are removed,
 * the "rn" param is always normalized. */
int select_uri_rn_user(str* res, select_t* s, struct sip_msg* msg)
{
	int	ret;
	str	val;

	if (select_uri_p == NULL) {
		if (parse_uri(res->s, res->len, &uri)<0)
			return -1;
		select_uri_p = &uri;
	}

	/* search for the "rn" parameter */
	if ((ret = search_param(select_uri_p->params, "rn", 2, &val)) != 0)
		goto done;

	if (select_uri_p->sip_params.s != select_uri_p->params.s) {
		/* check also the original sip: URI parameters */
		if ((ret = search_param(select_uri_p->sip_params, "rn", 2, &val)) != 0)
			goto done;
	}

	if ((select_uri_p->flags & URI_USER_NORMALIZE) == 0)
		RETURN0_res(select_uri_p->user);
	/* else normalize the user name */
	val = select_uri_p->user;
done:
	if (ret < 0)
		return -1; /* error */

	if (!(res->s=get_static_buffer(val.len)))
		return -1;
	if ((res->len=normalize_tel_user(res->s, &val))==0)
		return 1;
	return 0;
}
예제 #2
0
파일: select_core.c 프로젝트: asyn/openvims
int select_uri_user(str* res, select_t* s, struct sip_msg* msg)
{
	if (parse_uri(res->s, res->len, &uri)<0)
		return -1;

	if (uri.flags & URI_USER_NORMALIZE) {
		if (!(res->s=get_static_buffer(uri.user.len)))
			return -1;
		if ((res->len=normalize_tel_user(res->s, (&uri.user)))==0)
			return 1;
		return 0;
	}
	RETURN0_res(uri.user);
}