| 1185 | } |
| 1186 | |
| 1187 | static void json_stream_forward_change_id(struct json_stream *stream, |
| 1188 | const char *buffer, |
| 1189 | const jsmntok_t *toks, |
| 1190 | const jsmntok_t *idtok, |
| 1191 | /* Full token, including "" */ |
| 1192 | const char *new_id) |
| 1193 | { |
| 1194 | /* We copy everything, but replace the id. Special care has to |
| 1195 | * be taken when the id that is being replaced is a string. If |
| 1196 | * we don't crop the quotes off we'll transform a numeric |
| 1197 | * new_id into a string, or even worse, quote a string id |
| 1198 | * twice. */ |
| 1199 | const char *id_start, *id_end; |
| 1200 | |
| 1201 | id_start = json_tok_full(buffer, idtok); |
| 1202 | id_end = id_start + json_tok_full_len(idtok); |
| 1203 | |
| 1204 | json_stream_append(stream, buffer + toks->start, |
| 1205 | id_start - (buffer + toks->start)); |
| 1206 | json_stream_append(stream, new_id, strlen(new_id)); |
| 1207 | json_stream_append(stream, id_end, (buffer + toks->end) - id_end); |
| 1208 | } |
| 1209 | |
| 1210 | static void plugin_rpcmethod_cb(const char *buffer, |
| 1211 | const jsmntok_t *toks, |
no test coverage detected