libcoap  4.1.1
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
Data Structures | Functions
uri.h File Reference
#include "hashkey.h"
#include "str.h"

Go to the source code of this file.

Data Structures

struct  coap_uri_t
 Representation of parsed URI. More...
 
struct  coap_parse_iterator_t
 Iterator to for tokenizing a URI path or query. More...
 

Functions

coap_uri_tcoap_new_uri (const unsigned char *uri, unsigned int length)
 Creates a new coap_uri_t object from the specified URI. More...
 
coap_uri_tcoap_clone_uri (const coap_uri_t *uri)
 Clones the specified coap_uri_t object. More...
 
int coap_hash_path (const unsigned char *path, size_t len, coap_key_t key)
 Calculates a hash over the given path and stores the result in key. More...
 
coap_parse_iterator_tcoap_parse_iterator_init (unsigned char *s, size_t n, unsigned char separator, unsigned char *delim, size_t dlen, coap_parse_iterator_t *pi)
 Initializes the given iterator pi. More...
 
unsigned char * coap_parse_next (coap_parse_iterator_t *pi)
 Updates the iterator pi to point to the next token. More...
 
int coap_split_uri (unsigned char *str_var, size_t len, coap_uri_t *uri)
 Parses a given string into URI components. More...
 
int coap_split_path (const unsigned char *s, size_t length, unsigned char *buf, size_t *buflen)
 Splits the given URI path into segments. More...
 
int coap_split_query (const unsigned char *s, size_t length, unsigned char *buf, size_t *buflen)
 Splits the given URI query into segments. More...
 

Function Documentation

coap_uri_t* coap_clone_uri ( const coap_uri_t uri)

Clones the specified coap_uri_t object.

Thie function allocates sufficient memory to hold the coap_uri_t structure and its contents. The object must be released with coap_free().

Definition at line 404 of file uri.c.

int coap_hash_path ( const unsigned char *  path,
size_t  len,
coap_key_t  key 
)

Calculates a hash over the given path and stores the result in key.

This function returns 0 on error or 1 on success.

Parameters
pathThe URI path to generate hash for.
lenThe length of path.
keyThe output buffer.
Returns
1 if key was set, 0 otherwise.

Definition at line 454 of file uri.c.

coap_uri_t* coap_new_uri ( const unsigned char *  uri,
unsigned int  length 
)

Creates a new coap_uri_t object from the specified URI.

Returns the new object or NULL on error. The memory allocated by the new coap_uri_t must be released using coap_free().

Parameters
uriThe URI path to copy. length The length of uri.
Returns
New URI object or NULL on error.

Definition at line 385 of file uri.c.