nsurl: Split out URL parsing.

This commit is contained in:
Michael Drake 2017-01-15 15:09:36 +00:00
parent 4c47f9c046
commit 95e5ede775
4 changed files with 1677 additions and 1524 deletions

View File

@ -1,6 +1,7 @@
# nsurl utils sources # nsurl utils sources
S_NSURL := \ S_NSURL := \
nsurl.c nsurl.c \
parse.c
S_NSURL := $(addprefix utils/nsurl/,$(S_NSURL)) S_NSURL := $(addprefix utils/nsurl/,$(S_NSURL))

File diff suppressed because it is too large Load Diff

1602
utils/nsurl/parse.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -21,6 +21,7 @@
#include <libwapcaplet/libwapcaplet.h> #include <libwapcaplet/libwapcaplet.h>
#include "utils/nsurl.h"
#include "utils/utils.h" #include "utils/utils.h"
/** A type for URL schemes */ /** A type for URL schemes */
@ -72,4 +73,71 @@ struct nsurl {
char string[FLEX_ARRAY_LEN_DECL]; /* Full URL as a string */ char string[FLEX_ARRAY_LEN_DECL]; /* Full URL as a string */
}; };
/** Marker set, indicating positions of sections within a URL string */
struct nsurl_component_lengths {
size_t scheme;
size_t username;
size_t password;
size_t host;
size_t port;
size_t path;
size_t query;
size_t fragment;
};
/** Flags indicating which parts of a URL string are required for a nsurl */
enum nsurl_string_flags {
NSURL_F_SCHEME = (1 << 0),
NSURL_F_SCHEME_PUNCTUATION = (1 << 1),
NSURL_F_AUTHORITY_PUNCTUATION = (1 << 2),
NSURL_F_USERNAME = (1 << 3),
NSURL_F_PASSWORD = (1 << 4),
NSURL_F_CREDENTIALS_PUNCTUATION = (1 << 5),
NSURL_F_HOST = (1 << 6),
NSURL_F_PORT = (1 << 7),
NSURL_F_AUTHORITY = (NSURL_F_USERNAME |
NSURL_F_PASSWORD |
NSURL_F_HOST |
NSURL_F_PORT),
NSURL_F_PATH = (1 << 8),
NSURL_F_QUERY = (1 << 9),
NSURL_F_FRAGMENT_PUNCTUATION = (1 << 10),
NSURL_F_FRAGMENT = (1 << 11)
};
/**
* Get nsurl string info; total length, component lengths, & components present
*
* \param url NetSurf URL components
* \param url_s Updated to contain the string
* \param l Individual component lengths
* \param flags String flags
*/
void nsurl__get_string(const struct nsurl_components *url, char *url_s,
struct nsurl_component_lengths *l,
enum nsurl_string_flags flags);
/**
* Get nsurl string info; total length, component lengths, & components present
*
* \param url NetSurf URL components
* \param parts Which parts of the URL are required in the string
* \param url_l Updated to total string length
* \param lengths Updated with individual component lengths
* \param pflags Updated to contain relevant string flags
*/
void nsurl__get_string_data(const struct nsurl_components *url,
nsurl_component parts, size_t *url_l,
struct nsurl_component_lengths *lengths,
enum nsurl_string_flags *pflags);
/**
* Calculate hash value
*
* \param url NetSurf URL object to set hash value for
*/
void nsurl__calc_hash(nsurl *url);
#endif #endif