#pragma once #include #include struct MHD_PostProcessor; struct App { char* dbname; }; void prepare_database(struct App *app); struct Server { struct App *app; char *page; }; int web_begin(struct Server *server, int port); int web_join(struct Server *server); #define CLIENT_NAME_MAX 32 struct PostCollector { char *data; size_t size; size_t capacity; }; struct FormData { char name[CLIENT_NAME_MAX]; int name_set; int64_t client_id; // For delete operations int client_id_set; }; struct Request { struct Server *server; struct PostCollector pp; struct MHD_PostProcessor *post_proc; // NULL when using PostCollector struct FormData form; }; struct CreateClientResult { int64_t id; char* name; }; int create_client(struct Request *req, char *name, struct CreateClientResult *result); int delete_client(struct Request *req, int64_t client_id); struct ListClientResultClient { int64_t id; char name[CLIENT_NAME_MAX]; }; struct ListClientResult { uint16_t clients_len; // Right now this has to be exactly 16 elements long, but it could be longer in the future struct ListClientResultClient clients[]; }; int list_clients(struct Request *req, struct ListClientResult *result);