nsurl: Expose scheme type accessor.

This commit is contained in:
Michael Drake 2020-05-19 21:01:09 +01:00
parent 20d46406ed
commit 1347f9e3a6
3 changed files with 28 additions and 12 deletions

View File

@ -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),
@ -145,6 +155,15 @@ nserror nsurl_get(const nsurl *url, nsurl_component parts,
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
*

View File

@ -236,6 +236,15 @@ lwc_string *nsurl_get_component(const nsurl *url, nsurl_component part)
}
/* exported interface, documented in nsurl.h */
enum nsurl_scheme_type nsurl_get_scheme_type(const nsurl *url)
{
assert(url != NULL);
return url->components.scheme_type;
}
/* exported interface, documented in nsurl.h */
bool nsurl_has_component(const nsurl *url, nsurl_component part)
{

View File

@ -25,18 +25,6 @@
#include "utils/utils.h"
/** 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
};
/**
* nsurl components
*