libcoap  4.1.1
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
Go to the documentation of this file.
1 /* uri.h -- helper functions for URI treatment
2  *
3  * Copyright (C) 2010,2011 Olaf Bergmann <>
4  *
5  * This file is part of the CoAP library libcoap. Please see
6  * README for terms of use.
7  */
9 #ifndef _COAP_URI_H_
10 #define _COAP_URI_H_
12 #include "hashkey.h"
13 #include "str.h"
18 typedef struct {
20  unsigned short port;
24 } coap_uri_t;
35 coap_uri_t *coap_new_uri(const unsigned char *uri, unsigned int length);
53 int coap_hash_path(const unsigned char *path, size_t len, coap_key_t key);
78 typedef struct {
79  size_t n;
80  unsigned char separator;
81  unsigned char *delim;
82  size_t dlen;
83  unsigned char *pos;
84  size_t segment_length;
100 coap_parse_iterator_init(unsigned char *s, size_t n,
101  unsigned char separator,
102  unsigned char *delim, size_t dlen,
116 unsigned char *coap_parse_next(coap_parse_iterator_t *pi);
134 int
135 coap_split_uri(unsigned char *str_var, size_t len, coap_uri_t *uri);
150 int coap_split_path(const unsigned char *s, size_t length,
151  unsigned char *buf, size_t *buflen);
168 int coap_split_query(const unsigned char *s, size_t length,
169  unsigned char *buf, size_t *buflen);
173 #endif /* _COAP_URI_H_ */
Representation of parsed URI.
Definition: uri.h:18
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:23
unsigned char coap_key_t[4]
Definition: hashkey.h:19
coap_uri_t * coap_clone_uri(const coap_uri_t *uri)
Clones the specified coap_uri_t object.
Definition: uri.c:404
str host
host part of the URI
Definition: uri.h:19
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:385
size_t segment_length
length of current segment
Definition: uri.h:84
size_t dlen
length of separator
Definition: uri.h:82
str path
Beginning of the first path segment.
Definition: uri.h:21
static coap_uri_t uri
Definition: client.c:36
unsigned short port
The port in host byte order.
Definition: uri.h:20
Iterator to for tokenizing a URI path or query.
Definition: uri.h:78
unsigned char * coap_parse_next(coap_parse_iterator_t *pi)
Updates the iterator pi to point to the next token.
Definition: uri.c:490
size_t n
number of remaining characters in buffer
Definition: uri.h:79
unsigned char separator
segment separators
Definition: uri.h:80
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:354
coap_parse_iterator_t * coap_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.
Definition: uri.c:472
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:454
unsigned char * delim
delimiters where to split the string
Definition: uri.h:81
Definition: str.h:14
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:368
definition of hash key type and helper functions
unsigned char * pos
current position in buffer
Definition: uri.h:83