Ada 2.7.8
Fast spec-compliant URL parser
No Matches
Go to the documentation of this file.
5#ifndef ADA_C_H
6#define ADA_C_H
8#include <stdbool.h>
9#include <stdint.h>
10#include <stddef.h>
12// This is a reference to ada::url_components::omitted
13// It represents "uint32_t(-1)"
14#define ada_url_omitted 0xffffffff
16// string that is owned by the ada_url instance
17typedef struct {
18 const char* data;
19 size_t length;
22// string that must be freed by the caller
23typedef struct {
24 const char* data;
25 size_t length;
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;
39typedef void* ada_url;
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);
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);
52void ada_free(ada_url result);
56bool ada_is_valid(ada_url result);
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);
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);
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);
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);
105// returns a pointer to the internal url_aggregator::url_components
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);
112// url search params
115// Represents an std::vector<std::string>
116typedef void* ada_strings;
127ada_url_search_params ada_parse_search_params(const char* input, size_t length);
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);
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);
185#endif // ADA_C_H
ada_url_search_params ada_parse_search_params(const char *input, size_t length)
Definition ada_c.cpp:468
ada_string ada_get_hash(ada_url result)
Definition ada_c.cpp:168
bool ada_set_port(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:290
ada_strings ada_search_params_get_all(ada_url_search_params result, const char *key, size_t key_length)
Definition ada_c.cpp:586
void ada_clear_search(ada_url result)
Definition ada_c.cpp:361
void ada_free_search_params_entries_iter(ada_url_search_params_entries_iter result)
Definition ada_c.cpp:708
bool ada_set_host(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:246
bool ada_has_password(ada_url result)
Definition ada_c.cpp:416
bool ada_search_params_keys_iter_has_next(ada_url_search_params_keys_iter result)
Definition ada_c.cpp:671
ada_string ada_search_params_values_iter_next(ada_url_search_params_values_iter result)
Definition ada_c.cpp:686
void ada_free_search_params_keys_iter(ada_url_search_params_keys_iter result)
Definition ada_c.cpp:653
ada_string ada_get_pathname(ada_url result)
Definition ada_c.cpp:195
const ada_url_components * ada_get_components(ada_url result)
Definition ada_c.cpp:441
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:560
bool ada_has_empty_hostname(ada_url result)
Definition ada_c.cpp:376
void ada_free_strings(ada_strings result)
Definition ada_c.cpp:631
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:508
bool ada_has_non_empty_password(ada_url result)
Definition ada_c.cpp:400
bool ada_set_password(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:281
ada_url_search_params_entries_iter ada_search_params_get_entries(ada_url_search_params result)
Definition ada_c.cpp:620
void * ada_url_search_params_entries_iter
Definition ada_c.h:125
ada_string ada_get_hostname(ada_url result)
Definition ada_c.cpp:186
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:572
uint8_t ada_get_host_type(ada_url result)
Definition ada_c.cpp:222
ada_string ada_get_password(ada_url result)
Definition ada_c.cpp:150
void * ada_strings
Definition ada_c.h:116
void ada_search_params_sort(ada_url_search_params result)
Definition ada_c.cpp:500
ada_owned_string ada_idna_to_unicode(const char *input, size_t length)
Definition ada_c.cpp:450
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:539
bool ada_set_hostname(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:254
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:474
ada_string ada_get_port(ada_url result)
Definition ada_c.cpp:159
bool ada_set_pathname(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:298
ada_string ada_get_host(ada_url result)
Definition ada_c.cpp:177
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:408
void ada_clear_hash(ada_url result)
Definition ada_c.cpp:348
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:479
ada_string ada_strings_get(ada_strings result, size_t index)
Definition ada_c.cpp:644
bool ada_set_href(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:238
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:727
size_t ada_search_params_size(ada_url_search_params result)
Definition ada_c.cpp:491
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:213
void ada_free_search_params_values_iter(ada_url_search_params_values_iter result)
Definition ada_c.cpp:680
bool ada_set_username(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:272
ada_string ada_get_username(ada_url result)
Definition ada_c.cpp:141
uint8_t ada_get_scheme_type(ada_url result)
Definition ada_c.cpp:230
ada_string ada_search_params_keys_iter_next(ada_url_search_params_keys_iter result)
Definition ada_c.cpp:658
ada_string_pair ada_search_params_entries_iter_next(ada_url_search_params_entries_iter result)
Definition ada_c.cpp:714
void ada_clear_port(ada_url result)
Definition ada_c.cpp:335
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:598
ada_owned_string ada_idna_to_ascii(const char *input, size_t length)
Definition ada_c.cpp:459
void ada_set_search(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:314
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:699
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:519
ada_string ada_get_href(ada_url result)
Definition ada_c.cpp:132
bool ada_set_protocol(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:263
size_t ada_strings_size(ada_strings result)
Definition ada_c.cpp:636
ada_url_search_params_values_iter ada_search_params_get_values(ada_url_search_params result)
Definition ada_c.cpp:609
bool ada_has_hash(ada_url result)
Definition ada_c.cpp:424
bool ada_search_params_has(ada_url_search_params result, const char *key, size_t key_length)
Definition ada_c.cpp:550
bool ada_has_hostname(ada_url result)
Definition ada_c.cpp:384
bool ada_has_credentials(ada_url result)
Definition ada_c.cpp:368
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:204
void ada_search_params_remove(ada_url_search_params result, const char *key, size_t key_length)
Definition ada_c.cpp:530
bool ada_has_non_empty_username(ada_url result)
Definition ada_c.cpp:392
bool ada_has_search(ada_url result)
Definition ada_c.cpp:432
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:328
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