static struct msg_data* msg_data_create(const struct ast_msg *msg, const char *to, const char *from) { char *tag; struct msg_data *mdata = ao2_alloc(sizeof(*mdata), msg_data_destroy); if (!mdata) { return NULL; } /* typecast to suppress const warning */ mdata->msg = ast_msg_ref((struct ast_msg*)msg); /* starts with 'pjsip:' the 'pj' needs to be removed and maybe even the entire string. */ if (!(to = strchr(to, ':'))) { ao2_ref(mdata, -1); return NULL; } /* Make sure we start with sip: */ mdata->to = ast_begins_with(to, "sip:") ? ast_strdup(++to) : ast_strdup(to - 3); mdata->from = ast_strdup(from); /* sometimes from can still contain the tag at this point, so remove it */ if ((tag = strchr(mdata->from, ';'))) { *tag = '\0'; } return mdata; }
static struct msg_data* msg_data_create(const struct ast_msg *msg, const char *to, const char *from) { char *tag; struct msg_data *mdata = ao2_alloc(sizeof(*mdata), msg_data_destroy); if (!mdata) { return NULL; } /* typecast to suppress const warning */ mdata->msg = ast_msg_ref((struct ast_msg*)msg); /* starts with 'pjsip:' the 'pj' needs to be removed and maybe even the entire string. */ if (!(to = strchr(to, ':'))) { ao2_ref(mdata, -1); return NULL; } /* if there is another sip in the uri then we are good, otherwise it needs a sip: in front */ mdata->to = to == skip_sip(to) ? ast_strdup(to - 3) : ast_strdup(++to); mdata->from = ast_strdup(from); /* sometimes from can still contain the tag at this point, so remove it */ if ((tag = strchr(mdata->from, ';'))) { *tag = '\0'; } return mdata; }