Loading...
Searching...
No Matches
ada_c.h
Go to the documentation of this file.
#ifndef ADA_C_H
#define ADA_C_H
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
// This is a reference to ada::url_components::omitted
// It represents "uint32_t(-1)"
#define ada_url_omitted 0xffffffff
// string that is owned by the ada_url instance
typedef struct {
const char* data;
size_t length;
} ada_string;
// string that must be freed by the caller
typedef struct {
const char* data;
size_t length;
} ada_owned_string;
typedef struct {
uint32_t protocol_end;
uint32_t username_end;
uint32_t host_start;
uint32_t host_end;
uint32_t port;
uint32_t pathname_start;
uint32_t search_start;
uint32_t hash_start;
} ada_url_components;
typedef void* ada_url;
// input should be a null terminated C string (ASCII or UTF-8)
// you must call ada_free on the returned pointer
ada_url ada_parse(const char* input, size_t length);
ada_url ada_parse_with_base(const char* input, size_t input_length,
const char* base, size_t base_length);
// input and base should be a null terminated C strings
bool ada_can_parse(const char* input, size_t length);
bool ada_can_parse_with_base(const char* input, size_t input_length,
const char* base, size_t base_length);
void ada_free(ada_url result);
void ada_free_owned_string(ada_owned_string owned);
ada_url ada_copy(ada_url input);
bool ada_is_valid(ada_url result);
// url_aggregator getters
// if ada_is_valid(result)) is false, an empty string is returned
ada_owned_string ada_get_origin(ada_url result);
ada_string ada_get_href(ada_url result);
ada_string ada_get_username(ada_url result);
ada_string ada_get_password(ada_url result);
ada_string ada_get_port(ada_url result);
ada_string ada_get_hash(ada_url result);
ada_string ada_get_host(ada_url result);
ada_string ada_get_hostname(ada_url result);
ada_string ada_get_pathname(ada_url result);
ada_string ada_get_search(ada_url result);
ada_string ada_get_protocol(ada_url result);
uint8_t ada_get_host_type(ada_url result);
uint8_t ada_get_scheme_type(ada_url result);
// url_aggregator setters
// if ada_is_valid(result)) is false, the setters have no effect
// input should be a null terminated C string
bool ada_set_href(ada_url result, const char* input, size_t length);
bool ada_set_host(ada_url result, const char* input, size_t length);
bool ada_set_hostname(ada_url result, const char* input, size_t length);
bool ada_set_protocol(ada_url result, const char* input, size_t length);
bool ada_set_username(ada_url result, const char* input, size_t length);
bool ada_set_password(ada_url result, const char* input, size_t length);
bool ada_set_port(ada_url result, const char* input, size_t length);
bool ada_set_pathname(ada_url result, const char* input, size_t length);
void ada_set_search(ada_url result, const char* input, size_t length);
void ada_set_hash(ada_url result, const char* input, size_t length);
// url_aggregator clear methods
void ada_clear_port(ada_url result);
void ada_clear_hash(ada_url result);
void ada_clear_search(ada_url result);
// url_aggregator functions
// if ada_is_valid(result) is false, functions below will return false
bool ada_has_credentials(ada_url result);
bool ada_has_empty_hostname(ada_url result);
bool ada_has_hostname(ada_url result);
bool ada_has_non_empty_username(ada_url result);
bool ada_has_non_empty_password(ada_url result);
bool ada_has_port(ada_url result);
bool ada_has_password(ada_url result);
bool ada_has_hash(ada_url result);
bool ada_has_search(ada_url result);
// returns a pointer to the internal url_aggregator::url_components
const ada_url_components* ada_get_components(ada_url result);
// idna methods
ada_owned_string ada_idna_to_unicode(const char* input, size_t length);
ada_owned_string ada_idna_to_ascii(const char* input, size_t length);
// url search params
typedef void* ada_url_search_params;
// Represents an std::vector<std::string>
typedef void* ada_strings;
typedef void* ada_url_search_params_keys_iter;
typedef void* ada_url_search_params_values_iter;
typedef struct {
ada_string key;
ada_string value;
} ada_string_pair;
typedef void* ada_url_search_params_entries_iter;
ada_url_search_params ada_parse_search_params(const char* input, size_t length);
void ada_free_search_params(ada_url_search_params result);
size_t ada_search_params_size(ada_url_search_params result);
void ada_search_params_sort(ada_url_search_params result);
ada_owned_string ada_search_params_to_string(ada_url_search_params result);
void ada_search_params_append(ada_url_search_params result, const char* key,
size_t key_length, const char* value,
size_t value_length);
void ada_search_params_set(ada_url_search_params result, const char* key,
size_t key_length, const char* value,
size_t value_length);
void ada_search_params_remove(ada_url_search_params result, const char* key,
size_t key_length);
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);
bool ada_search_params_has(ada_url_search_params result, const char* key,
size_t key_length);
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);
ada_string ada_search_params_get(ada_url_search_params result, const char* key,
size_t key_length);
ada_strings ada_search_params_get_all(ada_url_search_params result,
const char* key, size_t key_length);
void ada_search_params_reset(ada_url_search_params result, const char* input,
size_t length);
ada_url_search_params_keys_iter ada_search_params_get_keys(
ada_url_search_params result);
ada_url_search_params_values_iter ada_search_params_get_values(
ada_url_search_params result);
ada_url_search_params_entries_iter ada_search_params_get_entries(
ada_url_search_params result);
void ada_free_strings(ada_strings result);
size_t ada_strings_size(ada_strings result);
ada_string ada_strings_get(ada_strings result, size_t index);
void ada_free_search_params_keys_iter(ada_url_search_params_keys_iter result);
ada_string ada_search_params_keys_iter_next(
ada_url_search_params_keys_iter result);
bool ada_search_params_keys_iter_has_next(
ada_url_search_params_keys_iter result);
void ada_free_search_params_values_iter(
ada_url_search_params_values_iter result);
ada_string ada_search_params_values_iter_next(
ada_url_search_params_values_iter result);
bool ada_search_params_values_iter_has_next(
ada_url_search_params_values_iter result);
void ada_free_search_params_entries_iter(
ada_url_search_params_entries_iter result);
ada_string_pair ada_search_params_entries_iter_next(
ada_url_search_params_entries_iter result);
bool ada_search_params_entries_iter_has_next(
ada_url_search_params_entries_iter result);
// Definitions for Ada's version number.
typedef struct {
int major;
int minor;
int revision;
} ada_version_components;
const char* ada_get_version();
ada_version_components ada_get_version_components();
#endif // ADA_C_H
ada_parse_search_params
ada_url_search_params ada_parse_search_params(const char *input, size_t length)
Definition ada_c.cpp:469
ada_get_hash
ada_string ada_get_hash(ada_url result)
Definition ada_c.cpp:169
ada_set_port
bool ada_set_port(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:291
ada_search_params_get_all
ada_strings ada_search_params_get_all(ada_url_search_params result, const char *key, size_t key_length)
Definition ada_c.cpp:596
ada_clear_search
void ada_clear_search(ada_url result)
Definition ada_c.cpp:362
ada_free_search_params_entries_iter
void ada_free_search_params_entries_iter(ada_url_search_params_entries_iter result)
Definition ada_c.cpp:718
ada_set_host
bool ada_set_host(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:247
ada_has_password
bool ada_has_password(ada_url result)
Definition ada_c.cpp:417
ada_search_params_keys_iter_has_next
bool ada_search_params_keys_iter_has_next(ada_url_search_params_keys_iter result)
Definition ada_c.cpp:681
ada_search_params_values_iter_next
ada_string ada_search_params_values_iter_next(ada_url_search_params_values_iter result)
Definition ada_c.cpp:696
ada_free_search_params_keys_iter
void ada_free_search_params_keys_iter(ada_url_search_params_keys_iter result)
Definition ada_c.cpp:663
ada_get_pathname
ada_string ada_get_pathname(ada_url result)
Definition ada_c.cpp:196
ada_get_components
const ada_url_components * ada_get_components(ada_url result)
Definition ada_c.cpp:442
ada_search_params_has_value
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:570
ada_has_empty_hostname
bool ada_has_empty_hostname(ada_url result)
Definition ada_c.cpp:377
ada_free_strings
void ada_free_strings(ada_strings result)
Definition ada_c.cpp:641
ada_search_params_append
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:518
ada_has_non_empty_password
bool ada_has_non_empty_password(ada_url result)
Definition ada_c.cpp:401
ada_set_password
bool ada_set_password(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:282
ada_search_params_get_entries
ada_url_search_params_entries_iter ada_search_params_get_entries(ada_url_search_params result)
Definition ada_c.cpp:630
ada_url_search_params_entries_iter
void * ada_url_search_params_entries_iter
Definition ada_c.h:125
ada_get_hostname
ada_string ada_get_hostname(ada_url result)
Definition ada_c.cpp:187
ada_can_parse_with_base
bool ada_can_parse_with_base(const char *input, size_t input_length, const char *base, size_t base_length)
Definition ada_c.cpp:92
ada_search_params_get
ada_string ada_search_params_get(ada_url_search_params result, const char *key, size_t key_length)
Definition ada_c.cpp:582
ada_get_host_type
uint8_t ada_get_host_type(ada_url result)
Definition ada_c.cpp:223
ada_get_password
ada_string ada_get_password(ada_url result)
Definition ada_c.cpp:151
ada_get_version
const char * ada_get_version()
Definition ada_c.cpp:752
ada_get_version_components
ada_version_components ada_get_version_components()
Definition ada_c.cpp:754
ada_strings
void * ada_strings
Definition ada_c.h:116
ada_search_params_sort
void ada_search_params_sort(ada_url_search_params result)
Definition ada_c.cpp:501
ada_idna_to_unicode
ada_owned_string ada_idna_to_unicode(const char *input, size_t length)
Definition ada_c.cpp:451
ada_search_params_remove_value
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:549
ada_set_hostname
bool ada_set_hostname(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:255
ada_parse_with_base
ada_url ada_parse_with_base(const char *input, size_t input_length, const char *base, size_t base_length)
Definition ada_c.cpp:75
ada_free_search_params
void ada_free_search_params(ada_url_search_params result)
Definition ada_c.cpp:475
ada_get_port
ada_string ada_get_port(ada_url result)
Definition ada_c.cpp:160
ada_set_pathname
bool ada_set_pathname(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:299
ada_get_host
ada_string ada_get_host(ada_url result)
Definition ada_c.cpp:178
ada_url_search_params
void * ada_url_search_params
Definition ada_c.h:113
ada_parse
ada_url ada_parse(const char *input, size_t length)
Definition ada_c.cpp:70
ada_has_port
bool ada_has_port(ada_url result)
Definition ada_c.cpp:409
ada_clear_hash
void ada_clear_hash(ada_url result)
Definition ada_c.cpp:349
ada_free_owned_string
void ada_free_owned_string(ada_owned_string owned)
Definition ada_c.cpp:129
ada_search_params_to_string
ada_owned_string ada_search_params_to_string(ada_url_search_params result)
Definition ada_c.cpp:480
ada_strings_get
ada_string ada_strings_get(ada_strings result, size_t index)
Definition ada_c.cpp:654
ada_set_href
bool ada_set_href(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:239
ada_free
void ada_free(ada_url result)
Definition ada_c.cpp:98
ada_url
void * ada_url
Definition ada_c.h:39
ada_search_params_entries_iter_has_next
bool ada_search_params_entries_iter_has_next(ada_url_search_params_entries_iter result)
Definition ada_c.cpp:737
ada_search_params_size
size_t ada_search_params_size(ada_url_search_params result)
Definition ada_c.cpp:492
ada_get_origin
ada_owned_string ada_get_origin(ada_url result)
Definition ada_c.cpp:114
ada_get_protocol
ada_string ada_get_protocol(ada_url result)
Definition ada_c.cpp:214
ada_free_search_params_values_iter
void ada_free_search_params_values_iter(ada_url_search_params_values_iter result)
Definition ada_c.cpp:690
ada_set_username
bool ada_set_username(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:273
ada_get_username
ada_string ada_get_username(ada_url result)
Definition ada_c.cpp:142
ada_get_scheme_type
uint8_t ada_get_scheme_type(ada_url result)
Definition ada_c.cpp:231
ada_search_params_keys_iter_next
ada_string ada_search_params_keys_iter_next(ada_url_search_params_keys_iter result)
Definition ada_c.cpp:668
ada_search_params_entries_iter_next
ada_string_pair ada_search_params_entries_iter_next(ada_url_search_params_entries_iter result)
Definition ada_c.cpp:724
ada_clear_port
void ada_clear_port(ada_url result)
Definition ada_c.cpp:336
ada_is_valid
bool ada_is_valid(ada_url result)
Definition ada_c.cpp:108
ada_search_params_get_keys
ada_url_search_params_keys_iter ada_search_params_get_keys(ada_url_search_params result)
Definition ada_c.cpp:608
ada_idna_to_ascii
ada_owned_string ada_idna_to_ascii(const char *input, size_t length)
Definition ada_c.cpp:460
ada_set_search
void ada_set_search(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:315
ada_url_search_params_keys_iter
void * ada_url_search_params_keys_iter
Definition ada_c.h:117
ada_search_params_values_iter_has_next
bool ada_search_params_values_iter_has_next(ada_url_search_params_values_iter result)
Definition ada_c.cpp:709
ada_search_params_set
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:529
ada_get_href
ada_string ada_get_href(ada_url result)
Definition ada_c.cpp:133
ada_set_protocol
bool ada_set_protocol(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:264
ada_strings_size
size_t ada_strings_size(ada_strings result)
Definition ada_c.cpp:646
ada_search_params_get_values
ada_url_search_params_values_iter ada_search_params_get_values(ada_url_search_params result)
Definition ada_c.cpp:619
ada_has_hash
bool ada_has_hash(ada_url result)
Definition ada_c.cpp:425
ada_search_params_has
bool ada_search_params_has(ada_url_search_params result, const char *key, size_t key_length)
Definition ada_c.cpp:560
ada_has_hostname
bool ada_has_hostname(ada_url result)
Definition ada_c.cpp:385
ada_has_credentials
bool ada_has_credentials(ada_url result)
Definition ada_c.cpp:369
ada_url_search_params_values_iter
void * ada_url_search_params_values_iter
Definition ada_c.h:118
ada_can_parse
bool ada_can_parse(const char *input, size_t length)
Definition ada_c.cpp:88
ada_get_search
ada_string ada_get_search(ada_url result)
Definition ada_c.cpp:205
ada_search_params_reset
void ada_search_params_reset(ada_url_search_params result, const char *input, size_t length)
Definition ada_c.cpp:509
ada_search_params_remove
void ada_search_params_remove(ada_url_search_params result, const char *key, size_t key_length)
Definition ada_c.cpp:540
ada_has_non_empty_username
bool ada_has_non_empty_username(ada_url result)
Definition ada_c.cpp:393
ada_has_search
bool ada_has_search(ada_url result)
Definition ada_c.cpp:433
ada_copy
ada_url ada_copy(ada_url input)
Definition ada_c.cpp:103
ada_set_hash
void ada_set_hash(ada_url result, const char *input, size_t length)
Definition ada_c.cpp:329
ada_owned_string
Definition ada_c.h:23
ada_owned_string::length
size_t length
Definition ada_c.h:25
ada_owned_string::data
const char * data
Definition ada_c.h:24
ada_string_pair
Definition ada_c.h:120
ada_string_pair::value
ada_string value
Definition ada_c.h:122
ada_string_pair::key
ada_string key
Definition ada_c.h:121
ada_string
Definition ada_c.h:17
ada_string::data
const char * data
Definition ada_c.h:18
ada_string::length
size_t length
Definition ada_c.h:19
ada_url_components
Definition ada_c.h:28
ada_url_components::username_end
uint32_t username_end
Definition ada_c.h:30
ada_url_components::host_end
uint32_t host_end
Definition ada_c.h:32
ada_url_components::hash_start
uint32_t hash_start
Definition ada_c.h:36
ada_url_components::pathname_start
uint32_t pathname_start
Definition ada_c.h:34
ada_url_components::port
uint32_t port
Definition ada_c.h:33
ada_url_components::protocol_end
uint32_t protocol_end
Definition ada_c.h:29
ada_url_components::search_start
uint32_t search_start
Definition ada_c.h:35
ada_url_components::host_start
uint32_t host_start
Definition ada_c.h:31
ada_version_components
Definition ada_c.h:188
ada_version_components::revision
int revision
Definition ada_c.h:191
ada_version_components::minor
int minor
Definition ada_c.h:190
ada_version_components::major
int major
Definition ada_c.h:189