diff options
| author | Jesper Jensen <jesper@jnsn.dev> | 2026-02-17 23:34:53 +0100 |
|---|---|---|
| committer | Jesper Jensen <jesper@jnsn.dev> | 2026-02-17 23:34:53 +0100 |
| commit | 78745e06f4a4365e9caa8ee12fb0d9e15fb59300 (patch) | |
| tree | fb24257a0942704408e0ed1c2513a0f1cdd8c20e /src/web.h | |
| parent | c9e3a4b2816ad23aa201a4f43f357a376947bd49 (diff) | |
Simple client CRUD
Diffstat (limited to 'src/web.h')
| -rw-r--r-- | src/web.h | 48 |
1 files changed, 48 insertions, 0 deletions
@@ -1,5 +1,10 @@ #pragma once +#include <stddef.h> +#include <stdint.h> + +struct MHD_PostProcessor; + struct App { char* dbname; }; @@ -15,3 +20,46 @@ struct Server { 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); + |
