| 2262 | } |
| 2263 | |
| 2264 | static struct io_plan *ld_read_json(struct io_conn *conn, |
| 2265 | struct plugin *plugin) |
| 2266 | { |
| 2267 | /* Gather an parse any new bytes */ |
| 2268 | for (;;) { |
| 2269 | const jsmntok_t *toks; |
| 2270 | const char *buf; |
| 2271 | const char *err; |
| 2272 | |
| 2273 | err = jsonrpc_io_parse(tmpctx, |
| 2274 | plugin->lightningd_in, |
| 2275 | &toks, &buf); |
| 2276 | if (err) |
| 2277 | plugin_err(plugin, "%s", err); |
| 2278 | |
| 2279 | if (!toks) |
| 2280 | break; |
| 2281 | |
| 2282 | ld_command_handle(plugin, buf, toks); |
| 2283 | jsonrpc_io_parse_done(plugin->lightningd_in); |
| 2284 | } |
| 2285 | |
| 2286 | /* Read more */ |
| 2287 | return jsonrpc_io_read(conn, plugin->lightningd_in, |
| 2288 | ld_read_json, plugin); |
| 2289 | } |
| 2290 | |
| 2291 | static struct io_plan *ld_write_json(struct io_conn *conn, |
| 2292 | struct plugin *plugin); |
no test coverage detected