11#ifndef LIGHTNING_LIGHTNINGD_JSONRPC_H
22#define LIGHTNING_LIGHTNINGD_JSONRPC_H
3+ #include "ccan/compiler/compiler.h"
34#include "config.h"
45#include <ccan/list/list.h>
56#include <common/autodata.h>
@@ -18,6 +19,10 @@ enum command_mode {
1819 CMD_CHECK
1920};
2021
22+ // FIXME(vincenzopalazzo): The filtering architecture
23+ // desearve an own file.
24+ struct jsonrpc_paginator { };
25+
2126/* Context for a command (from JSON, but might outlive the connection!). */
2227/* FIXME: move definition into jsonrpc.c */
2328struct command {
@@ -43,6 +48,8 @@ struct command {
4348 struct json_stream * json_stream ;
4449 /* Optional output field filter. */
4550 struct json_filter * filter ;
51+ /* Option filtering option */
52+ struct jsonrpc_paginator * paginator ;
4653};
4754
4855/**
@@ -223,6 +230,7 @@ struct jsonrpc_notification *jsonrpc_notification_start(const tal_t *ctx, const
223230 */
224231void jsonrpc_notification_end (struct jsonrpc_notification * n );
225232
233+
226234/**
227235 * start a JSONRPC request; id_prefix is non-NULL if this was triggered by
228236 * another JSONRPC request.
@@ -271,6 +279,15 @@ struct jsonrpc_request *jsonrpc_request_start_(
271279
272280void jsonrpc_request_end (struct jsonrpc_request * request );
273281
282+ #define PAGINATOR (callback ) \
283+ static struct command_result *callback##_paginator(struct command *cmd, \
284+ const char *buffer, \
285+ const jsmntok_t *obj UNNEEDED, \
286+ const jsmntok_t *params) \
287+ { \
288+ return callback(cmd, buffer, obj, params); \
289+ }
290+
274291AUTODATA_TYPE (json_command , struct json_command );
275292
276293#endif /* LIGHTNING_LIGHTNINGD_JSONRPC_H */
0 commit comments