Merge branch 't/decoder_fixes'
[paraslash.git] / command.h
1 /** \file command.h The structure of server and afs commands. */
2
3 /** Per connection data available to command handlers. */
4 struct command_context {
5 /** Network address of the peer. */
6 const char *peer;
7 /** The paraslash user that executes this command. */
8 struct user *u;
9 /** Argument count. */
10 int argc;
11 /** Argument vector. */
12 char **argv;
13 /** The command being executed. */
14 struct server_command *cmd;
15 /** File descriptor and crypto keys. */
16 struct stream_cipher_context scc;
17 /** Whether to use the sideband API for this command. */
18 bool use_sideband;
19 };
20
21 /**
22 * Defines one command of para_server.
23 */
24 struct server_command {
25 /** The name of the command. */
26 const char *name;
27 /** Pointer to the function that handles the command. */
28 int (*handler)(struct command_context *);
29 /** The privileges a user must have to execute this command. */
30 unsigned int perms;
31 /** One-line description of the command. */
32 const char *description;
33 /** Summary of the command line options. */
34 const char *usage;
35 /** The long help text. */
36 const char *help;
37 };
38
39 int send_sb(struct stream_cipher_context *scc, void *buf, size_t numbytes,
40 int band, bool dont_free);
41 __printf_3_4 int send_sb_va(struct stream_cipher_context *scc, int band,
42 const char *fmt, ...);
43 int send_strerror(struct command_context *cc, int err);
44 int recv_sb(struct stream_cipher_context *scc,
45 enum sb_designator expected_band,
46 size_t max_size, struct iovec *result);