Concord - C Discord API library
A Discord API wrapper library written in C
|
Go to the source code of this file.
Data Structures | |
struct | jsmnftok |
JSON token description. More... | |
struct | jsmnf_pair |
JSON object. More... | |
struct | jsmnf_loader |
Bucket (jsmnf_pair) loader, keeps track of pair array position. More... | |
Macros | |
#define | CHASH_KEY_FIELD k |
#define | CHASH_VALUE_FIELD v |
#define | CHASH_BUCKETS_FIELD fields |
#define | CHASH_LENGTH_FIELD size |
#define | _jsmnf_key_hash(key, hash) |
#define | _jsmnf_key_compare(cmp_a, cmp_b) |
#define | _JSMNF_TABLE_HEAP 0 |
#define | _JSMNF_TABLE_BUCKET struct jsmnf_pair |
#define | _JSMNF_TABLE_FREE_KEY(_key) |
#define | _JSMNF_TABLE_HASH(_key, _hash) _jsmnf_key_hash(_key, _hash) |
#define | _JSMNF_TABLE_FREE_VALUE(_value) |
#define | _JSMNF_TABLE_COMPARE(_cmp_a, _cmp_b) _jsmnf_key_compare(_cmp_a, _cmp_b) |
#define | _JSMNF_TABLE_INIT(_bucket, _key, _value) chash_default_init(_bucket, _key, _value) |
#define | _JSMNF_STRING_A js |
#define | _JSMNF_STRING_B js |
#define | _JSMNF_STRING_A js |
#define | _JSMNF_STRING_B key |
#define | RECALLOC_OR_ERROR(ptr, prev_size) |
#define | _JSMNF_UTF16_IS_FIRST_SURROGATE(c) (0xD800 <= (unsigned)c && (unsigned)c <= 0xDBFF) |
#define | _JSMNF_UTF16_IS_SECOND_SURROGATE(c) (0xDC00 <= (unsigned)c && (unsigned)c <= 0xDFFF) |
#define | _JSMNF_UTF16_JOIN_SURROGATE(c1, c2) (((((unsigned long)c1 & 0x3FF) << 10) | ((unsigned)c2 & 0x3FF)) + 0x10000) |
#define | _JSMNF_UTF8_IS_VALID(c) |
#define | _JSMNF_UTF8_IS_TRAIL(c) (((unsigned char)c & 0xC0) == 0x80) |
#define | _JSMNF_UTF_ILLEGAL 0xFFFFFFFFu |
#define | BUF_PUSH(buf_tok, c, buf_end) |
Typedefs | |
typedef struct jsmnf_pair | jsmnf_pair |
JSON object. More... | |
typedef struct jsmnf_loader | jsmnf_loader |
Bucket (jsmnf_pair) loader, keeps track of pair array position. More... | |
Functions | |
JSMN_API void | jsmnf_init (jsmnf_loader *loader) |
Initialize a jsmnf_loader. More... | |
JSMN_API int | jsmnf_load (jsmnf_loader *loader, const char *js, const jsmntok_t tokens[], unsigned num_tokens, jsmnf_pair pairs[], unsigned num_pairs) |
Populate the jsmnf_pair pairs from jsmn tokens. More... | |
JSMN_API jsmnf_pair * | jsmnf_find (const jsmnf_pair *head, const char *js, const char key[], int length) |
Find a jsmnf_pair token by its associated key. More... | |
JSMN_API jsmnf_pair * | jsmnf_find_path (const jsmnf_pair *head, const char *js, char *const path[], unsigned depth) |
Find a jsmnf_pair token by its full key path. More... | |
JSMN_API int | jsmnf_load_auto (jsmnf_loader *loader, const char *js, const jsmntok_t tokens[], unsigned num_tokens, jsmnf_pair **p_pairs, unsigned *num_pairs) |
Populate and automatically allocate the jsmnf_pair pairs from jsmn tokens. More... | |
JSMN_API int | jsmn_parse_auto (jsmn_parser *parser, const char *js, size_t length, jsmntok_t **p_tokens, unsigned *num_tokens) |
jsmn_parse() counterpart that automatically allocates the necessary amount of tokens necessary for parsing the JSON string More... | |
JSMN_API long | jsmnf_unescape (char buf[], size_t bufsize, const char src[], size_t length) |
Utility function for unescaping a Unicode string. More... | |
JSMN_API struct jsmnf_pair * | jsmnf_find (const struct jsmnf_pair *head, const char *js, const char key[], int length) |
JSMN_API struct jsmnf_pair * | jsmnf_find_path (const struct jsmnf_pair *head, const char *js, char *const path[], unsigned depth) |
#define CHASH_KEY_FIELD k |
#define CHASH_VALUE_FIELD v |
#define CHASH_BUCKETS_FIELD fields |
#define CHASH_LENGTH_FIELD size |
#define _jsmnf_key_hash | ( | key, | |
hash | |||
) |
#define _jsmnf_key_compare | ( | cmp_a, | |
cmp_b | |||
) |
#define _JSMNF_TABLE_HEAP 0 |
#define _JSMNF_TABLE_BUCKET struct jsmnf_pair |
#define _JSMNF_TABLE_FREE_KEY | ( | _key | ) |
#define _JSMNF_TABLE_HASH | ( | _key, | |
_hash | |||
) | _jsmnf_key_hash(_key, _hash) |
#define _JSMNF_TABLE_FREE_VALUE | ( | _value | ) |
#define _JSMNF_TABLE_COMPARE | ( | _cmp_a, | |
_cmp_b | |||
) | _jsmnf_key_compare(_cmp_a, _cmp_b) |
#define _JSMNF_TABLE_INIT | ( | _bucket, | |
_key, | |||
_value | |||
) | chash_default_init(_bucket, _key, _value) |
#define _JSMNF_STRING_A js |
#define _JSMNF_STRING_B js |
#define _JSMNF_STRING_A js |
#define _JSMNF_STRING_B key |
#define RECALLOC_OR_ERROR | ( | ptr, | |
prev_size | |||
) |
#define _JSMNF_UTF16_IS_FIRST_SURROGATE | ( | c | ) | (0xD800 <= (unsigned)c && (unsigned)c <= 0xDBFF) |
#define _JSMNF_UTF16_IS_SECOND_SURROGATE | ( | c | ) | (0xDC00 <= (unsigned)c && (unsigned)c <= 0xDFFF) |
#define _JSMNF_UTF16_JOIN_SURROGATE | ( | c1, | |
c2 | |||
) | (((((unsigned long)c1 & 0x3FF) << 10) | ((unsigned)c2 & 0x3FF)) + 0x10000) |
#define _JSMNF_UTF8_IS_VALID | ( | c | ) |
#define _JSMNF_UTF8_IS_TRAIL | ( | c | ) | (((unsigned char)c & 0xC0) == 0x80) |
#define _JSMNF_UTF_ILLEGAL 0xFFFFFFFFu |
#define BUF_PUSH | ( | buf_tok, | |
c, | |||
buf_end | |||
) |
typedef struct jsmnf_pair jsmnf_pair |
JSON object.
typedef struct jsmnf_loader jsmnf_loader |
Bucket (jsmnf_pair) loader, keeps track of pair array position.
JSMN_API void jsmnf_init | ( | jsmnf_loader * | loader | ) |
Initialize a jsmnf_loader.
[out] | loader | jsmnf_loader to be initialized |
JSMN_API int jsmnf_load | ( | jsmnf_loader * | loader, |
const char * | js, | ||
const jsmntok_t | tokens[], | ||
unsigned | num_tokens, | ||
jsmnf_pair | pairs[], | ||
unsigned | num_pairs | ||
) |
Populate the jsmnf_pair pairs from jsmn tokens.
[in,out] | loader | the jsmnf_loader initialized with jsmnf_init() |
[in] | js | the JSON data string |
[in] | tokens | jsmn tokens initialized with jsmn_parse() / jsmn_parse_auto() |
[in] | num_tokens | amount of tokens initialized with jsmn_parse() / jsmn_parse_auto() |
[out] | pairs | jsmnf_pair pairs array |
[in] | num_pairs | maximum amount of pairs provided |
enum jsmnerr
value for error or the amount of pairs
used JSMN_API jsmnf_pair * jsmnf_find | ( | const jsmnf_pair * | head, |
const char * | js, | ||
const char | key[], | ||
int | length | ||
) |
Find a jsmnf_pair token by its associated key.
[in] | head | a jsmnf_pair object or array loaded at jsmnf_start() |
[in] | js | the JSON data string |
[in] | key | the key too be matched |
[in] | length | length of the key too be matched |
head
's field matched to key
, or NULL if not encountered JSMN_API jsmnf_pair * jsmnf_find_path | ( | const jsmnf_pair * | head, |
const char * | js, | ||
char *const | path[], | ||
unsigned | depth | ||
) |
Find a jsmnf_pair token by its full key path.
[in] | head | a jsmnf_pair object or array loaded at jsmnf_start() |
[in] | js | the JSON data string |
[in] | path | an array of key path strings, from least to highest depth |
[in] | depth | the depth level of the last path key |
head
's field matched to path
, or NULL if not encountered JSMN_API int jsmnf_load_auto | ( | jsmnf_loader * | loader, |
const char * | js, | ||
const jsmntok_t | tokens[], | ||
unsigned | num_tokens, | ||
jsmnf_pair ** | p_pairs, | ||
unsigned * | num_pairs | ||
) |
Populate and automatically allocate the jsmnf_pair pairs from jsmn tokens.
jsmnf_load() counterpart that automatically allocates the necessary amount of pairs necessary for sorting the JSON tokens
[in,out] | loader | the jsmnf_loader initialized with jsmnf_init() |
[in] | js | the JSON data string |
[in] | tokens | jsmn tokens initialized with jsmn_parse() / jsmn_parse_auto() |
[in] | num_tokens | amount of tokens initialized with jsmn_parse() / jsmn_parse_auto() |
[out] | p_pairs | pointer to jsmnf_pair to be dynamically increased |
free()
'd once done being used [in,out] | num_pairs | initial amount of pairs provided |
enum jsmnerr
value for error or the amount of pairs
used JSMN_API int jsmn_parse_auto | ( | jsmn_parser * | parser, |
const char * | js, | ||
size_t | length, | ||
jsmntok_t ** | p_tokens, | ||
unsigned * | num_tokens | ||
) |
jsmn_parse()
counterpart that automatically allocates the necessary amount of tokens necessary for parsing the JSON string
[in,out] | parser | the jsmn_parser initialized with jsmn_init() |
[in] | js | the JSON data string |
[in] | length | the raw JSON string length |
[out] | p_tokens | pointer to jsmntok_t to be dynamically increased |
free()
'd once done being used [in,out] | num_tokens | amount of tokens |
enum jsmnerr
value for error or the amount of tokens
used JSMN_API long jsmnf_unescape | ( | char | buf[], |
size_t | bufsize, | ||
const char | src[], | ||
size_t | length | ||
) |
Utility function for unescaping a Unicode string.
[out] | buf | destination buffer |
[in] | bufsize | destination buffer size |
[in] | src | source string to be unescaped |
[in] | length | source string length |
JSMN_API struct jsmnf_pair * jsmnf_find | ( | const struct jsmnf_pair * | head, |
const char * | js, | ||
const char | key[], | ||
int | length | ||
) |
JSMN_API struct jsmnf_pair * jsmnf_find_path | ( | const struct jsmnf_pair * | head, |
const char * | js, | ||
char *const | path[], | ||
unsigned | depth | ||
) |