diff options
Diffstat (limited to 'utils/nsurl.h')
-rw-r--r-- | utils/nsurl.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/utils/nsurl.h b/utils/nsurl.h index f97562bf0..fcae12e0c 100644 --- a/utils/nsurl.h +++ b/utils/nsurl.h @@ -30,6 +30,16 @@ /** NetSurf URL object */ typedef struct nsurl nsurl; +/** A type for URL schemes */ +enum nsurl_scheme_type { + NSURL_SCHEME_OTHER, + NSURL_SCHEME_HTTP, + NSURL_SCHEME_HTTPS, + NSURL_SCHEME_FILE, + NSURL_SCHEME_FTP, + NSURL_SCHEME_MAILTO, + NSURL_SCHEME_DATA +}; typedef enum nsurl_component { NSURL_SCHEME = (1 << 0), @@ -146,6 +156,15 @@ lwc_string *nsurl_get_component(const nsurl *url, nsurl_component part); /** + * Get the scheme type from a NetSurf URL object + * + * \param url NetSurf URL object + * \return The URL scheme type. + */ +enum nsurl_scheme_type nsurl_get_scheme_type(const nsurl *url); + + +/** * Enquire about the existence of componenets in a given URL * * \param url NetSurf URL object @@ -181,6 +200,24 @@ const char *nsurl_access(const nsurl *url); /** + * Variant of \ref nsurl_access for logging. + * + * \param url NetSurf URL to retrieve a string pointer for. + * \return the required string + * + * This will not necessarily return the actual nsurl's URL, but something + * that is suitable for recording to logs. E.g. URLs with the `data` scheme + * will return a simple place holder, to avoid repeatedly dumping loads of data. + * + * The returned string is owned by the NetSurf URL object. It will die + * with the NetSurf URL object. Keep a reference to the URL if you need it. + * + * The returned string has a trailing '\0'. + */ +const char *nsurl_access_log(const nsurl *url); + + +/** * Get a UTF-8 string (for human readable IDNs) from a NetSurf URL object * * \param url NetSurf URL object @@ -295,12 +332,34 @@ nserror nsurl_refragment(const nsurl *url, lwc_string *frag, nsurl **new_url); * the created object. * * Any query component in url is replaced with query in new_url. + * + * Passing the empty string as a replacement will result in the query + * component being removed. */ nserror nsurl_replace_query(const nsurl *url, const char *query, nsurl **new_url); /** + * Create a NetSurf URL object, with scheme replaced + * + * \param url NetSurf URL to create new NetSurf URL from + * \param scheme Scheme to use + * \param new_url Returns new NetSurf URL with scheme provided + * \return NSERROR_OK on success, appropriate error otherwise + * + * If return value != NSERROR_OK, nothing will be returned in new_url. + * + * It is up to the client to call nsurl_unref when they are finished with + * the created object. + * + * Any scheme component in url is replaced with scheme in new_url. + */ +nserror nsurl_replace_scheme(const nsurl *url, lwc_string *scheme, + nsurl **new_url); + + +/** * Attempt to find a nice filename for a URL. * * \param url A NetSurf URL object to create a filename from @@ -329,4 +388,14 @@ nserror nsurl_nice(const nsurl *url, char **result, bool remove_extensions); */ nserror nsurl_parent(const nsurl *url, nsurl **new_url); +/** + * Dump a NetSurf URL's internal components to stderr + * + * This is helper functionality for developers, and shouldn't be called + * generally. + * + * \param url The NetSurf URL to dump components of + */ +void nsurl_dump(const nsurl *url); + #endif |