Prefix is usually a cmd->id */
| 341 | |
| 342 | /* Prefix is usually a cmd->id */ |
| 343 | static const char *json_id(const tal_t *ctx, struct plugin *plugin, |
| 344 | const char *method, const char *prefix) |
| 345 | { |
| 346 | const char *rawid; |
| 347 | int rawidlen; |
| 348 | |
| 349 | /* Strip quotes! */ |
| 350 | if (strstarts(prefix, "\"")) { |
| 351 | assert(strlen(prefix) >= 2); |
| 352 | assert(strends(prefix, "\"")); |
| 353 | rawid = prefix + 1; |
| 354 | rawidlen = strlen(prefix) - 2; |
| 355 | } else { |
| 356 | rawid = prefix; |
| 357 | rawidlen = strlen(prefix); |
| 358 | } |
| 359 | |
| 360 | /* Don't create weird IDs: they get escaped, we won't match the |
| 361 | * reply, and the command never finishes. */ |
| 362 | if (json_escape_needed(method, strlen(method))) |
| 363 | method = "!weird!"; |
| 364 | if (json_escape_needed(rawid, rawidlen)) { |
| 365 | rawid = "!weird!"; |
| 366 | rawidlen = strlen(rawid); |
| 367 | } |
| 368 | |
| 369 | return tal_fmt(ctx, "\"%.*s/%s:%s#%"PRIu64"\"", |
| 370 | rawidlen, rawid, plugin->id, method, plugin->next_outreq_id++); |
| 371 | } |
| 372 | |
| 373 | static void destroy_out_req(struct out_req *out_req, struct plugin *plugin) |
| 374 | { |
no test coverage detected