machinatrix
A very silly Matrix bot written in C
Loading...
Searching...
No Matches
numeraria.h
1#ifndef MACHINATRIX_NUMERARIA_H
2#define MACHINATRIX_NUMERARIA_H
3
4#include <assert.h>
5#include <stddef.h>
6#include <stdint.h>
7
11 uint32_t len;
13 uint8_t cmd;
15 char data[];
16};
17
18enum {
20 MTRIX_NUMERARIA_MAX_CMD = 1024,
22 MTRIX_NUMERARIA_CMD_SIZE = offsetof(struct mtrix_numeraria_cmd, data),
24 MTRIX_NUMERARIA_MAX_PACKET =
25 MTRIX_NUMERARIA_MAX_CMD + MTRIX_NUMERARIA_CMD_SIZE,
26 MTRIX_NUMERARIA_CMD_EXIT = 1,
27 MTRIX_NUMERARIA_CMD_SQL = 2,
28 MTRIX_NUMERARIA_CMD_RECORD_CMD = 3,
29 MTRIX_NUMERARIA_CMD_STATS = 4,
30};
31
32static_assert(
33 MTRIX_NUMERARIA_CMD_SIZE
34 == sizeof(((struct mtrix_numeraria_cmd*)0)->len)
35 + sizeof(((struct mtrix_numeraria_cmd*)0)->cmd));
36
41int mtrix_numeraria_init_socket(const char *addr);
42
47int mtrix_numeraria_init_unix(const char *path);
48
49#endif
Format of each command packet.
Definition numeraria.h:9
char data[]
Variable-length data.
Definition numeraria.h:15
uint8_t cmd
One of the MTRIX_NUMERARIA_CMD_* constants.
Definition numeraria.h:13
uint32_t len
Length of the packet's data section.
Definition numeraria.h:11