From 1c85bf04293cfba663c5170bbe762825b7e72af1 Mon Sep 17 00:00:00 2001 From: James Bursa Date: Tue, 2 Mar 2004 18:02:41 +0000 Subject: [project @ 2004-03-02 18:02:17 by bursa] Add new url functions and modify to use them. svn path=/import/netsurf/; revision=578 --- utils/utils.c | 105 +--------------------------------------------------------- 1 file changed, 1 insertion(+), 104 deletions(-) (limited to 'utils/utils.c') diff --git a/utils/utils.c b/utils/utils.c index 889985178..f2c7188ea 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -2,7 +2,7 @@ * This file is part of NetSurf, http://netsurf.sourceforge.net/ * Licensed under the GNU General Public License, * http://www.opensource.org/licenses/gpl-license - * Copyright 2003 James Bursa + * Copyright 2004 James Bursa * Copyright 2003 Phil Mellor * Copyright 2003 John M Bell */ @@ -12,17 +12,11 @@ #include #include #include -#include #include #include #include #include "libxml/encoding.h" -#include "libxml/uri.h" #include "netsurf/utils/config.h" -#ifdef riscos -#include "netsurf/riscos/about.h" -#include "netsurf/riscos/constdata.h" -#endif #define NDEBUG #include "netsurf/utils/log.h" #include "netsurf/utils/messages.h" @@ -189,103 +183,6 @@ char *squash_tolat1(xmlChar *s) } -/** - * Calculate an URL from a relative and base URL. - * - * base may be 0 for a new URL, in which case the URL is canonicalized and - * returned. Returns 0 in case of error. - */ - -char *url_join(char *rel_url, char *base_url) -{ - char *res; - uri_t *base = 0, *rel = 0, *abs; - - LOG(("rel_url = %s, base_url = %s", rel_url, base_url)); - -#ifdef riscos - /* hacky, hacky, hacky... - * It is, however, best to do this here as it avoids - * duplicating code for clicking links and url bar handling. - * It simplifies the code it the other places too (they just - * call this as usual, then we handle it here). - */ -#ifdef WITH_ABOUT - if (strcasecmp(rel_url, "about:") == 0) { - about_create(); - return xstrdup(ABOUT_URL); - } -#ifdef WITH_COOKIES - if (strcasecmp(rel_url, "about:cookies") == 0) { - cookie_create(); - return xstrdup(COOKIE_URL); - } -#endif -#endif -#endif - - if (!base_url) { - res = uri_cannonicalize_string(rel_url, - (int)(strlen(rel_url)), - URI_STRING_URI_STYLE); - LOG(("res = %s", res)); - if (res) - return xstrdup(res); - return 0; - } - - base = uri_alloc(base_url, (int)(strlen(base_url))); - rel = uri_alloc(rel_url, (int)(strlen(rel_url))); - if (!base || !rel) - goto fail; - if (!base->scheme) - goto fail; - - abs = uri_abs_1(base, rel); - - res = xstrdup(uri_uri(abs)); - - uri_free(base); - uri_free(rel); - - LOG(("res = %s", res)); - return res; - -fail: - if (base) - uri_free(base); - if (rel) - uri_free(rel); - - LOG(("error")); - - return 0; -} - - -/** - * Extract the host name from a url. - * - * \param url an absolute URL - * \return a new string, or 0 in case of error - */ - -char *get_host_from_url(char *url) -{ - char *host = 0; - uri_t *uri; - - uri = uri_alloc(url, (int)(strlen(url))); - if (!uri) - return 0; - if (uri->host) - host = xstrdup(uri->host); - uri_free(uri); - - return host; -} - - /** * Check if a directory exists. */ -- cgit v1.2.3