mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
param: make command sinks (fail/success) return a special type.
These routines free the 'struct command': a common coding error is not to return immediately. To catch this, we make them return a non-NULL 'struct command_result *', and we're going to make the command handlers return the same (to encourage 'return command_fail(...)'-style usage). We also provide two sources for external use: 1. command_param_failed() when param() fails. 2. command_its_complicated() for some complex cases. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -7,10 +7,12 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
struct command;
|
||||
struct command_result;
|
||||
|
||||
/* Caller supplied this: param assumes it can call it. */
|
||||
void PRINTF_FMT(3, 4) command_fail(struct command *cmd, int code,
|
||||
const char *fmt, ...);
|
||||
struct command_result *command_fail(struct command *cmd, int code,
|
||||
const char *fmt, ...)
|
||||
PRINTF_FMT(3, 4);
|
||||
|
||||
/* Also caller supplied: is this invoked simply to get usage? */
|
||||
bool command_usage_only(const struct command *cmd);
|
||||
|
||||
Reference in New Issue
Block a user