89#define X(name) action_type_##name,
95#define ACTION_TYPE(name) CAT(action_type_, name)
136 } block, unblock, ban, unban;
void put_role(role_flags_t role, FILE *stream)
Put an user role.
response_t response_for_rate_limit(time_t next_request_at)
Builds a response for a rate limit error.
void response_destroy(response_t *response)
Destroy a response.
action_error_type_t
Enumerates the type of errors that occur while parsing or running an action.
@ action_error_type_missing_key
Parsing JSON missing key.
@ action_error_type_type
Parsing JSON type error.
@ action_error_type_other
Another error occured.
@ action_error_type_invalid
Parsing JSON invalid value.
@ action_error_type_invariant
An invariant was broken.
@ action_error_type_rate_limit
The rate limit has been reached.
json_object * response_to_json(response_t *response)
Convert an action response to JSON.
action_t action_parse(cfg_t *cfg, db_t *db, json_object *obj)
Parse an action from a JSON object.
void action_explain(action_t const *action, FILE *output)
Explain an action.
response_t action_evaluate(action_t const *action, cfg_t *cfg, db_t *db, server_t *server)
Evaluate an action.
action_type_t
Enumerates the types of actions, representing the various commands available.
@ action_type_error
Special value for an action triggered an error.
status_t
Status codes for the Tchatator413 protocol, modeled after HTTP status codes.
@ status_bad_request
Bad request.
@ status_payload_too_large
Payload too large.
@ status_unauthorized
Unauthorized.
@ status_internal_server_error
Internal server error.
@ status_too_many_requests
Too many requests.
@ status_forbidden
Forbidden.
@ status_unprocessable_content
Unprocessable content.
@ status_not_found
Not found.
Tchatator413 server configuration - Interface.
struct cfg cfg_t
An opaque handle to a configuration object.
General constants - Standalone header.
#define X_ACTIONS(X)
X-macro that expands to the list of actions.
void db_t
An opaque handle to a database connection.
json-c wrapper. Include this instead of JSON-C (compile time error mechanisms)
Tchatator413 dynamic server state - Interface.
struct server server_t
Opaque type handle representing a server instance.
An error that occured while parsing or running an action.
action_error_type_t type
Type of the error.
json_object * obj_bad
The faulty JSON object.
json_type expected
The type obj_actual should have been of.
time_t next_request_at
The Unix time at which the next request will be accepted.
json_object * obj_actual
The JSON object that is of the wrong type.
status_t status
A status code for the error.
char const * name
The name of the invariant that was broken.
char const * location
A human-friendly representation of the location of the error in the JSON request structure.
char const * reason
The reason why the value is invalid.
An action. Actions represent the commands the protocol implements.
action_type_t type
Type of the action.
Represents a list of messages.
Represents a user in the system.
General types - Standalone header.
int32_t serial_t
A PosrgreSQL SERIAL primary key value starting at 1. (1..2^31-1)
enum ATTR_FLAG_ENUM role_flags_t
A bit flags enumeration representing the roles of an user.
int64_t token_t
A session token.
int32_t page_number_t
A page number (1..2^31-1)