| 238 | }; |
| 239 | |
| 240 | static struct cond_info *new_cond_info(const tal_t *ctx, |
| 241 | struct commando *incoming, |
| 242 | const jsmntok_t *toks STEALS, |
| 243 | const jsmntok_t *method, |
| 244 | const jsmntok_t *params, |
| 245 | const jsmntok_t *id, |
| 246 | const jsmntok_t *filter) |
| 247 | { |
| 248 | struct cond_info *cinfo = tal(ctx, struct cond_info); |
| 249 | |
| 250 | cinfo->incoming = incoming; |
| 251 | /* Convenience pointer, since contents is u8 */ |
| 252 | cinfo->buf = cast_signed(const char *, incoming->contents); |
| 253 | cinfo->toks = tal_steal(cinfo, toks); |
| 254 | cinfo->method = method; |
| 255 | cinfo->params = params; |
| 256 | cinfo->filter = filter; |
| 257 | |
| 258 | if (!id) { |
| 259 | cinfo->cmdid_prefix = NULL; |
| 260 | incoming->json_id = NULL; |
| 261 | } else { |
| 262 | cinfo->cmdid_prefix = json_strdup(cinfo, cinfo->buf, id); |
| 263 | /* Includes quotes, if any! */ |
| 264 | incoming->json_id = tal_strndup(incoming, |
| 265 | json_tok_full(cinfo->buf, id), |
| 266 | json_tok_full_len(id)); |
| 267 | } |
| 268 | return cinfo; |
| 269 | } |
| 270 | |
| 271 | static struct command_result *execute_command(struct command *cmd, |
| 272 | struct cond_info *cinfo) |
no test coverage detected