GRU - Generic Reusable Utilities
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Data Structures | Typedefs | Enumerations | Functions
gru_uri.h File Reference
#include <inttypes.h>
#include <stdbool.h>
#include <common/gru_status.h>
#include <string/gru_alt.h>
#include <uriparser/Uri.h>

Go to the source code of this file.

Data Structures

struct  gru_uri_t_
 

Typedefs

typedef enum gru_uri_parse_opt_t_ gru_uri_parse_opt_t
 
typedef enum gru_uri_format_opt_t_ gru_uri_format_opt_t
 
typedef struct gru_uri_t_ gru_uri_t
 

Enumerations

enum  gru_uri_parse_opt_t_ { GRU_URI_PARSE_DEFAULT = 0, GRU_URI_PARSE_STRIP = 1 }
 
enum  gru_uri_format_opt_t_ { GRU_URI_FORMAT_NONE = 0, GRU_URI_FORMAT_PORT = 1, GRU_URI_FORMAT_PATH = 2, GRU_URI_FORMAT_DEFAULT }
 

Functions

gru_export gru_uri_t gru_uri_parse (const char *gru_restrict uri, gru_status_t *gru_restrict status)
 Default URI parser. More...
 
gru_export gru_uri_t gru_uri_parse_ex (const char *gru_restrict url, gru_uri_parse_opt_t parseopt, gru_status_t *gru_restrict status)
 URI parser with additional options. More...
 
gru_export char * gru_uri_simple_format (const gru_uri_t *gru_restrict uri, gru_status_t *gru_restrict status)
 Converts a URI object to a string. More...
 
gru_export char * gru_uri_format (const gru_uri_t *gru_restrict uri, gru_uri_format_opt_t fopt, gru_status_t *gru_restrict status)
 A more elaborate URI string converter that can filter parts of the URI. More...
 
gru_export bool gru_uri_set_scheme (gru_uri_t *uri, const char *scheme)
 Sets the scheme in a URI object. More...
 
gru_export bool gru_uri_set_path (gru_uri_t *uri, const char *path)
 Sets the URI path. More...
 
gru_export gru_uri_t gru_uri_clone (gru_uri_t other, gru_status_t *status)
 Clone a URI object. More...
 
gru_export void gru_uri_cleanup (gru_uri_t *uri)
 Cleans up a URI object. More...
 

Typedef Documentation

typedef struct gru_uri_t_ gru_uri_t

Enumeration Type Documentation

Enumerator
GRU_URI_FORMAT_NONE 
GRU_URI_FORMAT_PORT 

Formats only scheme and host.

GRU_URI_FORMAT_PATH 

Formats only scheme, host and port if available.

GRU_URI_FORMAT_DEFAULT 

Formats scheme, host, port and path if available.

Enumerator
GRU_URI_PARSE_DEFAULT 
GRU_URI_PARSE_STRIP 

Function Documentation

gru_export void gru_uri_cleanup ( gru_uri_t uri)

Cleans up a URI object.

Parameters
uria pointer to a URI object to clean
gru_export gru_uri_t gru_uri_clone ( gru_uri_t  other,
gru_status_t status 
)

Clone a URI object.

Parameters
otherthe object to clone
statusstatus object
Returns
A cloned object that must's be cleaned up after use. Check the status object to determine whether cloning was successful or not
gru_export char* gru_uri_format ( const gru_uri_t *gru_restrict  uri,
gru_uri_format_opt_t  fopt,
gru_status_t *gru_restrict  status 
)

A more elaborate URI string converter that can filter parts of the URI.

Parameters
uria pointer to an URI object
foptformatting options (see gru_uri_format_opt_t)
statusstatus object
Returns
a new URI string that must be free'd after use
gru_export gru_uri_t gru_uri_parse ( const char *gru_restrict  uri,
gru_status_t *gru_restrict  status 
)

Default URI parser.

Parameters
uriURI string (ie.: scheme://host:port/path)
statusstatus object
Returns
A parsed URI object with each component of the URI broken down
gru_export gru_uri_t gru_uri_parse_ex ( const char *gru_restrict  url,
gru_uri_parse_opt_t  parseopt,
gru_status_t *gru_restrict  status 
)

URI parser with additional options.

Parameters
uriURI string (ie.: scheme://host:port/path)
parseoptparse options (see gru_uri_format_opt_t)
statusstatus object
Returns
A parsed URI object with each component of the URI broken down
gru_export bool gru_uri_set_path ( gru_uri_t uri,
const char *  path 
)

Sets the URI path.

Parameters
uria pointer to an URI object
paththe path
Returns
true if success or false otherwise
gru_export bool gru_uri_set_scheme ( gru_uri_t uri,
const char *  scheme 
)

Sets the scheme in a URI object.

Parameters
uria pointer to an URI object
schemethe scheme to set it to
Returns
true if success or false otherwise
gru_export char* gru_uri_simple_format ( const gru_uri_t *gru_restrict  uri,
gru_status_t *gru_restrict  status 
)

Converts a URI object to a string.

Parameters
uria pointer to an URI object
statusstatus object
Returns
a new URI string that must be free'd after use