uri.h
Go to the documentation of this file.
/*
* uri.h -- helper functions for URI treatment
*
* Copyright (C) 2010-2011,2016 Olaf Bergmann <bergmann@tzi.org>
*
* This file is part of the CoAP library libcoap. Please see README for terms
* of use.
*/
#ifndef _COAP_URI_H_
#define _COAP_URI_H_
#include "hashkey.h"
#include "str.h"
typedef struct {
str host;
unsigned short port;
str path;
str query;
} coap_uri_t;
coap_uri_t *coap_new_uri(const unsigned char *uri, unsigned int length);
coap_uri_t *coap_clone_uri(const coap_uri_t *uri);
int coap_hash_path(const unsigned char *path, size_t len, coap_key_t key);
int coap_split_uri(const unsigned char *str_var, size_t len, coap_uri_t *uri);
int coap_split_path(const unsigned char *s,
size_t length,
unsigned char *buf,
size_t *buflen);
int coap_split_query(const unsigned char *s,
size_t length,
unsigned char *buf,
size_t *buflen);
#endif /* _COAP_URI_H_ */
coap_uri_t
Representation of parsed URI.
Definition: uri.h:20
coap_uri_t::query
str query
The query part if present.
Definition: uri.h:25
coap_key_t
unsigned char coap_key_t[4]
Definition: hashkey.h:20
coap_clone_uri
coap_uri_t * coap_clone_uri(const coap_uri_t *uri)
Clones the specified coap_uri_t object.
Definition: uri.c:433
coap_uri_t::host
str host
host part of the URI
Definition: uri.h:21
coap_new_uri
coap_uri_t * coap_new_uri(const unsigned char *uri, unsigned int length)
Creates a new coap_uri_t object from the specified URI.
Definition: uri.c:414
coap_uri_t::path
str path
Beginning of the first path segment.
Definition: uri.h:23
str.h
coap_split_uri
int coap_split_uri(const unsigned char *str_var, size_t len, coap_uri_t *uri)
Parses a given string into URI components.
Definition: uri.c:48
coap_uri_t::port
unsigned short port
The port in host byte order.
Definition: uri.h:22
cnt_str::buf
str buf
Definition: uri.c:357
coap_split_path
int coap_split_path(const unsigned char *s, size_t length, unsigned char *buf, size_t *buflen)
Splits the given URI path into segments.
Definition: uri.c:376
coap_hash_path
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.
Definition: uri.c:483
str
Definition: str.h:15
coap_split_query
int coap_split_query(const unsigned char *s, size_t length, unsigned char *buf, size_t *buflen)
Splits the given URI query into segments.
Definition: uri.c:388
hashkey.h
definition of hash key type and helper functions