Revision: 14695 Author: adrian.chadd Date: Sun May 23 06:10:13 2010 Log: Migrate urlHostname() to libsqurl.
http://code.google.com/p/lusca-cache/source/detail?r=14695 Modified: /branches/LUSCA_HEAD/libsqurl/url.c /branches/LUSCA_HEAD/libsqurl/url.h /branches/LUSCA_HEAD/src/protos.h /branches/LUSCA_HEAD/src/url.c ======================================= --- /branches/LUSCA_HEAD/libsqurl/url.c Sun May 23 06:02:25 2010 +++ /branches/LUSCA_HEAD/libsqurl/url.c Sun May 23 06:10:13 2010 @@ -7,6 +7,9 @@ #include "../include/util.h" +#include "../libcore/tools.h" + +#include "defines.h" #include "url.h" char * @@ -59,3 +62,34 @@ return (1); } +/* + * Quick-n-dirty host extraction from a URL. Steps: + * Look for a colon + * Skip any '/' after the colon + * Copy the next SQUID_MAXHOSTNAMELEN bytes to host[] + * Look for an ending '/' or ':' and terminate + * Look for login info preceeded by '@' + */ +char * +urlHostname(const char *url) +{ + LOCAL_ARRAY(char, host, SQUIDHOSTNAMELEN); + char *t; + host[0] = '\0'; + if (NULL == (t = strchr(url, ':'))) + return NULL; + t++; + while (*t != '\0' && *t == '/') + t++; + xstrncpy(host, t, SQUIDHOSTNAMELEN); + if ((t = strchr(host, '/'))) + *t = '\0'; + if ((t = strchr(host, ':'))) + *t = '\0'; + if ((t = strrchr(host, '@'))) { + t++; + xmemmove(host, t, strlen(t) + 1); + } + return host; +} + ======================================= --- /branches/LUSCA_HEAD/libsqurl/url.h Sun May 23 06:02:25 2010 +++ /branches/LUSCA_HEAD/libsqurl/url.h Sun May 23 06:10:13 2010 @@ -3,5 +3,7 @@ extern char * url_convert_hex(char *org_url, int allocate); extern int urlIsRelative(const char *url); +extern char * urlHostname(const char *url); + #endif ======================================= --- /branches/LUSCA_HEAD/src/protos.h Sun May 23 06:02:25 2010 +++ /branches/LUSCA_HEAD/src/protos.h Sun May 23 06:10:13 2010 @@ -791,7 +791,6 @@ extern char *urlInternal(const char *dir, const char *name); extern int urlCheckRequest(const request_t *); extern char *urlCanonicalClean(const request_t *); -extern char *urlHostname(const char *url); extern void useragentOpenLog(void); extern void useragentRotateLog(void); ======================================= --- /branches/LUSCA_HEAD/src/url.c Sun May 23 06:02:25 2010 +++ /branches/LUSCA_HEAD/src/url.c Sun May 23 06:10:13 2010 @@ -490,34 +490,3 @@ } return rc; } - -/* - * Quick-n-dirty host extraction from a URL. Steps: - * Look for a colon - * Skip any '/' after the colon - * Copy the next SQUID_MAXHOSTNAMELEN bytes to host[] - * Look for an ending '/' or ':' and terminate - * Look for login info preceeded by '@' - */ -char * -urlHostname(const char *url) -{ - LOCAL_ARRAY(char, host, SQUIDHOSTNAMELEN); - char *t; - host[0] = '\0'; - if (NULL == (t = strchr(url, ':'))) - return NULL; - t++; - while (*t != '\0' && *t == '/') - t++; - xstrncpy(host, t, SQUIDHOSTNAMELEN); - if ((t = strchr(host, '/'))) - *t = '\0'; - if ((t = strchr(host, ':'))) - *t = '\0'; - if ((t = strrchr(host, '@'))) { - t++; - xmemmove(host, t, strlen(t) + 1); - } - return host; -} -- You received this message because you are subscribed to the Google Groups "lusca-commit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/lusca-commit?hl=en.
