18 const size_t remaining =
end -
pos;
19 const auto *n =
static_cast<const char *
>(memchr(
pos,
'\n', remaining));
22 const auto *r =
static_cast<const char *
>(memchr(
pos,
'\r', n !=
nullptr ? n -
pos : remaining));
23 if (n ==
nullptr && r ==
nullptr) {
24 sink(ctx,
pos, remaining);
27 const char *brk = (r !=
nullptr && (n ==
nullptr || r < n)) ? r : n;
29 pos = brk + ((brk == r && brk + 1 == n) ? 2 : 1);
41 len = buf_append_printf(buf,
size,
len,
"retry: %" PRIu32
"\r\n", reconnect);
44 len = buf_append_printf(buf,
size,
len,
"id: %" PRIu32
"\r\n",
id);
46 if (event && *event) {
61 std::memcpy(buf, digits, 8);
const LogString * message
constexpr size_t CHUNK_END_LEN
size_t build_chunk_prefix(char *buf, size_t size, const char *event, uint32_t id, uint32_t reconnect, bool with_data)
constexpr size_t SSE_SUFFIX_LEN
constexpr char CHUNK_END[]
constexpr size_t SSE_SEP_LEN
void(*)(void *ctx, const char *piece, size_t len) ChunkPieceSink
void write_chunk_header(char *buf, size_t chunk_len)
constexpr size_t CHUNK_HDR_LEN
constexpr char SSE_SUFFIX[]
void for_each_chunk_piece(const char *message, size_t message_len, ChunkPieceSink sink, void *ctx)
size_t buf_append_str(char *buf, size_t size, size_t pos, const char *str)
Safely append a string to buffer, returning new position (capped at size).
char * format_hex_to(char *buffer, size_t buffer_size, const uint8_t *data, size_t length)
Format byte array as lowercase hex to buffer (base implementation).