libcoap  4.1.2
uri.h
Go to the documentation of this file.
1 /*
2  * uri.h -- helper functions for URI treatment
3  *
4  * Copyright (C) 2010-2011,2016 Olaf Bergmann <bergmann@tzi.org>
5  *
6  * This file is part of the CoAP library libcoap. Please see README for terms
7  * of use.
8  */
9 
10 #ifndef _COAP_URI_H_
11 #define _COAP_URI_H_
12 
13 #include "hashkey.h"
14 #include "str.h"
15 
20 typedef struct {
22  unsigned short port;
26 } coap_uri_t;
27 
38 coap_uri_t *coap_new_uri(const unsigned char *uri, unsigned int length);
39 
45 
56 int coap_hash_path(const unsigned char *path, size_t len, coap_key_t key);
57 
79 int coap_split_uri(const unsigned char *str_var, size_t len, coap_uri_t *uri);
80 
94 int coap_split_path(const unsigned char *s,
95  size_t length,
96  unsigned char *buf,
97  size_t *buflen);
98 
114 int coap_split_query(const unsigned char *s,
115  size_t length,
116  unsigned char *buf,
117  size_t *buflen);
118 
121 #endif /* _COAP_URI_H_ */
Representation of parsed URI.
Definition: uri.h:20
str query
The query part if present.
Definition: uri.h:25
unsigned char coap_key_t[4]
Definition: hashkey.h:20
coap_uri_t * coap_clone_uri(const coap_uri_t *uri)
Clones the specified coap_uri_t object.
Definition: uri.c:433
str host
host part of the URI
Definition: uri.h:21
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
str path
Beginning of the first path segment.
Definition: uri.h:23
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
unsigned short port
The port in host byte order.
Definition: uri.h:22
str buf
Definition: uri.c:357
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
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
Definition: str.h:15
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
definition of hash key type and helper functions