e2k-uri

e2k-uri — URI utility routines

Synopsis




struct      E2kUri;
E2kUri*     e2k_uri_new                     (const char *uri_string);
void        e2k_uri_free                    (E2kUri *uri);

const char* e2k_uri_get_param               (E2kUri *uri,
                                             const char *name);

void        e2k_uri_decode                  (char *part);
char*       e2k_uri_encode                  (const char *in,
                                             gboolean wss_encoding,
                                             const char *extra_enc_chars);
void        e2k_uri_append_encoded          (GString *str,
                                             const char *in,
                                             gboolean wss_encoding,
                                             const char *extra_enc_chars);

const char* e2k_uri_path                    (const char *uri_string);
char*       e2k_uri_concat                  (const char *uri_prefix,
                                             const char *tail);
const char* e2k_uri_relative                (const char *uri_prefix,
                                             const char *uri);

Description

Details

struct E2kUri

struct E2kUri {

	char  *protocol;
	char  *user;
	char  *domain;
	char  *authmech;
	char  *passwd;
	char  *host;
	int    port;
	char  *path;
	GData *params;
	char  *query;
	char  *fragment;
};


e2k_uri_new ()

E2kUri*     e2k_uri_new                     (const char *uri_string);

Parses uri_string.

uri_string : the URI
Returns : a parsed E2kUri

e2k_uri_free ()

void        e2k_uri_free                    (E2kUri *uri);

Frees uri

uri : an E2kUri

e2k_uri_get_param ()

const char* e2k_uri_get_param               (E2kUri *uri,
                                             const char *name);

Fetches a parameter from uri

uri : an E2kUri
name : name of the parameter
Returns : the value of name, or NULL if it is not set

e2k_uri_decode ()

void        e2k_uri_decode                  (char *part);

Undoes URI-escaping in part in-place.

part : a piece of a URI

e2k_uri_encode ()

char*       e2k_uri_encode                  (const char *in,
                                             gboolean wss_encoding,
                                             const char *extra_enc_chars);

Encodes URI-unsafe characters as in e2k_uri_append_encoded()

in : data to encode
wss_encoding :
extra_enc_chars : additional characters beyond the normal URI-reserved characters to encode when appending to str
Returns : the encoded string

e2k_uri_append_encoded ()

void        e2k_uri_append_encoded          (GString *str,
                                             const char *in,
                                             gboolean wss_encoding,
                                             const char *extra_enc_chars);

Appends in to str, encoding URI-unsafe characters as needed (optionally including some Exchange-specific encodings).

When appending a path, you must append each segment separately; e2k_uri_append_encoded() will encode any "/"s passed in.

str : a GString containing part of a URI
in : data to append to str
wss_encoding :
extra_enc_chars : additional characters beyond the normal URI-reserved characters to encode when appending to str

e2k_uri_path ()

const char* e2k_uri_path                    (const char *uri_string);

Returns the path component of uri_string, including the initial "/". (The return value is actually a pointer into the passed-in string, meaning this will only really work if the URI has no query/fragment/etc.)

uri_string : a well-formed absolute URI
Returns : the path component of uri_string.

e2k_uri_concat ()

char*       e2k_uri_concat                  (const char *uri_prefix,
                                             const char *tail);

Constructs a new URI consisting of the concatenation of uri_prefix and tail. If uri_prefix does not end with a "/", one will be inserted between uri_prefix and tail.

uri_prefix : an absolute URI
tail : a relative path
Returns : the new URI

e2k_uri_relative ()

const char* e2k_uri_relative                (const char *uri_prefix,
                                             const char *uri);

Returns a URI describing uri's relation to uri_prefix; either a relative URI consisting of the subpath of uri underneath uri_prefix, or all of uri if it is not a sub-uri of uri_prefix.

uri_prefix : an absolute URI
uri : another URI, presumably a child of uri_prefix
Returns : the relative URI