summaryrefslogtreecommitdiff
path: root/utils/nsurl.h
diff options
context:
space:
mode:
Diffstat (limited to 'utils/nsurl.h')
-rw-r--r--utils/nsurl.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/utils/nsurl.h b/utils/nsurl.h
index 054baf26b..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,6 +332,9 @@ 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);
@@ -348,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