Rename sofia_glue_get_user_host to switch_split_user_domain

and move to switch_utils. To allow use by other modules.
This commit is contained in:
Mathieu Parent
2010-06-02 01:09:54 +02:00
parent a291af5768
commit 3f7cafd709
8 changed files with 57 additions and 48 deletions

View File

@@ -2349,6 +2349,49 @@ SWITCH_DECLARE(int) switch_number_cmp(const char *exp, int val)
}
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: