diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/utils.c | 25 | ||||
-rw-r--r-- | utils/utils.h | 1 |
2 files changed, 23 insertions, 3 deletions
diff --git a/utils/utils.c b/utils/utils.c index bc912fdc7..ca7d7f2fc 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -197,14 +197,14 @@ char *url_join(const char* new, const char* base) nn[j] = new[i]; k = j; } - + j++; } if(k < j){ nn[k+1] = '\0'; LOG(("before: %s after: %s", new, nn)); } - + new = nn; if (base == 0) @@ -252,7 +252,26 @@ char *url_join(const char* new, const char* base) strcpy(ret, new); } - xfree(nn); + xfree(nn); return ret; } +char *get_host_from_url (char *url) { + + char *host = xcalloc(strlen(url)+10, sizeof(char)); + int i; + + i = strspn(url, "abcdefghijklmnopqrstuvwxyz"); + if (url[i] == ':') { + strcpy(host, url); + i += 3; + } + + for (; host[i] != 0 && host[i] != '/'; i++) + host[i] = tolower(host[i]); + + host[i] = '/'; + host[i+1] = 0; + + return host; +} diff --git a/utils/utils.h b/utils/utils.h index 9403d194e..30050b0ae 100644 --- a/utils/utils.h +++ b/utils/utils.h @@ -24,5 +24,6 @@ char * tolat1(xmlChar * s); char * tolat1_pre(xmlChar * s); char *squash_tolat1(xmlChar *s); char *url_join(const char* new, const char* base); +char *get_host_from_url(char* url); #endif |