We promise it will end in '\n\n' */
| 96 | |
| 97 | /* We promise it will end in '\n\n' */ |
| 98 | void json_stream_double_cr(struct json_stream *js) |
| 99 | { |
| 100 | const char *contents; |
| 101 | size_t len, cr_needed; |
| 102 | |
| 103 | /* Must be well-formed at this point! */ |
| 104 | json_out_finished(js->jout); |
| 105 | |
| 106 | contents = json_out_contents(js->jout, &len); |
| 107 | /* It's an object (with an id!): definitely can't be less that "{}" */ |
| 108 | assert(len >= 2); |
| 109 | if (contents[len-1] == '\n') { |
| 110 | if (contents[len-2] == '\n') |
| 111 | return; |
| 112 | cr_needed = 1; |
| 113 | } else |
| 114 | cr_needed = 2; |
| 115 | |
| 116 | json_stream_append(js, "\n\n", cr_needed); |
| 117 | } |
| 118 | |
| 119 | void json_stream_close(struct json_stream *js, struct command *writer) |
| 120 | { |
no test coverage detected