E2kUri

## E2kUri E2kUri — URI utility routines |

## Synopsis

                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_encode,
                                                 const char *extra_enc_chars);
    void        e2k_uri_append_encoded          (GString *str,
                                                 const char *in,
                                                 gboolean wss_encode,
                                                 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

### E2kUri

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

A URI.

char *`protocol`; | the URI protocol
char *`user`; | the username to authenticate with
char *`domain`; | the Windows NT domain of `user`
char *`authmech`; | the HTTP authentication mechanism to use
char *`passwd`; | `user`'s password
char *`host`; | the host to connect to
int `port`; | the port to connect to
char *`path`; | the path on `host`
GData *`params`; | additional parameters
char *`query`; | query string
char *`fragment`; | URI 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_encode,
                                                 const char *extra_enc_chars);

Encodes URI-unsafe characters as in `e2k_uri_append_encoded()`

`in` : | data to encode
`wss_encode` : | whether or not to use the special Web Storage System encoding rules
`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_encode,
                                                 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_encode` : | whether or not to use the special Web Storage System encoding rules
`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