summaryrefslogtreecommitdiff
path: root/utils/url.c
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2014-10-26 10:23:28 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2014-10-26 10:23:28 +0000
commit64d591676b638b43831f5ae78a6c59a7753c62df (patch)
treed783eb375dd4f32cfbce6cb6bb28c168a54883d7 /utils/url.c
parent1ccfcfe953d9a5144746bfafcf5d37a8229ca998 (diff)
downloadnetsurf-64d591676b638b43831f5ae78a6c59a7753c62df.tar.gz
netsurf-64d591676b638b43831f5ae78a6c59a7753c62df.tar.bz2
Remove unused url_components stuff.
Diffstat (limited to 'utils/url.c')
-rw-r--r--utils/url.c141
1 files changed, 0 insertions, 141 deletions
diff --git a/utils/url.c b/utils/url.c
index d1b6805b5..e1903a816 100644
--- a/utils/url.c
+++ b/utils/url.c
@@ -31,15 +31,6 @@
#include "utils/utils.h"
#include "utils/url.h"
-struct url_components_internal {
- char *buffer; /* buffer used for all the following data */
- char *scheme;
- char *authority;
- char *path;
- char *query;
- char *fragment;
-};
-
regex_t url_re, url_up_re;
@@ -154,138 +145,6 @@ out_true:
return true;
}
-/**
- * Split a URL into separate components
- *
- * URLs passed to this function are assumed to be valid and no error checking
- * or recovery is attempted.
- *
- * See RFC 3986 for reference.
- *
- * \param url A valid absolute or relative URL.
- * \param result Pointer to buffer to hold components.
- * \return NSERROR_OK on success
- */
-static nserror
-url_get_components(const char *url, struct url_components *result)
-{
- int storage_length;
- char *storage_end;
- const char *scheme;
- const char *authority;
- const char *path;
- const char *query;
- const char *fragment;
- struct url_components_internal *internal;
-
- assert(url);
-
- /* clear our return value */
- internal = (struct url_components_internal *)result;
- memset(result, 0x00, sizeof(struct url_components));
-
- /* get enough storage space for a URL with termination at each node */
- storage_length = strlen(url) + 8;
- internal->buffer = malloc(storage_length);
- if (!internal->buffer)
- return NSERROR_NOMEM;
- storage_end = internal->buffer;
-
- /* look for a valid scheme */
- scheme = url;
- if (isalpha(*scheme)) {
- for (scheme = url + 1;
- ((*scheme != ':') && (*scheme != '\0'));
- scheme++) {
- if (!isalnum(*scheme) && (*scheme != '+') &&
- (*scheme != '-') && (*scheme != '.'))
- break;
- }
-
- if (*scheme == ':') {
- memcpy(storage_end, url, scheme - url);
- storage_end[scheme - url] = '\0';
- result->scheme = storage_end;
- storage_end += scheme - url + 1;
- scheme++;
- } else {
- scheme = url;
- }
- }
-
-
- /* look for an authority */
- authority = scheme;
- if ((authority[0] == '/') && (authority[1] == '/')) {
- authority = strpbrk(scheme + 2, "/?#");
- if (!authority)
- authority = scheme + strlen(scheme);
- memcpy(storage_end, scheme + 2, authority - scheme - 2);
- storage_end[authority - scheme - 2] = '\0';
- result->authority = storage_end;
- storage_end += authority - scheme - 1;
- }
-
-
- /* look for a path */
- path = authority;
- if ((*path != '?') && (*path != '#') && (*path != '\0')) {
- path = strpbrk(path, "?#");
- if (!path)
- path = authority + strlen(authority);
- memcpy(storage_end, authority, path - authority);
- storage_end[path - authority] = '\0';
- result->path = storage_end;
- storage_end += path - authority + 1;
- }
-
-
- /* look for a query */
- query = path;
- if (*query == '?') {
- query = strchr(query, '#');
- if (!query)
- query = path + strlen(path);
- memcpy(storage_end, path + 1, query - path - 1);
- storage_end[query - path - 1] = '\0';
- result->query = storage_end;
- storage_end += query - path;
- }
-
-
- /* look for a fragment */
- fragment = query;
- if (*fragment == '#') {
- fragment = query + strlen(query);
-
- /* make a copy of the result for the caller */
- memcpy(storage_end, query + 1, fragment - query - 1);
- storage_end[fragment - query - 1] = '\0';
- result->fragment = storage_end;
- storage_end += fragment - query;
- }
-
- assert((result->buffer + storage_length) >= storage_end);
- return NSERROR_OK;
-}
-
-
-/**
- * Release some url components from memory
- *
- * \param result pointer to buffer containing components
- */
-static void url_destroy_components(const struct url_components *components)
-{
- const struct url_components_internal *internal;
-
- assert(components);
-
- internal = (const struct url_components_internal *)components;
- if (internal->buffer)
- free(internal->buffer);
-}
-
/* exported interface documented in utils/url.h */
nserror url_nice(const char *url, char **result,