From 1b19afaa339f2f68520d61b634600ddeb04effb7 Mon Sep 17 00:00:00 2001 From: Jesper Jensen Date: Sat, 21 Feb 2026 11:14:42 +0100 Subject: Split up the rendering from the logic --- src/web.h | 65 ++------------------------------------------------------------- 1 file changed, 2 insertions(+), 63 deletions(-) (limited to 'src/web.h') diff --git a/src/web.h b/src/web.h index dd6e824..2bd85ea 100644 --- a/src/web.h +++ b/src/web.h @@ -1,25 +1,12 @@ #pragma once +#include "app.h" + #include #include -#include struct MHD_PostProcessor; -#define CLIENT_NAME_MAX 32 -#define CLIENT_SECRET_LEN 33 -#define BACKUP_STATUS_MAX 16 -#define MAX_BACKUPS_DISPLAY 50 - -struct App { - const char* dbname; - char session_secret[CLIENT_SECRET_LEN]; - const char *admin_user; - const char *admin_pass; -}; - -void prepare_database(struct App *app); - struct Server { struct App *app; @@ -53,51 +40,3 @@ struct Request { struct FormData form; const char *host; }; - -struct CreateClientResult { - int64_t id; - char* name; - char secret[CLIENT_SECRET_LEN]; -}; - -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]; - char secret[CLIENT_SECRET_LEN]; - struct timespec last_backup; - char status[BACKUP_STATUS_MAX]; // "OK", "RUNNING", "STALE", "FAILED", "INTERRUPTED" - int is_stale; -}; - -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); - -struct BackupRecord { - int64_t id; - char status[BACKUP_STATUS_MAX]; - struct timespec started; - struct timespec completed; -}; - -struct GetClientOnlyResult { - int found; - int64_t id; - char name[CLIENT_NAME_MAX]; - char secret[CLIENT_SECRET_LEN]; -}; - -struct GetBackupsResult { - uint16_t backups_len; // On input: max backups to fetch; On output: actual count - struct BackupRecord backups[]; -}; - -int get_client(struct Request *req, int64_t client_id, struct GetClientOnlyResult *result); -int get_client_backups(struct Request *req, int64_t client_id, struct GetBackupsResult *result); -- cgit v1.2.3