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 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 
81 int coap_split_uri(unsigned char *str_var, size_t len, coap_uri_t *uri);
82 
96 int coap_split_path(const unsigned char *s,
97  size_t length,
98  unsigned char *buf,
99  size_t *buflen);
100 
116 int coap_split_query(const unsigned char *s,
117  size_t length,
118  unsigned char *buf,
119  size_t *buflen);
120 
123 #endif /* _COAP_URI_H_ */
Representation of parsed URI.
Definition: uri.h:20
int coap_split_uri(unsigned char *str_var, size_t len, coap_uri_t *uri)
Parses a given string into URI components.
Definition: uri.c:45
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:431
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:412
str path
Beginning of the first path segment.
Definition: uri.h:23
unsigned short port
The port in host byte order.
Definition: uri.h:22
str buf
Definition: uri.c:355
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:374
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:481
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:386
definition of hash key type and helper functions