Loading...
Searching...
No Matches
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
35extern "C" {
36#endif
37
41typedef struct {
42 const char *scheme;
43 const char *userinfo;
52 const char *host;
53
61 const char *ipv6addr;
62
68 const char *zoneid;
69
70 const char *port_str;
71 const char *path;
72 const char *query;
73 uint16_t port;
74 uint16_t scheme_len;
75 uint16_t userinfo_len;
76 uint16_t host_len;
77 uint16_t ipv6addr_len;
78 uint16_t zoneid_len;
79 uint16_t port_str_len;
80 uint16_t path_len;
81 uint16_t query_len;
83
87typedef struct {
88 const char *name;
89 const char *value;
90 uint16_t name_len;
91 uint16_t value_len;
93
105bool uri_parser_is_absolute(const char *uri, size_t uri_len);
106
117bool uri_parser_is_absolute_string(const char *uri);
118
131int uri_parser_process(uri_parser_result_t *result, const char *uri,
132 size_t uri_len);
133
145int uri_parser_process_string(uri_parser_result_t *result, const char *uri);
146
175 size_t params_len);
176
177#ifdef __cplusplus
178}
179#endif
180
181#endif /* URI_PARSER_H */
int uri_parser_process_string(uri_parser_result_t *result, const char *uri)
Parse a URI reference.
int uri_parser_process(uri_parser_result_t *result, const char *uri, size_t uri_len)
Parse a URI reference.
int uri_parser_split_query(const uri_parser_result_t *uri_parsed, uri_parser_query_param_t *params, size_t params_len)
Provides a list of URI query parameters from a given URI parser result.
bool uri_parser_is_absolute_string(const char *uri)
Checks whether uri is in absolute form.
bool uri_parser_is_absolute(const char *uri, size_t uri_len)
Checks whether uri is in absolute form.
Container to represent a query parameter.
Definition uri_parser.h:87
const char * value
value of the query parameter
Definition uri_parser.h:89
const char * name
name of the query parameter
Definition uri_parser.h:88
uint16_t name_len
length of name
Definition uri_parser.h:90
uint16_t value_len
length of value
Definition uri_parser.h:91
container that holds all results
Definition uri_parser.h:41
uint16_t scheme_len
length of scheme
Definition uri_parser.h:74
const char * scheme
scheme
Definition uri_parser.h:42
uint16_t zoneid_len
length of zoneid
Definition uri_parser.h:78
uint16_t path_len
length of path
Definition uri_parser.h:80
const char * host
host part
Definition uri_parser.h:52
const char * userinfo
userinfo
Definition uri_parser.h:43
uint16_t userinfo_len
length of userinfo
Definition uri_parser.h:75
const char * query
query
Definition uri_parser.h:72
uint16_t query_len
length of query
Definition uri_parser.h:81
uint16_t port_str_len
length of port_str
Definition uri_parser.h:79
uint16_t ipv6addr_len
length of ipv6addr
Definition uri_parser.h:77
const char * port_str
port as str
Definition uri_parser.h:70
uint16_t port
port as uint16_t
Definition uri_parser.h:73
const char * path
path
Definition uri_parser.h:71
const char * zoneid
zoneid if host is IPv6 address, NULL otherwise
Definition uri_parser.h:68
uint16_t host_len
length of host
Definition uri_parser.h:76
const char * ipv6addr
Pointer to the start of the address, if host is an IPv6 address and NULL otherwise.
Definition uri_parser.h:61