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
|
#pragma once
#include <stddef.h>
typedef void cmd_handle_t(char *);
typedef char** cmd_complete_t(const char*, int, int);
struct cmd {
cmd_handle_t * handle;
const char* name;
const char* info;
cmd_complete_t * complete;
};
typedef struct cmd cmd_t;
cmd_handle_t cmd_exit;
cmd_handle_t cmd_test;
cmd_handle_t cmd_help;
cmd_handle_t cmd_reset;
cmd_handle_t cmd_ls;
cmd_handle_t cmd_send;
cmd_handle_t cmd_skip;
cmd_handle_t cmd_dump;
cmd_complete_t cmd_dump_complete;
static const cmd_t cmds[] = {
{
.handle = cmd_exit,
.name = "exit",
.info = "exit pbc",
},
{
.handle = cmd_help,
.name = "help",
.info = "show this help",
},
{
.handle = cmd_reset,
.name = "reset",
.info = "set game state to 'idle' for one or more puzzle modules",
},
{
.handle = cmd_skip,
.name = "skip",
.info = "set game state to 'solved' for one or more puzzle modules",
},
{
.handle = cmd_ls,
.name = "ls",
.info = "list connected puzzle modules and their state",
},
#ifdef DEBUG
{
.handle = cmd_send,
.name = "send",
.info = "[debug] send raw message",
},
{
.handle = cmd_test,
.name = "test",
.info = "[debug] send a test puzbus message",
},
{
.handle = cmd_dump,
.name = "dump",
.info = "[debug] dump sent or received messages",
.complete = cmd_dump_complete,
},
#endif
};
static const size_t cmds_length = sizeof(cmds) / sizeof(cmds[0]);
|