summaryrefslogtreecommitdiff
path: root/src/web.h
blob: 2bd85eaa1a4be02fcccdb30c9805128e2bdb0702 (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
#pragma once

#include "app.h"

#include <stddef.h>
#include <stdint.h>

struct MHD_PostProcessor;

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;
};