|
Concord - C Discord API library
A Discord API wrapper library written in C
|
#include <stddef.h>#include <stdio.h>#include <stdlib.h>Go to the source code of this file.
Data Structures | |
| struct | jsonb |
| Handle for building a JSON string. More... | |
Macros | |
| #define | JSONB_API extern |
| #define | JSONB_MAX_DEPTH 128 |
| #define | jsonb_reset(builder) ((builder)->pos = 0) |
| Reset a jsonb handle buffer's position tracker (for streaming purposes) More... | |
| #define | TRACE(prev, next) next |
| #define | DECORATOR(a) |
| #define | STACK_HEAD(b, state) *(b)->top = (state) |
| #define | STACK_PUSH(b, state) TRACE(*(b)->top, *++(b)->top = (state)) |
| #define | STACK_POP(b) TRACE(*(b)->top, DECORATOR(*)--(b)->top) |
| #define | BUFFER_COPY_CHAR_STATIC(b, c, _pos, buf, bufsize) |
| #define | BUFFER_COPY_STATIC(b, value, len, _pos, buf, bufsize) |
| #define | BUFFER_COPY_CHAR_REALLOC(b, c, _pos, p_buf, p_bufsize) |
| #define | BUFFER_COPY_REALLOC(b, value, len, _pos, p_buf, p_bufsize) |
| #define | JSONB_OBJECT_EXEC(_type, buf, bufsize) |
| #define | JSONB_OBJECT_POP_EXEC(_type, buf, bufsize) |
| #define | JSONB_KEY_EXEC(_type, buf, bufsize, key, len) |
| #define | JSONB_ARRAY_EXEC(_type, buf, bufsize) |
| #define | JSONB_ARRAY_POP_EXEC(_type, buf, bufsize) |
| #define | JSONB_TOKEN_EXEC(_type, buf, bufsize, token, len) |
| #define | JSONB_STRING_EXEC(_type, buf, bufsize, str, len) |
Typedefs | |
| typedef enum jsonbcode | jsonbcode |
| json-builder return codes More... | |
| typedef struct jsonb | jsonb |
| Handle for building a JSON string. More... | |
Enumerations | |
| enum | jsonbcode { JSONB_OK = 0 , JSONB_END , JSONB_ERROR_NOMEM = -1 , JSONB_ERROR_INPUT = -2 , JSONB_ERROR_STACK = -3 , JSONB_ERROR_OVERFLOW = -4 } |
| json-builder return codes More... | |
| enum | jsonbstate { JSONB_INIT = 0 , JSONB_ARRAY_OR_OBJECT_OR_VALUE = JSONB_INIT , JSONB_OBJECT_KEY_OR_CLOSE , JSONB_OBJECT_VALUE , JSONB_OBJECT_NEXT_KEY_OR_CLOSE , JSONB_ARRAY_VALUE_OR_CLOSE , JSONB_ARRAY_NEXT_VALUE_OR_CLOSE , JSONB_ERROR , JSONB_DONE } |
| json-builder serializing state More... | |
Functions | |
| void | jsonb_init (jsonb *builder) |
| Initialize a jsonb handle. More... | |
| jsonbcode | jsonb_object (jsonb *builder, char buf[], size_t bufsize) |
| Push an object to the builder. More... | |
| jsonbcode | jsonb_object_auto (jsonb *builder, char *p_buf[], size_t *p_bufsize) |
| jsonb_object() with dynamic buffer More... | |
| jsonbcode | jsonb_object_pop (jsonb *builder, char buf[], size_t bufsize) |
| Pop an object from the builder. More... | |
| jsonbcode | jsonb_object_pop_auto (jsonb *builder, char *p_buf[], size_t *p_bufsize) |
| jsonb_object_pop() with dynamic buffer More... | |
| jsonbcode | jsonb_key (jsonb *builder, char buf[], size_t bufsize, const char key[], size_t len) |
| Push a key to the builder. More... | |
| jsonbcode | jsonb_key_auto (jsonb *builder, char *p_buf[], size_t *p_bufsize, const char key[], size_t len) |
| jsonb_key() with dynamic buffer More... | |
| jsonbcode | jsonb_array (jsonb *builder, char buf[], size_t bufsize) |
| Push an array to the builder. More... | |
| jsonbcode | jsonb_array_auto (jsonb *builder, char *p_buf[], size_t *p_bufsize) |
| jsonb_array() with dynamic buffer More... | |
| jsonbcode | jsonb_array_pop (jsonb *builder, char buf[], size_t bufsize) |
| Pop an array from the builder. More... | |
| jsonbcode | jsonb_array_pop_auto (jsonb *builder, char *p_buf[], size_t *p_bufsize) |
| jsonb_array_pop() with dynamic buffer More... | |
| jsonbcode | jsonb_token (jsonb *builder, char buf[], size_t bufsize, const char token[], size_t len) |
| Push a raw JSON token to the builder. More... | |
| jsonbcode | jsonb_token_auto (jsonb *builder, char *p_buf[], size_t *p_bufsize, const char token[], size_t len) |
| jsonb_token() with dynamic buffer More... | |
| jsonbcode | jsonb_bool (jsonb *builder, char buf[], size_t bufsize, int boolean) |
| Push a boolean token to the builder. More... | |
| jsonbcode | jsonb_bool_auto (jsonb *builder, char *p_buf[], size_t *p_bufsize, int boolean) |
| jsonb_bool() with dynamic buffer More... | |
| jsonbcode | jsonb_null (jsonb *builder, char buf[], size_t bufsize) |
| Push a null token to the builder. More... | |
| jsonbcode | jsonb_null_auto (jsonb *builder, char *p_buf[], size_t *p_bufsize) |
| jsonb_null() with dynamic buffer More... | |
| jsonbcode | jsonb_string (jsonb *builder, char buf[], size_t bufsize, const char str[], size_t len) |
| Push a string token to the builder. More... | |
| jsonbcode | jsonb_string_auto (jsonb *builder, char *p_buf[], size_t *p_bufsize, const char str[], size_t len) |
| jsonb_string() with dynamic buffer More... | |
| jsonbcode | jsonb_number (jsonb *builder, char buf[], size_t bufsize, double number) |
| Push a number token to the builder. More... | |
| jsonbcode | jsonb_number_auto (jsonb *builder, char *p_buf[], size_t *p_bufsize, double number) |
| jsonb_number() with dynamic buffer More... | |
| #define JSONB_API extern |
| #define JSONB_MAX_DEPTH 128 |
Maximum JSON nesting depth, if default value is unwanted then it should be defined before json-build.h is included:
#define JSONB_MAX_DEPTH 256 #include "json-build.h"
| #define jsonb_reset | ( | builder | ) | ((builder)->pos = 0) |
Reset a jsonb handle buffer's position tracker (for streaming purposes)
| builder | pointer to the jsonb handle |
| #define TRACE | ( | prev, | |
| next | |||
| ) | next |
| #define DECORATOR | ( | a | ) |
| #define STACK_HEAD | ( | b, | |
| state | |||
| ) | *(b)->top = (state) |
| #define STACK_PUSH | ( | b, | |
| state | |||
| ) | TRACE(*(b)->top, *++(b)->top = (state)) |
| #define BUFFER_COPY_CHAR_STATIC | ( | b, | |
| c, | |||
| _pos, | |||
| buf, | |||
| bufsize | |||
| ) |
| #define BUFFER_COPY_STATIC | ( | b, | |
| value, | |||
| len, | |||
| _pos, | |||
| buf, | |||
| bufsize | |||
| ) |
| #define BUFFER_COPY_CHAR_REALLOC | ( | b, | |
| c, | |||
| _pos, | |||
| p_buf, | |||
| p_bufsize | |||
| ) |
| #define BUFFER_COPY_REALLOC | ( | b, | |
| value, | |||
| len, | |||
| _pos, | |||
| p_buf, | |||
| p_bufsize | |||
| ) |
| #define JSONB_OBJECT_EXEC | ( | _type, | |
| buf, | |||
| bufsize | |||
| ) |
| #define JSONB_OBJECT_POP_EXEC | ( | _type, | |
| buf, | |||
| bufsize | |||
| ) |
| #define JSONB_KEY_EXEC | ( | _type, | |
| buf, | |||
| bufsize, | |||
| key, | |||
| len | |||
| ) |
| #define JSONB_ARRAY_EXEC | ( | _type, | |
| buf, | |||
| bufsize | |||
| ) |
| #define JSONB_ARRAY_POP_EXEC | ( | _type, | |
| buf, | |||
| bufsize | |||
| ) |
| #define JSONB_TOKEN_EXEC | ( | _type, | |
| buf, | |||
| bufsize, | |||
| token, | |||
| len | |||
| ) |
| #define JSONB_STRING_EXEC | ( | _type, | |
| buf, | |||
| bufsize, | |||
| str, | |||
| len | |||
| ) |
| enum jsonbcode |
json-builder return codes
| enum jsonbstate |
| void jsonb_init | ( | jsonb * | builder | ) |
Initialize a jsonb handle.
| builder | the handle to be initialized |
Push an object to the builder.
| builder | the builder initialized with jsonb_init() |
| buf | the JSON buffer |
| bufsize | the JSON buffer size |
jsonb_object() with dynamic buffer
| builder | the builder initialized with jsonb_init() |
| p_buf | pointer to the JSON buffer |
| p_bufsize | pointer the JSON buffer size |
Pop an object from the builder.
| builder | the builder initialized with jsonb_init() |
| buf | the JSON buffer |
| bufsize | the JSON buffer size |
jsonb_object_pop() with dynamic buffer
| builder | the builder initialized with jsonb_init() |
| p_buf | pointer to the JSON buffer |
| p_bufsize | pointer the JSON buffer size |
Push a key to the builder.
| builder | the builder initialized with jsonb_init() |
| buf | the JSON buffer |
| bufsize | the JSON buffer size |
| key | the key to be inserted |
| len | the key length |
| jsonbcode jsonb_key_auto | ( | jsonb * | builder, |
| char * | p_buf[], | ||
| size_t * | p_bufsize, | ||
| const char | key[], | ||
| size_t | len | ||
| ) |
jsonb_key() with dynamic buffer
| builder | the builder initialized with jsonb_init() |
| p_buf | pointer to the JSON buffer |
| p_bufsize | pointer to the JSON buffer size |
| key | the key to be inserted |
| len | the key length |
Push an array to the builder.
| builder | the builder initialized with jsonb_init() |
| buf | the JSON buffer |
| bufsize | the JSON buffer size |
jsonb_array() with dynamic buffer
| builder | the builder initialized with jsonb_init() |
| p_buf | pointer to the JSON buffer |
| p_bufsize | pointer to the JSON buffer size |
Pop an array from the builder.
| builder | the builder initialized with jsonb_init() |
| buf | the JSON buffer |
| bufsize | the JSON buffer size |
jsonb_array_pop() with dynamic buffer
| builder | the builder initialized with jsonb_init() |
| p_buf | pointer to the JSON buffer |
| p_bufsize | pointer to the JSON buffer size |
| jsonbcode jsonb_token | ( | jsonb * | builder, |
| char | buf[], | ||
| size_t | bufsize, | ||
| const char | token[], | ||
| size_t | len | ||
| ) |
Push a raw JSON token to the builder.
| builder | the builder initialized with jsonb_init() |
| buf | the JSON buffer |
| bufsize | the JSON buffer size |
| token | the token to be inserted |
| len | the token length |
| jsonbcode jsonb_token_auto | ( | jsonb * | builder, |
| char * | p_buf[], | ||
| size_t * | p_bufsize, | ||
| const char | token[], | ||
| size_t | len | ||
| ) |
jsonb_token() with dynamic buffer
| builder | the builder initialized with jsonb_init() |
| p_buf | pointer to the JSON buffer |
| p_bufsize | pointer to the JSON buffer size |
| token | the token to be inserted |
| len | the token length |
Push a boolean token to the builder.
| builder | the builder initialized with jsonb_init() |
| buf | the JSON buffer |
| bufsize | the JSON buffer size |
| boolean | the boolean to be inserted |
jsonb_bool() with dynamic buffer
| builder | the builder initialized with jsonb_init() |
| p_buf | pointer to the JSON buffer |
| p_bufsize | pointer to the JSON buffer size |
| boolean | the boolean to be inserted |
Push a null token to the builder.
| builder | the builder initialized with jsonb_init() |
| buf | the JSON buffer |
| bufsize | the JSON buffer size |
jsonb_null() with dynamic buffer
| builder | the builder initialized with jsonb_init() |
| p_buf | pointer to the JSON buffer |
| p_bufsize | pointer to the JSON buffer size |
| jsonbcode jsonb_string | ( | jsonb * | builder, |
| char | buf[], | ||
| size_t | bufsize, | ||
| const char | str[], | ||
| size_t | len | ||
| ) |
Push a string token to the builder.
| builder | the builder initialized with jsonb_init() |
| buf | the JSON buffer |
| bufsize | the JSON buffer size |
| str | the string to be inserted |
| len | the string length |
| jsonbcode jsonb_string_auto | ( | jsonb * | builder, |
| char * | p_buf[], | ||
| size_t * | p_bufsize, | ||
| const char | str[], | ||
| size_t | len | ||
| ) |
jsonb_string() with dynamic buffer
| builder | the builder initialized with jsonb_init() |
| p_buf | pointer to the JSON buffer |
| p_bufsize | pointer to the JSON buffer size |
| str | the string to be inserted |
| len | the string length |
Push a number token to the builder.
| builder | the builder initialized with jsonb_init() |
| buf | the JSON buffer |
| bufsize | the JSON buffer size |
| number | the number to be inserted |
jsonb_number() with dynamic buffer
| builder | the builder initialized with jsonb_init() |
| p_buf | pointer to the JSON buffer |
| p_bufsize | pointer to the JSON buffer size |
| number | the number to be inserted |