Ada 2.8.0
Fast spec-compliant URL parser
Loading...
Searching...
No Matches
ada_c.h
Go to the documentation of this file.
1
5#ifndef ADA_C_H
6#define ADA_C_H
7
8#include <stdbool.h>
9#include <stdint.h>
10#include <stddef.h>
11
12// This is a reference to ada::url_components::omitted
13// It represents "uint32_t(-1)"
14#define ada_url_omitted 0xffffffff
15
16// string that is owned by the ada_url instance
17typedef struct {
18 const char* data;
19 size_t length;
21
22// string that must be freed by the caller
23typedef struct {
24 const char* data;
25 size_t length;
27
28typedef struct {
29 uint32_t protocol_end;
30 uint32_t username_end;
31 uint32_t host_start;
32 uint32_t host_end;
33 uint32_t port;
35 uint32_t search_start;
36 uint32_t hash_start;
38
39typedef void* ada_url;
40
41// input should be a null terminated C string (ASCII or UTF-8)
42// you must call ada_free on the returned pointer
43ada_url ada_parse(const char* input, size_t length);
44ada_url ada_parse_with_base(const char* input, size_t input_length,
45 const char* base, size_t base_length);
46
47// input and base should be a null terminated C strings
48bool ada_can_parse(const char* input, size_t length);
49bool ada_can_parse_with_base(const char* input, size_t input_length,
50 const char* base, size_t base_length);
51
52void ada_free(ada_url result);
55
56bool ada_is_valid(ada_url result);
57
58// url_aggregator getters
59// if ada_is_valid(result)) is false, an empty string is returned
71uint8_t ada_get_host_type(ada_url result);
72uint8_t ada_get_scheme_type(ada_url result);
73
74// url_aggregator setters
75// if ada_is_valid(result)) is false, the setters have no effect
76// input should be a null terminated C string
77bool ada_set_href(ada_url result, const char* input, size_t length);
78bool ada_set_host(ada_url result, const char* input, size_t length);
79bool ada_set_hostname(ada_url result, const char* input, size_t length);
80bool ada_set_protocol(ada_url result, const char* input, size_t length);
81bool ada_set_username(ada_url result, const char* input, size_t length);
82bool ada_set_password(ada_url result, const char* input, size_t length);
83bool ada_set_port(ada_url result, const char* input, size_t length);
84bool ada_set_pathname(ada_url result, const char* input, size_t length);
85void ada_set_search(ada_url result, const char* input, size_t length);
86void ada_set_hash(ada_url result, const char* input, size_t length);
87
88// url_aggregator clear methods
89void ada_clear_port(ada_url result);
90void ada_clear_hash(ada_url result);
91void ada_clear_search(ada_url result);
92
93// url_aggregator functions
94// if ada_is_valid(result) is false, functions below will return false
95bool ada_has_credentials(ada_url result);
97bool ada_has_hostname(ada_url result);
100bool ada_has_port(ada_url result);
101bool ada_has_password(ada_url result);
102bool ada_has_hash(ada_url result);
103bool ada_has_search(ada_url result);
104
105// returns a pointer to the internal url_aggregator::url_components
107
108// idna methods
109ada_owned_string ada_idna_to_unicode(const char* input, size_t length);
110ada_owned_string ada_idna_to_ascii(const char* input, size_t length);
111
112// url search params
114
115// Represents an std::vector<std::string>
116typedef void* ada_strings;
119
124
126
127ada_url_search_params ada_parse_search_params(const char* input, size_t length);
129
133
134void ada_search_params_append(ada_url_search_params result, const char* key,
135 size_t key_length, const char* value,
136 size_t value_length);
137void ada_search_params_set(ada_url_search_params result, const char* key,
138 size_t key_length, const char* value,
139 size_t value_length);
140void ada_search_params_remove(ada_url_search_params result, const char* key,
141 size_t key_length);
143 const char* key, size_t key_length,
144 const char* value, size_t value_length);
145bool ada_search_params_has(ada_url_search_params result, const char* key,
146 size_t key_length);
147bool ada_search_params_has_value(ada_url_search_params result, const char* key,
148 size_t key_length, const char* value,
149 size_t value_length);
151 size_t key_length);
153 const char* key, size_t key_length);
155 ada_url_search_params result);
157 ada_url_search_params result);
159 ada_url_search_params result);
160
161void ada_free_strings(ada_strings result);
162size_t ada_strings_size(ada_strings result);
163ada_string ada_strings_get(ada_strings result, size_t index);
164
170
177
184
185#endif // ADA_C_H
ada_url_search_params ada_parse_search_params(const char *input, size_t length)
Definition ada_c.cpp:466
ada_string ada_get_hash(ada_url result)
Definition ada_c.cpp:166
bool ada_set_port(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:288
ada_strings ada_search_params_get_all(ada_url_search_params result, const char *key, size_t key_length)
Definition ada_c.cpp:584
void ada_clear_search(ada_url result)
Definition ada_c.cpp:359
void ada_free_search_params_entries_iter(ada_url_search_params_entries_iter result)
Definition ada_c.cpp:706
bool ada_set_host(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:244
bool ada_has_password(ada_url result)
Definition ada_c.cpp:414
bool ada_search_params_keys_iter_has_next(ada_url_search_params_keys_iter result)
Definition ada_c.cpp:669
ada_string ada_search_params_values_iter_next(ada_url_search_params_values_iter result)
Definition ada_c.cpp:684
void ada_free_search_params_keys_iter(ada_url_search_params_keys_iter result)
Definition ada_c.cpp:651
ada_string ada_get_pathname(ada_url result)
Definition ada_c.cpp:193
const ada_url_components * ada_get_components(ada_url result)
Definition ada_c.cpp:439
bool ada_search_params_has_value(ada_url_search_params result, const char *key, size_t key_length, const char *value, size_t value_length)
Definition ada_c.cpp:558
bool ada_has_empty_hostname(ada_url result)
Definition ada_c.cpp:374
void ada_free_strings(ada_strings result)
Definition ada_c.cpp:629
void ada_search_params_append(ada_url_search_params result, const char *key, size_t key_length, const char *value, size_t value_length)
Definition ada_c.cpp:506
bool ada_has_non_empty_password(ada_url result)
Definition ada_c.cpp:398
bool ada_set_password(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:279
ada_url_search_params_entries_iter ada_search_params_get_entries(ada_url_search_params result)
Definition ada_c.cpp:618
void * ada_url_search_params_entries_iter
Definition ada_c.h:125
ada_string ada_get_hostname(ada_url result)
Definition ada_c.cpp:184
bool ada_can_parse_with_base(const char *input, size_t input_length, const char *base, size_t base_length)
Definition ada_c.cpp:89
ada_string ada_search_params_get(ada_url_search_params result, const char *key, size_t key_length)
Definition ada_c.cpp:570
uint8_t ada_get_host_type(ada_url result)
Definition ada_c.cpp:220
ada_string ada_get_password(ada_url result)
Definition ada_c.cpp:148
void * ada_strings
Definition ada_c.h:116
void ada_search_params_sort(ada_url_search_params result)
Definition ada_c.cpp:498
ada_owned_string ada_idna_to_unicode(const char *input, size_t length)
Definition ada_c.cpp:448
void ada_search_params_remove_value(ada_url_search_params result, const char *key, size_t key_length, const char *value, size_t value_length)
Definition ada_c.cpp:537
bool ada_set_hostname(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:252
ada_url ada_parse_with_base(const char *input, size_t input_length, const char *base, size_t base_length)
Definition ada_c.cpp:72
void ada_free_search_params(ada_url_search_params result)
Definition ada_c.cpp:472
ada_string ada_get_port(ada_url result)
Definition ada_c.cpp:157
bool ada_set_pathname(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:296
ada_string ada_get_host(ada_url result)
Definition ada_c.cpp:175
void * ada_url_search_params
Definition ada_c.h:113
ada_url ada_parse(const char *input, size_t length)
Definition ada_c.cpp:67
bool ada_has_port(ada_url result)
Definition ada_c.cpp:406
void ada_clear_hash(ada_url result)
Definition ada_c.cpp:346
void ada_free_owned_string(ada_owned_string owned)
Definition ada_c.cpp:126
ada_owned_string ada_search_params_to_string(ada_url_search_params result)
Definition ada_c.cpp:477
ada_string ada_strings_get(ada_strings result, size_t index)
Definition ada_c.cpp:642
bool ada_set_href(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:236
void ada_free(ada_url result)
Definition ada_c.cpp:95
void * ada_url
Definition ada_c.h:39
bool ada_search_params_entries_iter_has_next(ada_url_search_params_entries_iter result)
Definition ada_c.cpp:725
size_t ada_search_params_size(ada_url_search_params result)
Definition ada_c.cpp:489
ada_owned_string ada_get_origin(ada_url result)
Definition ada_c.cpp:111
ada_string ada_get_protocol(ada_url result)
Definition ada_c.cpp:211
void ada_free_search_params_values_iter(ada_url_search_params_values_iter result)
Definition ada_c.cpp:678
bool ada_set_username(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:270
ada_string ada_get_username(ada_url result)
Definition ada_c.cpp:139
uint8_t ada_get_scheme_type(ada_url result)
Definition ada_c.cpp:228
ada_string ada_search_params_keys_iter_next(ada_url_search_params_keys_iter result)
Definition ada_c.cpp:656
ada_string_pair ada_search_params_entries_iter_next(ada_url_search_params_entries_iter result)
Definition ada_c.cpp:712
void ada_clear_port(ada_url result)
Definition ada_c.cpp:333
bool ada_is_valid(ada_url result)
Definition ada_c.cpp:105
ada_url_search_params_keys_iter ada_search_params_get_keys(ada_url_search_params result)
Definition ada_c.cpp:596
ada_owned_string ada_idna_to_ascii(const char *input, size_t length)
Definition ada_c.cpp:457
void ada_set_search(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:312
void * ada_url_search_params_keys_iter
Definition ada_c.h:117
bool ada_search_params_values_iter_has_next(ada_url_search_params_values_iter result)
Definition ada_c.cpp:697
void ada_search_params_set(ada_url_search_params result, const char *key, size_t key_length, const char *value, size_t value_length)
Definition ada_c.cpp:517
ada_string ada_get_href(ada_url result)
Definition ada_c.cpp:130
bool ada_set_protocol(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:261
size_t ada_strings_size(ada_strings result)
Definition ada_c.cpp:634
ada_url_search_params_values_iter ada_search_params_get_values(ada_url_search_params result)
Definition ada_c.cpp:607
bool ada_has_hash(ada_url result)
Definition ada_c.cpp:422
bool ada_search_params_has(ada_url_search_params result, const char *key, size_t key_length)
Definition ada_c.cpp:548
bool ada_has_hostname(ada_url result)
Definition ada_c.cpp:382
bool ada_has_credentials(ada_url result)
Definition ada_c.cpp:366
void * ada_url_search_params_values_iter
Definition ada_c.h:118
bool ada_can_parse(const char *input, size_t length)
Definition ada_c.cpp:85
ada_string ada_get_search(ada_url result)
Definition ada_c.cpp:202
void ada_search_params_remove(ada_url_search_params result, const char *key, size_t key_length)
Definition ada_c.cpp:528
bool ada_has_non_empty_username(ada_url result)
Definition ada_c.cpp:390
bool ada_has_search(ada_url result)
Definition ada_c.cpp:430
ada_url ada_copy(ada_url input)
Definition ada_c.cpp:100
void ada_set_hash(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:326
size_t length
Definition ada_c.h:25
const char * data
Definition ada_c.h:24
ada_string value
Definition ada_c.h:122
ada_string key
Definition ada_c.h:121
const char * data
Definition ada_c.h:18
size_t length
Definition ada_c.h:19
uint32_t username_end
Definition ada_c.h:30
uint32_t host_end
Definition ada_c.h:32
uint32_t hash_start
Definition ada_c.h:36
uint32_t pathname_start
Definition ada_c.h:34
uint32_t port
Definition ada_c.h:33
uint32_t protocol_end
Definition ada_c.h:29
uint32_t search_start
Definition ada_c.h:35
uint32_t host_start
Definition ada_c.h:31