GATE
uris.h File Reference

URI and URL parsing and creation functions. More...

#include "gate/gate_core_api.h"
#include "gate/gatetypes.h"
#include "gate/strings.h"

Classes

struct  gate_uri_class
 

Macros

#define GATE_URI_SCHEME_FILE   "file"
 
#define GATE_URI_SCHEME_FTP   "ftp"
 
#define GATE_URI_SCHEME_GOPHER   "gopher"
 
#define GATE_URI_SCHEME_HTTP   "http"
 
#define GATE_URI_SCHEME_HTTPS   "https"
 
#define GATE_URI_SCHEME_MAILTO   "mailto"
 
#define GATE_URI_SCHEME_NETPIPE   "net.pipe"
 
#define GATE_URI_SCHEME_NETTCP   "net.tcp"
 
#define GATE_URI_SCHEME_NETUDP   "net.udp"
 
#define GATE_URI_SCHEME_NEWS   "news"
 
#define GATE_URI_SCHEME_NNTP   "nntp"
 
#define GATE_URI_SCHEME_SEPARATOR   "://"
 

Typedefs

typedef struct gate_uri_class gate_uri_t
 

Functions

GATE_CORE_API gate_result_t gate_uri_init (gate_uri_t *uri)
 Initializes an empty URI object.
 
GATE_CORE_API gate_result_t gate_uri_copy (gate_uri_t *target, gate_uri_t const *src)
 Initializes an URI object by copying data from another URI object.
 
GATE_CORE_API gate_result_t gate_uri_destroy (gate_uri_t *uri)
 Destroys the URI object by releasing all its contained strings.
 
GATE_CORE_API gate_result_t gate_uri_parse (gate_uri_t *uri, gate_string_t const *text)
 Initializes an URI object by parsing a text string.
 
GATE_CORE_API gate_result_t gate_uri_to_string (gate_uri_t const *uri, gate_string_t *text, gate_bool_t absolute_path_only)
 Creates a string from the contents of the given URI object.
 
GATE_CORE_API gate_result_t gate_uri_escape (gate_string_t const *src, gate_string_t *dest)
 Performs an URI string ESCAPE conversion.
 
GATE_CORE_API gate_result_t gate_uri_unescape (gate_string_t const *src, gate_string_t *dest)
 Performs an URI string UNESCAPE conversion.
 
GATE_CORE_API gate_result_t gate_uri_parse_user_info (gate_string_t const *src, gate_string_t *username, gate_string_t *password)
 Parses an URI's userinfo field and creates username and password tokens from it.
 
GATE_CORE_API gate_result_t gate_uri_build_user_info (gate_string_t const *username, gate_string_t const *password, gate_string_t *user_info)
 Generates an URI's userinfo field from username and password parameters.
 
GATE_CORE_API gate_result_t gate_uri_parse_path (gate_string_t const *path, gate_string_t *abs_path, gate_string_t *query_part)
 Generates an URI's userinfo field from username and password parameters.
 

Detailed Description

URI and URL parsing and creation functions.

Function Documentation

◆ gate_uri_build_user_info()

GATE_CORE_API gate_result_t gate_uri_build_user_info ( gate_string_t const * username,
gate_string_t const * password,
gate_string_t * user_info )

Generates an URI's userinfo field from username and password parameters.

Parameters
[in]usernamePointer to plain username content
[in]passwordPointer to plain password content
[out]user_infoPointer to target string to be initialized with encoded userinfo
Returns
GATE_RESULT_* code

◆ gate_uri_copy()

GATE_CORE_API gate_result_t gate_uri_copy ( gate_uri_t * target,
gate_uri_t const * src )

Initializes an URI object by copying data from another URI object.

Parameters
[out]targetPointer to target URI object to be initialized
[in]srcPointer to source URI object to copy content from
Returns
GATE_RESULT_* code

◆ gate_uri_destroy()

GATE_CORE_API gate_result_t gate_uri_destroy ( gate_uri_t * uri)

Destroys the URI object by releasing all its contained strings.

Parameters
[in]uriPointer to target URI object to be destroyed
Returns
GATE_RESULT_* code

◆ gate_uri_escape()

GATE_CORE_API gate_result_t gate_uri_escape ( gate_string_t const * src,
gate_string_t * dest )

Performs an URI string ESCAPE conversion.

Parameters
[in]srcPointer to plain input string to be escaped
[out]destPointer to target string to be initialized with escaped content
Returns
GATE_RESULT_* code

◆ gate_uri_init()

GATE_CORE_API gate_result_t gate_uri_init ( gate_uri_t * uri)

Initializes an empty URI object.

Parameters
[out]uriPointer to URI object to be initialized
Returns
GATE_RESULT_* code

◆ gate_uri_parse()

GATE_CORE_API gate_result_t gate_uri_parse ( gate_uri_t * uri,
gate_string_t const * text )

Initializes an URI object by parsing a text string.

Parameters
[out]uriPointer to target URI object to be initialized
[in]textPointer to source string to be parsed
Returns
GATE_RESULT_* code

◆ gate_uri_parse_path()

GATE_CORE_API gate_result_t gate_uri_parse_path ( gate_string_t const * path,
gate_string_t * abs_path,
gate_string_t * query_part )

Generates an URI's userinfo field from username and password parameters.

Parameters
[in]usernamePointer to plain username content
[in]passwordPointer to plain password content
[out]user_infoPointer to target string to be initialized with encoded userinfo
Returns
GATE_RESULT_* code

◆ gate_uri_parse_user_info()

GATE_CORE_API gate_result_t gate_uri_parse_user_info ( gate_string_t const * src,
gate_string_t * username,
gate_string_t * password )

Parses an URI's userinfo field and creates username and password tokens from it.

Parameters
[in]srcPointer to encoded userinfo string
[out]usernamePointer to target string to be initialized with username content
[out]passwordPointer to target string to be initialized with password content
Returns
GATE_RESULT_* code

◆ gate_uri_to_string()

GATE_CORE_API gate_result_t gate_uri_to_string ( gate_uri_t const * uri,
gate_string_t * text,
gate_bool_t absolute_path_only )

Creates a string from the contents of the given URI object.

Parameters
[in]uriPointer to source URI object
[out]textPointer to target string to be initialized with URI's content
[in]absolute_path_onlyIf TRUE, only the path part is exported - schema, user and host is skipped
Returns
GATE_RESULT_* code

◆ gate_uri_unescape()

GATE_CORE_API gate_result_t gate_uri_unescape ( gate_string_t const * src,
gate_string_t * dest )

Performs an URI string UNESCAPE conversion.

Parameters
[in]srcPointer to escaped input string to be unescaped
[out]destPointer to target string to be initialized with plain content
Returns
GATE_RESULT_* code