Example #1
0
static int fixup_replace_disp_uri(void** param)
{
	char *p;
	str *s = (str*)*param;
	str repl;

	/* check to see if it is already quoted */
	if ((s->s[0] == '\"' && s->s[s->len - 1] == '\"') ||
			str_check_token(s)) {
		if (pkg_nt_str_dup(&repl, s) < 0)
			return E_OUT_OF_MEM;
		*s = repl;
		return 0;
	}

	/* put " around display name */
	p = (char*)pkg_malloc(s->len+3);
	if (p==0) {
		LM_CRIT("no more pkg mem\n");
		return E_OUT_OF_MEM;
	}
	p[0] = '\"';
	memcpy(p+1, s->s, s->len);
	p[s->len+1] = '\"';
	p[s->len+2] = '\0';
	s->s = p;
	s->len += 2;

	return 0;
}
Example #2
0
static int fixup_replace_disp_uri(void** param, int param_no)
{
	pv_elem_t *model;
	char *p;
	str s;

	/* convert to str */
	s.s = (char*)*param;
	s.len = strlen(s.s);

	model=NULL;
	if (param_no==1 && s.len) {
		/* check to see if it is already quoted */
		if ((s.s[0] == '\"' && s.s[s.len - 1] == '\"') ||
				str_check_token(&s))
			goto unquoted;

		/* put " around display name */
		p = (char*)pkg_malloc(s.len+3);
		if (p==0) {
			LM_CRIT("no more pkg mem\n");
			return E_OUT_OF_MEM;
		}
		p[0] = '\"';
		memcpy(p+1, s.s, s.len);
		p[s.len+1] = '\"';
		p[s.len+2] = '\0';
		pkg_free(s.s);
		s.s = p;
		s.len += 2;
	}
unquoted:
	if(pv_parse_format(&s ,&model)<0) {
		LM_ERR("wrong format [%s] for param no %d!\n", s.s, param_no);
		pkg_free(s.s);
		return E_UNSPEC;
	}
	*param = (void*)model;

	return 0;
}