and move to switch_utils. To allow use by other modules.
SWITCH_DECLARE(int) switch_number_cmp(const char *exp, int val);
+/*!
+ \brief Split a user@domain string as user and domain
+ \param in the input string
+ \param user the string to put the user into
+ \param domain the string to put the domain into
+ \return 1 if successfull
+ \note Extended formats protocol:user@domain:port (Example: sip:toto@example.org)
+*/
+int switch_split_user_domain(char *in, char **user, char **domain);
+
/* malloc or DIE macros */
#ifdef NDEBUG
#define switch_malloc(ptr, len) (void)( (!!(ptr = malloc(len))) || (fprintf(stderr,"ABORT! Malloc failure at: %s:%s", __FILE__, __LINE__),abort(), 0), ptr )
switch_channel_set_variable_printf(nchannel, "sip_local_network_addr", "%s", profile->extsipip ? profile->extsipip : profile->sipip);
switch_channel_set_variable(nchannel, "sip_profile_name", profile_name);
- sofia_glue_get_user_host(switch_core_session_strdup(nsession, tech_pvt->dest), NULL, &tech_pvt->remote_ip);
+ switch_split_user_domain(switch_core_session_strdup(nsession, tech_pvt->dest), NULL, &tech_pvt->remote_ip);
if (dest_to) {
if (strchr(dest_to, '@')) {
const char *sourceip, switch_memory_pool_t *pool);
void sofia_glue_pass_sdp(private_object_t *tech_pvt, char *sdp);
-int sofia_glue_get_user_host(char *in, char **user, char **host);
switch_call_cause_t sofia_glue_sip_cause_to_freeswitch(int status);
void sofia_glue_do_xfer_invite(switch_core_session_t *session);
uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip,
if ((mwi_account = switch_event_get_header_nil(event, "orig-mwi-account"))) {
dup_mwi_account = strdup(mwi_account);
switch_assert(dup_mwi_account != NULL);
- sofia_glue_get_user_host(dup_mwi_account, &mwi_user, &mwi_host);
+ switch_split_user_domain(dup_mwi_account, &mwi_user, &mwi_host);
}
if (!mwi_user) {
return ret;
}
-int sofia_glue_get_user_host(char *in, char **user, char **host)
-{
- char *p = NULL, *h = NULL, *u = in;
-
- if (!in) {
- return 0;
- }
-
- /* First isolate the host part from the user part */
- if ((h = strchr(u, '@'))) {
- *h++ = '\0';
- }
-
- /* Clean out the user part of its protocol prefix (if any) */
- if ((p = strchr(u, ':'))) {
- *p++ = '\0';
- u = p;
- }
-
- /* Clean out the host part of any suffix */
- if (h) {
- if ((p = strchr(h, ':'))) {
- *p = '\0';
- }
-
- if ((p = strchr(h, ';'))) {
- *p = '\0';
- }
-
- if ((p = strchr(h, ' '))) {
- *p = '\0';
- }
- }
- if (user) {
- *user = u;
- }
- if (host) {
- *host = h;
- }
-
- return 1;
-}
-
const char *sofia_glue_strip_proto(const char *uri)
{
char *p;
dup_account = strdup(account);
switch_assert(dup_account != NULL);
- sofia_glue_get_user_host(dup_account, &user, &host);
+ switch_split_user_domain(dup_account, &user, &host);
if ((pname = switch_event_get_header(event, "sofia-profile"))) {
if (v_event && *v_event && (mwi_account = switch_event_get_header(*v_event, "mwi-account"))) {
dup_mwi_account = strdup(mwi_account);
switch_assert(dup_mwi_account != NULL);
- sofia_glue_get_user_host(dup_mwi_account, &mwi_user, &mwi_host);
+ switch_split_user_domain(dup_mwi_account, &mwi_user, &mwi_host);
}
if (!mwi_user) {
}
+int switch_split_user_domain(char *in, char **user, char **domain)
+{
+ char *p = NULL, *h = NULL, *u = in;
+
+ if (!in) {
+ return 0;
+ }
+
+ /* First isolate the host part from the user part */
+ if ((h = strchr(u, '@'))) {
+ *h++ = '\0';
+ }
+
+ /* Clean out the user part of its protocol prefix (if any) */
+ if ((p = strchr(u, ':'))) {
+ *p++ = '\0';
+ u = p;
+ }
+
+ /* Clean out the host part of any suffix */
+ if (h) {
+ if ((p = strchr(h, ':'))) {
+ *p = '\0';
+ }
+
+ if ((p = strchr(h, ';'))) {
+ *p = '\0';
+ }
+
+ if ((p = strchr(h, ' '))) {
+ *p = '\0';
+ }
+ }
+ if (user) {
+ *user = u;
+ }
+ if (domain) {
+ *domain = h;
+ }
+
+ return 1;
+}
+
/* For Emacs:
* Local Variables: