From 78745e06f4a4365e9caa8ee12fb0d9e15fb59300 Mon Sep 17 00:00:00 2001 From: Jesper Jensen Date: Tue, 17 Feb 2026 23:34:53 +0100 Subject: Simple client CRUD --- src/web.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'src/web.h') diff --git a/src/web.h b/src/web.h index 4b7e89f..96e5f7f 100644 --- a/src/web.h +++ b/src/web.h @@ -1,5 +1,10 @@ #pragma once +#include +#include + +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); + -- cgit v1.2.3