blob: 3a6e315541f81a7e5ca49c5f255a8a57653651aa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
#pragma once
#include <stddef.h>
#include <stdint.h>
struct MHD_PostProcessor;
#define CLIENT_NAME_MAX 32
#define CLIENT_SECRET_LEN 33
struct App {
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;
char *page;
};
int web_begin(struct Server *server, int port, const char *admin_user, const char *admin_pass);
int web_join(struct Server *server);
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;
char username[32];
int username_set;
char password[64];
int password_set;
};
struct Request {
struct Server *server;
struct PostCollector pp;
struct MHD_PostProcessor *post_proc; // NULL when using PostCollector
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 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);
#define BACKUP_STATUS_MAX 16
#define BACKUP_DATETIME_MAX 32
#define MAX_BACKUPS_DISPLAY 50
struct BackupRecord {
int64_t id;
char status[BACKUP_STATUS_MAX];
char started[BACKUP_DATETIME_MAX];
char completed[BACKUP_DATETIME_MAX];
};
struct GetClientResult {
int found;
int64_t id;
char name[CLIENT_NAME_MAX];
char secret[CLIENT_SECRET_LEN];
uint16_t backups_len;
struct BackupRecord backups[];
};
int get_client_with_backups(struct Request *req, int64_t client_id, struct GetClientResult *result);
|