23 char const *email, *last_name, *first_name, *display_name;
29 void *memory_owner_db;
44db_t *
db_connect(
cfg_t *cfg,
int verbosity,
char const *host,
char const *port,
char const *database,
char const *username,
char const *password);
Tchatator413 server configuration - Interface.
struct cfg cfg_t
An opaque handle to a configuration object.
errstatus_t db_check_password(db_t *db, cfg_t *cfg, serial_t user_id, char const *password)
Check a password against the stored hash for an user.
errstatus_t db_verify_user_api_key(db_t *db, cfg_t *cfg, user_identity_t *out_user, api_key_t api_key)
Verify an API key.
void db_destroy(db_t *db)
Destroy a database connection.
errstatus_t db_transaction(db_t *db, cfg_t *cfg, fn_transaction_t body, void *ctx)
Perform a transaction.
errstatus_t db_rm_msg(db_t *db, cfg_t *cfg, serial_t msg_id)
Removes a message from the database.
serial_t db_send_msg(db_t *db, cfg_t *cfg, serial_t sender_id, serial_t recipient_id, char const *content)
Sends a message.
serial_t db_get_user_id_by_email(db_t *db, cfg_t *cfg, char const *email)
Get the ID of an user from their e-mail.
msg_list_t db_get_inbox(db_t *db, cfg_t *cfg, int32_t limit, int32_t offset, serial_t recipient_id)
Creates an array with the messages an user has recieved, sorted by sent/edited date,...
errstatus_t(* fn_transaction_t)(db_t *db, cfg_t *cfg, void *ctx)
A transaction body function.
void db_collect(void *memory_owner)
Cleans up a memory owner.
db_t * db_connect(cfg_t *cfg, int verbosity, char const *host, char const *port, char const *database, char const *username, char const *password)
Initialize a database connection.
errstatus_t db_get_msg(db_t *db, cfg_t *cfg, msg_t *msg, void **out_memory_owner_db)
Retrieves a message from the database. If msg->id is undefined, the behavior is undefined.
serial_t db_get_user_id_by_name(db_t *db, cfg_t *cfg, char const *name)
Get the ID of an user from their name.
int db_get_user_role(db_t *db, cfg_t *cfg, serial_t user_id)
Get the role of an user.
errstatus_t db_get_user(db_t *db, cfg_t *cfg, user_t *user)
Fills a user record from its ID. If user->id is undefined, the behavior is undefined.
void db_t
An opaque handle to a database connection.
int db_count_msg(db_t *db, cfg_t *cfg, serial_t sender_id, serial_t recipient_id)
Counts the amount of messages sent from sender to a recipient.
Error status enumeration - Interface.
errstatus_t
An error status.
Represents a list of messages.
Represents a message in the chat application.
Information about the identity of an user.
Represents a user in the system.
void * memory_owner_db
Handle to the database memory owner.
General types - Standalone header.
user_kind_t
The kind of an user.
int32_t serial_t
A PosrgreSQL SERIAL primary key value starting at 1. (1..2^31-1)