Skip to content

Commit

Permalink
- complete backport from 1.8 of pull request #15
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan-iancu committed Aug 28, 2013
1 parent a3e12f6 commit 80c48e6
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions modules/presence_dialoginfo/notify_body.c
Expand Up @@ -59,12 +59,33 @@ void free_xml_body(char* body)
str* dlginfo_agg_nbody(str* pres_user, str* pres_domain, str** body_array, int n, int off_index)
{
str* n_body= NULL;
str *pres_uri= NULL;
char buf[MAX_URI_SIZE+1];

LM_DBG("[pres_user]=%.*s [pres_domain]= %.*s, [n]=%d\n",
pres_user->len, pres_user->s, pres_domain->len, pres_domain->s, n);
if ( (pres_user->len + pres_domain->len + 1) > MAX_URI_SIZE) {
LM_ERR("entity URI too long, maximum=%d\n", MAX_URI_SIZE);
return NULL;
}
memcpy(buf, "sip:", 4);
memcpy(buf+4, pres_user->s, pres_user->len);
buf[pres_user->len+4] = '@';
memcpy(buf + pres_user->len + 5, pres_domain->s, pres_domain->len);
buf[pres_user->len + 5 + pres_domain->len]= '\0';

pres_uri = (str*)pkg_malloc(sizeof(str));
if(pres_uri == NULL)
{
LM_ERR("while allocating memory\n");
return NULL;
}
memset(pres_uri, 0, sizeof(str));
pres_uri->s = buf;
pres_uri->len = pres_user->len + 5 + pres_domain->len;

LM_DBG("[pres_uri] %.*s, [n]=%d\n", pres_uri->len, pres_uri->s, n);

if(body_array== NULL)
return build_dialoginfo(pres_user, pres_domain);
return build_empty_dialoginfo(pres_uri, NULL);

n_body= agregate_xmls(pres_user, pres_domain, body_array, n);
LM_DBG("[n_body]=%p\n", n_body);
Expand All @@ -81,7 +102,7 @@ str* dlginfo_agg_nbody(str* pres_user, str* pres_domain, str** body_array, int n
xmlMemoryDump();

if (n_body== NULL)
n_body= build_dialoginfo(pres_user, pres_domain);
n_body= build_empty_dialoginfo(pres_uri, NULL);
return n_body;
}

Expand Down

0 comments on commit 80c48e6

Please sign in to comment.