Concord - C Discord API library
A Discord API wrapper library written in C
Internal implementation details

Documentation useful when developing or debugging Concord itself. More...

Collaboration diagram for Internal implementation details:

Modules

 Timer API
 Callback scheduling API.
 
 REST API
 Wrapper to the Discord REST API.
 
 WebSockets API
 Wrapper to the Discord Gateway API.
 
 Reference counter
 Handle automatic cleanup of user's data.
 
 Message Commands API
 The Message Commands API for registering and parsing user commands.
 
 Cache API
 The Cache API for storage and retrieval of Discord data.
 
 Global threadpool
 A global threadpool for worker-threads handling.
 

Files

file  discord-internal.h
 Internal functions and datatypes.
 

Data Structures

struct  discord
 The Discord client handler. More...
 

Macros

#define CLIENT(_ptr, _path)   CONTAINEROF(_ptr, struct discord, _path)
 get client from its nested field More...
 
#define CCORD_EXPECT(_client, _expect, _code, _reason)
 log and return code if expect condition is false More...
 
#define CCORD_DATA_TO_JSON(_client, _type, _body, _params)
 log and return code if function call doesn't returns CCORD_OK More...
 
#define DISCORD_ENDPT_LEN   512
 
#define DISCORD_ROUTE_LEN   256
 

Detailed Description

Documentation useful when developing or debugging Concord itself.

Macro Definition Documentation

◆ CLIENT

#define CLIENT (   _ptr,
  _path 
)    CONTAINEROF(_ptr, struct discord, _path)

get client from its nested field

Parameters
[in]_ptrthe nested field pointer
[in]_paththe path to the discord client from the nested field POV

◆ CCORD_EXPECT

#define CCORD_EXPECT (   _client,
  _expect,
  _code,
  _reason 
)
Value:
do { \
if (!(_expect)) { \
logmod_log(ERROR, (_client)->logger, \
"Expected: " #_expect " | %s (%s)", \
discord_strerror(_code, _client), \
return _code; \
} \
} while (0)
const char * discord_code_as_string(CCORDcode code)
Return the value of CCORDcode as a string.
const char * discord_strerror(CCORDcode code, struct discord *client)
Return the meaning of CCORDcode.

log and return code if expect condition is false

Parameters
[in]_clientthe Discord client
[in]_expectthe expected outcome
[in]_codereturn CCORDcode error code
[in]_reasonfor return
Returns
the provided CCORDcode code parameter

◆ CCORD_DATA_TO_JSON

#define CCORD_DATA_TO_JSON (   _client,
  _type,
  _body,
  _params 
)
Value:
do { \
struct reflectc_wrap *w_params = \
reflectc_from_##_type((_client)->registry, _params, NULL); \
CCORDcode code = discord_data_wrap_to_json(w_params, &(_body)->start, \
&(_body)->size); \
reflectc_cleanup((_client)->registry, w_params); \
if (code != CCORD_OK) { \
logmod_log(ERROR, (_client)->logger, \
"Expected: CCORD_OK == discord_data_wrap_to_json | " \
"%s (%s)", \
discord_strerror(code, _client), \
return code; \
} \
} while (0)
#define CCORD_OK
Definition: concord-error.h:60
CCORDcode discord_data_wrap_to_json(const struct reflectc_wrap *member, char *p_buf[], size_t *p_bufsize)
Transform a wrapped Discord data type into a JSON string.

log and return code if function call doesn't returns CCORD_OK

Parameters
[in]_clientthe Discord client
[in]_typethe datatype to be converted to JSON
[out]_bodythe JSON body buffer
[in]_paramsthe parameters to be converted to JSON
Returns
the returned CCORDcode code parameter

◆ DISCORD_ENDPT_LEN

#define DISCORD_ENDPT_LEN   512

URL endpoint threshold length

◆ DISCORD_ROUTE_LEN

#define DISCORD_ROUTE_LEN   256

Route's unique key threshold length