uri_parser.h
1 /*
2  * Copyright (C) 2020 HAW Hamburg
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
27 #ifndef URI_PARSER_H
28 #define URI_PARSER_H
29 
30 #include <string.h>
31 #include <stdint.h>
32 #include <stdbool.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
41 typedef struct {
42  char *scheme;
43  char *userinfo;
52  char *host;
53 
61  char *ipv6addr;
62 
68  char *zoneid;
69 
70  char *port;
71  char *path;
72  char *query;
73  uint16_t scheme_len;
74  uint16_t userinfo_len;
75  uint16_t host_len;
76  uint16_t ipv6addr_len;
77  uint16_t zoneid_len;
78  uint16_t port_len;
79  uint16_t path_len;
80  uint16_t query_len;
82 
94 bool uri_parser_is_absolute(const char *uri, size_t uri_len);
95 
106 bool uri_parser_is_absolute_string(const char *uri);
107 
120 int uri_parser_process(uri_parser_result_t *result, const char *uri,
121  size_t uri_len);
122 
134 int uri_parser_process_string(uri_parser_result_t *result, const char *uri);
135 
136 #ifdef __cplusplus
137 }
138 #endif
139 
140 #endif /* URI_PARSER_H */
141 
uri_parser_process_string
int uri_parser_process_string(uri_parser_result_t *result, const char *uri)
Parse a URI reference.
uri_parser_result_t::userinfo_len
uint16_t userinfo_len
length of userinfo
Definition: uri_parser.h:74
uri_parser_result_t::host
char * host
host part
Definition: uri_parser.h:52
uri_parser_result_t::zoneid_len
uint16_t zoneid_len
length of zoneid
Definition: uri_parser.h:77
uri_parser_result_t::port
char * port
port
Definition: uri_parser.h:70
uri_parser_is_absolute
bool uri_parser_is_absolute(const char *uri, size_t uri_len)
Checks whether uri is in absolute form.
uri_parser_result_t::query
char * query
query
Definition: uri_parser.h:72
uri_parser_result_t::scheme
char * scheme
scheme
Definition: uri_parser.h:42
uri_parser_result_t::ipv6addr_len
uint16_t ipv6addr_len
length of ipv6addr
Definition: uri_parser.h:76
uri_parser_result_t::path_len
uint16_t path_len
length of path
Definition: uri_parser.h:79
uri_parser_result_t
container that holds all results
Definition: uri_parser.h:41
uri_parser_result_t::path
char * path
path
Definition: uri_parser.h:71
uri_parser_result_t::ipv6addr
char * ipv6addr
Pointer to the start of the address, if host is an IPv6 address and NULL otherwise.
Definition: uri_parser.h:61
uri_parser_result_t::host_len
uint16_t host_len
length of host
Definition: uri_parser.h:75
uri_parser_result_t::query_len
uint16_t query_len
length of query
Definition: uri_parser.h:80
uri_parser_result_t::userinfo
char * userinfo
userinfo
Definition: uri_parser.h:43
uri_parser_result_t::scheme_len
uint16_t scheme_len
length of scheme
Definition: uri_parser.h:73
uri_parser_result_t::port_len
uint16_t port_len
length of port
Definition: uri_parser.h:78
uri_parser_result_t::zoneid
char * zoneid
zoneid if host is IPv6 address, NULL otherwise
Definition: uri_parser.h:68
uri_parser_is_absolute_string
bool uri_parser_is_absolute_string(const char *uri)
Checks whether uri is in absolute form.
uri_parser_process
int uri_parser_process(uri_parser_result_t *result, const char *uri, size_t uri_len)
Parse a URI reference.