MCPcopy Create free account
hub / github.com/SmingHub/Sming / transform

Method transform

Sming/Components/Network/src/Data/Stream/ChunkedStream.cpp:20–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18}
19
20size_t ChunkedStream::transform(const uint8_t* source, size_t sourceLength, uint8_t* target, size_t targetLength)
21{
22 if(sourceLength == 0) {
23 memcpy(target, _F("0\r\n\r\n"), 5);
24 return 5;
25 }
26
27 // Header
28 unsigned offset =
29 m_snprintf(reinterpret_cast<char*>(target), targetLength, "%X\r\n", static_cast<unsigned>(sourceLength));
30
31 // Content
32 memcpy(target + offset, source, sourceLength);
33 offset += sourceLength;
34
35 // Footer
36 memcpy(target + offset, "\r\n", 2);
37 offset += 2;
38
39 return offset;
40}

Callers

nothing calls this directly

Calls 1

m_snprintfFunction · 0.85

Tested by

no test coverage detected